tkinter.Tk.geometry


Definition
Define the geometry of widget of the form =widthxheight. 

Syntax
tkinter.Tk.geometry(widthxheight)

Examples
Tk.geometry
The method created the dimension of the Tk Widget.
 
from tkinter import*

master=Tk()
master.geometry("300x300")

master.mainloop()




tkinter.Tk.geometry()
The frame is adjusted in grid().
 from tkinter import*

master=Tk()
master.geometry("400x300")

frame1=Frame(master, width=200, height=150, background="Blue")
frame1.grid(row=0, column=0)

frame2=Frame(master, width=200, height=150, background="Red")
frame2.grid(row=1, column=0)

frame3=Frame(master, width=200, height=150, background="Green")
frame3.grid(row=0, column=1)

frame4=Frame(master, width=200, height=150, background="Yellow")
frame4.grid(row=1, column=1)

master.mainloop()






The URL is opened through tkinter.Button() through its command option.
import webbrowser
from tkinter import*

def url():
    url=webbrowser.open_new("www.pythonlake.com")

master=Tk()
master.geometry("100x200")

button=Button(master, text="pythonlake.com", command=url)
button.pack()

master.mainloop()






The button has positioned in LEFT, RIGHT, TOP, and BOTTOM in the Tk Widget.
import tkinter

master=tkinter.Tk()
master.title("tkinter.LEFT, RIGHT, TOP, BOTTOM")
master.geometry("450x350")

button1=tkinter.Button(master, text="LEFT")
button1.pack(side=tkinter.LEFT)

button2=tkinter.Button(master, text="RIGHT")
button2.pack(side=tkinter.RIGHT)

button3=tkinter.Button(master, text="TOP")
button3.pack(side=tkinter.TOP)

button4=tkinter.Button(master, text="BOTTOM")
button4.pack(side=tkinter.BOTTOM)

master.mainloop()





              


Comments