@@ -126,61 +126,39 @@ def handle_uri(path: str, launch_args: Tuple[str, ...]) -> None:
126
126
elif component .display_name == "Text Client" :
127
127
text_client_component = component
128
128
129
- from kvui import App , Button , BoxLayout , Label , Clock , Window
129
+ if client_component is None :
130
+ run_component (text_client_component , * launch_args )
131
+ return
130
132
131
- class Popup (App ):
132
- timer_label : Label
133
- remaining_time : Optional [int ]
133
+ from kvui import App , Button , BoxLayout , Label , Window
134
134
135
+ class Popup (App ):
135
136
def __init__ (self ):
136
137
self .title = "Connect to Multiworld"
137
138
self .icon = r"data/icon.png"
138
139
super ().__init__ ()
139
140
140
141
def build (self ):
141
142
layout = BoxLayout (orientation = "vertical" )
143
+ layout .add_widget (Label (text = "Select client to open and connect with." ))
144
+ button_row = BoxLayout (orientation = "horizontal" , size_hint = (1 , 0.4 ))
142
145
143
- if client_component is None :
144
- self .remaining_time = 7
145
- label_text = (f"A game client able to parse URIs was not detected for { game } .\n "
146
- f"Launching Text Client in 7 seconds..." )
147
- self .timer_label = Label (text = label_text )
148
- layout .add_widget (self .timer_label )
149
- Clock .schedule_interval (self .update_label , 1 )
150
- else :
151
- layout .add_widget (Label (text = "Select client to open and connect with." ))
152
- button_row = BoxLayout (orientation = "horizontal" , size_hint = (1 , 0.4 ))
153
-
154
- text_client_button = Button (
155
- text = text_client_component .display_name ,
156
- on_release = lambda * args : run_component (text_client_component , * launch_args )
157
- )
158
- button_row .add_widget (text_client_button )
146
+ text_client_button = Button (
147
+ text = text_client_component .display_name ,
148
+ on_release = lambda * args : run_component (text_client_component , * launch_args )
149
+ )
150
+ button_row .add_widget (text_client_button )
159
151
160
- game_client_button = Button (
161
- text = client_component .display_name ,
162
- on_release = lambda * args : run_component (client_component , * launch_args )
163
- )
164
- button_row .add_widget (game_client_button )
152
+ game_client_button = Button (
153
+ text = client_component .display_name ,
154
+ on_release = lambda * args : run_component (client_component , * launch_args )
155
+ )
156
+ button_row .add_widget (game_client_button )
165
157
166
- layout .add_widget (button_row )
158
+ layout .add_widget (button_row )
167
159
168
160
return layout
169
161
170
- def update_label (self , dt ):
171
- if self .remaining_time > 1 :
172
- # countdown the timer and string replace the number
173
- self .remaining_time -= 1
174
- self .timer_label .text = self .timer_label .text .replace (
175
- str (self .remaining_time + 1 ), str (self .remaining_time )
176
- )
177
- else :
178
- # our timer is finished so launch text client and close down
179
- run_component (text_client_component , * launch_args )
180
- Clock .unschedule (self .update_label )
181
- App .get_running_app ().stop ()
182
- Window .close ()
183
-
184
162
def _stop (self , * largs ):
185
163
# see run_gui Launcher _stop comment for details
186
164
self .root_window .close ()
0 commit comments