MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / show_main_menu

Method show_main_menu

pager/pager_menu.py:256–299  ·  view source on GitHub ↗

Show the main menu. Returns config dict or None to exit.

(self)

Source from the content-addressed store, hash-verified

254 return items
255
256 def show_main_menu(self):
257 """Show the main menu. Returns config dict or None to exit."""
258 selected = 0
259 iface_idx = 0
260 web_ui = True
261 num_options = 5
262
263 self._draw_main_menu(selected, iface_idx, web_ui)
264
265 while True:
266 btn = self._wait_button()
267
268 if btn == 'UP':
269 selected = (selected - 1) % num_options
270 self._draw_main_menu(selected, iface_idx, web_ui)
271 elif btn == 'DOWN':
272 selected = (selected + 1) % num_options
273 self._draw_main_menu(selected, iface_idx, web_ui)
274 elif btn == 'SELECT':
275 if selected == 0:
276 if not self.interfaces:
277 self._show_message("No network!", WARNING_COLOR, "Connect to a network first", DIM_COLOR)
278 self._wait_button()
279 self._draw_main_menu(selected, iface_idx, web_ui)
280 continue
281 iface = self.interfaces[iface_idx]
282 return {
283 'interface': iface['name'],
284 'ip': iface['ip'],
285 'web_ui': web_ui,
286 }
287 elif selected == 1 and self.interfaces:
288 iface_idx = (iface_idx + 1) % len(self.interfaces)
289 self._draw_main_menu(selected, iface_idx, web_ui)
290 elif selected == 2:
291 web_ui = not web_ui
292 self._draw_main_menu(selected, iface_idx, web_ui)
293 elif selected == 3:
294 self._show_clear_data_menu()
295 self._draw_main_menu(selected, iface_idx, web_ui)
296 elif selected == 4:
297 return None
298 elif btn == 'BACK':
299 return None
300
301 def _show_message(self, text, color, subtext=None, subcolor=None):
302 self.gfx.clear(Pager.BLACK)

Callers 1

mainFunction · 0.95

Calls 4

_draw_main_menuMethod · 0.95
_wait_buttonMethod · 0.95
_show_messageMethod · 0.95
_show_clear_data_menuMethod · 0.95

Tested by

no test coverage detected