Initial commit: Dabit Time Manager project
Python-based time management application with UDP discovery, TCP protocol communication, time sync, and drift monitoring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
68
gui/settings_dialog.py
Normal file
68
gui/settings_dialog.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""컨트롤러 설정 변경 다이얼로그"""
|
||||
|
||||
import tkinter as tk
|
||||
from tkinter import ttk, messagebox
|
||||
|
||||
from models.controller import Controller
|
||||
from network.udp_discovery import send_sett
|
||||
|
||||
|
||||
class SettingsDialog(tk.Toplevel):
|
||||
|
||||
def __init__(self, parent, ctrl: Controller, bind_ip: str):
|
||||
super().__init__(parent)
|
||||
self.title(f"설정 변경 - {ctrl.mac}")
|
||||
self.resizable(False, False)
|
||||
self.grab_set()
|
||||
self._ctrl = ctrl
|
||||
self._bind_ip = bind_ip
|
||||
self._build_ui()
|
||||
self.transient(parent)
|
||||
# 화면 중앙
|
||||
self.update_idletasks()
|
||||
x = parent.winfo_rootx() + (parent.winfo_width() - self.winfo_width()) // 2
|
||||
y = parent.winfo_rooty() + (parent.winfo_height() - self.winfo_height()) // 2
|
||||
self.geometry(f"+{x}+{y}")
|
||||
|
||||
def _build_ui(self):
|
||||
f = ttk.Frame(self, padding=15)
|
||||
f.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
fields = [
|
||||
("MAC:", self._ctrl.mac, False),
|
||||
("IP:", self._ctrl.ip, True),
|
||||
("포트:", str(self._ctrl.port), True),
|
||||
("이름:", self._ctrl.name, True),
|
||||
("서브넷:", self._ctrl.subnet, True),
|
||||
("게이트웨이:", self._ctrl.gateway, True),
|
||||
]
|
||||
|
||||
self._vars = {}
|
||||
for i, (label, value, editable) in enumerate(fields):
|
||||
ttk.Label(f, text=label).grid(row=i, column=0, sticky=tk.E, padx=(0, 8), pady=3)
|
||||
var = tk.StringVar(value=value)
|
||||
state = "normal" if editable else "readonly"
|
||||
ttk.Entry(f, textvariable=var, width=22, state=state).grid(row=i, column=1, pady=3)
|
||||
self._vars[label] = var
|
||||
|
||||
btn = ttk.Frame(f)
|
||||
btn.grid(row=len(fields), column=0, columnspan=2, pady=(12, 0))
|
||||
ttk.Button(btn, text="설정", command=self._on_apply).pack(side=tk.LEFT, padx=5)
|
||||
ttk.Button(btn, text="닫기", command=self.destroy).pack(side=tk.LEFT, padx=5)
|
||||
|
||||
def _on_apply(self):
|
||||
self._ctrl.ip = self._vars["IP:"].get().strip()
|
||||
try:
|
||||
self._ctrl.port = int(self._vars["포트:"].get().strip())
|
||||
except ValueError:
|
||||
messagebox.showerror("오류", "포트는 숫자여야 합니다.", parent=self)
|
||||
return
|
||||
self._ctrl.name = self._vars["이름:"].get().strip()
|
||||
self._ctrl.subnet = self._vars["서브넷:"].get().strip()
|
||||
self._ctrl.gateway = self._vars["게이트웨이:"].get().strip()
|
||||
|
||||
ok = send_sett(self._ctrl, self._bind_ip)
|
||||
if ok:
|
||||
messagebox.showinfo("성공", "설정 되었습니다.", parent=self)
|
||||
else:
|
||||
messagebox.showerror("실패", "설정 전송에 실패했습니다.", parent=self)
|
||||
Reference in New Issue
Block a user