Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:14:38+00:00 2026-06-09T05:14:38+00:00

I’ve noticed that when you make buttons using the grid layout in Kivy they

  • 0

I’ve noticed that when you make buttons using the grid layout in Kivy they are created at (0,0) and move over a number of spaces depending on the length and width of previous buttons.
However, I’d like to have a 3×4 grid in the middle of the bottom of the screen.

I have this so far:

import kivy
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.uix.button import Button

class CalcApp(App):
    def build(self):
        layout = GridLayout(cols=3, row_force_default=True, row_default_height=50)
        layout.add_widget(Button(text='1', size_hint_x=None, width=100))
        layout.add_widget(Button(text='2', size_hint_x=None, width=100))
        layout.add_widget(Button(text='3', size_hint_x=None, width=100))
        layout.add_widget(Button(text='4', size_hint_x=None, width=100))
        layout.add_widget(Button(text='5', size_hint_x=None, width=100))
        layout.add_widget(Button(text='2', size_hint_x=None, width=100))
        layout.add_widget(Button(text='6', size_hint_x=None, width=100))
        layout.add_widget(Button(text='7', size_hint_x=None, width=100))
        layout.add_widget(Button(text='8', size_hint_x=None, width=100))
        layout.add_widget(Button(text='9', size_hint_x=None, width=100))
        layout.add_widget(Button(text='0', size_hint_x=None, width=100))
        layout.add_widget(Button(text='Enter', size_hint_x=None, width=100))
        return layout

CalcApp().run()

So, how do I shift the position?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:14:41+00:00Added an answer on June 9, 2026 at 5:14 am
    import kivy
    from kivy.uix.gridlayout import GridLayout
    from kivy.app import App
    from kivy.uix.button import Button
    
    class CalcApp(App):
        def build(self):
            layout = GridLayout(cols=3, row_force_default=True, row_default_height=50,
                pos_hint={'center_x':.5} , size_hint=(None, None))
                # ^ position grid in mid horizontally, ^ make grid use custom
                # size.
            # Bind the size of the gridlayout of to it's minimum_size(calculated
            # by children size)
            layout.bind(minimum_size = layout.setter('size'))
            # bind the top of the grid to it's height'
            layout.bind(height = layout.setter('top'))
            for x in (1, 2, 3, 4, 5, 2, 6, 7, 8, 9, 0):
                layout.add_widget(Button(text=str(x), size_hint_x=None, width=100))
            layout.add_widget(Button(text='Enter', size_hint_x=None, width=100))
            return layout
    
    CalcApp().run()
    

    The same code using kv lang::

    import kivy
    
    from kivy.uix.gridlayout import GridLayout
    from kivy.app import App
    from kivy.lang import Builder
    
    Builder.load_string('''
    # a template Butt of type Button
    [Butt@Button]
        # ctx.'attribute_name' is used to access the 
        # attributes defined in the instance of Butt.
        text: ctx.text
        # below vars are constant for every instance of Butt
        size_hint_x: None
        width: 100
    
    <CalcApp>:
        cols: 3
        row_force_default: True
        row_default_height: 50
        pos_hint: {'center_x':.5}
        size_hint: (None, None)
        # size is updated whenever minimum_size is.
        size: self.minimum_size
        # top is updated whenever height is.
        top: self.height
        Butt:
            text: '1'
        Butt:
            text: '2'
        Butt:
            text: '3'
        Butt:
            text: '4'
        Butt:
            text: '5'
        Butt:
            text: '2'
        Butt:
            text: '6'
        Butt:
            text: '7'
        Butt:
            text: '8'
        Butt:
            text: '9'
        Butt:
            text: '0'
        Butt:
            text: 'Enter'
    ''')
    
    class CalcApp(App, GridLayout):
    
        def build(self):
            return self
    
    CalcApp().run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.