2.4.0.7 introduces a change in wxListCtrl?

Robin Dunn wrote:

Ah. I added a manifest file in 2.4.0.4 that tells XP to turn on the themes. If you can reduce it to a small sample I'll be interested in taking a look at it.

Here is a small example that demonstrates the problem I am seeing. If I run it with themes enabled on XP, the list ctrl appears and then is quickly erased. If I run it with themes disabled it works (in a squarish way).

Any workaround appreciated.

Thanks
gb

from wxPython.wx import *

class mailbox_window(wxSplitterWindow):
def __init__(self, parent, frame, mailbox):
splitterId = wxNewId()
wxSplitterWindow.__init__(self, parent, splitterId)
listId = wxNewId()
self.msglist = wxListCtrl(self, listId,
style=wxLC_REPORT|wxNO_BORDER)
self.msglist.InsertColumn(0, 'From/To')
self.msglist.InsertColumn(1, 'Subject')
self.msglist.InsertColumn(2, 'Date')
self.msglist.InsertColumn(3, 'Size')
self.text = wxPanel(self, -1)
self.sashPosition = 200
self.SplitHorizontally(self.msglist, self.text, self.sashPosition)
self.SetSashPosition(self.sashPosition)

for i in range(20):
s = str(i)
row = i
self.msglist.InsertStringItem(row, s)
self.msglist.SetStringItem(row, 1, s)
self.msglist.SetStringItem(row, 2, s)
self.msglist.SetStringItem(row, 3, s)

class MailboxNotebook(wxNotebook):
def __init__(self, parent, style):
self.parent = parent
self.currentPage = None
id = wxNewId()
wxNotebook.__init__(self, parent, id, style=style)

def AddIndexedPage(self, page, label, selected, index):
self.AddPage(page, label, selected)

class GBMailFrame(wxFrame):
def __init__(self, parent, title):
id = wxNewId()
wxFrame.__init__(self, parent, id, title)
self.splitter = wxSplitterWindow(self, -1)
self.boxtree = wxPanel(self.splitter, -1)
self.mailboxes = MailboxNotebook(self.splitter, style=wxNB_BOTTOM)
self.splitter.SplitVertically(self.boxtree, self.mailboxes, 200)
self.Show(true)
self.AddMailbox('{localhost}INBOX')

def AddMailbox(self, boxname):
win = mailbox_window(self.mailboxes, self, boxname)
self.mailboxes.AddIndexedPage(win, 'INBOX', 1, boxname)

class GBMailApp(wxApp):
def OnInit(self):
self.frame = GBMailFrame(None, "GBMail")
return true

def main():
app = GBMailApp(0)
app.MainLoop()

main()

Hey guys:

I have a question about getting control back after a confirmation popup window. So...you make some changes to an image or document etc, and then before you save it, you try to open another doc, or change modes or something. I have a little window popup giving you options like "Save changes and continue" "Undo changes and continue" "Cancel".

The question is: How do I return control back to my function right after the point where I opened the window? In psudo code...like this:

def function changeMode(...):
   if changes not saved:
      popupWindow asking for confirmation
    change mode, do other operations, etc.

In my code, I can't figure out how to get it to do the "change mode, do other..." after the window pops up. I thought I could just have the popup call that function...but this popup is spawned by 4 or 5 different functions. So, it would be best to return control...rather than perform the operations from in the popup.

Ideas?

Thanks!
Matt

If I understand the question correctly, I've just covered the same thing.

This is how I did it, with all the guts pulled out. Run Weekly.Py & play with the buttons or spin controls to see what happens.

I'm only using a yes/no dialog, but the principle is the same.

