python - Passing an argument to create a window using wxpython? -


I'm learning how to create a GUI in Python. After an online tutorial, I came to know that the following code 'works' in creating an empty window:

  import wx to sys import arg class class (wx.frame): def __init __ (Self, parent, id): wx.frame.__init__ (self, guardian, id, 'frame aka window', size = (300, 200)) if __name__ == '__ main__': App = wx.PySimpleApp () frame = bucky (parent = none, id = -1) frame.show () app. Main Loop ()  

This brings me to a window, which is great though, what if I want to get an argument on the program to determine the size of the window? I thought that something like this should be done to:

  import wx to sys import argv script, x, y = argv class mywindow (wx.frame): def __init __ (self, Parent, id): Wx.Frame .__ init __ (self, guardian, id, 'frame aka window', size = (x, y)) if ___name == '__ main__': app = wx PySimpleApp () frame = mywindo (original = none), id = -1) frame. Show () app The main loop ()  

But, sorry, it does not work! I am getting the following error:

  traceback  

How do I create a window based on user input such as I have tried the above?

sys.argv elements are string; They need to convert them to integers before using them instead of relying on

, though they consider moving them to the constructor

Comments