Greetings –
This question might be more of a python question than a
wxpython question. I apologize for the wordiness…
I am writing an application that uses wxpython as the front
end to a postgresql database. One frame (the main frame) has several combo
boxes and text boxes along with a few buttons. One button should bring up a
listctrl. I want to be able to select (double-click) one of rows in the list
and have this selection pass to the main application window. I can get the
listctrl to work by itself but doing a self.Destroy() at the end of the
double-click does not seem to completely clear that frame. In other words, using
print statements judiciously to monitor what is happening, the button opens the
list frame but after selecting a row with a double-click the main frame seems to
be disconnected from the operation of the listctrl until I close the main
frame.
Any guidance would be greatly appreciated.
Thank you,
Hal
Shortened versions of the pertinent code follow:
···
==============================================
Main frame:
Importing wx, some database utilities, and the listctrl
frame
Import wx, hg, hg_utilities, list_report
This is a VERY truncated version of the main
showing what I think is the pertinent items.
class CasesMainFrame(wx.Frame):
def init(self, *args, **kwds):
begin wxGlade:
CasesMainFrame.init
kwds[“style”] = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL
wx.Frame.init(self, *args, **kwds)
def OnPrint(self,event):
print
“Cases_Main_Search hg.case_selected: %s” % (hg.case_selected)
thisisatest = hg.case_selected
self.TicketLookup(thisisatest)
CaseListMain2 = CaseListMain.CaseListMain(0)
CaseListMain2.MainLoop()
For importat
class CasesMain(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
CasesMain =
CasesMainFrame(None, -1, “”)
self.SetTopWindow(CasesMain)
CasesMain.Show()
return 1
Direct call
if name == “main”:
CasesMain = CasesMain(0)
CasesMain.MainLoop()
===============================
List Control:
import wx
import hg, hg_utilities
Making use of the examples from Robin’s book
class CaseListMainFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, -1,
“wx.ListCtrl in wx.LC_REPORT mode”,
size=(600,400))
Called independently, this is a working listctrl
displaying information and closing properly on double-click
def OnDoubleClick(self, event):
print
self.ticketNumber
hg.case_selected
= self.ticketNumber
self.Destroy()
def OnItemSelected(self, event):
self.currentItem
= event.m_itemIndex
self.ticketNumber
= self.getColumnText(self.currentItem,3)
print
“self.currentItem: %s” % (self.getColumnText(self.currentItem,3))
print
“self.list.GetItemText(self.currentItem): %s” %
(self.list.GetItemText(self.currentItem))
print
“self.getColumnText(self.currentItem, 3): %s” %
(self.getColumnText(self.currentItem, 3))
For import
class CaseListMain(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
CaseListMain =
CaseListMainFrame()
CaseListMain.Show()
return 1
Direct Call
if name == “main”:
CaseListMain =
CaseListMain(0)
CaseListMain.MainLoop()