gui syntax
gui syntax
#syntax
#*********************************
#*********************************
#*********************************
from tkinter import *
root=Tk()
root.title('GUI Demo Window')
root.geometry('300x200') #LxB
label=Label(root,text="Hello",font=("arial","20","italic",'bold'))
label.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(name.get())
def changelabel():
label.config(text=name.get())
def optionselection():
messagebox.showinfo("message","you have selected a "+choice.get())
def listselection():
str1=listbox.curselection()
messagebox.showinfo("Message","you have selected a"+
listbox.get(listbox.curselection()))
#entry
name= tk.StringVar()
text=Entry(window,width =20 , textvariable = name)
text.grid(column = 1, row = 0)
#button
btn=Button(window,text="Click me", bg="orange", command=listselection)
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)
#listbox
listbox=Listbox(window,selectmode=tk.SINGLE)
listbox.grid(row=5,column=1)
listbox.insert(1,"fruits")
listbox.insert(2,"veg")
listbox.insert(3,"cosmetics")
window.mainloop()
#*********************************
'''
#Simple menu
from tkinter import *
top = Tk()
def hello():
print("hello!")
top.mainloop()
'''