newString = ""
newString += calculations
newString += (here is the button text(for example if button1 was clicked i will add to newString "1")
return newString
我想按下按钮,调用函数并将newString返回到计算字符串。有什么想法吗?
答案 0 :(得分:0)
要按下按钮上的功能,首先必须创建这样的功能;
def Foo():
print("Bar")
然后当你创建按钮时,指定你希望它在按下时执行该功能,就像这样;
from tkinter import ttk
my_button= ttk.Button(self, text = "button", command = Foo)
但是如果你想将参数传递给它,在你的例子中你可能会这样做;
def Foo(bar):
print(bar)
my_button_paramaters= ttk.Button(self, text = "button", command = lambda: Foo(paramater))