Se the guess below. Could be you aren't sending a proper parent
···
-----Original Message-----
From: Paul.Kunysch@DaimlerChrysler.com
[mailto:Paul.Kunysch@DaimlerChrysler.com]
Sent: Tuesday, January 09, 2001 11:27 AM
To: wxpython-users@lists.sourceforge.net
Subject: [wxPython] stored dialogs
Hello
I'd like to write a generic dialog with 'customizable' sub-dialogs
but I can't use the 'stored' dialog after the first invokation of
wxDialog.ShowModel().
Even the close-button in the title-bar doesn't work - only ESC is
recognized. I wonder whether I'm doing something wrong or whether
there's a bug in the event system.
I've written a small demo in order to illustrate some problems:
(wxPython 2.2.2, Python 1.5.2 (2.0 crashes ), NT4 SP6)
from wxPython import wx
# This is just a boring utility function.
def init_panel_with_sizer_and_widget(panel, sizer, widget):
sizer.Add(widget, 1, wx.wxEXPAND)
panel.SetSizer(sizer)
panel.SetAutoLayout(1)
sizer.Fit(panel)
sizer.SetSizeHints(panel)
# This dialog will be created and stored in a more complex dialog.
class SimpleDialog(wx.wxDialog):
def __init__(self, parent):
wx.wxDialog.__init__(
self, parent, -1, 'SimpleDialog',
style=wx.wxDEFAULT_DIALOG_STYLE|wx.wxRESIZE_BORDER)
button = wx.wxButton(self, wx.wxID_CANCEL, 'Press ESC if broken.')
init_panel_with_sizer_and_widget(
self, wx.wxBoxSizer(wx.wxVERTICAL), button)
class TestDialog(wx.wxDialog):
def __init__(self, parent=None):
wx.wxDialog.__init__(
self, parent, -1, 'wxDialog',
style=wx.wxDEFAULT_DIALOG_STYLE|wx.wxRESIZE_BORDER)
panel = wx.wxPanel(self, -1)
box = wx.wxStaticBox(panel, -1, '')
inner_panel = wx.wxPanel(panel, -1) # Or should "box" be the parent?
inner_panel.SetBackgroundColour(wx.wxColour(0, 0, 0))
inner_panel.SetForegroundColour(wx.wxColour(255, 255, 255))
lbl_info = wx.wxStaticText(inner_panel, -1, """
The 'stored dialog' can only be used after the second
invocation. The 'generated' dialog works as expected.
Why? (Btw: it works if the parent is a wxFrame)
The inner panel is taller than expected.
The StaticBoxSizer doesn't seem to expect an empty title.
After resizing the dialog the inner panel is even taller and
the right button isn't repainted properly.
I have the impression that the right button is copied to its
new position after the original position was overwritten by the
'new' left button.
""")
init_panel_with_sizer_and_widget(
inner_panel, wx.wxStaticBoxSizer(box, wx.wxVERTICAL), lbl_info)
init_panel_with_sizer_and_widget(
panel, wx.wxStaticBoxSizer(box, wx.wxVERTICAL), inner_panel)
btn_stored = wx.wxButton(self, -1, '&Stored Dialog')
btn_generated = wx.wxButton(self, -1, '&Generated Dialog')
h_sizer = wx.wxBoxSizer(wx.wxHORIZONTAL)
h_sizer.Add(btn_stored)
h_sizer.Add(btn_generated, 0, wx.wxLEFT, 5)
sizer = wx.wxBoxSizer(wx.wxVERTICAL)
sizer.Add(panel, 1, wx.wxEXPAND|wx.wxALL, 5)
sizer.Add(h_sizer, 0, wx.wxALIGN_RIGHT|wx.wxALL^wx.wxTOP, 5)
self.SetSizer(sizer)
self.SetAutoLayout(1)
sizer.Fit(self)
sizer.SetSizeHints(self)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Just a guess but try < stored_dialog = SimpleDialog(self) >
instead of
stored_dialog = SimpleDialog(parent)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
def open_stored_dialog(event, dlg=stored_dialog):
dlg.ShowModal()
wx.EVT_BUTTON(self, btn_stored.GetId(), open_stored_dialog)
def open_generated_dialog(event, parent=parent):
SimpleDialog(parent).ShowModal()
wx.EVT_BUTTON(self, btn_generated.GetId(), open_generated_dialog)
if __name__ == '__main__':
app = wx.wxPySimpleApp()
TestDialog().ShowModal()
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users