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

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

Python:無法在多個文件中拆分文件

Python:無法在多個文件中拆分文件

開滿天機 2022-12-27 15:23:50
我有一個游戲項目,其中有我的服務(wù)器和客戶端。我想拆分我的客戶端和服務(wù)器,這樣更容易閱讀。我將所有配置 tkinter 窗口放在一個文件中,然后放入服務(wù)器from window import *。start_server()但是在 Windows 文件中,我正在調(diào)用客戶端中的一個函數(shù),當我啟動客戶端時它無法識別該函數(shù)。有什么建議我該怎么做?謝謝你的幫助 !server.pyimport socketimport threadingfrom time import sleepfrom window import *def start_server():    global server, HOST_ADDR, HOST_PORT  # code is fine without this    btnStart.config(state=tk.DISABLED)    btnStop.config(state=tk.NORMAL)(...)window.pyimport tkinter as tkwindow = tk.Tk()window.title("Tic-Tac-Toe Server")window.iconbitmap("logo.ico")window.config(background='#4065A4')# Top frame consisting of two buttons widgets (i.e. btnStart, btnStop)topFrame = tk.Frame(window)btnStart = tk.Button(topFrame, text="Start", font=("Helvetica", 20), bg='#4065A4', fg='white',                     command=lambda : start_server())btnStart.pack(side=tk.LEFT)btnStop = tk.Button(topFrame, text="Stop", font=("Helvetica", 20), bg='#4065A4', fg='white', command=lambda : stop_server(), state=tk.DISABLED)btnStop.pack(side=tk.LEFT)topFrame.pack(side=tk.TOP, pady=(5, 0))# Middle frame consisting of two labels for displaying the host and port infomiddleFrame = tk.Frame(window)lblHost = tk.Label(middleFrame, font=("Helvetica", 10), bg='#4065A4', fg='white', text = "Address: X.X.X.X")lblHost.pack(side=tk.LEFT)lblPort = tk.Label(middleFrame, font=("Helvetica", 10), bg='#4065A4', fg='white', text = "Port:XXXX")lblPort.pack(side=tk.LEFT)middleFrame.pack(side=tk.TOP, pady=(5, 0))# The client frame shows the client areaclientFrame = tk.Frame(window)lblLine = tk.Label(clientFrame,  font=("Helvetica"), text="Liste des joueurs").pack()scrollBar = tk.Scrollbar(clientFrame)scrollBar.pack(side=tk.RIGHT, fill=tk.Y)tkDisplay = tk.Text(clientFrame, height=10, width=30)tkDisplay.pack(side=tk.LEFT, fill=tk.Y, padx=(5, 0))scrollBar.config(command=tkDisplay.yview)tkDisplay.config(yscrollcommand=scrollBar.set, background="#F4F6F7", highlightbackground="grey", state="disabled")clientFrame.pack(side=tk.BOTTOM, pady=(5, 10))
查看完整描述

1 回答

?
胡子哥哥

TA貢獻1825條經(jīng)驗 獲得超6個贊

window導入后在 server.py 中綁定/配置回調(diào)。

window.py

...
btnStart = tk.Button(topFrame, text="Start", font=("Helvetica", 20), bg='#4065A4', fg='white')
...

server.py

...
from window import *
btnStart.configure(command=lambda : start_server())
...

設(shè)置選項


查看完整回答
反對 回復 2022-12-27
  • 1 回答
  • 0 關(guān)注
  • 99 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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