python - Kivy - formatting issues with a scrollview pane. -
i trying create following in kivy: https://imgur.com/a/rwdb6. each new recipe in screenshot want able add screen block. far have following code:
from kivy.app import app kivy.uix.label import label kivy.lang import builder kivy.properties import listproperty kivy.uix.boxlayout import boxlayout kivy.uix.gridlayout import gridlayout kivy.uix.dropdown import dropdown kivy.uix.button import button kivy.uix.textinput import textinput kivy.uix.checkbox import checkbox kivy.uix.screenmanager import screenmanager, screen, fadetransition kivy.properties import stringproperty class shoppingscreen(screen): def addrecipe(self): self.ids.grid.add_widget(recipelabel(recipename = "test")) self.ids.grid.add_widget(recipe()) self.ids.grid.add_widget(ingredient(ingredientname = "test", quantity="test")) def activate_checkbox(self): print("test") class recipelabel(boxlayout): recipename = stringproperty('') class recipe(boxlayout): ingredient = stringproperty('ingredient') quantity = stringproperty('quantity') class thescreenmanager(screenmanager): pass class ingredient(boxlayout): ingredientname = stringproperty('') quantity = stringproperty('') root_widget = builder.load_string(''' #:import fadetransition kivy.uix.screenmanager.fadetransition #:import factory kivy.factory.factory thescreenmanager: shoppingscreen: <shoppingscreen>: name: 'shopping' dropdown: dropdown.__self__ boxlayout: orientation: 'vertical' boxlayout: orientation: 'horizontal' size_hint: 1, .3 button: text: '<' size_hint: .1, 1 font_size: 75 background_normal: "" background_color: 0.18, .5, .92, 1 on_release: app.root.current = 'main' label: text: 'shopping list' halign: 'left' font_size: 50 canvas.before: color: rgb: 0.18, .5, .92 rectangle: pos: self.pos size: self.size widget: size_hint: .1, 1 canvas.before: color: rgb: 0.18, .5, .92 rectangle: pos: self.pos size: self.size boxlayout: orientation: 'horizontal' size_hint: 1, .4 spacing: 50 canvas.before: color: rgb: 0.8, 0.8, 0.8 rectangle: pos: self.pos size: self.size label: text: 'duration' font_size: 30 color: 0.18, .5, .92, 1 button: id: btn text: 'select duration of time...' font_size: 15 on_release: dropdown.open(self) height: '48dp' pos_hint: { 'top' : 0.75} size_hint: .8, .5 dropdown: id: dropdown on_parent: self.dismiss() on_select: btn.text = '{}'.format(args[1]) button: text: '1 week' font_size: 15 size_hint_y: none height: '48dp' on_release: root.addrecipe() button: text: '2 weeks' font_size: 15 size_hint_y: none height: '48dp' #on_release: root.formatscreen(5, 'vegetarian lasagne') button: text: '3 weeks' font_size: 15 size_hint_y: none height: '48dp' #on_release: root.formatscreen(3, 'tomato , linguine') widget: size_hint: .02, 1 boxlayout: canvas.before: color: rgb: 1, 1, 1 rectangle: pos: self.pos size: self.size scrollview: scroll_timeout: 250 scroll_distance: 20 do_scroll_y: true do_scroll_x: false gridlayout: id: grid height: self.minimum_height cols: 1 spacing: 45 padding: 25 size_hint_y: none <recipelabel>: label: text: root.recipename color: (0.18, .5, .92, 1) font_size: 30 canvas.before: color: rgb: 0.18, .5, .92 rectangle: pos: self.pos size: self.size <ingredient>: label: text: root.ingredientname color: (0.18, .5, .92, 1) font_size: 15 label: text: root.quantity color: (0.18, .5, .92, 1) font_size: 15 checkbox: active: true on_active: root.activate_checkbox color: (0.18, .5, .92, 1) <recipe>: label: text: 'ingredient' color: (0.18, .5, .92, 1) font_size: 20 label: text: 'quantity' color: (0.18, .5, .92, 1) font_size: 20 widget: size_hint: .2, 1 ''') class temprecipeapp(app): def build(self): return root_widget if __name__ == "__main__": temprecipeapp().run()
if run code (just copy , paste python file , should work if have kivy installed), select '1 week' dropdown menu load 1 of these 'recipe blocks' i'm trying create, 2 things go wrong. firstly, checkbox not clickable @ all. cannot change state. secondly, label of 'test' label @ top of scrollview should have blue background doesn't show @ all. believe both these issues scrollview/grid can't sure. ideas should do?
Comments
Post a Comment