mardi 24 février 2015

Is tkk not included in Tkinter for Python 3.4.x Windows

I am following the documentation for tkinter here, which works on Linux and Mac as expected, but not windows: http://ift.tt/1kQtoW1


Here is the code I'm testing:



from tkinter import *
from tkinter import ttk

def click(*args):
message.set("Clicky Click")


# Initialize the Window
root = Tk()
root.title("Title")

# Window Configuration
mainframe = ttk.Frame(root,padding="10 10 15 15")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0,weight=1)
mainframe.rowconfigure(0,weight=1)

message = StringVar()
message.set("This is a program")

tkk.Label(mainframe, width=4, textvariable=message).grid(column=1,row=1,sticky=(W,E))
tkk.Button(mainframe, text="BUTTONS ARE FUN", width=2, command=click).grid(column=1, row=2, sticky=(W))

for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)

root.bind('<Return>', click)

root.mainloop()


Though the program runs and draws a window, it is missing everything ttk related. What I get back from the interpreter when I run this is:



Traceback (most recent call last):
File "C:\Users\Miner\Desktop\pos.py", line 21, in <module>
tkk.Label(mainframe, width=4, textvariable=message).grid(column=1,row=1,sticky=(W,E))
NameError: name 'tkk' is not defined


I am using Windows 7 64-bit with Python 3.4.2, which would come bundled with Tkinter 8.5.something to the best of my knowledge, as this is how it works in Mac and Linux.


Can someone please point out what I'm missing?


Aucun commentaire:

Enregistrer un commentaire