继续优化深色模式显示
This commit is contained in:
@@ -20,6 +20,21 @@ if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
style = ttk.Style()
|
||||
colors = style.colors
|
||||
return {
|
||||
"bg": colors.bg,
|
||||
"fg": colors.fg,
|
||||
"muted": colors.secondary,
|
||||
"input_bg": colors.inputbg,
|
||||
"input_fg": colors.inputfg,
|
||||
"select_bg": colors.selectbg,
|
||||
"select_fg": colors.selectfg,
|
||||
"border": colors.border,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +65,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
container.columnconfigure(0, weight=0)
|
||||
container.columnconfigure(1, weight=1)
|
||||
container.rowconfigure(0, weight=1)
|
||||
palette = _theme_colors()
|
||||
|
||||
left = ttk.Frame(container, width=360)
|
||||
left.grid(row=0, column=0, sticky=tk.NS, padx=(0, 10))
|
||||
@@ -72,10 +88,12 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
bd=1,
|
||||
relief=tk.FLAT,
|
||||
highlightthickness=1,
|
||||
highlightbackground="#d8d8d8",
|
||||
highlightcolor="#4a90e2",
|
||||
selectbackground="#2b6cb0",
|
||||
selectforeground="#ffffff",
|
||||
bg=palette["input_bg"],
|
||||
fg=palette["input_fg"],
|
||||
highlightbackground=palette["border"],
|
||||
highlightcolor=palette["select_bg"],
|
||||
selectbackground=palette["select_bg"],
|
||||
selectforeground=palette["select_fg"],
|
||||
yscrollcommand=scroll.set,
|
||||
)
|
||||
scroll.config(command=self.ai_image_listbox.yview)
|
||||
@@ -135,7 +153,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
preview_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
self.ai_image_canvas = tk.Canvas(
|
||||
preview_frame, bg="#1e1e1e", highlightthickness=0
|
||||
preview_frame, bg=palette["bg"], highlightthickness=0
|
||||
)
|
||||
self.ai_image_canvas.pack(fill=tk.BOTH, expand=True)
|
||||
self.ai_image_canvas.bind("<Configure>", lambda e: _redraw_preview(self))
|
||||
@@ -145,14 +163,21 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
self.ai_image_meta_var = tk.StringVar(value="未选择图片")
|
||||
ttk.Label(
|
||||
meta_row, textvariable=self.ai_image_meta_var,
|
||||
foreground="#666", font=("微软雅黑", 9),
|
||||
foreground=palette["muted"], font=("微软雅黑", 9),
|
||||
).pack(side=tk.LEFT)
|
||||
|
||||
# 输入区
|
||||
input_frame = ttk.LabelFrame(right, text="提示输入(Ctrl+Enter 发送)", padding=6)
|
||||
input_frame.pack(fill=tk.X, pady=(4, 0))
|
||||
|
||||
self.ai_image_input = tk.Text(input_frame, height=3, wrap=tk.WORD)
|
||||
self.ai_image_input = tk.Text(
|
||||
input_frame,
|
||||
height=3,
|
||||
wrap=tk.WORD,
|
||||
bg=palette["input_bg"],
|
||||
fg=palette["input_fg"],
|
||||
insertbackground=palette["input_fg"],
|
||||
)
|
||||
self.ai_image_input.pack(fill=tk.X, side=tk.TOP)
|
||||
self.ai_image_input.bind("<Control-Return>", lambda e: (_send_prompt(self), "break"))
|
||||
|
||||
@@ -161,7 +186,7 @@ def create_ai_image_panel(self: "PQAutomationApp"):
|
||||
self.ai_image_status_var = tk.StringVar(value="就绪")
|
||||
ttk.Label(
|
||||
send_row, textvariable=self.ai_image_status_var,
|
||||
foreground="#888", font=("微软雅黑", 9),
|
||||
foreground=palette["muted"], font=("微软雅黑", 9),
|
||||
).pack(side=tk.LEFT)
|
||||
self.ai_image_progress = ttk.Progressbar(
|
||||
send_row,
|
||||
@@ -220,6 +245,7 @@ def reload_ai_image_list(self: "PQAutomationApp", auto_select_first=True):
|
||||
其下列出该轮生成的所有图片。会话按"最近使用"倒序,组内按时间倒序。
|
||||
auto_select_first: 是否自动选中第一张图片(默认 True)。
|
||||
"""
|
||||
palette = _theme_colors()
|
||||
self.ai_image_records = _svc.list_records(base_dir=_get_app_base_dir(self))
|
||||
self.ai_image_listbox.delete(0, tk.END)
|
||||
# 维护行号 → 记录索引的映射;分隔头处为 None
|
||||
@@ -236,8 +262,8 @@ def reload_ai_image_list(self: "PQAutomationApp", auto_select_first=True):
|
||||
# 头部行:禁用选中(视觉上变灰)
|
||||
last = self.ai_image_listbox.size() - 1
|
||||
self.ai_image_listbox.itemconfig(
|
||||
last, foreground="#888", selectforeground="#888",
|
||||
background="#f5f5f5", selectbackground="#f5f5f5",
|
||||
last, foreground=palette["muted"], selectforeground=palette["muted"],
|
||||
background=palette["bg"], selectbackground=palette["bg"],
|
||||
)
|
||||
self._ai_image_row_map.append(None)
|
||||
self._ai_image_row_session_map.append(sid)
|
||||
@@ -331,6 +357,7 @@ def _select_record(self: "PQAutomationApp", rec: _svc.AIImageRecord):
|
||||
def _redraw_preview(self: "PQAutomationApp"):
|
||||
rec = getattr(self, "ai_image_current", None)
|
||||
canvas = self.ai_image_canvas
|
||||
palette = _theme_colors()
|
||||
canvas.delete("all")
|
||||
if rec is None or not os.path.isfile(rec.image_path):
|
||||
return
|
||||
@@ -340,7 +367,7 @@ def _redraw_preview(self: "PQAutomationApp"):
|
||||
img = Image.open(rec.image_path)
|
||||
img.load()
|
||||
except Exception as exc:
|
||||
canvas.create_text(cw // 2, ch // 2, text=f"加载失败: {exc}", fill="#f66")
|
||||
canvas.create_text(cw // 2, ch // 2, text=f"加载失败: {exc}", fill=palette["select_bg"])
|
||||
return
|
||||
iw, ih = img.size
|
||||
scale = min(cw / iw, ch / ih, 1.0)
|
||||
|
||||
Reference in New Issue
Block a user