Link to home
Start Free TrialLog in
Avatar of burnedfaceless
burnedfaceless

asked on

Trying to run a Python Tkinter program

I'm trying to create a Tkinter tutorial https://likegeeks.com/python-gui-examples-tkinter-tutorial/amp/

I'm running Ubuntu 18.04 with Python 3.6.5 installed.

Here is my code

from tkinter import *

window = Tk()

window.title("Welcome to LikeGeeks app")

window.mainloop()

Open in new window


I get an error that Tk() is not defined.

When I run sudo apt install python3-tk it says it is already installed.

I have run variations of the code below

window = Tkinter()
window = tk()

Open in new window


All of these say they are undefined.
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

You're code runs successfully on Windows.
The fact that you are getting an error suggests that your installation of Python is incomplete.
I would suggest that you check it, or reinstall it.

From the tutorial:

"Tkinter package is shipped with Python as a standard package, so we don’t need to install anything to use it."

So, if "Tk()" is undefined, it's missing from the installation.
Avatar of burnedfaceless
burnedfaceless

ASKER

What's weird is that I wanted to run some Turtle programs, and I got an error message and ran

sudo apt install python3-tk

and now it's installed. Turtle programs run.


When I run the shell command above it says python3-tk is already installed.

Any ideas on how to trouble shoot this?
I'm going to reinstall it, thanks.
ASKER CERTIFIED SOLUTION
Avatar of burnedfaceless
burnedfaceless

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial