0% found this document useful (0 votes)
3 views4 pages

gui syntax-1

Uploaded by

nobita.vahith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

gui syntax-1

Uploaded by

nobita.vahith
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#syntax

# GUI --- GRAPHICAL USER INTERFACE


# tkinter
# pyqt
# kivy
'''
from tkinter import *

R=Tk()

#R.mainloop()

#*********************************
from tkinter import *
root=Tk()
root.title('Python Demo window')
root.geometry('1000x600') #LxH
root.maxsize(width = 1000,height =1100)
root.minsize(width = 500,height = 100)
root.configure(background="#36BA98")# hex code r g b

#root.mainloop()

#*********************************

from tkinter import *


root=Tk()
root.title('GUI Demo Window')
root.geometry('300x200') #LxB

lbl=Label(root,text="username")
lbl.place(x=100,y=100)
#lbl.pack()
#lbl.grid(row=2,column=5)
#root.mainloop()

#pack = place the text automatically center


#place = place the text in given position

#*********************************
from tkinter import *

root=Tk()
root.title('GUI Demo Window')
root.geometry('500x500') #LxB
root.maxsize(width = 750,height = 500)
root.minsize(width = 500,height = 350)
root.configure(bg="#F0FF42")
label=Label(root,text="username",font=("times","16","bold"),foreground='red',bg='#F
FDDD2')
label.place(x=10,y=50)
user=Entry(root,width=20,justify='left')
user.place(x=155,y=55)
root.mainloop()
#pack = place the text automatically center
#place = place the text in given position
#*********************************
from tkinter import *
root=Tk()
root.title('GUI Demo Window')
root.geometry('900x900') #LxB
label=Label(root,text="Hello",font=("calibri","16","bold"),

bg="#22a6b3",fg='#eb4d4b',relief='solid')
label.pack()

bt=Button(root,text="click1",font=('cartier',"16",'bold'),bg='red',fg='cyan'
,relief='sunken')
bt.pack()

bt1=Button(root,text="click2",font=('castellar',"28",'bold'),
bg='#6ab04c',fg='#30336b',relief='ridge')
bt1.pack()

bt2=Button(root,text="click3",font=('chiller',"28",'bold'),bg='red',fg='cyan',
relief='groove')
bt2.pack()
bt3=Button(root,text="click4",font=('fixedsys',"28",'bold'),bg='red',fg='cyan',
relief='raised',bd=10)
bt3.pack()

root.mainloop()

#*********************************
'''
#my gui
from tkinter import *
import tkinter as tk
from tkinter import messagebox
window=Tk()
window.title("Text Box example")
window.geometry("300x400")

#label
label=Label(window,text="Name:",font=("arial",20),fg="black",bg="pink")
label.grid(column = 0, row = 0)

def click():
messagebox.showinfo('information',text.get())
#changelabel()
def changelabel():
label.config(text=text.get())

def optionselection():
messagebox.showinfo("message","you have selected a "+choice.get())

def listselection(event):
str1=listbox.curselection()
messagebox.showinfo("Message","you have selected a "+listbox.get(str1))
#name= tk.StringVar()
text=Entry(window,width =20 )
text.grid(column = 1, row = 0)
#button
btn=Button(window,text="Click me", bg="orange", command=click)
btn.grid(row = 1, column = 1)

#radio button
choice=tk.StringVar()

rd1=Radiobutton(window,text="Fruits", variable=choice,
value="fruits",command=optionselection)
rd1.grid(row=2,column=0)
rd2=Radiobutton(window,text="Vegetables", var=choice,
value="vegetable",command=optionselection)
rd2.grid(row=3,column=0)
rd3=Radiobutton(window,text="Cosmetics", var=choice,
value="Cosmetics",command=optionselection)
rd3.grid(row=4,column=0)

#listbox
listbox=Listbox(window,selectmode=SINGLE)
listbox.grid(row=5,column=1)
listbox.insert(1,"veg")
listbox.insert(2,"fruits")
listbox.insert(3,"HELLO")
listbox.insert(4,"cosmetics")

listbox.bind("<<ListboxSelect>>",listselection)

window.mainloop()
'''
#*********************************
#Simple menu
from tkinter import *
top = Tk()
top.geometry('500x500') #LxB

def hello():
print("hello!")

def quitt():
print('Bye....')
def but():
print('How are you?')
# create a toplevel menu
menubar = Menu(top )
menubar.add_command(label="Hello!", command=hello)
menubar.add_command(label="Quit!", command=quitt)

bt=Button(top,text="Hi",font=('cartier',"28",'bold'),bg='red',fg='cyan',
command=but)
bt.place(x=235,y=235)

# display the menu


top.configure(bg="red",menu=menubar)
top.mainloop()

#*********************************
from tkinter import *
root = Tk()
root.geometry('500x500') #WxB
root.title('Example')
def hi():
label=Label(root,text="Gud Mrng...",font=("arial",20),fg="black",bg="pink")
label.pack()
def bye():
# a=Tk()
#a.geometry('500x500')
frm =Frame(root,bg='red',width=1400,height=800)
#frm.configure()
frm.place(x=0,y=0)
l=Label(frm,text="Bye...",font=("arial",20),fg="black",bg="pink")
l.place(x=10,y=10)

bt1=Button(root,text="Hi",font=('castellar',"28",'bold'),
bg='#6ab04c',fg='#30336b',relief='ridge',command=hi)
bt1.pack()

bt2=Button(root,text="Bye",command=bye)
bt2.pack()
root.mainloop()

from tkinter import *


root = Tk()
root.geometry('500x500') #LxB
root.title('Example')
s=StringVar()
en=Entry(root,width=35,textvariable=s)#"4566779gfhjk"
en.pack()
def arivu():
#print(3456)
#print(en.get())
print(s.get())
bt2=Button(root,text="Bye",font=('castellar',"28",'bold'),
bg='#6ab04c',fg='#30336b',relief='ridge',command=arivu)
bt2.pack()
root.mainloop()
'''

You might also like