第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

Python / Tkinter-將按鈕狀態(tài)寫入文件以在下次啟動時(shí)自動重新應(yīng)用?

Python / Tkinter-將按鈕狀態(tài)寫入文件以在下次啟動時(shí)自動重新應(yīng)用?

猛跑小豬 2021-05-11 17:32:36
我試圖將按鈕的前景色(由用戶單擊更改)的狀態(tài)保存到.txt文件中,以便在下次運(yùn)行時(shí)自動重新應(yīng)用所述前景色。這是我擁有的代碼... toggle_color可以完美地工作,它也可以將顏色狀態(tài)寫入.txt文件。但是,它不會在啟動時(shí)自動更改顏色。意思是,我可能在最后一部分弄糟了。我做錯(cuò)了什么?編輯:忘記調(diào)用.read()。但這toggle_color(colors = ['white', '#0055C4'])不是更改先前定義的公認(rèn)方法。因此,我將如何更改toggle_color的colors變量? def toggle_color(last=[0]): #this is what toggles the fg color of the button        colors = ['#0055C4', 'white']        color = colors[last[0]]        last[0] = (last[0] + 1) % 2        savepass.config(fg=color)        with open('loaderstate.txt', 'w') as loader_file:            loader_file.write(savepass.cget('fg'))savepasspic = PhotoImage(file="RememberMeBackground.png")savepass=Button(root, font=('Arial Black',10),image=savepasspic, text="    remember me", compound=CENTER, command=toggle_color, activeforeground="#0055C4", activebackground="#303030", relief=GROOVE)savepass.config(borderwidth=0, highlightthickness=0, width=120, height=18, fg='white', bg="grey")savepass.place(x=105, y=287)def blueoverall(): #changes the fg color of the button, and reverses toggle_color ordersavepass.config(fg='#0055C4')toggle_color(colors = ['white', '#0055C4'])with open('loaderstate.txt', 'r') as loader_file: #should run automatically on startup and determine color of button fg    if loader_file.read == '#0055C4':        blueoverall()    if loader_file.read == 'white':        savepass.config(fg='white')
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 262 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號