Tkinter #6: Grid layout and Buttons:
Grid layout and Buttons:
In the tkinter there are three ways to bound the widget in the window.
- Pack
- Grid
- Place
The Grid layout is used to pack the widgets in a row or column likewise. Like in the excel sheets the whole the sheets is divided into row and columns, similarly in tkinter the grid layout is used.
Syntax of Grid:
************
label = Label(text='hello',bg='yellow')
label.grid(row=0,column=0)
label2 = Label(text='hello',bg='yellow')
label2.grid(row=1,column=1)
# in the grid layout all the placement will be done by using grid layout
***********
Attributes in Grid layout
Grid has two attributes only.
Buttons and its Attributes
Buttons are used to make button in Window and hit some target.
Syntax:
******************
a = Button(name of window,text='submit',other attributes)
a.pack() or a.grid()
******************
Other Attributes of Buttons in Tkinter.
·
activebackground: to set the background color
when button is under the cursor.
·
activeforeground: to set the foreground color
when button is under the cursor.
·
bg: to set he normal background color.
·
command: to call a function.
·
font: to set the font on the button label.
·
image: to set the image on the button.
·
width: to set the width of the button.
·
height: to set the height of the
button.
Comments
Post a Comment