Hello Guest it is November 16, 2019, 07:14:54 PM

Author Topic: wx.widgets  (Read 900 times)

0 Members and 1 Guest are viewing this topic.

wx.widgets
« 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!

Re: wx.widgets
« Reply #1 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.
« Last Edit: March 29, 2018, 08:19:38 AM by Cbyrdtopper »
Chad Byrd
Re: wx.widgets
« Reply #2 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/

Steve Stallings
www.PMDX.com
For PMDX product support, please use PMDX forum or direct email for quickest response. We do not use this forum as our primary product support site.

Online Chaoticone

*
  • *
  •  5,628 5,628
  • Precision Chaos
    • View Profile
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Online Chaoticone

*
  • *
  •  5,628 5,628
  • Precision Chaos
    • View Profile
Re: wx.widgets
« Reply #4 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
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: wx.widgets
« Reply #5 on: March 29, 2018, 12:32:21 PM »
Thanks !