wxTextEntryDialog Error

(Python 2.2, wxPython 2.4.1.2, Windows XP)

I've used this function for a long time without any problems.

def EntryDialog(message,title,**kwargs):
     if splashactive: return
     try:
         default = kwargs['default']
     except KeyError:
         default = ''
     dialog = wxTextEntryDialog(None,message,title,default)
     result = None
     if dialog.ShowModal()==wxID_OK:
         result = dialog.GetValue()
     dialog.Destroy()
     return result

Starting yesterday, calling the function from a specific routine reliably gives

. . .

   File "C:\CMI\Development\Modules\modCommon.py", line 868, in EntryDialog
     if dialog.ShowModal()==wxID_OK:
   File "C:\Python22\lib\site-packages\wxPython\cmndlgs.py", line 260, in ShowModal
     val = cmndlgsc.wxTextEntryDialog_ShowModal(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in c:\PROJECTS\wx\src\msw\dcmemory.cpp(115): Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)

What's causing this problem and how can I correct it?

Steve Williams wrote:

(Python 2.2, wxPython 2.4.1.2, Windows XP)

I've used this function for a long time without any problems.

def EntryDialog(message,title,**kwargs):
    if splashactive: return
    try:
        default = kwargs['default']
    except KeyError:
        default = ''
    dialog = wxTextEntryDialog(None,message,title,default)
    result = None
    if dialog.ShowModal()==wxID_OK:
        result = dialog.GetValue()
    dialog.Destroy()
    return result

Starting yesterday, calling the function from a specific routine reliably gives

. . .

  File "C:\CMI\Development\Modules\modCommon.py", line 868, in EntryDialog
    if dialog.ShowModal()==wxID_OK:
  File "C:\Python22\lib\site-packages\wxPython\cmndlgs.py", line 260, in ShowModal
    val = cmndlgsc.wxTextEntryDialog_ShowModal(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in c:\PROJECTS\wx\src\msw\dcmemory.cpp(115): Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)

What's causing this problem and how can I correct it?

I don't know. Can you reduce it to a small sample that shows the problem?

···

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

Robin Dunn wrote:

Steve Williams wrote:

(Python 2.2, wxPython 2.4.1.2, Windows XP)

I've used this function for a long time without any problems.

def EntryDialog(message,title,**kwargs):
    if splashactive: return
    try:
        default = kwargs['default']
    except KeyError:
        default = ''
    dialog = wxTextEntryDialog(None,message,title,default)
    result = None
    if dialog.ShowModal()==wxID_OK:
        result = dialog.GetValue()
    dialog.Destroy()
    return result

Starting yesterday, calling the function from a specific routine reliably gives

. . .

  File "C:\CMI\Development\Modules\modCommon.py", line 868, in EntryDialog
    if dialog.ShowModal()==wxID_OK:
  File "C:\Python22\lib\site-packages\wxPython\cmndlgs.py", line 260, in ShowModal
    val = cmndlgsc.wxTextEntryDialog_ShowModal(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in c:\PROJECTS\wx\src\msw\dcmemory.cpp(115): Bitmap is selected in another wxMemoryDC, delete the first wxMemoryDC or use SelectObject(NULL)

What's causing this problem and how can I correct it?

I don't know. Can you reduce it to a small sample that shows the problem?

Hmmm, this happens inside a routine called by OnPrintPage in a wxPrintout instance, so I don't know about a small sample. I'm prompting the operator for something to insert into a letter being printed.

I did fix the problem by creating a Dialog Frame inside the OnPrintPage routine as follows:

···

#===================================================================================
class DialogFrame(wxDialog):
     def __init__(self,parent,pos=wxDefaultPosition,size=wxDefaultSize
         ,style=wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL):
         wxDialog.__init__(self,parent,-1,'Dialog Window'
         ,wxDefaultPosition,wxDefaultSize)

     def GetResult(self,title):
         result = EntryDialog(title,'Reports')
         return result

     def Close(self):
         self.OnCloseWindow(None)

     def OnCloseWindow(self,event):
         self.Destroy()
#===================================================================================

(inside the OnPrintPage routine)
. . .

     dialogframe=DialogFrame(None,-1)
     dialogframe.Show(true)
     ColumnValue = dialogframe.GetResult('%s?' % Field[6:])
     dialogframe.Close()

. . .

This works okay.