WxPython crashing PSSE
I'm running the code below using the run macro button on the toolbar in PSSE 32. It runs fine the first time. I close the window and run it again. When I close it this time, PSSE says it has encountered an error and needs to close. It seems as if the first time, there was something left running that conflicts with the second request. Is there something I need to do to effectively close the python script? Some sort of garbage collection?
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (550, 350))
system_events_list = ['Bridger Fault', 'Salt Solar Outage', 'Hunter Fault']
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
hbox3 = wx.BoxSizer(wx.HORIZONTAL)
panel = wx.Panel(self, -1)
self.system_events = wx.ListBox(panel, 26, wx.DefaultPosition, (170, 130), system_events_list, wx.LB_SINGLE)
self.system_events.SetSelection(0)
btn = wx.Button(panel, wx.ID_CLOSE, 'Close')
hbox1.Add(self.system_events, 0, wx.TOP, 40)
hbox3.Add(btn, 0, wx.ALIGN_CENTRE)
vbox.Add(hbox1, 0, wx.ALIGN_CENTRE)
vbox.Add(hbox3, 1, wx.ALIGN_CENTRE)
panel.SetSizer(vbox)
self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
self.Bind(wx.EVT_LISTBOX, self.OnSelect, id=26)
def OnClose(self, event):
self.Close()
def OnSelect(self, event):
index = event.GetSelection()
system_event = self.system_events.GetString(index)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'listbox.py')
frame.Centre()
frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()
thanks EBahr! Works perfect now.
@nwilson no problem! This one had me scratching my head for a while... also, those look like PACE system events ;)