Last active
June 10, 2021 05:15
-
-
Save VICTORVICKIE/e6e2044bee3db9a10e68b2181724d266 to your computer and use it in GitHub Desktop.
Compact Labels
This file contains hidden or 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
from kivymd.app import MDApp | |
from kivy.lang import Builder | |
from kivy.uix.recycleview import RecycleView | |
from kivy.properties import StringProperty | |
from kivy.uix.boxlayout import BoxLayout | |
from kivymd.theming import ThemableBehavior | |
from kivymd.uix.behaviors import RectangularRippleBehavior | |
from kivy.uix.behaviors import ButtonBehavior | |
from kivy.uix.floatlayout import FloatLayout | |
from kivymd.uix.screen import MDScreen | |
from kivy.core.window import Window | |
from kivy.modules import inspector | |
Builder.load_string(''' | |
<Label>: | |
color: 0, 0, 0, 1 | |
<SearchResults>: | |
MDBoxLayout: | |
MDCard: | |
radius:[5,5,5,5] | |
RelativeLayout: | |
# FitImage: | |
# radius:[5,5,5,5] | |
# source:"assets/images/bg/Madhavaram.png" | |
BoxLayout: | |
padding:[10,10,10,10] | |
size_hint: None, None | |
size: self.minimum_size | |
pos_hint:{"center_y":0.66} | |
Label: | |
text:"Madhavaram ," | |
size_hint_x:None | |
width:self.texture_size[0] | |
MDIconButton: | |
icon:"arrow-right" | |
_no_ripple_effect:True | |
BoxLayout: | |
pos_hint:{"right":1} | |
size_hint: None, None | |
size: self.minimum_size | |
padding:[10,0,5,15] | |
Label: | |
text:"10 " + "\u00B0C" + " , 5 km" | |
# color: 1, 1, 1, 1 | |
size_hint_x:None | |
width:self.texture_size[0] | |
halign:"right" | |
<SearchRV>: | |
key_viewclass: "viewclass" | |
key_size: "height" | |
RecycleBoxLayout: | |
padding: "10dp" | |
spacing:20 | |
default_size: None, dp(100) | |
default_size_hint: 1, None | |
size_hint_y: None | |
height: self.minimum_height | |
orientation: "vertical" | |
''') | |
class SearchResults(ThemableBehavior, RectangularRippleBehavior, ButtonBehavior, BoxLayout): | |
area = StringProperty() | |
shop = StringProperty() | |
balance = StringProperty() | |
class SearchRV(RecycleView): | |
def __init__(self,**kwargs): | |
super().__init__(**kwargs) | |
self.data = [] | |
for num in range(1,3): | |
self.add_data(num) | |
def add_data(self, num): | |
self.data.append({ | |
"viewclass": "SearchResults", | |
"area": f"area {num}", | |
"shop": f"shop {num}", | |
"balance": str(num) | |
}) | |
class TestApp(MDApp): | |
def build(self): | |
screen = MDScreen(name="RV") | |
rv = SearchRV() | |
screen.add_widget(rv) | |
inspector.create_inspector(Window, screen) | |
return screen | |
def on_start(self): | |
balance_pad = self.root.width - (0) | |
if __name__ == '__main__': | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment