How to add space between two widgets placed in grid in tkinter ~ python?
<p>a. Have placed a widget in the row 0 in the grid as shown below.</p>

<pre><code>self.a_button = Button(root, text="A Button")
self.a_button.grid(row=0, column=1)
</code></pre>

<p>b. And tried placing another widget in row 2 inside the grid.</p>

<pre><code>self.b_button = Button(root, text="B Button")
self.b_button.grid(row=2, column=1)
</code></pre>

<p>But when I run the program, I don't see any space between the widgets, rather its stacked once after the other. </p>

<p>So, how do I program to allow space between two widgets placed in different rows? Share your comments !!</p>

<p>When you pack the widget you can use</p>

<pre><code>self.a_button = Button(root, text="A Button") 
self.a_button.grid(row=0, column=1, padx=10, pady=10)
</code></pre>

<p>Using padx and pady you can add padding to the outer side of the button and alternatively if you want to increase the size of the button you can add inner padding using ipadx and ipady.</p>

<p>If you want more on the Grid function you can view all the options and uses here:
<a href="http://effbot.org/tkinterbook/grid.htm" rel="nofollow">http://effbot.org/tkinterbook/grid.htm</a></p>

python python-2.7 tkinter