82 lines
2.9 KiB
Python
82 lines
2.9 KiB
Python
"""
|
|
GUIダイアログでフロー名とタスク説明を入力してから controller.py を起動する。
|
|
VS Code タスクから呼び出す用。
|
|
"""
|
|
import os
|
|
import sys
|
|
import tkinter as tk
|
|
from tkinter import messagebox
|
|
|
|
|
|
def main() -> None:
|
|
root = tk.Tk()
|
|
root.title("Windmill フロー生成")
|
|
root.resizable(True, True)
|
|
|
|
pad = {"padx": 12, "pady": 4}
|
|
|
|
# ── フロー名 ──────────────────────────────────
|
|
tk.Label(root, text="フロー名", anchor="w").grid(
|
|
row=0, column=0, sticky="ew", **pad
|
|
)
|
|
flow_var = tk.StringVar()
|
|
flow_entry = tk.Entry(root, textvariable=flow_var, width=46)
|
|
flow_entry.grid(row=1, column=0, sticky="ew", padx=12, pady=(0, 8))
|
|
|
|
# ── タスク説明 ────────────────────────────────
|
|
tk.Label(root, text="タスク説明", anchor="w").grid(
|
|
row=2, column=0, sticky="ew", **pad
|
|
)
|
|
task_text = tk.Text(root, width=46, height=8, wrap=tk.WORD)
|
|
task_text.grid(row=3, column=0, sticky="nsew", padx=12, pady=(0, 8))
|
|
|
|
# ── ボタン ────────────────────────────────────
|
|
btn_frame = tk.Frame(root)
|
|
btn_frame.grid(row=4, column=0, sticky="e", padx=12, pady=(4, 12))
|
|
|
|
def on_cancel():
|
|
root.destroy()
|
|
sys.exit(0)
|
|
|
|
def on_run():
|
|
flow_name = flow_var.get().strip()
|
|
task_desc = task_text.get("1.0", tk.END).strip()
|
|
|
|
if not flow_name:
|
|
messagebox.showwarning("入力エラー", "フロー名を入力してください。", parent=root)
|
|
flow_entry.focus()
|
|
return
|
|
if not task_desc:
|
|
messagebox.showwarning("入力エラー", "タスク説明を入力してください。", parent=root)
|
|
task_text.focus()
|
|
return
|
|
|
|
root.destroy()
|
|
|
|
# controller.py をカレントプロセスと置き換えて実行
|
|
# → ターミナルにそのままログが流れる
|
|
script = os.path.join(os.path.dirname(os.path.abspath(__file__)), "controller.py")
|
|
os.execv(sys.executable, [sys.executable, script, flow_name, task_desc])
|
|
|
|
tk.Button(btn_frame, text="キャンセル", width=10, command=on_cancel).pack(
|
|
side=tk.LEFT, padx=(0, 6)
|
|
)
|
|
tk.Button(btn_frame, text="実行", width=10, command=on_run, default=tk.ACTIVE).pack(
|
|
side=tk.LEFT
|
|
)
|
|
|
|
# ── レイアウト調整 ────────────────────────────
|
|
root.columnconfigure(0, weight=1)
|
|
root.rowconfigure(3, weight=1)
|
|
|
|
# Enter キーで実行、Escape でキャンセル
|
|
root.bind("<Return>", lambda _: on_run())
|
|
root.bind("<Escape>", lambda _: on_cancel())
|
|
|
|
flow_entry.focus()
|
|
root.mainloop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|