Hello Guest it is November 14, 2019, 11:03:04 AM

Author Topic: Un-Supported wxNumberEntryDialog  (Read 684 times)

0 Members and 1 Guest are viewing this topic.

Re: Un-Supported wxNumberEntryDialog
« Reply #10 on: January 21, 2019, 12:38:34 PM »
Hi Daz,
great stuff there. Some new concepts for me to get my head around.

For instance:
Code: [Select]
coords_val = ""
coordsObj = wxlua.wxLuaObject(coords_val)
What does this do and why is it required? Hang on......just seen it, the numeric filter requires an object on which to operate?

Another query I have is say 'dialog' is defined....is it necessary to define as global or is it permissible to define it as local?

I see mainframe has been defined with 0 size, so presumably it does not have an onscreen image but what is:
Code: [Select]
wx.wxFRAME_TOOL_WINDOW
This is exactly the sort of thing that I want.....enough new concepts included in a working example so I can work out
how all the individual pieces get put together. Thanks again.

Craig

My wife left with my best friend...
     and I miss him!

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #11 on: January 21, 2019, 02:37:03 PM »
When creating a Frame by default it will add a menu bar and the close icon as a minimum so you still see the frame, the wxFRAME_TOOL_WINDOW doesnt so works good as a dummy frame. You can declare the dialog however you like, that code is something I just threw together as an example.

