Reputation: 87
How do I get a gap in between the two buttons, generate and clear?
Upvotes: 0
Views: 7261
Reputation: 15236
If you are only looking to have padding between the 2 buttons you can use pady = (0,5)
in your grid()
manager for your Generate button. If you want to add space between all 3 pady = (5,5)
or pady = 5
.
There are 2 ways you can provide a number/numbers to your padx
or pady
. You can use just a number like pady = 5
and this would do both the top and bottom padding but if you want to specifically pad just one side you can provide a tuple like this pady = (0,5)
and this would just pad the bottom of the widget.
Here is an example:
import tkinter as tk
root = tk.Tk()
tk.Entry(root, width = 25).grid(row=0, column=0)
tk.Button(root, text = "Generate").grid(row=1, column=0, pady = (5,5))
tk.Button(root, text = "clear").grid(row=2, column=0)
root.mainloop()
Results:
And here is an example for just space between the buttons:
import tkinter as tk
root = tk.Tk()
tk.Entry(root, width = 25).grid(row=0, column=0)
tk.Button(root, text = "Generate").grid(row=1, column=0, pady = (0,5))
tk.Button(root, text = "clear").grid(row=2, column=0)
root.mainloop()
Results:
Upvotes: 7