Popups done, Readout Screen prepared, Small fixes

This commit is contained in:
2025-04-09 17:13:24 +02:00
parent 36a3079040
commit e0a54ac2bd
12 changed files with 248 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
<SettingsScreen>:
name: "settings"
<AboutScreen>:
name: "about"
canvas.before:
Color:
rgba: (50,50,50,0.2)
@@ -9,7 +9,7 @@
GridLayout:
cols: 1
Label:
text: "Settings"
text: "About"
font_size: 40
color: (0, 113, 0, 1)
bold: True

View File

@@ -3,8 +3,8 @@ from kivy.lang import Builder
import webbrowser
class SettingsScreen(Screen):
class AboutScreen(Screen):
def report_issue(self):
webbrowser.open('https://github.com/janishutz/BiogasControllerApp/issues', new=2)
Builder.load_file('./gui/settings/settings.kv')
Builder.load_file('./gui/about/about.kv')

View File

@@ -12,7 +12,7 @@
size_hint: 0.4, 0.2
pos_hint: {"x":0.3, "y":0.1}
on_release:
app.root.current = "settings"
app.root.current = "about"
root.manager.transition.direction = "right"
GridLayout:
cols:1

View File

@@ -37,10 +37,10 @@
font_size: 13
pos_hint: {"y": -0.45, "x":0.05}
Button:
text: "Settings"
text: "About"
font_size: 13
size_hint: 0.07, 0.06
pos_hint: {"x":0.01, "y":0.01}
background_color: (50, 0, 0, 0.2)
on_release:
root.to_settings()
root.to_about()

View File

@@ -1,16 +1,29 @@
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from gui.popups.popups import QuitPopup, SingleRowPopup, TwoActionPopup
from lib.com import Com
class HomeScreen(Screen):
def __init__(self, com: Com, **kw):
self._com = com;
super().__init__(**kw)
def start(self):
pass
if self._com.connect(19200):
self.manager.current = 'main'
self.manager.transition.direction = 'right'
else:
TwoActionPopup().open('Failed to connect', 'Details', self.open_details_popup)
print('ERROR connecting')
def open_details_popup(self):
print( 'Details' )
def quit(self):
pass
QuitPopup(self._com).open()
def to_settings(self):
self.manager.current = 'settings'
def to_about(self):
self.manager.current = 'about'
self.manager.transition.direction = 'down'

View File

@@ -0,0 +1,107 @@
<MainScreen>:
on_pre_enter: root.reset()
name: "main"
canvas.before:
Color:
rgba: (50,50,50,0.2)
Rectangle:
size: self.size
pos: self.pos
GridLayout:
FloatLayout:
Label:
pos_hint: {"y":0.4}
text: "READOUT"
font_size: 40
color: (0, 113, 0, 1)
bold: True
GridLayout:
cols:4
size_hint: 0.8, 0.3
pos_hint: {"x":0.1, "y":0.4}
Label:
text: "SENSOR 1: "
font_size: 20
Label:
id: sonde1
text: ""
Label:
text: "SENSOR 2: "
font_size: 20
Label:
id: sonde2
text: ""
Label:
text: "SENSOR 3: "
font_size: 20
Label:
id: sonde3
text: ""
Label:
text: "SENSOR 4: "
font_size: 20
Label:
id: sonde4
text: ""
Button:
text: "Start communication"
size_hint: 0.2, 0.1
pos_hint: {"x": 0.5, "y": 0.05}
background_color: (255, 0, 0, 0.6)
on_release:
root.start()
Button:
text: "End communication"
size_hint: 0.2, 0.1
pos_hint: {"x": 0.7, "y": 0.05}
background_color: (255, 0, 0, 0.6)
on_release:
root.end()
Button:
text: "Back"
size_hint: 0.3, 0.1
pos_hint: {"x":0.05, "y":0.05}
background_color: (255, 0, 0, 0.6)
on_release:
root.end()
app.root.current = "home"
root.manager.transition.direction = "left"
ToggleButton:
id: mode_selector
size_hint: 0.15, 0.1
pos_hint: {"x":0.1, "y":0.2}
text: "Normal Mode" if self.state == "normal" else "Fast Mode"
on_text: root.switch_mode(mode_selector.text)
background_color: (255,0,0,0.6) if self.state == "normal" else (0,0,255,0.6)
Button:
text: "Read Data"
size_hint: 0.15, 0.1
pos_hint: {"x":0.3, "y":0.2}
background_color: (255, 0, 0, 0.6)
on_release:
root.end()
app.root.current = "read"
root.manager.transition.direction = "down"
Button:
text: "Temperature"
size_hint: 0.15, 0.1
pos_hint: {"x":0.5, "y":0.2}
background_color: (255, 0, 0, 0.6)
on_release:
root.end()
app.root.current = "temperature"
root.manager.transition.direction = "down"
Button:
text: "Change all Data"
size_hint: 0.15, 0.1
pos_hint: {"x":0.7, "y":0.2}
background_color: (255, 0, 0, 0.6)
on_release:
root.end()
app.root.current = "program"
root.manager.transition.direction = "down"
Label:
id: frequency
text: "Frequency will appear here"
font_size: 10
pos_hint: {"x":0.4, "y": 0.3}

