Hi. I just got started using wxPython and I was wondering how to create a button which transferred the user from one screen to another.
To kind of illustrate what I mean, I created two files, 'main.py' and 'newgame.py'. I've made a button called 'New Game' in the main.py file, and I'm trying to create a scenario where clicking this button will bring you to the 'newgame.py' screen.
What I've got for the 'main.py' file so far is:
import wx class velvet(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Example', size = (800, 640)) panel = wx.Panel(self) ngbutton = wx.Button(panel, label = "New Game", pos = (50, 50), size = (120, 120)) self.Bind(wx.EVT_BUTTON, self.newgamebutton, ngbutton) exitbutton = wx.Button(panel, label = "Exit", pos = (50, 250), size = (120, 120)) self.Bind(wx.EVT_BUTTON, self.closebutton, exitbutton) self.Bind(wx.EVT_CLOSE, self.closewindow) def newgamebutton(self, event): def closebutton(self, event): self.Close(True) def closewindow(self, event): self.Destroy() if __name__ == '__main__': app = wx.PySimpleApp() frame = velvet(parent = None, id = -1) frame.Show() app.MainLoop()
I was thinking that entering a self.event command for newgamebutton would solve the problem, but I'm not sure which event I could use or how I'd even get it to recognise that it should display the newgame.py file.
I've probably went about this in entirely the wrong way, but any help will be very much appreciated!