我理解並看過問題,但我無法弄清楚代碼是什麼,人們在暗示什麼,或者只是不知道我在做什麼。如何添加一個gui?
所以,我想添加一個gui到這個貨幣的東西,我正在和我的朋友一起玩RPG遊戲。
迄今爲止它的文本爲基礎,但如果它是一個gui我想它。
bronze = 0
silver = 0
gold = 0
inpt = ""
temp1 = ""
temp2 = 0
def convert():
global bronze
global silver
global gold
while bronze >= 100:
bronze -=100
silver += 1
while silver >= 100:
silver -= 100
gold += 1
while bronze < 0:
bronze += 100
silver -= 1
while silver < 0:
silver += 100
gold -= 1
if gold < 0:
print("Illegal action")
print("You have", int(bronze), "bronze,", int(silver), "silver,", int(gold), "gold.")
while 1>0:
inpt = input("Add, Subtract, Convert, Space or Help? ")
if inpt.lower() == "add":
temp1 = input("What do you want to add? ")
if temp1.lower() == "bronze":
temp2 = int(input("How much bronze do you want to add? "))
bronze += temp2
elif temp1.lower() == "silver":
temp2 = int(input("How much silver do you want to add? "))
silver += temp2
elif temp1.lower() == "gold":
temp2 = int(input("How much gold do you want to add? "))
gold += temp2
else:
print("That is not a currency...")
convert()
elif inpt.lower() == "subtract":
temp1 = input("What do you want to subtract? ")
if temp1.lower() == "bronze":
temp2 = int(input("How much bronze do you want to subtract? "))
bronze -= temp2
elif temp1.lower() == "silver":
temp2 = int(input("How much silver do you want to subtract? "))
silver -= temp2
elif temp1.lower() == "gold":
temp2 = int(input("How much gold do you want to subtract? "))
gold -= temp2
else:
print("That is not a currency...")
convert()
elif inpt.lower() == "space":
print("")
elif inpt.lower() == "help":
print("Add command adds currencies together.")
print("Subtract command subtracts currencies together.")
print("Space command makes a paragraph space")
else:
print("Unknown command")
我一直在尋找如何使用tkinter的文章,但它真的很難理解,我無法弄清楚如何使按鈕工作。
這裏是規格:
它需要爲青銅,分別金銀多項指標。與他們的顏色相應。
它需要一個添加按鈕和一個按鈕來減去青銅,銀和金的子按鈕。以便輸入知道您輸入的位置。
它需要一個輸入空間。
感謝您的幫助!
如果您閱讀過有關如何使用tkinter的完整文章,您認爲我們能夠以簡短的答案爲您提供幫助嗎? –
,因爲我可以提出不同的問題。我看到他們正在使用的一些例子,但他們有「自己」用在他們或「班級」,我不知道他們是什麼 –
你所看到的稱爲「面向對象編程(OOP)」。這是一個編程範例,與您正在編程的程序類似。如果不理解OOP,那麼使用tkinter幾乎是完全不可能的。我建議在重新訪問GUI編程之前學習OOP的基本知識,不管tkinter如何。 –