Skip to content

Commit 8620cb7

Browse files
committed
Enhance minecraft_server_gui.py with EULA agreement and logo support
- Added a checkbox for users to accept the Minecraft EULA before server installation. - Implemented logo display in the GUI with fallback handling for environments without display support. - Adjusted layout of the top bar to accommodate the new logo and EULA components. - Updated requirements.txt to include new dependencies: psutil, Pillow, and matplotlib.
1 parent 12f336c commit 8620cb7

File tree

10 files changed

+47
-5
lines changed

10 files changed

+47
-5
lines changed
-171 KB
Binary file not shown.

assets/logo.png

155 KB
Loading
-10.9 KB
Binary file not shown.

minecraft_server_gui.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ def __init__(self, master):
5858
self.java_path_var = tk.StringVar(value=self.config_manager.get("java_path", "java"))
5959

6060
master.title("Minecraft Server Control")
61+
try:
62+
logo_path = os.path.join(self.script_dir, "assets", "logo.png")
63+
self.logo_image = tk.PhotoImage(file=logo_path)
64+
master.iconphoto(True, self.logo_image)
65+
except tk.TclError:
66+
# Fallback for environments where PhotoImage might fail (e.g., no display)
67+
pass
6168
master.configure(bg=PRIMARY_BG)
6269

6370
self.style = ttk.Style()
@@ -136,14 +143,24 @@ def _create_main_layout(self, parent_frame):
136143
self.top_bar_frame = ttk.Frame(parent_frame, height=70, style='Header.TFrame')
137144
self.top_bar_frame.pack(side=tk.TOP, fill=tk.X, padx=(5,10), pady=(10,5))
138145
self.top_bar_frame.pack_propagate(False)
139-
self.top_bar_frame.columnconfigure(0, weight=1)
140-
self.top_bar_frame.columnconfigure(1, weight=0)
146+
self.top_bar_frame.columnconfigure(0, weight=0)
147+
self.top_bar_frame.columnconfigure(1, weight=1)
148+
self.top_bar_frame.columnconfigure(2, weight=0)
149+
150+
try:
151+
logo_path = os.path.join(self.script_dir, "assets", "logo.png")
152+
logo_img = Image.open(logo_path).resize((48, 48), Image.Resampling.LANCZOS)
153+
self.dashboard_logo = ImageTk.PhotoImage(logo_img)
154+
logo_label = ttk.Label(self.top_bar_frame, image=self.dashboard_logo, style='Title.TLabel')
155+
logo_label.grid(row=0, column=0, sticky='w', padx=(15, 10), pady=5)
156+
except (FileNotFoundError, tk.TclError):
157+
pass # Logo not found or image processing failed, continue without it.
141158

142159
self.server_title_label = ttk.Label(self.top_bar_frame, text="Minecraft Server Dashboard", font=FONT_UI_TITLE, style='Title.TLabel')
143-
self.server_title_label.grid(row=0, column=0, sticky='ew', padx=(15, 5), pady=5)
160+
self.server_title_label.grid(row=0, column=1, sticky='ew', padx=(0, 5), pady=5)
144161

145162
top_bar_actions_frame = ttk.Frame(self.top_bar_frame, style='Header.TFrame')
146-
top_bar_actions_frame.grid(row=0, column=1, sticky='e', padx=(0, 15), pady=5)
163+
top_bar_actions_frame.grid(row=0, column=2, sticky='e', padx=(0, 15), pady=5)
147164

148165
self.server_status_label = ttk.Label(top_bar_actions_frame, text="Status: Offline", style='StatusOffline.TLabel')
149166
self.server_status_label.pack(side=tk.LEFT, padx=(0,15))
@@ -230,6 +247,24 @@ def _create_setup_wizard(self):
230247
self.server_name_entry = ttk.Entry(self.install_frame, textvariable=self.server_name_var)
231248
self.server_name_entry.pack(fill=tk.X, padx=20, pady=5)
232249

250+
# --- EULA Agreement ---
251+
self.eula_accepted_var = tk.BooleanVar(value=False)
252+
eula_frame = ttk.Frame(self.install_frame, style='TFrame')
253+
eula_frame.pack(fill=tk.X, padx=20, pady=10)
254+
ttk.Checkbutton(eula_frame, variable=self.eula_accepted_var, style='Switch.TCheckbutton').pack(side=tk.LEFT)
255+
eula_label_frame = ttk.Frame(eula_frame, style='TFrame')
256+
eula_label_frame.pack(side=tk.LEFT, padx=5)
257+
258+
def open_eula_link(event):
259+
import webbrowser
260+
webbrowser.open("https://www.minecraft.net/en-us/eula")
261+
262+
eula_text_label = ttk.Label(eula_label_frame, text="I agree to the Minecraft EULA.", style='TLabel', background=PRIMARY_BG)
263+
eula_text_label.pack(side=tk.LEFT)
264+
eula_link_label = ttk.Label(eula_label_frame, text="(View)", style='TLabel', foreground=ACCENT_COLOR, cursor="hand2", background=PRIMARY_BG)
265+
eula_link_label.pack(side=tk.LEFT)
266+
eula_link_label.bind("<Button-1>", open_eula_link)
267+
233268
self.server_version_var.trace_add('write', self._update_default_folder_name)
234269
self.server_type_var.trace_add('write', self._update_server_versions)
235270

@@ -315,6 +350,10 @@ def _start_setup_action(self):
315350
messagebox.showerror("Error", "Please select a parent directory and provide a folder name.")
316351
self.action_button.config(state=tk.NORMAL)
317352
return
353+
if not self.eula_accepted_var.get():
354+
messagebox.showerror("EULA Required", "You must agree to the Minecraft EULA to install a new server.")
355+
self.action_button.config(state=tk.NORMAL)
356+
return
318357
threading.Thread(target=self._perform_server_installation, daemon=True).start()
319358
else: # existing
320359
threading.Thread(target=self._use_existing_server, daemon=True).start()

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
requests
1+
requests
2+
psutil
3+
Pillow
4+
matplotlib
-2.51 KB
Binary file not shown.
-9.29 KB
Binary file not shown.
-5.81 KB
Binary file not shown.
-729 Bytes
Binary file not shown.
-2.05 KB
Binary file not shown.

0 commit comments

Comments
 (0)