Tkinter Frame, Label & Menubutton

 


Tkinter Frame

Sintax :

w = Frame(parent,  options)


Contoh :

from tkinter import *  

top = Tk()  

top.geometry("140x100")  

frame = Frame(top)  

frame.pack()  

leftframe = Frame(top)  

leftframe.pack(side = LEFT)  

rightframe = Frame(top)  

rightframe.pack(side = RIGHT)  

btn1 = Button(frame, text="Submit", fg="red",activebackground = "red")  

btn1.pack(side = LEFT)  

btn2 = Button(frame, text="Remove", fg="brown", activebackground = "brown")  

btn2.pack(side = RIGHT)  

btn3 = Button(rightframe, text="Add", fg="blue", activebackground = "blue")  

btn3.pack(side = LEFT)  

btn4 = Button(leftframe, text="Modify", fg="black", activebackground = "white")  

btn4.pack(side = RIGHT)  

top.mainloop()  



Tkinter Label

Sintax :

w = Label (master, options)


Contoh :

# !/usr/bin/python3  

from tkinter import *  

top = Tk()  

top.geometry("400x250")  

#creating label  

uname = Label(top, text = "Username").place(x = 30,y = 50)  

#creating label  

password = Label(top, text = "Password").place(x = 30, y = 90)  

sbmitbtn = Button(top, text = "Submit",activebackground = "pink", activeforeground = "blue").place(x = 30, y = 120)  

e1 = Entry(top,width = 20).place(x = 100, y = 50)  

e2 = Entry(top, width = 20).place(x = 100, y = 90)  

top.mainloop()  



Tkinter Menubutton

Sintax :

w = Menubutton(Top, options)


Contoh :

# !/usr/bin/python3  

from tkinter import *  

top = Tk()  

top.geometry("200x250")  

menubutton = Menubutton(top, text = "Language", relief = FLAT)  

menubutton.grid()  

menubutton.menu = Menu(menubutton)  

menubutton["menu"]=menubutton.menu  

menubutton.menu.add_checkbutton(label = "Hindi", variable=IntVar())  

menubutton.menu.add_checkbutton(label = "English", variable = IntVar())  

menubutton.pack()  

top.mainloop()