私はpythonでクリッカーゲームを作ろうとしていますが、エラーが続きます"TypeError: unorderable types: IntVar() > int()"
私は他の投稿を見て、まだ.get
のことを理解していません。ここまでは私のコードです:TypeError:並べ替えることのできない型:IntVar()> int()
import tkinter
from tkinter import *
import sys
root = tkinter.Tk()
root.geometry("160x100")
root.title("Cliker game")
global counter
counter = tkinter.IntVar()
global multi
multi = 1
def onClick(event=None):
counter.set(counter.get() + 1*multi)
tkinter.Label(root, textvariable=counter).pack()
tkinter.Button(root, text="I am Cookie! Click meeeeee", command=onClick,
fg="dark green", bg = "white").pack()
clickable = 0
def button1():
global multi
global counter
if counter > 79: # this is the line where the error happens
counter = counter - 80
multi = multi + 1
print ("you now have a multiplier of", multi)
else:
print ("not enough moneys!")
b = Button(text="+1* per click, 80 cookies", command=button1)
b.pack()
root.mainloop()
例外の完全なトレースバックが少なくとも*必要です。 –
'IntVar'を' int'に変換するとどうなりますか? 'int(counter)> 79:' – Joe
'counter'は' IntVar'であり、それを整数と比較しています。おそらく、代わりに 'IntVar'に格納された値を取得するために' counter.get()> 79'を使用したかったでしょうか? –