#!/usr/bin/python # -*- coding: UTF-8 -*- #----------------------------------------------------- # Project5.py #----------------------------------------------------- # imports import sys if sys.version_info[0] == 2: #Python 2.x from Tkinter import * import tkFont else: # Python 3.X from tkinter import * import random # Main class class hiProject5: # Global vars # Functions def onCommand4(self): self.ventry1.set(random.randint(1, 20)) # self.ventry1.set('1') print(self.ventry1.get()) # Program body def __init__(self, root): if sys.version_info[0] == 2: helvetica20 = tkFont.Font(family="Helvetica", size=20) else: helvetica20 = ("Helvetica",20,) self.master = root self.ventry1 = StringVar() self.entry1 = Entry(self.master, text="0", textvariable=self.ventry1, width = 3, justify="right", font = helvetica20, foreground = "red") self.entry1.pack(side="left", expand=0, fill="none", padx=1, pady=1) self.button4 = Button(self.master, text=u"Roll", command=self.onCommand4) self.button4.pack(side="bottom", expand=1, fill="both") ####################################################################### # Program body if __name__ == "__main__": root = Tk() root.title(u"Test") run = hiProject5(root) root.mainloop()