due crude knowledge of python, expecting more mistakes following script positional argument error. hence, appreciate , kind of observations/corrections. again, like, if @ possible, fix positional argument error without having use class. thank much.
# python 3.5.1 tkinter import * tkinter import ttk root = tk() root.geometry("300x200+150+50") total = 0.0 amount = 0.0 n = 0 x = 0 def total_amount(): total = entry.get() print ('got total!') lb=ttk.label(root, text="enter total").grid(row=n, column=1) totalent=ttk.entry(root).grid(row=n, column=2) button=ttk.button(root, text='ok', command=total_amount).grid(row=n, column=3) if total !=0: while true: if amount < total: while true: n = n + 1 if x == 0: def amount_entered(event): amount = amount + entry.get() x = x + 1 print ('got amount!') lb=ttk.label(root, text="enter amount").grid(row=n, column=1) amountent=ttk.entry(root).grid(row=n, column=2) button=ttk.button(root, text='ok', command=amount_entered).grid(row=n, column=3) elif x != 0: print ('gone internal loop!') break elif sub == total: print ('done!') break else: print ('sum of amount(s) cannot greater total') else: pass root.mainloop()
you're getting error message because .get() won't work on class entry. work on object such totalent instance of entry.
so need
total = totalent.get()
also, like
totalent=ttk.entry(root).grid(row=n, column=2)
won't work. if need give name object such totalent, need create first, call grid on it.
totalent=ttk.entry(root) totalent.grid(row=n, column=2)
you don't have write of own classes, use tkinter (or gui package in object oriented language) have use of classes part of it. when like
totalent=ttk.entry(root)
you creating object, totalent, instance of class ttk.entry. imported class tkinter.
Comments
Post a Comment