如何使每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))
答案 0 :(得分:0)
尝试这个,希望对您有帮助
DWORD WINAPI CreateThreads(LPVOID param)
{
int n = *(int*)param;
HANDLE* threads = (HANDLE*)malloc(n * sizeof(HANDLE));
for (int i = 0; i < n; i++)
{
threads[i] = CreateThread(NULL,0, CreateThreads, &n, 0,NULL);
}
for (int i = 0; i < n; i++)
{
WaitForSingleObject(threads[i], INFINITE);
}
return 0;
}
int main()
{
int n = 5;
CreateThreads(&n);
return 0;
}
答案 1 :(得分:0)
您可以使用计时器:
import threading
timer = threading.Timer(interval, function)
//interval is the lapse of time you want between each execution of the function "function"
timer.start()