嘿我想点击按钮时显示功能输出。我的函数在一个类中,我想在GUI中的文本框中显示输出。任何人都可以帮我这里是功能代码。例如,我想从绘图功能
中显示from random import shuffle
class spilastokkur():
def __init__(self):
self.spil=[]
self.bord=[]
self.hond=[]
def shuffle(self):
spil= self.spil
sort = ['H', 'S', 'T', 'L']
num = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',]
for i in range(0,4):
for j in range(0, 13):
spil.append(sort[i]+ num[j])
shuffle(spil)
#print spil
return spil
def draw(self):
hond = self.hond
spil = self.spil
if len(hond) >= 3:
print 'Geturu fjarlaegt spil????'
if len(spil) > 0:
x = spil.pop(0)
hond.append(x)
print(hond)
else:
y = hond.pop(0)
hond.append(y)
print hond
output.insert(hond.get())
if len(hond)<=2:
print 'winner'
def sort_cheat(self):
hond = self.hond
if len(hond) >= 4:
del hond[-2]
del hond[-2]
print hond
print 'You got rid of 2 cards. You can do better :)'
enter code here
def number(self):
hond = self.hond
if len(hond) >= 4:
if (hond[-1][1]== hond[-4][1]):
del hond[-4:]
print hond
else:
print 'You are cheating'
这将是我在Gui tkinter中的文本框女巫我希望我的输出显示
output = Text(root, height=20, width=50)
output.pack()
和调用绘图功能的按钮
#Buttons
Draw_button = Button(command=s.draw).pack()
#ignore