Skip to content
This repository has been archived by the owner on Jun 18, 2021. It is now read-only.

Commit

Permalink
Disable Launch Button While MCPI Is Running
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBrokenRail committed Dec 9, 2020
1 parent 8e0a15d commit 180760a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/mcpil.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
'Classic Miecraft Pi Edition. (Not Recommended)\nNo mods.',
'Modded Miecraft Pi Edition.\nDefault MCPI-Docker mods without Touch GUI.',
'Minecraft Pocket Edition. (Recommended)\nDefault MCPI-Docker mods.',
'Custom Profile.\nModify its settings in the Profile tab.',
'Custom Profile.\nModify its settings in the Features tab.',
]
current_selection = 0
description_text: Label

launch_button: Button

current_username: StringVar
current_features = []
feature_widgets: Dict[str, ttk.Checkbutton] = {}
Expand Down Expand Up @@ -149,15 +151,22 @@ def get_features() -> list:
# Custom (TODO)
return current_features

# Launch Minecraft
def launch():
global current_username, current_process
launch_button.config(state=DISABLED)
if current_process is None or current_process.poll() is not None:
current_process = launcher.run(get_features(), current_username.get())
return 0

def pre_launch():
return launch()
# Update Launch Button
def update_launch_button():
global launch_button
if (current_process is None or current_process.poll() is not None) and launch_button['state'] == DISABLED:
launch_button.config(state=NORMAL)
launch_button.after(10, update_launch_button)

# Close MCPIL
def bye():
global current_process
if current_process is not None and current_process.poll() is None:
Expand Down Expand Up @@ -213,7 +222,7 @@ def on_select_versions(event):
'''

def play_tab(parent):
global description_text
global description_text, launch_button

tab = Frame(parent)

Expand Down Expand Up @@ -248,9 +257,12 @@ def play_tab(parent):
versions_frame.grid(row=2, sticky='NSEW')

launch_frame = Frame(tab)
launch_button = Button(launch_frame, text='Launch!', command=pre_launch)
launch_button = Button(launch_frame, text='Launch', command=launch)
launch_button.pack(side=RIGHT, anchor=S)
launch_frame.grid(row=3, sticky='SE')

launch_button.after(0, update_launch_button)

return tab

def settings_tab(parent):
Expand Down

0 comments on commit 180760a

Please sign in to comment.