Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: thespindoctor on March 29, 2018, 07:49:27 AM

Title: wx.widgets
Post by: thespindoctor on March 29, 2018, 07:49:27 AM
Really having trouble getting started with wx.widgets

I can handle a message box and number from user but am not able to get text input from user at this point.  Figuring out much from the documentation is difficult.

I would like to collect a word from the user like filename, or username etc.  1 is minimum # characters and 3 is max I think.

This does not work. 
Code: [Select]
local newname = wx.wxGetTextFromUser("Enter a name","Name Entry Screen",name,1,3)
What have I done wrong?  Has anyone found a good source for learning this stuff...  I sure would like some getting started when you know nothing examples for wx.widgets

Thanks!

Title: Re: wx.widgets
Post by: Cbyrdtopper on March 29, 2018, 08:09:58 AM
I haven't found a good source for wx.widgets.  But I am using boxes to get info from the operators.

local MyNum = wx.wxGetNumberFromUser("Message", "Prompt", "Caption", 50, 0, 100) --Default, min, max

local MyText = wx.wxGetTextFromUser("Message", "Caption", "Default Value")

http://www.machsupport.com/forum/index.php/topic,36207.0.html

Check out this thread as well.
Title: Re: wx.widgets
Post by: Steve Stallings on March 29, 2018, 09:37:52 AM
One tool that helps with creating GUI objects for wxWidgets is DialogBlocks.

http://www.anthemion.co.uk/dialogblocks/

Title: Re: wx.widgets
Post by: Chaoticone on March 29, 2018, 11:30:45 AM
I use this http://docs.wxwidgets.org/3.0.1/group__group__funcmacro__dialog.html#ga3267f33060d2ae403862427acb758bab

For your wxGetTextFromUser in particular.....
http://docs.wxwidgets.org/3.0.1/group__group__funcmacro__dialog.html#ga5a6a376f69f87e48e618f6f79e2c4a1b

Title: Re: wx.widgets
Post by: Chaoticone on March 29, 2018, 11:39:37 AM
This is a cheat sheet for message boxes.

Code: [Select]
--Get input from user
local MyPass = wx.wxGetPasswordFromUser("Message", "Caption", "Default Value")
local MyText = wx.wxGetTextFromUser("Message", "Caption", "Default Value")
local MyNum = wx.wxGetNumberFromUser("Message", "Prompt", "Caption", 50, 0, 100) --Default, min, max
local MyChoice = wx.wxGetSingleChoice ("message", "caption", ({"Choice1", "Choice2", "Choice3"})) --, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord, bool centre=true, int width=wxCHOICE_WIDTH, int height=wxCHOICE_HEIGHT, int initialSelection=0)
local dir = wx.wxDirSelector ("Choose a Directory", "C:\\")--Caption, default directory --long style=0, const wxPoint &pos=wxDefaultPosition, wxWindow *parent=NULL)

--wxMessageBox Types
--2 = Yes, No
--4 = Ok
--16 = Ok, Cancel
--18 = Yes, No, Cancel

--wxMessageBox Return Values
--Yes = 2
--OK = 4
--No = 8
--Cancel = 16

--Have user click a button
local Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",2) --Yes,No
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",2) --Yes,No
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",4) --Ok
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",16) --Ok, Cancel
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",16) --Ok, Cancel
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",18) --Yes, No, Cancel
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",18) --Yes, No, Cancel
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns
Iclicked = wx.wxMessageBox("This is my Message", "This is my Caption",18) --Yes, No, Cancel
wx.wxMessageBox(tostring(Iclicked)) --Show in another message box what the button click in the previous message box returns

--Another way of using a messagebox Type defined with a wx constant
local yesno = wx.wxMessageBox("This is my Message", "This is my Caption", wx.wxYES_NO)
if (yesno == wx.wxYES) then

elseif (yesno == wx.wxNO) then

end

--http://docs.wxwidgets.org/3.0.1/group__group__funcmacro__dialog.html#ga193c64ed4802e379799cdb42de252647
Title: Re: wx.widgets
Post by: thespindoctor on March 29, 2018, 12:32:21 PM
Thanks !