forked from beeware/briefcase-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a0d2ea
commit 6884990
Showing
7 changed files
with
363 additions
and
131 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
....app_name }}/src/{{ cookiecutter.module_name }}/components/SettingNadooitAPISchluessel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from {{ cookiecutter.module_name }}.components.SettingsElement import SettingsElement | ||
import toga | ||
from toga.style import Pack | ||
from {{ cookiecutter.module_name }}.services import set_api_key, get_settings | ||
|
||
class SettingNadooitAPISchluessel(SettingsElement): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
# Eingabefeld für den User Code erstellen | ||
self.api_key_input = toga.TextInput( | ||
placeholder="NADOO API Schlüssel", | ||
) | ||
|
||
setting_lable = toga.Label( | ||
"NADOO API Schlüssel", style=Pack(padding_bottom=10) | ||
) | ||
|
||
self.gui.add(setting_lable) | ||
self.gui.add(self.api_key_input) | ||
self.load_settings() | ||
|
||
def save(self): | ||
set_api_key(self.api_key_input.value) | ||
|
||
def load_settings(self): | ||
settings = get_settings() | ||
self.api_key_input.value = settings.get("api_key", "") |
49 changes: 49 additions & 0 deletions
49
...pp_name }}/src/{{ cookiecutter.module_name }}/components/SettingUhrzeitWerktagswechsel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from {{ cookiecutter.module_name }}.components.SettingsElement import SettingsElement | ||
import toga | ||
from toga.style import Pack | ||
from toga.style.pack import ROW | ||
from {{ cookiecutter.module_name }}.services import set_uhrzeit_nächsten_werktag_wechsel, get_settings | ||
|
||
class SettingUhrzeitWerktagswechsel(SettingsElement): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
# Dropdown-Menü für die Stunde erstellen | ||
self.stunde_dropdown = toga.Selection( | ||
items=[f"{stunde:02d}" for stunde in range(24)], | ||
style=Pack(flex=1) | ||
) | ||
|
||
# Dropdown-Menü für die Minute erstellen | ||
self.minute_dropdown = toga.Selection( | ||
items=[f"{minute:02d}" for minute in range(0, 60, 15)], | ||
style=Pack(flex=1) | ||
) | ||
|
||
# Dropdown-Menüs nebeneinander platzieren | ||
dropdown_box = toga.Box( | ||
children=[self.stunde_dropdown, self.minute_dropdown], | ||
style=Pack(direction=ROW) | ||
) | ||
|
||
setting_lable = toga.Label( | ||
"Uhrzeit für den nächsten Werktag wechseln", style=Pack(padding_bottom=10) | ||
) | ||
|
||
self.gui.add(setting_lable) | ||
self.gui.add(dropdown_box) | ||
self.load_settings() | ||
|
||
def save(self): | ||
stunde = self.stunde_dropdown.value | ||
minute = self.minute_dropdown.value | ||
uhrzeit = f"{stunde}:{minute}:00" | ||
set_uhrzeit_nächsten_werktag_wechsel(uhrzeit) | ||
|
||
def load_settings(self): | ||
settings = get_settings() | ||
uhrzeit = settings.get("uhrzeit_nächsten_werktag_wechsel", "16:00:00") | ||
stunde, minute, _ = uhrzeit.split(":") | ||
self.stunde_dropdown.value = stunde | ||
self.minute_dropdown.value = minute |
28 changes: 28 additions & 0 deletions
28
{{ cookiecutter.app_name }}/src/{{ cookiecutter.module_name }}/components/SettingUserCode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from {{ cookiecutter.module_name }}.SettingsElement import SettingsElement | ||
import toga | ||
from toga.style import Pack | ||
from {{ cookiecutter.module_name }}.services import set_user_code, get_settings | ||
|
||
class SettingUserCode(SettingsElement): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
# Eingabefeld für den User Code erstellen | ||
self.user_code_input = toga.TextInput( | ||
placeholder="User Code", | ||
) | ||
|
||
setting_lable = toga.Label( | ||
"NADOO Nutzercode", style=Pack(padding_bottom=10) | ||
) | ||
|
||
self.gui.add(setting_lable) | ||
self.gui.add(self.user_code_input) | ||
self.load_settings() | ||
|
||
def save(self): | ||
set_user_code(self.user_code_input.value) | ||
|
||
def load_settings(self): | ||
settings = get_settings() | ||
self.user_code_input.value = settings.get("user_code", "") |
15 changes: 15 additions & 0 deletions
15
{{ cookiecutter.app_name }}/src/{{ cookiecutter.module_name }}/components/SettingsElement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import toga | ||
from toga.style import Pack | ||
from toga.style.pack import COLUMN | ||
|
||
class SettingsElement: | ||
|
||
def __init__(self): | ||
self.gui = toga.Box(style=Pack(direction=COLUMN, padding_bottom=5)) | ||
pass | ||
|
||
def save(self): | ||
pass | ||
|
||
def load_settings(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.