Modal window not behaving modally

I'm sure this is not wxPython problem but my conceptual mis-understanding of
how to implement it. If anyone finds time to reply can you make the reply
basic and not general as my programming skills are very basic and I am just
learning this still (otherwise I won't understand your reply)

Prior to description, it is part of www.gnumed.org project, and as the code is
complex, dependent for running on other complex imported database dependant
modules I cannot reproduce it here in running form, so I'll describe it as
best I can.

We have a textbox which takes input and searches the postgresql backend for
patients. If multiple patients are found it calls a picklist as a modal
wxMessageDialog box:

class cPatientPickList(wx.wxDialog):
  def __init__(
    self,
    parent,
    id = -1,
    title = _('please select a patient'),
    pos = (-1, -1),
    size = (600, 400),
  ):
    wx.wxDialog.__init__(
      self,
      parent,
      id,
      title,
      pos,
      size,
      style = wx.wxDEFAULT_DIALOG_STYLE | wx.wxRESIZE_BORDER | wx.wxSTAY_ON_TOP
    )

    self._do_layoutb() #add the list and extra buttons
    self.items = []

This is called from:

class cPatientSelector(wx.wxTextCtrl):
  """Widget for smart search for patients."""
  def __init__ (self, parent, id = -1, pos = wx.wxPyDefaultPosition, size =
wx.wxPyDefaultSize):
    self.curr_pat = gmPatient.gmCurrentPatient()

    # need to explicitely process ENTER events to avoid
    # them being handed over to the next control
    wx.wxTextCtrl.__init__(
      self,
      parent,
      id,
      '',
      pos,
      size,
      style = wx.wxTE_PROCESS_ENTER
    )

When multiple patient occurences exist this code is used and is passed the
data and column lists:

      dlg = cPatientPickList(parent = self)
      dlg.SetItems(pat_list, self.prev_col_order)
      dlg.Centre()
      dlg.ShowModal()
      dlg.Destroy()

Now if run via the wigit tester it behaves modally as one would expect,
exactly the same as in the wxPython demo - ie one cannot click on the
background but have to close the dialog first.

if __name__ == "__main__":
  _log.SetAllLogLevels(gmLog.lData)
  app = wx.wxPyWidgetTester(size = (200, 40))
  app.SetWidget(cPatientSelector, -1)
  app.MainLoop()

Now, within the main gnuMed program the cPatientSelector(wx.wxTextCtrl):
sits on a toolbar at the top. when multiple patients occur, the list pops up
Now however, the 'modal' dialog doesn't behave and one can click anywhere on
the gnumed interface, or on the calling textbox and one 'loses' the box to
the back. Obviously a mis-understanding about how and where one calls it
from.

Any pointers (in simple language) appreciated.

Thanks

Richard Terry
gnuMed Project.

Richard Terry wrote:

Now, within the main gnuMed program the cPatientSelector(wx.wxTextCtrl): sits on a toolbar at the top. when multiple patients occur, the list pops up
Now however, the 'modal' dialog doesn't behave and one can click anywhere on the gnumed interface, or on the calling textbox and one 'loses' the box to the back. Obviously a mis-understanding about how and where one calls it from.

Does it make a difference what the dialog's parent window is? Try using wxGetTopLevelParent(self) or perhaps None.

Which platform and version are you working with?

···

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

I've got something like this in a little project I'm working on:

class MyFrame(wx.Frame):
    def __init__( <stuff> ):
        self.SetIcon(wx.Icon("media/ToolBox.ico",wxBITMAP_TYPE_ICO))

When I run the application, it crashes out with the following error message:

NameError: global name 'wxBITMAP_TYPE_ICO' is not defined

I found some sample code on the net, and *IT* seems to validate what I've done. I've tried sprinkling around a few of these in my code:

wx.InitAllImageHandlers()

But that didn't seem to make any difference. I've changed the icon type. I've tried loading .ICO, .XPM, .GIF files. None work, and all give me the appropriate variation of the above error message.

I expect the solution is astonishingly simple, but google didn't return anything useful.

I'll provide more information if that would help anybody make a suggestion for me to try.

Thanks in Advance

Brian Ackermann

Make that wx.BITMAP_TYPE_ICO and you're ready for the races.

···

On Tue, 24 Aug 2004 15:58:00 -0500, Brian J. Ackermann <brianj774@gmx.net> wrote:

NameError: global name 'wxBITMAP_TYPE_ICO' is not defined