UI Tweaks

This commit is contained in:
2025-05-12 16:28:28 +02:00
parent b694d9d086
commit 986d887587
5 changed files with 39 additions and 7 deletions

View File

@@ -1,9 +1,23 @@
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from gui.popups.popups import QuitPopup, TwoActionPopup
from gui.popups.popups import DualRowPopup, QuitPopup, TwoActionPopup
from lib.com import ComSuperClass
import platform
import configparser
# Information for errors encountered when using pyserial
information = {
"Windows": {
"2": "Un- and replug the cable and ensure you have the required driver(s) installed",
"13": "You are probably missing a required driver or your cable doesn't work. Consult the wiki for more information",
"NO_COM": "Could not find a microcontroller. Please ensure you have one connected and the required driver(s) installed"
},
"Linux": {
"2": "Un- and replug the cable, or if you haven't plugged a controller in yet, do that",
"13": "Incorrect permissions at /dev/ttyUSB0. Open a terminal and type: sudo chmod 777 /dev/ttyUSB0",
"NO_COM": "Could not find a microcontroller. Please ensure you have one connected"
}
}
# This is the launch screen, i.e. what you see when you start up the app
@@ -24,8 +38,22 @@ class HomeScreen(Screen):
# Open popup for details as to why the connection failed
def open_details_popup(self):
# TODO: Finish
print( 'Details' )
DualRowPopup().open("Troubleshooting tips", self._generate_help())
def _generate_help(self) -> str:
operating_system = platform.system()
if operating_system == "Windows" or operating_system == "Linux":
port = self._com.get_comport();
information["Linux"]["13"] = f"Incorrect permissions at {port}. Resolve by running 'sudo chmod 777 {port}'"
if port == "":
return information[operating_system]["NO_COM"]
err = self._com.get_error()
if err != None:
return information[operating_system][str(err.errno)]
else:
return "No error message available"
else:
return "You are running on an unsupported Operating System. No help available"
# Helper to open a Popup to ask user whether to quit or not
def quit(self):