View File

@@ -0,0 +1,25 @@
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from lib.com import Com
class MainScreen(Screen):
def __init__(self, com: Com, **kw):
self._com = com;
super().__init__(**kw)
def start(self):
pass
def end(self):
pass
def reset(self):
pass
def back(self):
pass
Builder.load_file('./gui/main/main.kv')

View File

@@ -1,26 +1,10 @@
<SingleRowPopUp>:
title: "INFORMATION"
size_hint: 0.7, 0.5
auto_dismiss: True
GridLayout:
cols: 1
Label:
id: msg
text_size: self.width, None
GridLayout:
cols: 1
Button:
text: "Ok"
on_release:
root.dismiss()
<QuitPopUp>:
<QuitPopup>:
title: "BiogasControllerApp"
font_size: 50
size_hint: 0.5, 0.4
auto_dismiss: False
GridLayout:
cols:1
cols: 1
Label:
text: "Are you sure you want to leave?"
font_size: 20
@@ -38,6 +22,24 @@
on_press:
root.dismiss()
<SingleRowPopup>:
title: "INFORMATION"
size_hint: 0.7, 0.5
auto_dismiss: True
GridLayout:
cols: 1
Label:
id: msg
text: "Message"
text_size: self.width, None
halign: 'center'
GridLayout:
cols: 1
Button:
text: "Ok"
on_release:
root.dismiss()
<TwoActionPopup>:
title: "WARNING!"
font_size: 50
@@ -49,16 +51,20 @@
id: msg
text: "Message"
font_size: 20
halign: 'center'
GridLayout:
cols:2
Button:
id: btn1
text: "Details"
on_release:
root.action()
root.action_one()
root.dismiss()
Button:
id: btn2
text:"Ok"
on_release:
root.action_two()
root.dismiss()
<DualRowPopup>:
@@ -87,8 +93,8 @@
size_hint: 1, 0.7
auto_dismiss: False
GridLayout:
cols: 1
Label:
cols:1
id: msg_title
text: "title"
font_size: 20

View File

@@ -1,16 +1,53 @@
from typing import Callable
from kivy.uix.popup import Popup
from kivy.lang import Builder
from lib.com import Com
class ThisPopup(Popup):
def start(self):
pass
def empty_func():
pass
class QuitPopup(Popup):
def __init__(self, com: Com, **kw):
self._com = com;
super().__init__(**kw)
def quit(self):
pass
self._com.close()
def to_settings(self):
pass
class SingleRowPopup(Popup):
def open(self, message, *_args, **kwargs):
self.ids.msg.text = message
return super().open(*_args, **kwargs)
class DualRowPopup(Popup):
def open(self, title: str, message: str, *_args, **kwargs):
self.ids.msg_title.text = title
self.ids.msg_body.text = message
return super().open(*_args, **kwargs)
Builder.load_file('./gui/home/home.kv')
class LargeTrippleRowPopup(Popup):
def open(self, title: str, message: str, details: str, *_args, **kwargs):
self.ids.msg_title.text = title
self.ids.msg_body.text = message
self.ids.msg_extra.text = details
return super().open(*_args, **kwargs)
class TwoActionPopup(Popup):
def open(self,
message: str,
button_one: str,
action_one: Callable[[], None],
button_two: str = 'Ok',
action_two: Callable[[], None] = empty_func,
*_args,
**kwargs
):
self.ids.msg.text = message
self.ids.btn1.text = button_one
self.ids.btn2.text = button_two
self.action_one = action_one
self.action_two = action_two
return super().open(*_args, **kwargs)
Builder.load_file('./gui/popups/popups.kv')

View File

@@ -3,6 +3,10 @@ from kivy.lang import Builder
class HomeScreen(Screen):
def __init__(self, com: Com, **kw):
self._com = com;
super().__init__(**kw)
def start(self):
pass