伺服端
要讓表格內的資料置中呈現,可以利用 Treeview 的 column 和 heading 方法來設定每一個欄位的 anchor 屬性為 CENTER。這樣可以讓表格中的資料以及欄位標題置中對齊。
# 建立表格 self.tree = ttk.Treeview(root, columns=("IP", "MAC", "Name", "Status"), show='headings') # 設定表格標題與資料置中 self.tree.heading("IP", text="IP 位置", anchor="center") self.tree.heading("MAC", text="MAC 位置", anchor="center") self.tree.heading("Name", text="電腦名稱", anchor="center") self.tree.heading("Status", text="狀態", anchor="center")
def select_client_and_file(self):
selected_items = self.tree.selection() # 可以選取多個客戶端
選取多個客戶端:self.tree.selection() 現在可以選取多個客戶端,每個選取的客戶端會存儲在 client_ips 列表中。
傳送檔案到多個客戶端:在選取檔案後,程式會對每個選取的客戶端進行傳輸。每個客戶端 IP 都會分別執行 prepare_file_transfer_list 和 send_file_list
Tkinter中使用 Label 並搭配 after() 方法來模擬跑馬燈的效果。接著,在左邊顯示 "感謝ChatGPT 感謝UDPcast",右邊顯示 "製作者:WCS 日期:202410.01"。
import socket
import threading
import tkinter as tk
from tkinter import messagebox,filedialog, ttk
import time
import subprocess
import socket
import threading
import tkinter as tk
from tkinter import filedialog, ttk, Text, messagebox
import time
import os
import subprocess
import hashlib
客戶端