# makes a game by showing 2 dialogs # after dialogs have been answered, starts the game by drawing the canvas. # imports import wx import Board # globals SCRWIDTH = 950 SCRHEIGHT = 700 # dialogbox class class MyDialog1(wx.Dialog): def __init__(self, parent): wx.Dialog.__init__(self, parent) self.username = wx.TextCtrl(self) self.okButton = wx.Button(self, wx.ID_OK, "OK") class MyDialog2(wx.Dialog): def __init__(self, parent): wx.Dialog.__init__(self, parent) self.canvasWidth = wx.TextCtrl(self) self.okButton = wx.Button(self, wx.ID_OK, "OK") # main class class Game(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, title='My game', size=(SCRWIDTH, SCRHEIGHT)) self.username = "" self.canvasWidth = 10 # hide the frame for now self.Hide() def OnInit(self): #Make your dialogs dlg1 = MyDialog1(self) #if the user pressed "OK" (i.e. NOT "Cancel" or any other button you might add) if dlg1.ShowModal() == wx.ID_OK: #get the username from the dialog self.username = dlg1.username.GetValue() #clean up the dialog (AFTER you get the username) dlg1.Destroy() dlg2 = MyDialog2(self) #if the user pressed "OK" (i.e. NOT "Cancel" or any other button you might add) if dlg2.ShowModal() == wx.ID_OK: #get the username from the dialog self.canvasWidth = dlg2.canvasWidth.GetValue() #clean up the dialog (AFTER you get the username) dlg2.Destroy() # Now that you have your settings, Make the gameboard # THIS PART IS STILL BROKEN! # I can paste the whole board class (structure of it is taken from the tetris tutorial) # but that seems a bit much tbh... self.gameBoard = Board.Board(self) self.gameBoard = SetFocus() self.gameBoard.start() self.Centre() self.Show(True) #show the frame if __name__ == '__main__': # how can I start the game here? app = wx.App() app.MainLoop()