如何让每10秒自动改变程序背景
how to make that every 10 sec automatically change the program background
如何让每10秒自动更换程序背景
颜色将随机选择
color = (random.randint(0,255),random.randint(0,255),random.randint(0,255))
更新:
我想在这段代码中使用:
app = wx.App()
window = wx.Frame(None, title = "test con", size=(800,300) )
window.SetMaxSize(wx.Size(800,300))
window.SetMinSize(wx.Size(800,300))
window.SetIcon(wx.Icon("eq.ico"))
window.SetBackgroundColour(color)
panel = wx.Panel(window, wx.ID_ANY)
suka = bat()
def on_timer():
label1aa.SetLabel(str(ram_uz()))
label8.SetLabel(doi)
label16.SetLabel(str(random.randint(1,100)))
label1a.SetLabel(str(bat()))
wx.CallLater(1000, on_timer)
panel.SetBackgroundColour(color)
panel.SetCursor(wx.Cursor(wx.CURSOR_HAND))
试试这个,希望对你有帮助
import threading
def change_color():
while True:
time.sleep(10)
color = (random.randint(0,255),random.randint(0,255),random.randint(0,255))
threading.Thread(target=change_color).start()
您可以使用计时器:
import threading
timer = threading.Timer(interval, function)
//interval is the lapse of time you want between each execution of the function "function"
timer.start()
如何让每10秒自动更换程序背景 颜色将随机选择
color = (random.randint(0,255),random.randint(0,255),random.randint(0,255))
更新:
我想在这段代码中使用:
app = wx.App()
window = wx.Frame(None, title = "test con", size=(800,300) )
window.SetMaxSize(wx.Size(800,300))
window.SetMinSize(wx.Size(800,300))
window.SetIcon(wx.Icon("eq.ico"))
window.SetBackgroundColour(color)
panel = wx.Panel(window, wx.ID_ANY)
suka = bat()
def on_timer():
label1aa.SetLabel(str(ram_uz()))
label8.SetLabel(doi)
label16.SetLabel(str(random.randint(1,100)))
label1a.SetLabel(str(bat()))
wx.CallLater(1000, on_timer)
panel.SetBackgroundColour(color)
panel.SetCursor(wx.Cursor(wx.CURSOR_HAND))
试试这个,希望对你有帮助
import threading
def change_color():
while True:
time.sleep(10)
color = (random.randint(0,255),random.randint(0,255),random.randint(0,255))
threading.Thread(target=change_color).start()
您可以使用计时器:
import threading
timer = threading.Timer(interval, function)
//interval is the lapse of time you want between each execution of the function "function"
timer.start()