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
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
All of these say they are undefined.
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()
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()
All of these say they are undefined.
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.
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.
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?
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?
ASKER
I'm going to reinstall it, thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.