Dave Coventry wrote:
The first parameter is the window that should be the parent of the dialog (if any.) The second is the name of the dialog definition in the XRC. In XRCed this is the XML ID field.
Thank you. The dialog displays very nicely. However, I'm having a bit of trouble processing the results:
wx.EVT_BUTTON(DataDialog, xrc.XRCID('wxID_OK'), self.CloseDataD)
def CloseDataD(self,e):
print xrc.XRCID('TABLE_SELECT') # <- This is a ComboBox
DataDialog.Close()
The above code generates an error "DataDialog is not defined" (obviously because the "DataDialog" is not in the "CloseDataD" namespace)
Right, so you would want to save a reference to it in self so you can access it later in the event handler. Also, the proper way to close a modal dialog is to call it's EndModal(value) method, where value is the integer that you want to be returned from the ShowModal call. Finally, dialogs already have a default button handler for the ok and cancel buttons, so you could write the above something like this instead:
if DataDialog.ShowModal() == wx.ID_OK:
# do something here with the values
DataDialog.Destroy()
Also, how can I get the Selected item in the ComboBox?
combo = xrc.XRCCTRL(DataDialog, 'TABLE_SELECT')
value = combo.GetValue()
Then my suggestion is to define panels in XRC with their controls, and then you can easily create the new panel when needed, then destroy the old one.
Yes, that was my plan.
However if I understand correctly you are talking about generating the XML on the fly and in that case pywxrc won't help you much as it is generating Python modules from the XRC.
Yes, I can't tell how many fields are going to be required in advance.
You might want to consider not using XRC for this. Since you have to dynamically decide at runtime what controls to put on the form and then generate the XRC for it, then it may be just as easy or easier to just dynamically generate the controls and such themselves. That way you can encapsulate some common functionality in a base class, and the code using the form doesn't have to know as much about how it is constructed.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!