Support Forums

Full Version: WXPython opening new screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
heeuy people

I'm creating a program but I'm finding a problem.. how to make a new window?

like when they press the button it goes to a new page?

code:
Code:
import wx

class bucky(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self, parent, id, "Welcome To The Game", size=(600,300))
        panel=wx.Panel(self)

        wx.StaticText(panel, -1, "Hello I'm Mister FeellingLeSS", (50,50))
        wx.StaticText(panel, -1, "When You Are Reading This You Have Fallen Victim To My Game", (50,80))
        wx.StaticText(panel, -1, "The Rules Are Simple, Play My Game And Win.", (50,100))
        wx.StaticText(panel, -1, "However When You Lose Your C: Drive Will Be Formatized.....", (50,120))
        wx.StaticText(panel, -1, "To Win You must Solve the Riddle On The Next Page", (50,140))
        wx.StaticText(panel, -1, "You will Have 20 Minutes To Solve It, Oh Btw Dont Close This Window For Your Own Sake...", (50,160))
        topage2button=wx.Button(panel, label="next page", pos=(200,200), size=(60,30))
        self.Bind(wx.EVT_BUTTON, self.page1button, topage2button)
        self.Bind(wx.EVT_CLOSE, self.closewindow)

    def closewindow(self,event):
        self.destroy()

    def page1button(self,event):
        page2.page2()


    
        
class page2(wx.Frame):

    def page2(self, parent, id):
        wx.Frame.page2(self, parent, id, "Welcome To The Game", size=(600,300))
        panel2=wx.Panel(self)
        wx.StaticText(panel2, -1, "Hello I'm Mister FeellingLeSS", (50,50))
        
class xbutton(wx.Frame):
    
    def thexbutton(self,parent,id):
        wx.Frame.page2(self, parent, id, "Welcome To The Game", size=(600,300))
        panel3=wx.Panel(self)
        wx.StaticText(panel3, -1, "ARE YOU SURE?", (50,80))
        
if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=bucky(parent=None,id=-1)
    frame.Show()
    app.MainLoop()

please tell me what I did wrong and replace it Big Grin