Python Forum

Full Version: Weird spacing in grid layout
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I am trying to make a form using kivy. Here is what i tried.
class MyMainApp(App):
	def build(self):
		x = 0.3
		x1 = 0.6
		y = 40
		lab0 =		custLabel(text='Date: ')
		datee =		DatePicker(size_hint=(x1, None), height=y)
		lab1 = 		custLabel(text='Patient ID: ')
		ID = 		custTextInput()
		lab2 = 		custLabel(text='Name: ')
		namee = 	custTextInput()
		lab3 = 		custLabel(text='Age: ')
		Age =		custTextInput()
		lab4 = 		custLabel(text='Informant: ')
		informant = custTextInput()
		spin =		Spinner(text='Parent', size_hint=(x, None), height=y, values=['Parent', 'Grand parent', 'Spouse', 'Neighbour', 'Friend', 'Other relative'])


		#informant relation and name
		box = BoxLayout(orientation='horizontal', size_hint=(1,0.8))
		box.add_widget(informant)
		box.add_widget(spin)

		gl = GridLayout(cols=2, size_hint=(0.9,0.8))
		gl.add_widget(lab0)
		gl.add_widget(datee)
		gl.add_widget(lab1)
		gl.add_widget(ID)
		gl.add_widget(lab2)
		gl.add_widget(namee)
		gl.add_widget(lab3)
		gl.add_widget(Age)
		gl.add_widget(lab4)
		gl.add_widget(box)

		return gl
But, when i run it, i am getting a space between the last two rows for some reason.
https://drive.google.com/open?id=1mx288A...O_paK8HXW1

Can someone please tell me how i can get rid of it?
Also, can i put this grid layout in a tabbed panel? (I tried to by doing this)
tp = TabbedPanel()
tp.content = gl
return tp
But it isnt showing any widgets inside.
Please advice :)
Hi,
Did you managed to fix it?
I do not use Kivy but when using the QGridLayout of Qt you need to supply the coordinates for the Widget you are adding .addWidget(self.MyWidget, row, col) but perhaps that is not the case with Kivy but if not how do you tell the Grid where to put the object you are adding?
The code is not complete.