搭單問用Jupyter notebook 會唔會學壞手勢?
因為好多時禁enter 已經有數出 唔洗禁print
import tkinter as tk
class Test():
def __init__(self):
self.root = tk.Tk()
self.root.geometry("250x100")
self.buttonA = tk.Button(self.root,
text = "Color",
bg = "blue",
fg = "red")
self.buttonB = tk.Button(self.root,
text="Click to change color",
command=self.changeColor)
self.buttonA.pack(side=tk.LEFT)
self.buttonB.pack(side=tk.RIGHT)
self.root.after(500, self.changeColor)
self.root.mainloop()
def changeColor(self):
if self.buttonA["fg"] == "red":
self.buttonA["fg"] = "cyan"
else:
self.buttonA["fg"] = "red"
self.root.after(500, self.changeColor)
app=Test()
import tkinter as tk
root = tk.Tk()
root.geometry("250x100")
A = tk.Label(text='I am a label!', fg='white')
A['bg'] = 'blue'
A.pack(side=tk.LEFT)
root.mainloop()
def chC(root, some_var):
if some_var['bg'] == 'blue':
some_var['bg'] = 'red'
else:
some_var['bg'] = 'blue'
root.after(1000, chC, root, some_var)
root = tk.Tk()
root.geometry("250x100")
A = tk.Label(text='I am a label!', fg='white')
A['bg'] = 'blue'
A.pack(side=tk.LEFT)
root.after(1000, chC, root, A)
root.mainloop()