0

I'm doing some tutorials trying to teach myself a little Python. I found one on GUI development using TCL/TK. This code works and displays a dialog...

import tkinter
import _tkinter
tkinter._test()

This code does not...

from tkinter import *
from tkinter import ttk
root = Tk()
label = ttk.Label(root, text='Hello World')
label.pack()

I'm pretty sure my problem is with setting up Visual Studio Code. Have any of you run into this? I don't know anyone who does Gui programming in Python and only a couple who use Visual Studio Code. Python 3 and TCL/TK are installed though or the first example would not have worked.

stovfl
  • 14,998
  • 7
  • 24
  • 51
pchancey
  • 19
  • 7
  • The built-in `_test()` function ends with a call to `root.mainloop()`, which is what actually handles user interaction with the GUI that has been created. Your code lacks that line. – jasonharper Oct 01 '19 at 03:14
  • Follow this pattern: [Best way to structure a tkinter application](https://stackoverflow.com/a/17470842/7414759). Throw away ***"some tutorials"*** that using `_tkinter` or `_test()`. – stovfl Oct 01 '19 at 08:02
  • jason probably answered the question. I also discovered that code ran and displayed the gui if I put it in a terminal. score one for the tutorial. I'll check that link out stof. Thanks – pchancey Oct 02 '19 at 22:38

0 Answers0