Smurph is absolutely correct about wxFormBuilder, best is to just have a play and then have a look at the code it spits out to see how things are put together and as you can see from my code you dont actually have to use sizers if you dont want too, you can make dialogs, msg`s etc absolute.

DazTheGas
Theres always time for a choccy biccy

Offline smurph

*
  • *
  •  1,149 1,149
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #12 on: January 21, 2019, 03:11:36 PM »
But sizers rule!!!  That was the greatest invention since beer cans.  They can be a bit confusing at first.  But once you get them, you'll wonder how the world got along without them in the past. 

Steve

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #13 on: January 21, 2019, 05:26:53 PM »
Quote
But sizers rule!!!

Totally agree ;-)
Theres always time for a choccy biccy
Re: Un-Supported wxNumberEntryDialog
« Reply #14 on: January 21, 2019, 11:16:41 PM »
So, I don't have any idea about wx stuff.  Looking through Daz's example makes a little bit of sense to me, but when I generate code from wxFormbuilder I don't really know what I'm looking at.
I have attached a screenshot of a simple test I made in wxFormbuilder (FB) and the code that was generated from that.
How do I get the ZeroBrane editor to run this file correctly and open up my APP. 

I haven't found any examples for FB and LUA on YouTube, just Python.

From what I understand I have to add the functionality behind the scenes outside of FB (since I can't edit anything in FB), so I will do that in ZeroBrane once I know and understand what allows it to run properly.
« Last Edit: January 21, 2019, 11:18:52 PM by Cbyrdtopper »
Chad Byrd
Re: Un-Supported wxNumberEntryDialog
« Reply #15 on: January 22, 2019, 02:13:02 AM »
Hi Chad,

Quote
So, I don't have any idea about wx stuff.  Looking through Daz's example makes a little bit of sense to me, but when I generate code from wxFormbuilder I don't really know what I'm looking at.

I must say that I found the same thing when I tried using wxFB......it generated lots of code which I didn't really understand.
Even worse it seemed like the code extended for miles.....hundreds of line of code to get one number from the user????

Digesting simpler blocks of code like the file dialog I have posted or the dialog Daz has posted are much closer to my expectation
of 'code overhead' that is desirable in simple Mach scripts.

For all that, wxFB is clever and if you wanted a truly complex sequence of screen windows then probably indispensable.

Craig
My wife left with my best friend...
     and I miss him!

Offline smurph

*
  • *
  •  1,149 1,149
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #16 on: January 22, 2019, 04:10:37 AM »
Nah...  you guys are making too much of the generated code.  Why?  Because you don't know the paradigm that wxFormBuilder is using.  Once you understand that, it becomes a tool to help you work smarter, not harder.  :)  Anyway, I was talking to Brett and he said he might do a video on how to make something useful with wxFormBuilder.  It is one of those things that is hard to explain but easy to show.  And when you get past that, the generated code will actually teach you what is doing what by example. 

Not say you HAVE to.  But I'm just thinking you guys would be REALLY dangerous :) and have fun with it at some point. 

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #17 on: January 26, 2019, 02:03:07 PM »
Hi guys,
have taken your advice and reinstalled wxFormBuilder and been experimenting with it.

I have for experimentation purposes made a grid of data values within a frame. The Lua code all looks pretty straight
forward. It includes a Create function, I have excerpted it below.

Code: [Select]
-- Grid
UI.m_grid1:CreateGrid( 8, 1 )
UI.m_grid1:EnableEditing( True )
UI.m_grid1:EnableGridLines( True )
UI.m_grid1:EnableDragGridSize( False )
UI.m_grid1:SetMargins( 0, 0 )

I have copied and pasted the code into a macro but when I run the macro the expected data input frame doesn't show up.
I suspect (hope) its something basic that I'm overlooking.

I have been trying to assign a value to a local variable by using the GetCellValue function. One potential problem I see
is that when I use Zero Brane to write the line of code GetCellValue is not supported as an auto-complete item.
Is indeed GetCellValue supported by wxLua?

Craig
Code: [Select]
local jewelWidth=UI.m_grid1:GetCellValue(1,1)
My wife left with my best friend...
     and I miss him!

Offline smurph

*
  • *
  •  1,149 1,149
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #18 on: January 26, 2019, 06:03:44 PM »
Did you use a frame or a dialog?  For a dialog, you use

rc = UI.<your dialog variable name>:ShowModal()

For a frame:

UI.<your frame variable name>:Show()

Code: [Select]
----------------------------------------------------------------------------
-- Lua code generated with wxFormBuilder (version Aug  8 2018)
-- http://www.wxformbuilder.org/
----------------------------------------------------------------------------

-- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
require("wx")

UI = {}


-- create MyDialog1
UI.MyDialog1 = wx.wxDialog (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 226,133 ), wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog1:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )

UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )

UI.bSizer2 = wx.wxBoxSizer( wx.wxHORIZONTAL )

UI.m_staticText1 = wx.wxStaticText( UI.MyDialog1, wx.wxID_ANY, "Steve:", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.m_staticText1:Wrap( -1 )

UI.bSizer2:Add( UI.m_staticText1, 0, wx.wxALL, 2 )

UI.m_textCtrl1 = wx.wxTextCtrl( UI.MyDialog1, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.bSizer2:Add( UI.m_textCtrl1, 1, wx.wxALL, 2 )


UI.bSizer1:Add( UI.bSizer2, 1, wx.wxEXPAND, 5 )

UI.m_sdbSizer1 = wx.wxStdDialogButtonSizer()
UI.m_sdbSizer1OK = wx.wxButton( UI.MyDialog1, wx.wxID_OK, "" )
UI.m_sdbSizer1:AddButton( UI.m_sdbSizer1OK )
UI.m_sdbSizer1Cancel = wx.wxButton( UI.MyDialog1, wx.wxID_CANCEL, "" )
UI.m_sdbSizer1:AddButton( UI.m_sdbSizer1Cancel )
UI.m_sdbSizer1:Realize();

UI.bSizer1:Add( UI.m_sdbSizer1, 1, wx.wxEXPAND, 5 )


UI.MyDialog1:SetSizer( UI.bSizer1 )
UI.MyDialog1:Layout()

UI.MyDialog1:Centre( wx.wxBOTH )

-- Connect Events

UI.m_sdbSizer1Cancel:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_Cancel()

event:Skip()
end )

UI.m_sdbSizer1OK:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_OnOk

event:Skip()
end )

--wx.wxGetApp():MainLoop()

To show the above dialog code:

rc = UI.MyDialog1:ShowModal()

rc will be wx.wxID_OK or wx.wxID_CANCEL, depending on what button was pressed.

The frame's Show() method isn't modal, as it is a top level window.  Frame and dialogs each have their pros and cons.

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #19 on: January 26, 2019, 06:20:31 PM »
Hi Steve,
after my post I tried a Dialog and used ShowModal() and it worked. I am a little familiar with ShowModal() syntax as
I have seen it used and I have copied/pasted and edited to use it  myself.

I have used a statments like:

if (UI.<dialogName>:ShowModal()==wx.wxID_OK) then.....

which achieves the same result as:

rc=UI.<dialogName>:ShowModal()

and then testing rc.

Either way I have some more stuff to experiment with. Thanks again.

You are correct.....letting wxFB generate the Lua code and then looking closely at the code is very illuminating.

Does your missus get sick of you being right all the time.... ;D....or does she even think that????

Craig

My wife left with my best friend...
     and I miss him!