Skip to content

Commit

Permalink
Merge pull request #5 from werryxgames/fix-tab-switch
Browse files Browse the repository at this point in the history
Исправлена ошибка с переключением вкладок
  • Loading branch information
werryxgames committed May 18, 2022
2 parents a03e0bc + c59c18a commit 61aa204
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sys import argv, exit
from json.decoder import JSONDecodeError
from mjson import read
from network import start_server, start_server_async
from network import start_server, start_server_async, stop_server, is_active
from logger import Logger
from singleton import set_data
from tests import tests
Expand Down Expand Up @@ -102,6 +102,9 @@ def tab_main(config, win):
win.place(Label, {"text": "Github: https://github.com/werryxgames/Tanks-Battle-Server", "font": "Arial 8"}, relx=0, rely=1, x=2, y=-2, anchor="sw")
win.place(Label, {"text": "Вебсайт: https://werryxgames.ml", "font": "Arial 8"}, relx=1, rely=1, x=-2, y=-2, anchor="se")

if is_active():
win.elements[2].configure(text=f"Статус: запущен\tIP: {config['host']}")
win.elements[3].configure(text="Остановить", command=stop_server)

def init_window(config, logger):
win = Window()
Expand Down
6 changes: 6 additions & 0 deletions network.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def receive(self, data):
return


def is_active():
return thr is not None


def stop_server():
global sock, thr

Expand All @@ -110,6 +114,8 @@ def stop_server():
gui.elements[2].configure(text="Статус: не запущен")
gui.elements[3].configure(text="Запустить", command=start_server_async)

thr = None


def start_server_async():
global thr
Expand Down

0 comments on commit 61aa204

Please sign in to comment.