I’m trying to use validators to transfer data between widget and app. Looks like a really convenient way to populate widgets with data. Robin Dunn’s book is a great resource.
The issue I’m running into is: some widgets get their data transferred, some not. Namely, CheckBox does not get transferred (and probably RadioButtons either, although I did not test those); the TransferFromWindow method gets called, but the data does not arrive anywhere (e.g. printing out the collected data misses the CheckBox values).
I found a StackOverflow thread on the topic (link) where the last answer says: have the dialog as parent for the widgets, not a panel of the dialog. I currently have a wx.Panel (direct child of the wx.Dialog) as parent for all my widgets.
Now back to Robin’s book: : Pt. 9.5.2 gives a nice example, and if reading between the lines, one understands: the transfer happens when the dialog is opened and closed. So things line up.
My question is: would this be so simple?
And a second question: is there some reference on how to create the parent/child tree within a Dialog to make sure all side effects happen as they should?
It’s not that you shouldn’t use a panel within the dialog, just that in most cases it is not necessary. The data transfer and validation functionality is designed for use when the widgets are direct children of the dialog, but there is the wx.WS_EX_VALIDATE_RECURSIVELY extra style flag that can be used to tell wx to go down to the next layer in the widget hierarchy. I don’t recall off the top of my head if the flag is needed on all containers or just the dialog, but you can experiment with that to find out.
···
On Tuesday, April 9, 2019 at 8:25:38 AM UTC-7, Jakab Gábor wrote:
I found a StackOverflow thread on the topic (link) where the last answer says: have the dialog as parent for the widgets, not a panel of the dialog. I currently have a wx.Panel (direct child of the wx.Dialog) as parent for all my widgets.
Now back to Robin’s book: : Pt. 9.5.2 gives a nice example, and if reading between the lines, one understands: the transfer happens when the dialog is opened and closed. So things line up.
My question is: would this be so simple?
And a second question: is there some reference on how to create the parent/child tree within a Dialog to make sure all side effects happen as they should?
I already had the recursive validation set, so I had to look elsewhere for the problem.
It turned out to be the lack of having the validator defined for said controls. Obviously a heavy case of PEBKAC.
So I have now two dev branches: one where panels are completely removed and one where widgets are on a panel. Both work but tests are broken in the panelless one. \o/
Which branch shall I choose?
I plan to extend the dialogs later (status bar, possible an area to show a dxf drawing etc.). I guess it makes more sense to keep the panels once they work.
···
On Tuesday, April 9, 2019 at 5:25:38 PM UTC+2, Jakab Gábor wrote:
Dear all,
I’m trying to use validators to transfer data between widget and app. Looks like a really convenient way to populate widgets with data. Robin Dunn’s book is a great resource.
The issue I’m running into is: some widgets get their data transferred, some not. Namely, CheckBox does not get transferred (and probably RadioButtons either, although I did not test those); the TransferFromWindow method gets called, but the data does not arrive anywhere (e.g. printing out the collected data misses the CheckBox values).
I found a StackOverflow thread on the topic (link) where the last answer says: have the dialog as parent for the widgets, not a panel of the dialog. I currently have a wx.Panel (direct child of the wx.Dialog) as parent for all my widgets.
Now back to Robin’s book: : Pt. 9.5.2 gives a nice example, and if reading between the lines, one understands: the transfer happens when the dialog is opened and closed. So things line up.
My question is: would this be so simple?
And a second question: is there some reference on how to create the parent/child tree within a Dialog to make sure all side effects happen as they should?