Python Forum
[Kivy] Weird spacing in grid layout
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Weird spacing in grid layout
#1
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 :)
Reply
#2
Hi,
Did you managed to fix it?
Reply
#3
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?
Reply
#4
The code is not complete.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Grid layout and QHBox hobbyist 1 3,024 Jan-26-2021, 12:35 AM
Last Post: deanhystad
  pyqt5 layout Nickd12 8 3,401 Jan-18-2021, 09:09 AM
Last Post: Axel_Erfurt
  Spacing Between two labels are very far and Top label is not in Center using Tkinter barry76 2 6,998 Jul-30-2019, 10:49 AM
Last Post: wuf
  Python GUI layout off between different OS shift838 5 3,622 Jan-02-2019, 02:53 AM
Last Post: shift838
  [Tkinter] tkiner spacing on a canvas help Chuy 1 4,199 Jul-21-2018, 08:02 PM
Last Post: Chuy
  [Tkinter] grid layout neech 8 17,493 Oct-14-2016, 07:06 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020