Displaying a modeless wxDialog

I created a wxDialog containing a multi-line wxTextCtrl and a (disabled)
close button and tried to display it as a modeless dialog using .Show(1)
The intention is to report the progress of some file processing as it
happens, then to enable the Close button and switch to a modal display
until the user has finished reading it. But the dialog doesn't get
displayed prperly using .Show, only the panel and the part of the text
control being updated.

Using wxPython 2.4.2.4 with Python 2.3 and Windows 2000, I can reproduce
this in the demo by replacing lines 88-104 of wxDialog.py in demo with:

        sizer.Fit(self)

        self.field2 = text # NEW

···

#---------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestDialog(frame, -1, "A wxDialog", size=wxSize(350, 200),
                     #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
                     style = wxDEFAULT_DIALOG_STYLE
                     )
    win.CenterOnScreen()

    import time #NEW
    win.Show(1) #NEW
    for n in range(10): #NEW
        win.field2.AppendText(str(n)) #NEW
        time.sleep(1) #NEW
    win.Show(0) #NEW

    val = win.ShowModal()
    if val == wxID_OK:
        log.WriteText("You pressed OK\n")
    else:
        log.WriteText("You pressed Cancel\n")

Is this a valid way to use a dialog?

Regards,

David Hughes
Forestfield Software Ltd
www.forestfield.co.uk

David Hughes wrote:

I created a wxDialog containing a multi-line wxTextCtrl and a (disabled) close button and tried to display it as a modeless dialog using .Show(1)
The intention is to report the progress of some file processing as it happens, then to enable the Close button and switch to a modal display until the user has finished reading it. But the dialog doesn't get displayed prperly using .Show, only the panel and the part of the text control being updated.

Using wxPython 2.4.2.4 with Python 2.3 and Windows 2000, I can reproduce this in the demo by replacing lines 88-104 of wxDialog.py in demo with:

        sizer.Fit(self)

        self.field2 = text # NEW

#---------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestDialog(frame, -1, "A wxDialog", size=wxSize(350, 200),
                     #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
                     style = wxDEFAULT_DIALOG_STYLE
                     )
    win.CenterOnScreen()

    import time #NEW
    win.Show(1) #NEW
    for n in range(10): #NEW
        win.field2.AppendText(str(n)) #NEW
        time.sleep(1) #NEW
    win.Show(0) #NEW

    val = win.ShowModal()
    if val == wxID_OK:
        log.WriteText("You pressed OK\n")
    else:
        log.WriteText("You pressed Cancel\n")

Is this a valid way to use a dialog?

Probably not. I think you need to either do it one way or another. If you use it modeless you need to return to the event loop in order for updates and what not to be processed.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

> Is this a valid way to use a dialog?

Probably not. I think you need to either do it one way or another. If
you use it modeless you need to return to the event loop in order for
updates and what not to be processed.

--
Robin Dunn

Thanks, Robin. A call to myApp.Yield() was the answer. Why is it that the
brain never clicks into the right mode until just after you ask for
help and press the send button? :wink:

David