|
3 | 3 | from PIL import Image, ImageTk |
4 | 4 | from ideeplc.ideeplc_core import main as run_ideeplc |
5 | 5 | import argparse |
6 | | -import sys |
7 | 6 | import os |
| 7 | +import requests |
| 8 | + |
| 9 | + |
| 10 | +PRIMARY_BG = "#1e1e2e" |
| 11 | +ACCENT = "#2d2d46" |
| 12 | +TEXT_COLOR = "#f5f5f5" |
| 13 | +BUTTON_COLOR = "#313244" |
| 14 | +BUTTON_HOVER = "#45475a" |
| 15 | +FONT = ("Segoe UI", 11) |
8 | 16 |
|
9 | 17 |
|
10 | 18 | def run_prediction(input_path, calibrate, finetune): |
@@ -33,53 +41,63 @@ def browse_file(entry_field): |
33 | 41 | entry_field.insert(0, filepath) |
34 | 42 |
|
35 | 43 |
|
| 44 | +def style_button(btn): |
| 45 | + btn.configure(bg=BUTTON_COLOR, fg=TEXT_COLOR, activebackground=BUTTON_HOVER, |
| 46 | + relief="flat", font=FONT, cursor="hand2") |
| 47 | + btn.bind("<Enter>", lambda e: btn.config(bg=BUTTON_HOVER)) |
| 48 | + btn.bind("<Leave>", lambda e: btn.config(bg=BUTTON_COLOR)) |
| 49 | + |
| 50 | + |
36 | 51 | def launch_gui(): |
37 | 52 | root = tk.Tk() |
38 | 53 | root.title("iDeepLC Predictor") |
39 | | - root.geometry("600x400") |
40 | | - root.configure(bg="#f0f0f0") |
| 54 | + root.geometry("700x550") |
| 55 | + root.configure(bg=PRIMARY_BG) |
41 | 56 |
|
42 | 57 | # Load and display the image |
43 | 58 | img_url = "https://github.com/user-attachments/assets/86e9b793-39be-4f62-8119-5c6a333af487" |
44 | 59 | img_path = "logo_temp.jpg" |
45 | | - |
46 | | - # Download if not exists (for local runs) |
47 | 60 | if not os.path.exists(img_path): |
48 | | - import requests |
49 | 61 | with open(img_path, "wb") as f: |
50 | 62 | f.write(requests.get(img_url).content) |
51 | 63 |
|
52 | 64 | image = Image.open(img_path) |
53 | | - image = image.resize((410,240)) |
| 65 | + image = image.resize((450, 200), Image.LANCZOS) |
54 | 66 | photo = ImageTk.PhotoImage(image) |
55 | | - |
56 | | - image_label = tk.Label(root, image=photo, bg="#f0f0f0") |
| 67 | + image_label = tk.Label(root, image=photo, bg=PRIMARY_BG) |
57 | 68 | image_label.image = photo |
58 | | - image_label.pack(pady=(10, 0)) |
| 69 | + image_label.pack(pady=(20, 10)) |
59 | 70 |
|
60 | | - # Input file selection |
61 | | - frame = tk.Frame(root, bg="#f0f0f0") |
| 71 | + # Input frame |
| 72 | + frame = tk.Frame(root, bg=PRIMARY_BG) |
62 | 73 | frame.pack(pady=10) |
63 | 74 |
|
64 | | - tk.Label(frame, text="Input CSV:", bg="#f0f0f0").grid(row=0, column=0, padx=5, sticky='e') |
65 | | - input_entry = tk.Entry(frame, width=40) |
66 | | - input_entry.grid(row=0, column=1, padx=5) |
67 | | - tk.Button(frame, text="Browse", command=lambda: browse_file(input_entry)).grid(row=0, column=2, padx=5) |
| 75 | + tk.Label(frame, text="Input CSV:", bg=PRIMARY_BG, fg=TEXT_COLOR, font=FONT).grid(row=0, column=0, padx=10) |
| 76 | + input_entry = tk.Entry(frame, width=45, font=FONT, bg="#2e2e3f", fg=TEXT_COLOR, insertbackground=TEXT_COLOR, |
| 77 | + relief="flat") |
| 78 | + input_entry.grid(row=0, column=1, padx=10) |
| 79 | + browse_btn = tk.Button(frame, text="Browse", command=lambda: browse_file(input_entry)) |
| 80 | + style_button(browse_btn) |
| 81 | + browse_btn.grid(row=0, column=2, padx=10) |
68 | 82 |
|
69 | | - # Options |
70 | | - options_frame = tk.Frame(root, bg="#f0f0f0") |
71 | | - options_frame.pack(pady=10) |
| 83 | + # Options frame |
| 84 | + options_frame = tk.Frame(root, bg=PRIMARY_BG) |
| 85 | + options_frame.pack(pady=15) |
72 | 86 |
|
73 | 87 | calibrate_var = tk.BooleanVar() |
74 | 88 | finetune_var = tk.BooleanVar() |
75 | 89 |
|
76 | | - tk.Checkbutton(options_frame, text="Calibrate", variable=calibrate_var, bg="#f0f0f0").pack(side=tk.LEFT, padx=10) |
77 | | - tk.Checkbutton(options_frame, text="Fine-tune", variable=finetune_var, bg="#f0f0f0").pack(side=tk.LEFT, padx=10) |
| 90 | + tk.Checkbutton(options_frame, text="Calibrate", variable=calibrate_var, |
| 91 | + bg=PRIMARY_BG, fg=TEXT_COLOR, selectcolor=ACCENT, font=FONT, activebackground=PRIMARY_BG).pack(side=tk.LEFT, padx=20) |
| 92 | + tk.Checkbutton(options_frame, text="Fine-tune", variable=finetune_var, |
| 93 | + bg=PRIMARY_BG, fg=TEXT_COLOR, selectcolor=ACCENT, font=FONT, activebackground=PRIMARY_BG).pack(side=tk.LEFT, padx=20) |
78 | 94 |
|
79 | 95 | # Run button |
80 | | - run_btn = tk.Button(root, text="Run Prediction", bg="#4CAF50", fg="white", font=("Arial", 12, "bold"), |
| 96 | + run_btn = tk.Button(root, text="Run Prediction", |
81 | 97 | command=lambda: run_prediction(input_entry.get(), calibrate_var.get(), finetune_var.get())) |
82 | | - run_btn.pack(pady=20) |
| 98 | + style_button(run_btn) |
| 99 | + run_btn.config(font=("Segoe UI", 12, "bold"), width=20) |
| 100 | + run_btn.pack(pady=30) |
83 | 101 |
|
84 | 102 | root.mainloop() |
85 | 103 |
|
|
0 commit comments