-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/network' into dev
# Conflicts: # poetry.lock
- Loading branch information
Showing
8 changed files
with
358 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
rotary_controller_python/components/forms/dropdown_item.kv
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,23 @@ | ||
<DropDownItem>: | ||
main_button: main_button | ||
height: 36 | ||
size_hint_y: None | ||
BoxLayout: | ||
orientation: "horizontal" | ||
Button: | ||
size_hint_x: None | ||
width: self.height | ||
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf" | ||
font_size: 21 | ||
text: "\uf129" | ||
Label: | ||
size_hint_x: 0.7 | ||
text: root.name | ||
Button: | ||
id: main_button | ||
size_hint_x: None | ||
width: 250 | ||
# multiline: False | ||
# text: 'ON' if root.value else 'OFF' | ||
# state: 'down' if root.value else 'normal' | ||
on_release: root.dropdown.open(self) |
46 changes: 46 additions & 0 deletions
46
rotary_controller_python/components/forms/dropdown_item.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,46 @@ | ||
import os | ||
|
||
from kivy.lang import Builder | ||
from kivy.logger import Logger | ||
from kivy.properties import StringProperty, ListProperty, ObjectProperty | ||
from kivy.uix.boxlayout import BoxLayout | ||
from kivy.uix.dropdown import DropDown | ||
from kivy.uix.button import Button | ||
|
||
|
||
log = Logger.getChild(__name__) | ||
kv_file = os.path.join(os.path.dirname(__file__), __file__.replace(".py", ".kv")) | ||
if os.path.exists(kv_file): | ||
log.info(f"Loading KV file: {kv_file}") | ||
Builder.load_file(kv_file) | ||
|
||
|
||
class DropDownItem(BoxLayout): | ||
name = StringProperty("") | ||
value = StringProperty(False) | ||
options = ListProperty([]) | ||
dropdown = ObjectProperty() | ||
main_button: Button = ObjectProperty() | ||
|
||
def __init__(self, **kv): | ||
super().__init__(**kv) | ||
self.dropdown = DropDown() | ||
self._options = [] | ||
self.dropdown.bind(on_select=lambda instance, x: setattr(self, 'value', x)) | ||
|
||
def delete_all_dropdown_options(self): | ||
for item in self._options: | ||
self.dropdown.remove_widget(item) | ||
|
||
def on_value(self, instance, value): | ||
self.main_button.text = value | ||
|
||
def on_options(self, instance, value): | ||
# Clean any existing | ||
self.delete_all_dropdown_options() | ||
|
||
for item in self.options: | ||
btn = Button(text=item, size_hint_y=None, height=44) | ||
btn.bind(on_release=lambda btn: self.dropdown.select(btn.text)) | ||
self.dropdown.add_widget(btn) | ||
self._options.append(btn) |
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
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
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.