IIJSD 2 Advanced Python Short Notes
IIJSD 2 Advanced Python Short Notes
4
5) GUI Program to illustrate Canvas 7.GUI Program to create a biodata form Program:
Program: from tkinter import *
from tkinter import * window = Tk() window.title("Canvas") window = Tk()
can = Canvas(window, bg="yellow",height=250, width=300) window.title("Biodata")
line = can.create_line(108, 120,320, 40,fill="green") window.geometry("400x300")
arc = can.create_arc(180, 150, 80,210, lab=Label( window, text="BIODATA",font=('Times', 20))
start=0,extent=220,fill="red") lab.pack()
oval = can.create_oval(80, 30, 140,150,fill="blue") can.pack() lab1=Label(window,text="Name",fg="blue",font=('Times',
window.mainloop() 12))
Output: lab1.place(x=30, y=60)
ent1=Entry(window,fg="red") ent1.place(x=150, y=60)
lab3=Label(window,text="PhoneNo.",fg="blue",font=('Times',
12))
lab3.place(x=30, y=90)
ent3=Entry(window,fg="red")
ent3.place(x=150, y=90)
lab2=Label( window, text="Email",fg="blue",font=('Times',
12))
lab2.place(x=30, y=120)
ent2=Entry(window,fg="red")
ent2.place(x=150, y=120)
6) Program to illustrate Checkbox and Radio button lab1=Label(window,text="Hobbies",fg="blue",height=1,font=
Program: ('Times',12)) lab1.place(x=30,y=150)
from tkinter import * chkvar1 = IntVar()
window = Tk() chkvar2 = IntVar()
window.title("CheckBox and Radio Button") chkvar3 = IntVar()
window.geometry("400x200") chk1 = Checkbutton(window, text='Cricket',variable=chkvar1,
lab1=Label( window, text="Programming Language onvalue=1, offvalue=0)
",fg="blue",height=1) chk1.place(x=150,y=150)
lab1.place(x=20,y=30) chk2 = Checkbutton(window, text='Football',variable=chkvar2,
chkvar1 = IntVar() onvalue=1, offvalue=0)
chkvar2 = IntVar() chk2.place(x=230,y=150)
chkvar3 = IntVar() chk3 = Checkbutton(window, text='Reading',variable=chkvar3,
chk1 = Checkbutton(window, text='Python',variable=chkvar1, onvalue=1, offvalue=0)
onvalue=1, offvalue=0) chk3.place(x=300,y=150)
chk1.place(x=200,y=30) lab2=Label( window, text="Gender",fg="blue",height=1,
chk2 = Checkbutton(window, text='C++',variable=chkvar2, font=('Times',12)) lab2.place(x=30,y=180)
onvalue=1, offvalue=0) radvar = IntVar()
chk2.place(x=280,y=30) rad1 = Radiobutton(window, text="Male", variable=radvar,
chk3 = Checkbutton(window, text='PHP',variable=chkvar3, value=1)
onvalue=1, offvalue=0) rad1.place(x=150,y=180)
chk3.place(x=330,y=30) rad2 = Radiobutton(window, text="Female", variable=radvar,
lab2=Label( window, text="Operating System value=2)
",fg="blue",height=1) rad2.place(x=200,y=180)
lab2.place(x=20,y=70) but1=Button( window, text="SAVE") but1.place(x=150,
radvar = IntVar() y=210)
rad1 = Radiobutton(window, text="Windows", window.mainloop()
variable=radvar, value=1) Output:
rad1.place(x=200,y=70)
rad2 = Radiobutton(window, text="Linux", variable=radvar,
value=2)
rad2.place(x=280,y=70) window.mainloop()
Output: