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.