Skip to content

Commit

Permalink
added a server active and inactive text
Browse files Browse the repository at this point in the history
  • Loading branch information
flexhd41 authored Dec 24, 2022
1 parent bd2e390 commit 0a1d4ac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def initUI(self):
global max_players_field
global port_field
global passwd_field
global status_label
global red_box
global green_box
# Create buttons to execute, stop, and restart the executable file
execute_btn = tk.Button(self, text='Execute', command=self.execute)
stop_btn = tk.Button(self, text='Stop', command=self.stop)
Expand All @@ -36,8 +39,13 @@ def initUI(self):
passwd_label.pack()
passwd_field = tk.Entry()
passwd_field.pack()


red_box = tk.Label(bg="red", width=4, height=2)
red_box.pack_forget()
green_box = tk.Label(bg="green", width=4, height=2)
green_box.pack_forget()
# Create a text label to display the status of the server
status_label = tk.Label(text="Server inactive")
status_label.pack(side="left")



Expand All @@ -56,6 +64,9 @@ def execute(self):
global pid
# Replace "path/to/executable" with the actual path to the executable file
process = subprocess.Popen(f'AMP_Server.exe {port} {max_players} {passwd}', creationflags=CREATE_NEW_CONSOLE)
status_label.config(text="Server active")
red_box.pack_forget()
green_box.pack(side="right")



Expand All @@ -68,6 +79,9 @@ def stop(self):
print("su1")
# Terminate the subprocess
os.kill((process.pid), signal.SIGTERM)
status_label.config(text="Server inactive")
green_box.pack_forget()
red_box.pack(side="right")


def restart(self):
Expand Down

0 comments on commit 0a1d4ac

Please sign in to comment.