I have a program which initiates a logon sequence when an instance of the main
window class is created. All i'm trying to do, is beable to destroy the main
window then restart it.
class MainWindow(wx.Frame):
def __init__(self, parent, title):
super(MainWindow, self).__init__(parent, wx.ID_ANY, title,
size=wx.Size(1024, 768))
self._create_log_on()
.....
.....
.....
def _logoff(self):
window_restart()
def window_restart():
view.Close(True)
view = MainWindow(None, "Title")
if __name__ == "__main__":
app = wx.PySimpleApp()
view = MainWindow(None, "Title")
app.MainLoop()
Now, when I call my self._logoff method, it correctly calls window_restart()
but I get "UnboundLocalError: local variable 'view' referenced before
assignment" on the view.Close(True) line. Surely view would still be
available within window_restart?
I have a feeling I should probably be doing this in a different way anyway, I
don't want to kill the app, just destroy the current MainWindow instance and
create a new one.
Many Thanks
Caig