tkinter window doesn't appear on Visual Studio for Mac
I am practicing classes with GUI and tkinter on Visual Studio for Mac. My piece of code is:
#!/usr/bin/env python3
import tkinter as tk
class AddGUI (tk.Frame):
def __init__ (self):
tk.Frame.__init__(self)
self.master.title('adding one')
self.define_widgets()
self.grid()
my_gui = AddGUI()
my_gui.mainloop()
When I run this script as python3 Tutoriol_Gui.py the script doesn't retrieve anything until I interrupt it meaning that the library is there but I don't know what to do to speed up the process or if something is missing.
$ python3 Tutoriol_Gui.py ^X^C Traceback (most recent call last): File "Tutoriol_Gui.py", line 15, in <module>
my_gui.mainloop() File "/Users/cacabezas/miniconda3/lib/python3.7/tkinter/__init__.py", line 1283, in mainloop
self.tk.mainloop(n) KeyboardInterrupt (base)
Additionally, if I run:
#!/usr/bin/env python3
import tkinter as tk
root = tk.Tk()
root.mainloop()
I got retrieved a window
I hope you could help me out. I already checked different websites but couldn't find anything useful. Thank you in advance.
• 1,892 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Not my area of expertise, and this isn't really a bioinformatics question so will probably be closed, but my guess would be that in your test case, you are instantiating the class properly:
root = tk.Tk(), which your actual code doesn't, because you're calling your own class.You
AddGUI()class should probably subclass thetk.TK()class or at least use its constructor, if that's what you intend it to do.Hello caro-ca!
We believe that this post does not fit the main topic of this site.
This isn't related to bioinformatics. If you can add context to relate it to bioinformatics, we can consider reopening it.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!