A really basic tkinter question
Posted: Sat Feb 21, 2015 4:50 pm
Hi,
This probably is really basic, but here goes...
I'm trying to learn python by reading books and checking online resources and doing OK so far. My next step is to put a small graphical wrapper around what I'm doing.
So far, I've got this:
I'm editing this in an IDLE3 window. If I hit 'run' from the window, the code behaves as expected. If I bring up a text terminal and type 'python filename.py' I get an error that there's no module called tkinter.
can someone tell me what's happening and how toi fix it so I can run my code from the command line?
Thanks
Paul
This probably is really basic, but here goes...
I'm trying to learn python by reading books and checking online resources and doing OK so far. My next step is to put a small graphical wrapper around what I'm doing.
So far, I've got this:
Code: Select all
#!/usr/bin/env python
#Import anything necessary
from tkinter import *
#define some functions
def OKaction():
print('Pressed OK')
def Quitaction():
print('Pressed Quit')
window = Tk()
window.title("Control Panel")
buttonOK=Button(window, text="OK", command = OKaction)
buttonOK.pack()
buttonQuit=Button(window, text="Quit", command = Quitaction)
buttonQuit.pack()
mainloop()
can someone tell me what's happening and how toi fix it so I can run my code from the command line?
Thanks
Paul