Error "ImportError: No module named tkinter" in Python Programming

Hi,

I am trying to write a Python program. This program is supposed to make a bar with two buttons on it pop up.

However, I cannot get this to work. The error is: "ImportError: No module named tkinter"

Below is the script of my program.

If anyone know enough about Python to know what I'm doing wrong, help would be greatly appreciated!

Thanks!

 

from tkinter import *

class Application(Frame):
    def say_Yeh(self):
        print("Yeh! Your button just did something!")

    def createWidgets(self):
        self.QUITBUTTON = Button(self)
        self.QUITBUTTON["text"] = "QUIT BUTTON"
        self.QUITBUTTON["fg"]   = "red"
        self.QUITBUTTON["command"] = self.quit
       
        self.QUITBUTTON.pack({"side": "left"})

        self.do_something = Button(self)
        self.do_something["text"] = "CLICK TO DO SOMETHING BUTTON",
        self.do_something["command"] = self.say_Yeh
       
        self.do_something.pack({"side": "left"})

    def _init_(self, master=None):
        Frame._init_(self, master)
        self.pack()
        self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()

 

Question Info


Last updated May 10, 2019 Views 2,381 Applies to:
Answer
Answer
Sorry, I figured it out!

1 person was helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.