我正在尋找添加信息到下面的這些按鈕,所以當按下信息出現....我一直在嘗試給我們的get()功能,這是正確的嗎?我似乎無法得到它的運行,但我的繼承人的代碼嘗試:添加信息到按鈕
submit = Button(frame, text="Enter", width=15, command=lambda: valueGET(E1.get(), E2.get()))
submit.grid()
和我的全碼:
def raise_frame(frame):
frame.tkraise()
f1 = tk.Frame(root)
f2 = tk.Frame(root)
f3 = tk.Frame(root)
f4 = tk.Frame(root)
f5 = tk.Frame(root)
for frame in (f1,f2,f3,f4,f5):
frame.grid(row=0, column=0, sticky='news')
class MyButton(tk.Button):
def __init__(self, *args, info=None, command=None, **kwargs):
super().__init__(*args, **kwargs, command=self.callback)
self.initialCommand = command
self.info = info
def display_info(self):
# Display the information the way you want
print(self.info)
def callback(self):
self.initialCommand()
self.display_info()
button1 = tk.Button(f1, text='Ya', command=lambda:raise_frame(f2)).pack()
button2 = tk.Button(f1, text=Yb', command=lambda:raise_frame(f3)).pack()
button3 = tk.Button(f1, text=Yc', command=lambda:raise_frame(f4)).pack()
button4 = tk.Button(f1, text='Yd', command=lambda:raise_frame(f5)).pack()
tk.Label(f2, text="Ya").pack()
button = tk.Button(root, text="Display info", command=lambda:print("Initial command"))
button.pack()
button.info = "Hello, world!"
tk.Button(f2, text="HOME", command=lambda:raise_frame(f1)).pack()
tk.Label(f3, text="Yb").pack()
button = tk.Button(root, text="Display info", command=lambda:print("Initial command"))
button.pack()
button.info = "Hello, world!"
tk.Button(f3, text="HOME", command=lambda:raise_frame(f1)).pack()
tk.Label(f4, text="Yc").pack()
button = tk.Button(root, text="Display info", command=lambda:print("Initial command"))
button.pack()
button.info = "Hello, world!"
tk.Button(f4, text="HOME", command=lambda:raise_frame(f1)).pack()
tk.Label(f5, text="Yd").pack()
button = tk.Button(root, text="Display info", command=lambda:print("Initial command"))
button.pack()
button.info = "Hello, world!"
tk.Button(f5, text="HOME", command=lambda:raise_frame(f1)).pack()
raise_frame(f1)
root.mainloop()
if os.path.isfile(creds):
Login()
else:
Signup()
第一:如果你有兩個問題,你應該問兩個問題。 秒:你的'sequentialSearch'函數查找單個項目。字符串中的單詞是子序列。你的功能只能找到單個字符。所以我建議你將'if'語句改爲'if alist [pos:pos + len(list(item))] == list(item):' – Aemyl
「你到底意味着什麼」將信息添加到按鈕「? –
添加文本以便按下按鈕後,信息出現在選項卡 – joe