mardi 14 avril 2015

Python Tkinter StringVar issues


Vote count:

0




I am trying to make a simple calculator for a game I play as a random project. I found myself very confused on how to go about doing this; I want the user to enter a number in the textbox and it will multiply that number by 64000 and display it in a label above. But, I cannot find out anywhere how to do this. This is just a small practice thing and im amazed I cannot figure it out. Please help meh! Here is my code:



from Tkinter import *

####The GUI#####
root = Tk()

#Title#
root.wm_title("TMF Coin Calculator")

####The Widgets####
a = StringVar()
b = StringVar()

def multiply_a():
d = (int(a) * 64000)
e = str(d)
b.set(e)

b.trace("w", multiply_a)

#Top Label#

top_label = Label(root, fg="red", text="Type the ammount of Coin Stacks you have.")
top_label.grid(row=0, column=0)

#The Output Label#
output_label = Label(root, textvariable=b, width = 20)
output_label.grid(row = 1, column=0)

#User Entry Box#
user_input_box = Entry(root, textvariable=a, width=30)
user_input_box.grid(row=2, column=0)

root.mainloop()


asked 56 secs ago







Python Tkinter StringVar issues

Aucun commentaire:

Enregistrer un commentaire