Hello Guest it is November 14, 2019, 09:31:26 PM

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

0 Members and 1 Guest are viewing this topic.

Offline smurph

*
  • *
  •  1,149 1,149
  • "That there... that's an RV."
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #20 on: January 26, 2019, 07:30:33 PM »
Ha!  I'm NEVER right, according to wifey.  But that's ok.  :) 

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #21 on: January 27, 2019, 03:25:46 AM »
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 )

wxFormbuilder is nice software but it does have its quirks, although created with wxFB the code above is actually incorrect and should be

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 )

true and false in lua is all lower case, try this simple example to show the effects.

Code: [Select]
local test = True -- change to true and see the difference

if test then
wx.wxMessageBox('true')
else
wx.wxMessageBox('false')
end

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 #22 on: January 27, 2019, 12:33:17 PM »
Wow!  Nice catch Daz.

I guess one could do

True = true
False = false

At the top of the code. 

Steve
Re: Un-Supported wxNumberEntryDialog
« Reply #23 on: January 28, 2019, 12:47:11 AM »
Hi,
yes Daz that was well spotted.
It was my intention to edit each cell to update the data but I could not edit the cells onscreen.....here was me
thinking %$FFR%&*(*&^%!!!! wxFB.....these guys are sending me up the garden path!

But despite me having checked Editing Enable and that setting apparently propagating through to code
the syntax was just not quite right.

I think smuphs quote was 'Lua syntax......is syntax only a mother could love'.

Craig
My wife left with my best friend...
     and I miss him!
Re: Un-Supported wxNumberEntryDialog
« Reply #24 on: January 29, 2019, 03:40:27 AM »
Hi Guys,
I have another lame newbie question.

I have set up a dialog with an TxtCtrl box and an OK button:
Code: [Select]
UI = {}


-- create MyDialog
UI.MyDialog = wx.wxDialog (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog:SetSizeHints( wx.wxSize( -1,-1 ), wx.wxSize( -1,-1 ) )

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

UI.DataEntry = wx.wxTextCtrl( UI.MyDialog, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.DataEntry, 0, wx.wxALL, 5 )

UI.m_button9 = wx.wxButton( UI.MyDialog, wx.wxID_ANY, "OK", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.m_button9, 0, wx.wxALL, 5 )


UI.MyDialog:SetSizer( UI.MyDialogSizer )
UI.MyDialog:Layout()
UI.MyDialogSizer:Fit( UI.MyDialog )

UI.MyDialog:Centre( wx.wxBOTH )

-- Connect Events

UI.m_button9:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements wxID_OK

event:Skip()
return
end )
local rc=UI.MyDialog:ShowModal()
if rc==wx.wxID_OK then wx.wxMessageBox('success') end
if rc==wx.wxID_CANCEL then wx.wxMessageBox('failure')end

Note that I explicitly attached the button which result in:
 UI.m_button9:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event).

The problem is that when I single step through it all goes swimmingly until I get to the:
local rc=UI.MyDialog:ShowModal() statement. It executes and the dialog pops up, I can enter a string and exit with
a <OK> button click. The code executes the event handler function but at the end of the function re-encounters
the ShowModal()  function again and the dialog pops up again in a never ending loop.

As you can see I even tried putting a Return statement in the event handler but it returns straight to the ShowModal() function
again.

I'm struggling with what code needs to go in the handler that allows the handler to execute and then return WITHOUT
executing what amounts to its own calling statement.

I have read the explanation for event:Skip() but am far from sure that I understand its intent.

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

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Un-Supported wxNumberEntryDialog
« Reply #25 on: January 29, 2019, 05:21:20 AM »
You dont have to use a button click event  to initiate wx.wxID_OK,  within wxFB change the id of the button from wx.wxID_ANY to wx.wxID_OK and it will automatically quit the dialog for you and return the appropiate msg, also if you add a close event to the dialog as well as a cancel button you can have this return the wx.ID_CANCEL using the EndModal method and passing back wx.ID_CANCEL this should be the default return for the close but for some reason wxlUA passes back wx.wxID_OK instead??.

Code: [Select]
UI = {}


-- create MyDialog
UI.MyDialog = wx.wxDialog (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog:SetSizeHints( wx.wxSize( -1,-1 ), wx.wxSize( -1,-1 ) )

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

UI.DataEntry = wx.wxTextCtrl( UI.MyDialog, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.DataEntry, 0, wx.wxALL, 5 )

UI.m_button9 = wx.wxButton( UI.MyDialog, wx.wxID_OK, "OK", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.m_button9, 0, wx.wxALL, 5 )


UI.MyDialog:SetSizer( UI.MyDialogSizer )
UI.MyDialog:Layout()
UI.MyDialogSizer:Fit( UI.MyDialog )

UI.MyDialog:Centre( wx.wxBOTH )

UI.MyDialog:Connect( wx.wxEVT_CLOSE_WINDOW, function(event)
UI.MyDialog:EndModal(wx.wxID_CANCEL) --End the dialog and pass back wxID_CANCEL

end )

local rc=UI.MyDialog:ShowModal()
if rc==wx.wxID_OK then wx.wxMessageBox('success') end
if rc==wx.wxID_CANCEL then wx.wxMessageBox('failure')end


DazTheGas
Theres always time for a choccy biccy
Re: Un-Supported wxNumberEntryDialog
« Reply #26 on: January 29, 2019, 05:49:51 AM »
Hi Daz,
thanks for your reply. Slowly getting the hang of it.

It seems that wxWidgets is vast bewildering array of options/classes/conventions/syntax.
Having the code synthesized before your eyes is very impressive.

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