Hello everyone.
I'm sorry to bother y'all with my stupid questions, but I just can't get some simple stuff and hours of search doesn't help me. :(
I'm trying to create classes for my GUI, so I could initialize main window through "w = Window()", not "w = tk.Tk()".
Window class should hold my default options for the window (i.e. "self.geometry("640x480" and etc.).
Next, I'd like to create inner class in the Window's class - "Form", and then inner classes for buttons and etc. in this form.
Is this the right idea of organizing my GUI?
I'd like to make my code good to understand for others and keep thing organized.
Also, one of the key features that I need is ability to access these elements from any other part of the code after initialization.
I've started to create a Window class and got some problems from the start.
My code:
Thanks in advance for help!
I'm sorry to bother y'all with my stupid questions, but I just can't get some simple stuff and hours of search doesn't help me. :(
I'm trying to create classes for my GUI, so I could initialize main window through "w = Window()", not "w = tk.Tk()".
Window class should hold my default options for the window (i.e. "self.geometry("640x480" and etc.).
Next, I'd like to create inner class in the Window's class - "Form", and then inner classes for buttons and etc. in this form.
Is this the right idea of organizing my GUI?
I'd like to make my code good to understand for others and keep thing organized.
Also, one of the key features that I need is ability to access these elements from any other part of the code after initialization.
I've started to create a Window class and got some problems from the start.
My code:
import tkinter as tk class Window(tk.Tk()): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if __name__ == "__main__": w = Window() w.mainloop()Errors:
Quote:Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\pydevd.py", line 1758, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\pydevd.py", line 1752, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\pydevd.py", line 1147, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/operator/PycharmProjects/forms/newforms.py", line 5, in <module>
class Window(tk.Tk()):
File "C:\Users\operator\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2023, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TypeError: create() argument 2 must be str, not tuple
Thanks in advance for help!