wxPython problems (XRC problems)

Andrei S. w3c at hot.ee
Sun Jan 26 18:00:06 CET 2003


I've met wxPython for GUI applications programming and just loved it. 
Especially for the XRC feature.

The bad thing is that there is no API docs specially for wxPython (not 
wxWindows), I have found so far. I understand, that wxPython is just a 
binding for wxWindows, but I need the Python-specific docs...

So, I've got the problem that I can't solve with docs reading...
The problem is the following.

I'm making a simple test application, with different controls to test, 
especially such as buttons, text inputs, wxCalendarCtrl and others. I 
want to have this all in the dynamically loaded XML resource file (XRC). 
The GUI is edited through the XRCed app, shipped with the wxPython package.

I have the following widget structure:


wxFrame "main_frame"
	   |-wxButton "button_select_date"

wxDialog "select_date_dialog"
	|	|
	|	|-wxCalendarCtrl
		|-wxButton "sdate_ok_button"
		|-wxButton "sdate_cancel_button"


(Spacers and some others are omitted here).

I'm initialising the dialog with wxCalendarCtrl widget by writing the 
following code in InitSelDate(self) function of class MyApp(wxApp):

*-- python code --*

self.date_dialog 	= self.res.LoadDialog(self.frame, "select_date_dialog")
self.calendar_ctrl	= XRCCTRL(self.date_dialog, "calendar_ctrl")

EVT_BUTTON(self, XRCID("sdate_button_ok"), self.OnSelectDateOK)
EVT_BUTTON(self, XRCID("sdate_button_cancel"), self.OnSelectDateCancel)

*-- python code --*

Then I call this function from OnInit method and from OnSelectDate 
method with "if not self.date_dialog" predicate.

Then I get the following when running the program:

AttributeError: wxControlPtr instance has no attribute 'GetDate'

So it seems like XRCCTRL(self.date_dialog, "calendar_ctrl") makes a 
wxControlPtr object but not wxCalendarCtrlPtr... Any tips on making it 
return wxCalendarCtrlPtr objects?

Ok, I remove this line. It runs successfully, but the "sdate_button_ok" 
and "sdate_button_cancel" seem like don't have an event boundary, I 
mean, when I click the button, program never calls the *OnSelectDateOK* 
and *OnSelectDateCancel* event handling methods...

Are there any wxPython users in here that could help me solve these 

Andrei Sosnin

  <!-- : it all depends on your vision : -->

More information about the Python-list mailing list