changing position of only one column in gridlayout

62 views
Skip to first unread message

Gaurav Bhoi

unread,
Mar 31, 2021, 1:25:03 PM3/31/21
to Kivy users support
Hello guys i m creating a scrollable form using gridlayout where row_force_default is True and row_default_height is 30 but  i want to change the height of a perticular column and widget in that column is textinput. I tried changing its size_hint_y to None and height to 300 but it overlaps other widgets. i m pasting some images for better understanding

This my kv code:
<Label@Label> :
color: (1, 0, 0, 1)
font_size: 20
halign: 'left'
valign: 'middle'
text_size: self.width, None
height: self.height

<TextInput@TextInput> :
background_color: (3, 3, 3, 1)

FloatLayout:
ScrollView:
id: scr
size_hint: .3, .8
pos_hint: {'right':.5, 'center_y': .5}

canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'white_background.jpg'

GridLayout:
size_hint: (None, None)
cols: 1
height: self.minimum_height
row_force_default: True
row_default_height: 50
width: self.parent.width
padding: 10

Label:
text: 'Address'

TextInput:
hint_text: 'Enter Your permanent address'
size_hint_y: None
height: 300
Main 31-03-2021 22_52_13.png
Main 31-03-2021 22_50_04.png

Elliot Garbus

unread,
Apr 1, 2021, 2:48:36 PM4/1/21
to kivy-...@googlegroups.com

I suggest using a vertical BoxLayout, rather than a GridLayout.  Do not set the default height.

 

If you would like more help, please attach a minimal executable example.  Also note the code below is not properly formatted.  I have found that if you right click on the web-set and select “paste as plain-text” the formatting is preserved.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d4760ffa-0443-401c-8616-203563492470n%40googlegroups.com.

 

Main 31-03-2021 22_52_13.png
Main 31-03-2021 22_50_04.png

Gaurav Bhoi

unread,
Apr 1, 2021, 6:06:58 PM4/1/21
to kivy-...@googlegroups.com
Thank you Elliot, But I don't Know how to execute this code using Boxlayout so I'm using gridlayout. If you show me how to obtain the same result using boxlayout that would be great. I'm attaching code files below. In the code I'm aiming to increase the height of address textinput only.  I also have one more problem in the same code, see when i press the "screen2" button i want to change the screen but not the whole screen but only the red portion. That means I want to treat the red portion as a screen. please help. Thank You

You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/_LVtU-fAy9I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6066157f.1c69fb81.a4479.078fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
test 2.py
test2.kv

Elliot Garbus

unread,
Apr 1, 2021, 7:08:58 PM4/1/21
to kivy-...@googlegroups.com

Give this a try

 

FloatLayout:
   
BoxLayout:
       
orientation: 'vertical'
       
size_hint: .3, .8
       
pos_hint: {'right':.5, 'center_y': .5}

       
BoxLayout:
           
size_hint_y: .08
           
Button:
               
text: 'Screen1'
               
on_release: app.root.ids.sm.current = 'input screen'
           
Button:
               
text: 'Screen2'
               
on_release: app.root.ids.sm.current = 'other screen'

       
ScreenManager:
           
id: sm
            InputScreen:
                name:
'input screen'
           
OtherScreen:
                name:
'other screen'

<InputScreen@Screen>:
   
ScrollView:
       
canvas.before:
           
Color:
               
rgba: (1, 0, 0, .5)
           
Rectangle:
               
pos: self.pos
               size
: self.size
        do_scroll_x
: False
       
do_scroll_y: True
       
BoxLayout:
           
orientation: 'vertical'
           
size_hint: None, None
           
height: self.minimum_height
           
width: self.parent.width
            padding
: 10

           
Label:
               
text: 'Name'
               
size_hint_y: None
               
height: 40

           
TextInput:
                hint_text:
'Name as per marksheet'
               
size_hint_y: None
               
height: 40

           
Label:
               
text: 'Address'
               
size_hint_y: None
               
height: 40

           
TextInput:
                hint_text:
'Enter your permanent address'
               
size_hint_y: None
               
height: 300

<OtherScreen@Screen>:
   
Label:
       
text: 'The Other Screen'


test2.zip

Gaurav Bhoi

unread,
Apr 2, 2021, 8:54:14 AM4/2/21
to kivy-...@googlegroups.com
Thank you Elliot, It Works. Thanks Alot

Reply all
Reply to author
Forward
0 new messages