import sqlite3 as lite
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
Window.size = (600, 325)
class UserGroup(Screen):
pass
class FactUserGroup(App):
def build(self):
self.root = Builder.load_file('test.kv')
return self.root
if __name__ == '__main__':
FactUserGroup().run()
<CustomLabel@Label>:
text_size: self.size
valign: "middle"
padding_x: 5
<SingleLineTextInput@TextInput>:
multiline: False
<GreenButton@Button>:
background_color: 1, 1, 1, 1
size_hint_y: None
height: self.parent.height * 0.120
UserGroup
GridLayout:
cols: 2
padding : 30,30
spacing: 20, 20
row_default_height: '30dp'
Label:
text: 'Male'
text_size: self.size
valign: 'middle'
CheckBox:
group: 'check'
id : chk
Label:
text: 'Female'
text_size: self.size
valign: 'middle'
CheckBox:
group: 'check'
CustomLabel:
text: 'age'
text_size: self.size
valign: 'middle'
SingleLineTextInput:
id: age
GreenButton:
text: 'Ok'
GreenButton:
text: 'Cancel'
on_press: app.stop()
How to set male,female in one row in same GridLayout.If i use two gridlaout first set cols: 4 and second set cols: 2 and show in pop up then it gives error "Popup can have only one widget as content".So how to set in one GridLayout with first row with 4 cols and second row 2 cols.
You cannot do that with gridlayout alone.
You could make a gridlayout with two columns, and put horizontal boxlayouts in the grid you need to split.
Or you could use stacklayout. stacklayout
I would just use two gridlayouts inside a vertical boxlayout.
You simply put both gridlayouts in a boxlayout. So the Popup will contain the boxlayout, and won't complain about multiple widgets.
MyBoxLayout:
orientation: "vertical"
GridLayout1:
cols: 2
GridLayout2:
cols: 4
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments