我理解并看过问题,但我无法弄清楚代码是什么,人们在暗示什么,或者只是不知道我在做什么。如何添加一个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如何。 –