So first I'm assuming I may need to create a separate kv file; however, I'm pretty sure this may do just fine with a py file.
Essentially, I'm trying to create where each column contains pulls a list of from a text file in the label (Checkbox test 1) and checkboxes next to each item. Once all checkboxes are checked, a button will appear to complete and exports the list to a text file and start over. I'm pretty beginnerish with this and I'm sure I'm missing a lot such as a loop and perhaps the kv file and maybe a bit more.
from kivy.uix.checkbox import CheckBox
# Graphics related
from kivy.graphics import InstructionGroup
from kivy.graphics import Color
from kivy.graphics import Rectangle
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window
#read text file here first?
class UserInterface(GridLayout):
def __init__(self, **kwargs):
super(UserInterface, self).__init__(**kwargs)
# Add labels and checkbox
self.rows = 3
self.cols = 3
self.add_widget(Label(text='Checkbox Test 1'))
self.cb_roateMode = CheckBox(active=True)
self.add_widget(self.cb_roateMode)
self.lbl_roateMode = Label(text='Checkbox 1 Sync Test')
self.add_widget(self.lbl_roateMode)
self.add_widget(Label(text='Checkbox Test 1'))
self.cb_roateMode = CheckBox(active=True)
self.add_widget(self.cb_roateMode)
self.lbl_roateMode = Label(text='Checkbox 1 Sync Test')
self.add_widget(self.lbl_roateMode)
self.add_widget(Label(text='Checkbox Test 1'))
self.cb_roateMode = CheckBox(active=True)
self.add_widget(self.cb_roateMode)
self.lbl_roateMode = Label(text='Checkbox 1 Sync Test')
self.add_widget(self.lbl_roateMode)
# Change the color of the background to grey
blue = InstructionGroup()
blue.add(Color(1, 1, 1, .3))
blue.add(Rectangle(pos=self.pos, size=(Window.width, Window.height)))
self.canvas.add(blue)
#callback
self.cb_roateMode.bind(active=self.on_roateMode_Active)
# Callback for the checkbox
def on_roateMode_Active(self, checkboxInstance, isActive):
if isActive:
self.lbl_roateMode.text = "Checkbox 1 Checks! Create Button"
else:
self.lbl_roateMode.text = "Checkbox 1 Unchecks! No Button"
#Button Here?
class CheckBoxApp(App):
def build(self):
ux = UserInterface()
return ux
# Run the app
if __name__ == '__main__':
CheckBoxApp().run()
Something like this; however, the layout I'm confident I can do just the functionality is where I'm struggling
Small List:
Bread
Meat
Lettuce
Mayo
Aucun commentaire:
Enregistrer un commentaire