diff cagou/core/cagou_widget.py @ 387:d61bbbac4160

cagou widget: don't add header_input systematically anymore: header input is often used in CagouWidget for e.g. filtering, but not always, and when it is not, it is weird and confusing to have a TextInput which doesn't do nothing. To avoid that, a new `use_header_input` bool attribute (set to False by default) has been added to CagouWidget.
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2020 20:47:17 +0100
parents 1da3c379205b
children 84ff5c917064
line wrap: on
line diff
--- a/cagou/core/cagou_widget.py	Tue Feb 04 20:47:17 2020 +0100
+++ b/cagou/core/cagou_widget.py	Tue Feb 04 20:47:17 2020 +0100
@@ -24,6 +24,7 @@
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.dropdown import DropDown
 from kivy.uix.screenmanager import Screen
+from kivy.uix.textinput import TextInput
 from kivy import properties
 from cagou import G
 from .common import ActionIcon
@@ -86,6 +87,7 @@
     main_container = properties.ObjectProperty(None)
     header_input = properties.ObjectProperty(None)
     header_box = properties.ObjectProperty(None)
+    use_header_input = False
     # set to True if you want to be able to switch between visible widgets of this
     # class using a carousel
     collection_carousel = False
@@ -104,6 +106,17 @@
                 break
         super().__init__(**kwargs)
         self.selector = HeaderWidgetSelector(self)
+        if self.use_header_input:
+            self.header_input = TextInput(
+                background_normal=G.host.app.expand(
+                    '{media}/misc/borders/border_hollow_light.png'),
+                multiline=False,
+            )
+            self.header_input.bind(
+                on_text_validate=lambda *args: self.onHeaderInput(),
+                text=self.onHeaderInputComplete,
+            )
+            self.header_box.add_widget(self.header_input)
 
     @property
     def screen_manager(self):