style: normalize code formatting across the codebase
- Standardize quote style (single to double quotes) - Improve code formatting consistency - Apply formatting to utilities, GUI components, and tools - Update imports and docstrings for consistency Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,7 +67,7 @@ class DataQueryTab(ttk.Frame):
|
||||
info_label = ttk.Label(
|
||||
parent,
|
||||
text="输入总排号列表(每行一个),查询对应的生产订单号信息",
|
||||
foreground="#666666"
|
||||
foreground="#666666",
|
||||
)
|
||||
info_label.pack(anchor=tk.W, pady=(0, 5))
|
||||
|
||||
@@ -82,7 +82,9 @@ class DataQueryTab(ttk.Frame):
|
||||
self.input_text = tk.Text(text_frame, height=10, wrap=tk.WORD)
|
||||
self.input_text.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||
|
||||
text_scrollbar = ttk.Scrollbar(text_frame, orient=tk.VERTICAL, command=self.input_text.yview)
|
||||
text_scrollbar = ttk.Scrollbar(
|
||||
text_frame, orient=tk.VERTICAL, command=self.input_text.yview
|
||||
)
|
||||
text_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
||||
self.input_text.configure(yscrollcommand=text_scrollbar.set)
|
||||
|
||||
@@ -102,20 +104,31 @@ class DataQueryTab(ttk.Frame):
|
||||
# 快捷按钮
|
||||
ttk.Separator(right_frame, orient=tk.HORIZONTAL).pack(fill=tk.X, pady=10)
|
||||
|
||||
ttk.Button(right_frame, text="加载 ProductionID.txt", command=self._load_production_id).pack(fill=tk.X, pady=2)
|
||||
ttk.Button(right_frame, text="清空输入", command=self._clear_input).pack(fill=tk.X, pady=2)
|
||||
ttk.Button(
|
||||
right_frame, text="加载 ProductionID.txt", command=self._load_production_id
|
||||
).pack(fill=tk.X, pady=2)
|
||||
ttk.Button(right_frame, text="清空输入", command=self._clear_input).pack(
|
||||
fill=tk.X, pady=2
|
||||
)
|
||||
|
||||
# 查询按钮
|
||||
button_frame = ttk.Frame(parent)
|
||||
button_frame.pack(fill=tk.X, pady=(10, 0))
|
||||
|
||||
self.query_button = ttk.Button(button_frame, text="执行查询", command=self.execute_query)
|
||||
self.query_button = ttk.Button(
|
||||
button_frame, text="执行查询", command=self.execute_query
|
||||
)
|
||||
self.query_button.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
self.export_button = ttk.Button(button_frame, text="导出结果", command=self.export_results, state=tk.DISABLED)
|
||||
self.export_button = ttk.Button(
|
||||
button_frame,
|
||||
text="导出结果",
|
||||
command=self.export_results,
|
||||
state=tk.DISABLED,
|
||||
)
|
||||
self.export_button.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
self.progress = ttk.Progressbar(parent, mode='indeterminate')
|
||||
self.progress = ttk.Progressbar(parent, mode="indeterminate")
|
||||
self.progress.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=5)
|
||||
|
||||
def _create_result_table(self, parent):
|
||||
@@ -135,9 +148,13 @@ class DataQueryTab(ttk.Frame):
|
||||
|
||||
# 添加滚动条
|
||||
scrollbar_y = ttk.Scrollbar(parent, orient=tk.VERTICAL, command=self.tree.yview)
|
||||
scrollbar_x = ttk.Scrollbar(parent, orient=tk.HORIZONTAL, command=self.tree.xview)
|
||||
scrollbar_x = ttk.Scrollbar(
|
||||
parent, orient=tk.HORIZONTAL, command=self.tree.xview
|
||||
)
|
||||
|
||||
self.tree.configure(yscrollcommand=scrollbar_y.set, xscrollcommand=scrollbar_x.set)
|
||||
self.tree.configure(
|
||||
yscrollcommand=scrollbar_y.set, xscrollcommand=scrollbar_x.set
|
||||
)
|
||||
|
||||
# 布局
|
||||
self.tree.grid(row=0, column=0, sticky="nsew")
|
||||
@@ -154,7 +171,7 @@ class DataQueryTab(ttk.Frame):
|
||||
|
||||
def _load_production_id(self):
|
||||
"""加载 ProductionID.txt 文件"""
|
||||
default_path = self.config.get('paths.production_id_file', 'ProductionID.txt')
|
||||
default_path = self.config.get("paths.production_id_file", "ProductionID.txt")
|
||||
|
||||
# 检查默认路径
|
||||
if os.path.exists(default_path):
|
||||
@@ -162,16 +179,17 @@ class DataQueryTab(ttk.Frame):
|
||||
else:
|
||||
# 打开文件选择对话框
|
||||
from tkinter import filedialog
|
||||
|
||||
file_path = filedialog.askopenfilename(
|
||||
title="选择 ProductionID 文件",
|
||||
filetypes=[("文本文件", "*.txt"), ("所有文件", "*.*")]
|
||||
filetypes=[("文本文件", "*.txt"), ("所有文件", "*.*")],
|
||||
)
|
||||
|
||||
if not file_path:
|
||||
return
|
||||
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
self.input_text.delete("1.0", tk.END)
|
||||
@@ -196,7 +214,9 @@ class DataQueryTab(ttk.Frame):
|
||||
return
|
||||
|
||||
# 解析总排号
|
||||
production_ids = [line.strip() for line in input_text.split('\n') if line.strip()]
|
||||
production_ids = [
|
||||
line.strip() for line in input_text.split("\n") if line.strip()
|
||||
]
|
||||
|
||||
if not production_ids:
|
||||
messagebox.showwarning("警告", "没有有效的总排号")
|
||||
@@ -215,9 +235,7 @@ class DataQueryTab(ttk.Frame):
|
||||
|
||||
# 在后台线程中执行查询
|
||||
query_thread = threading.Thread(
|
||||
target=self._query_worker,
|
||||
args=(production_ids,),
|
||||
daemon=True
|
||||
target=self._query_worker, args=(production_ids,), daemon=True
|
||||
)
|
||||
query_thread.start()
|
||||
|
||||
@@ -253,6 +271,7 @@ class DataQueryTab(ttk.Frame):
|
||||
|
||||
def _display_results(self, results: list):
|
||||
"""在主线程中显示结果"""
|
||||
|
||||
def update():
|
||||
for 总排号, 生产订单号 in results:
|
||||
self.tree.insert("", tk.END, values=(总排号, 生产订单号, ""))
|
||||
@@ -265,6 +284,7 @@ class DataQueryTab(ttk.Frame):
|
||||
|
||||
def _update_log(self, message: str, level: str = "INFO"):
|
||||
"""线程安全的日志更新"""
|
||||
|
||||
def update():
|
||||
if level == "INFO":
|
||||
self.log_text.info(message)
|
||||
@@ -287,7 +307,7 @@ class DataQueryTab(ttk.Frame):
|
||||
title="导出查询结果",
|
||||
defaultextension=".xlsx",
|
||||
filetypes=[("Excel 文件", "*.xlsx"), ("所有文件", "*.*")],
|
||||
initialfile="生产订单号查询结果.xlsx"
|
||||
initialfile="生产订单号查询结果.xlsx",
|
||||
)
|
||||
|
||||
if not output_file:
|
||||
|
||||
Reference in New Issue
Block a user