Relevant code from Weekly.py (so you don't read the whole thing):

The dialog is shown in this function:

    def Question(self, message):
        dlg = wxMessageDialog(self, message, \
                    "Chris's Footy Tipping", \
                    wxYES_NO | wxICON_INFORMATION)
        if dlg.ShowModal() == wxID_YES:
            dlg.Destroy()
            return True
        else:
            dlg.Destroy()
            return False

which gets called from an event triggered function eg

    def ChooseTipper(self, event):
        message = "Do you want to save the changes?"
        result = self.Question(message)
        self.ShowResult(result)

I did the testing in a different function, rather that edit every function

    def ShowResult(self, result):
        if result:
            self.label_3.SetLabel('You pressed Yes')
        else:
            self.label_3.SetLabel('You pressed No')
        self.label_3.Show(True)
        self.timer.Start(2500, wxTIMER_ONE_SHOT)

Hope this helps a little,

Chris.

wWeekly.py (12.4 KB)

Weekly.py (25.8 KB)

···

----- Original Message -----
From: Matt Graham
To: wxPython-users@lists.wxwindows.org
Sent: Monday, April 07, 2003 1:46 PM
Subject: [wxPython-users] Getting Control back after a Popup confirm Dialog

Hey guys:

I have a question about getting control back after a confirmation popup
window. So...you make some changes to an image or document etc, and
then before you save it, you try to open another doc, or change modes or
something. I have a little window popup giving you options like "Save
changes and continue" "Undo changes and continue" "Cancel".

The question is: How do I return control back to my function right
after the point where I opened the window? In psudo code...like this:

def function changeMode(...):
   if changes not saved:
      popupWindow asking for confirmation

   change mode, do other operations, etc.

In my code, I can't figure out how to get it to do the "change mode, do
other..." after the window pops up. I thought I could just have the
popup call that function...but this popup is spawned by 4 or 5 different
functions. So, it would be best to return control...rather than perform
the operations from in the popup.

Ideas?

Thanks!
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Gary Bishop wrote:

Robin Dunn wrote:

Ah. I added a manifest file in 2.4.0.4 that tells XP to turn on the themes. If you can reduce it to a small sample I'll be interested in taking a look at it.

Here is a small example that demonstrates the problem I am seeing. If I run it with themes enabled on XP, the list ctrl appears and then is quickly erased. If I run it with themes disabled it works (in a squarish way).

Any workaround appreciated.

A quickie workaround for your sample is to move Self.Show() to be after the self.AddMailbox. Since the frame will get a resize event when it is first shown then the mailbox window will get sized too and refreshed. This isn't a general solution for you though since you probably want to add more of them after is is created. So you can either do something that causes the wxListCtrl to get resized after it is initially shown, or at least give it a Refresh, such as this at the end of mailbox_window.__init__

  wxCallAfter(self.msglist.Refresh, True)

BTW, this is definitely a bug, please enter a bug report about it in the wxMSW category.

···

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

Matt Graham wrote:

Hey guys:

I have a question about getting control back after a confirmation popup window. So...you make some changes to an image or document etc, and then before you save it, you try to open another doc, or change modes or something. I have a little window popup giving you options like "Save changes and continue" "Undo changes and continue" "Cancel".

The question is: How do I return control back to my function right after the point where I opened the window? In psudo code...like this:

def function changeMode(...):
  if changes not saved:
     popupWindow asking for confirmation

  change mode, do other operations, etc.
\

Use a class derived from wxDialog and then use it's ShowModal method to display it. When the dialog is closed then control returns to just after the ShowModal call.

···

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

Thanks Chris:

This was just what I needed. I was able to add a cancel button as well,
so the users have "Yes" "No" and "Cancel" as options. Totally helpful.

Keep on keepin' on,
Matt

···

On Mon, 2003-04-07 at 00:19, Chris Munchenberg wrote:

If I understand the question correctly, I've just covered the same thing.

This is how I did it, with all the guts pulled out. Run Weekly.Py & play with the buttons or spin controls to see what happens.

I'm only using a yes/no dialog, but the principle is the same.

Relevant code from Weekly.py (so you don't read the whole thing):

The dialog is shown in this function:

    def Question(self, message):
        dlg = wxMessageDialog(self, message, \
                    "Chris's Footy Tipping", \
                    wxYES_NO | wxICON_INFORMATION)
        if dlg.ShowModal() == wxID_YES:
            dlg.Destroy()
            return True
        else:
            dlg.Destroy()
            return False

which gets called from an event triggered function eg

    def ChooseTipper(self, event):
        message = "Do you want to save the changes?"
        result = self.Question(message)
        self.ShowResult(result)

I did the testing in a different function, rather that edit every function

    def ShowResult(self, result):
        if result:
            self.label_3.SetLabel('You pressed Yes')
        else:
            self.label_3.SetLabel('You pressed No')
        self.label_3.Show(True)
        self.timer.Start(2500, wxTIMER_ONE_SHOT)

Hope this helps a little,

Chris.

----- Original Message -----
From: Matt Graham
To: wxPython-users@lists.wxwindows.org
Sent: Monday, April 07, 2003 1:46 PM
Subject: [wxPython-users] Getting Control back after a Popup confirm Dialog

Hey guys:

I have a question about getting control back after a confirmation popup
window. So...you make some changes to an image or document etc, and
then before you save it, you try to open another doc, or change modes or
something. I have a little window popup giving you options like "Save
changes and continue" "Undo changes and continue" "Cancel".

The question is: How do I return control back to my function right
after the point where I opened the window? In psudo code...like this:

def function changeMode(...):
   if changes not saved:
      popupWindow asking for confirmation

   change mode, do other operations, etc.

In my code, I can't figure out how to get it to do the "change mode, do
other..." after the window pops up. I thought I could just have the
popup call that function...but this popup is spawned by 4 or 5 different
functions. So, it would be best to return control...rather than perform
the operations from in the popup.

Ideas?

Thanks!
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org