I am finally at wits end trying to figure out why a dialog doesn't
display properly. I have a wxFrame app that otherwise runs fine in
that I can take input from menu items, but I cannot get a dialog box
to display properly. Here is the relevant code for the app
initialization:
Note that I don't do any Bindings to the test dialog in the init_frame
() call. One of the menu items is bound to the following function to
get access to the dialog:
So, I run the app, select Options on the menu, and the dialog pops
up. However, all I have is what appears to be the frame, and no
buttons. The background of the 'frame' shows whatever was behind it.
It is like the frame is created but nothing is re-drawn over the
dialog. I am running Python 2.6 with wxWidgets 2.8.10 on WinXP SP3.
I have copied an example right out of the wxPython demo and got the
same results, so it's something I've done wrong somewhere. Any ideas
on what I should look to next?
So, I run the app, select Options on the menu, and the dialog pops
up. However, all I have is what appears to be the frame, and no
buttons. The background of the 'frame' shows whatever was behind it.
It is like the frame is created but nothing is re-drawn over the
dialog. I am running Python 2.6 with wxWidgets 2.8.10 on WinXP SP3.
I have copied an example right out of the wxPython demo and got the
same results, so it's something I've done wrong somewhere. Any ideas
on what I should look to next?
The dialog is probably hidden behind the frame. Try delaying its creation until you need it, and be sure to call its Destroy method when you are done with it. If that doesn't help then try duplicating the problem in a small standalone example.
I went back through and removed the extraneous code from the program.
I think there is a problem with the way I'm handling Paint events. In
the init_frame function, I have the following line:
self.Bind(wx.EVT_PAINT, self.OnPaint)
This is done after the resources are loaded, but before .Show() is
called on the frame. I have the following function for the OnPaint:
def OnPaint(self, evt):
dc = wx.PaintDC(evt.GetEventObject())
if (evt.GetEventObject() == self.MapPanel):
PyMapperApp.DrawMapWindow(self) #draws graphics
to the Map panel
elif (evt.GetEventObject() == self.TilePanel):
if (globals.TilesLoaded):
PyMapperApp.DrawTileWindow(self) #If loaded, draws tiles to
the Tile panel
I tried removing various line in this OnPaint function, but each time
when the dialog is to be displayed, it will pop up (in front of the
frame) but has nothing drawn on it. It is like the border of the
dialog is visible, but the buttons are hidden. Anyway, removing the
Bind statement corrects the problem, in that I can see the dialog
correctly, but without it, I can't get the panels in the frame to
update correctly.
···
On Jul 4, 3:09 pm, Robin Dunn <ro...@alldunn.com> wrote:
Mike wrote:
> So, I run the app, select Options on the menu, and the dialog pops
> up. However, all I have is what appears to be the frame, and no
> buttons. The background of the 'frame' shows whatever was behind it.
> It is like the frame is created but nothing is re-drawn over the
> dialog. I am running Python 2.6 with wxWidgets 2.8.10 on WinXP SP3.
> I have copied an example right out of the wxPython demo and got the
> same results, so it's something I've done wrong somewhere. Any ideas
> on what I should look to next?
The dialog is probably hidden behind the frame. Try delaying its
creation until you need it, and be sure to call its Destroy method when
you are done with it. If that doesn't help then try duplicating the
problem in a small standalone example.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
I went back through and removed the extraneous code from the program.
I think there is a problem with the way I'm handling Paint events. In
the init_frame function, I have the following line:
self.Bind(wx.EVT_PAINT, self.OnPaint)
This is done after the resources are loaded, but before .Show() is
called on the frame. I have the following function for the OnPaint:
def OnPaint(self, evt):
dc = wx.PaintDC(evt.GetEventObject())
if (evt.GetEventObject() == self.MapPanel):
PyMapperApp.DrawMapWindow(self) #draws graphics
to the Map panel
elif (evt.GetEventObject() == self.TilePanel):
if (globals.TilesLoaded):
PyMapperApp.DrawTileWindow(self) #If loaded, draws tiles to
the Tile panel
I tried removing various line in this OnPaint function, but each time
when the dialog is to be displayed, it will pop up (in front of the
frame) but has nothing drawn on it. It is like the border of the
dialog is visible, but the buttons are hidden. Anyway, removing the
Bind statement corrects the problem, in that I can see the dialog
correctly, but without it, I can't get the panels in the frame to
update correctly.