Hello Guest it is March 28, 2024, 05:02:42 PM

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

0 Members and 1 Guest are viewing this topic.

Un-Supported wxNumberEntryDialog
« on: January 20, 2019, 01:27:32 PM »
Hi All,
I have always struggled to make sense of wxLua. I have started doing some reading and experimenting and a glimmer of
understanding/hope is coming.

I have encountered a difficulty that maybe someone can explain.

I was experimenting with wx.wxNumberEntryDialog() As found in the wxWidgets web pages but found that neither
ZeroBrane supported it neither would the dialog execute.

I found that the convenience dialog wx.wxGetNumberFromUser() works but that is limited to positive integers only.

I was hoping that wx.wxNumberEntryDialog would allow the entry of real numbers which would be appropriate for
a dimension in a CNC job say.

Is there a means of real number entry in wxLua?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #1 on: January 20, 2019, 03:23:17 PM »
Just use a text entry and convert the text to a real with tonumber().

One thing that you guys may not know is wxFormBuilder generates code for wxLua.  Just build you own dialog in wxFormBuilder and do what ever you need.  There will be a learning curve, but it is worth it. 

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #2 on: January 20, 2019, 04:50:34 PM »
Steve, great suggestion converting text to number; I just had to try it out, works great!

I remember going to the class that Scott had up in Michigan when Mach4 was first released, he strongly suggested downloading wxFormBuilder to make stuff.  I have tried to mess with wxFormBuilder before, I just don't know where to start with the code.  Maybe it's worth another try, it has been a while since I have opened it up.
Chad Byrd

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #3 on: January 20, 2019, 07:46:31 PM »
I miss the Digital Machinist shows.  :( 

The wxFormbuilder stuff isn't that hard once you realize that it puts all of the GUI code in one table called UI (I guess for User Interface).  You just paste all of that generated code into your LUA file and call it, basically.

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #4 on: January 20, 2019, 08:10:37 PM »
Easy enough.   I'll open it up and try it again. 
I wonder who should show uo to a meet up if one was put together.   
Chad Byrd

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #5 on: January 20, 2019, 09:28:10 PM »
We usually do a show called Cabin Fever (this weekend, in fact) in PA.  But the weather prevented most of us from going.  Besides that, we do IMTS and FabTech every now and then.

I LOVED doing the Cabin Fever show when it was in March and in York, PA.  Now it is back (original time anyway) in January and in Lebanon, PA.  :(  I haven't been too excited about the Jan/Lebanon combination. 

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #6 on: January 21, 2019, 12:35:57 AM »
Hi,
I did try fiddling with wxFormBuilder and quite liked the idea but obviously did not put the effort to master
it. I'll have to try it again.

Putting all the code in a table is a great idea.

I guess the question is.....'for the simple dialogs I am likely to require for Mach4 macros is it necessary or even
desirable to have a utility like wxFormBuilder?'.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #7 on: January 21, 2019, 12:54:39 AM »
It isn't necessary.  But I would say it is desirable.  Because if you can't use the stock "data grabber" dialogs and require something juuuuust a bit more complex, the wxFormbuilder thing pays big dividends.   Otherwise, you start to have to know MORE about wxWidgets to code a dialog by hand. 

Maybe someone can do a video on how to work with wxFormBuilder.

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #8 on: January 21, 2019, 01:06:04 AM »
Hi Smurph,
whether I make the effort to get wxFormBuilder working for me I still have a hankering to see and understand
the wxLua code.

I guess its not unlike the parallel between using a Wizard or a CAM program to generate Gcode without having a clue
about Gcode. I know plenty of people seem to work that way but I need to be able to scan Gcode and get a feel for what its
going to do.

One of the reasons I started really looking into wxWidgets was because I am so unfamiliar with the public member functions.
Without knowing the sorts of functionality they can confer how could I possibly know to try to use them to achieve a specific
behavior?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #9 on: January 21, 2019, 09:56:18 AM »
If all you want to do is get NUMERIC characters from a user then just use a validator on the TextCtrl, by using the wxFILTER_NUMERIC you will get your 0-9 and your - and . oh and an e

Here`s a dirty way of getting rid of the frame too and center the dialog ;-)

Code: [Select]
coords_val = ""
coordsObj = wxlua.wxLuaObject(coords_val)

mainFrame = wx.wxFrame( wx.NULL, wx.wxID_ANY, "Dummy Frame", wx.wxDefaultPosition, wx.wxSize(0,0), wx.wxFRAME_TOOL_WINDOW)
dialog = wx.wxDialog(mainFrame, wx.wxID_ANY, "Enter Coords")
dialog:Center()
coords = wx.wxTextCtrl(dialog, wx.wxID_ANY, "",  wx.wxPoint( 10,12 ), wx.wxDefaultSize, 0,  wx.wxTextValidator(wx.wxFILTER_NUMERIC, coordsObj))
ok = wx.wxButton( dialog, wx.wxID_OK, "OK", wx.wxPoint( 10,40 ), wx.wxDefaultSize, 0 )
cancel = wx.wxButton( dialog, wx.wxID_CANCEL, "Cancel", wx.wxPoint( 100,40 ), wx.wxDefaultSize, 0 )

if dialog:ShowModal() == wx.wxID_OK then
    wx.wxMessageBox(tostring(coords:GetValue()))
else
wx.wxMessageBox('User Canx')
end

Most of these "convenience functions" are just that ;-)

DazTheGas
New For 2022 - Instagram: dazthegas