I want between button and label to be at minimum 6 rows of grid framework based. I put ttk.Label(mainframe, text="enter url ").grid(column=3, row=1, sticky=('N'))
row is one, and sticky which is North.
If the cell is larger than the widget, the sticky option specifies which side the widget should sticks to and how to distribute any extra space within the cell that is not taken up by the widget at its original size.
And with button button.grid(column=3, row=7, sticky=tk.S)
stiky to South, if there is space, and row start from 7. When you run you see that they are near each other like row =3 in button.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.title("Your App crawler")
mainframe = ttk.Frame(root)
mainframe.grid(column=0, row=0, sticky=('N'))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
feet = tk.StringVar()
feet_entry = ttk.Entry(mainframe, width=21, textvariable=feet)
feet_entry.grid(column=0, row=1, sticky=(tk.N),ipadx=100)
feet_entry.focus()
ttk.Label(mainframe, text="enter url ").grid(column=3, row=1, sticky=('N')) #attention:row is 1
def crawler():
button = ttk.Button(mainframe, text="scrape", command=crawler)
button.grid(column=3, row=7, sticky=tk.S) #even though row is 7, and sticky equals 'S'
root.bind("<Return>", crawler)
for child in mainframe.winfo_children():
child.grid_configure(padx=5, pady=5)
root.mainloop()
Why it is so, and how to change the way I desire? Nice resource for practice enter link description here