text: """
  Getting Started with Tkinter
  =============================================================================
  
  from tkinter import *
  window=Tk()
  # add widgets here
  
  window.title('Hello Python')
  window.geometry("300x200+10+20")
  window.mainloop()
  
  """
  
  """
  Button Customization
  =============================================================================
  
  text : caption of the button
  bg : background colour
  fg : foreground colour
  font : font name and size
  image : to be displayed instead of text
  command : function to be called when clicked
  
  
  from tkinter import *
  window=Tk()
  btn=Button(window, text="This is Button widget", fg='blue')
  btn.place(x=80, y=100)
  window.title('Hello Python')
  window.geometry("300x200+10+10")
  window.mainloop()
  
  """
  """
  Label Customization
  =============================================================================
  
  from tkinter import *
  window=Tk()
  lbl=Label(window, text="This is Label widget", fg='red', font=("Helvetica", 16))
  lbl.place(x=60, y=50)
  window.title('Hello Python')
  window.geometry("300x200+10+10")
  window.mainloop()
  
  """
  
  """
  Entry Customization
  =============================================================================
  
  txtfld=Entry(window, text="This is Entry Widget", bg='black',fg='white', bd=5)
  
  from tkinter import *
  window=Tk()
  btn=Button(window, text="This is Button widget", fg='blue')
  btn.place(x=80, y=100)
  lbl=Label(window, text="This is Label widget", fg='red', font=("Helvetica", 16))
  lbl.place(x=60, y=50)
  txtfld=Entry(window, text="This is Entry Widget", bd=5)
  txtfld.place(x=80, y=150)
  window.title('Hello Python')
  window.geometry("300x200+10+10")
  window.mainloop()
  
  """
  
  
  """
  Selection Widgets
  =============================================================================
  
  -> Radiobutton: This widget displays a toggle button having an ON/OFF state. There may be more than one button, but only one of them will be ON at a given time.
  
  -> Checkbutton: This is also a toggle button. A rectangular check box appears before its caption. Its ON state is displayed by the tick mark in the box which disappears when it is clicked to OFF.
  
  -> Combobox: This class is defined in the ttk module of tkinterpackage. It populates drop down data from a collection data type, such as a tuple or a list as values parameter.
  
  -> Listbox: Unlike Combobox, this widget displays the entire collection of string items. The user can select one or multiple items.
  =============================================================================
  
  from tkinter import *
  from tkinter.ttk import Combobox
  window=Tk()
  var = StringVar()
  var.set("one")
  data=("one", "two", "three", "four")
  cb=Combobox(window, values=data)
  cb.place(x=60, y=150)
  
  lb=Listbox(window, height=5, selectmode='multiple')
  for num in data:
      lb.insert(END,num)
  lb.place(x=250, y=150)
  
  v0=IntVar()
  v0.set(1)
  r1=Radiobutton(window, text="male", variable=v0,value=1)
  r2=Radiobutton(window, text="female", variable=v0,value=2)
  r1.place(x=100,y=50)
  r2.place(x=180, y=50)
  
  v1 = IntVar()
  v2 = IntVar()
  C1 = Checkbutton(window, text = "Cricket", variable = v1)
  C2 = Checkbutton(window, text = "Tennis", variable = v2)
  C1.place(x=100, y=100)
  C2.place(x=180, y=100)
  
  window.title('Hello Python')
  window.geometry("400x300+10+10")
  window.mainloop()
  
  """
  
  
  """
  Event Handling
  =============================================================================
  The bind() method associates an event to a callback function so that, when the even occurs, the function is called.
  
  Widget.bind(event, callback)
  
  
  
  Example of Event Binding
  =============================================================================
  
  For example, to invoke the MyButtonClicked() function on left button click, use the following code:
  
  from tkinter import *
  window=Tk()
  btn = Button(window, text='OK')
  btn.bind('<Button-1>', MyButtonClicked)
  
  """
  
  """
  A Simple Addition Subtraction Program
  =============================================================================
  
  from tkinter import *
  class MyWindow:
      def __init__(self, win):
          self.lbl1=Label(win, text='First number')
          self.lbl2=Label(win, text='Second number')
          self.lbl3=Label(win, text='Result')
          self.t1=Entry(bd=3)
          self.t2=Entry()
          self.t3=Entry()
          self.btn1 = Button(win, text='Add')
          self.btn2=Button(win, text='Subtract')
          self.lbl1.place(x=100, y=50)
          self.t1.place(x=200, y=50)
          self.lbl2.place(x=100, y=100)
          self.t2.place(x=200, y=100)
          self.b1=Button(win, text='Add', command=self.add)
          self.b2=Button(win, text='Subtract')
          self.b2.bind('<Button-1>', self.sub)
          self.b1.place(x=100, y=150)
          self.b2.place(x=200, y=150)
          self.lbl3.place(x=100, y=200)
          self.t3.place(x=200, y=200)
      def add(self):
          self.t3.delete(0, 'end')
          num1=int(self.t1.get())
          num2=int(self.t2.get())
          result=num1+num2
          self.t3.insert(END, str(result))
      def sub(self, event):
          self.t3.delete(0, 'end')
          num1=int(self.t1.get())
          num2=int(self.t2.get())
          result=num1-num2
          self.t3.insert(END, str(result))
  
  window=Tk()
  mywin=MyWindow(window)
  window.title('Hello Python')
  window.geometry("400x300+10+10")
  window.mainloop()
  
  """
  
  
  
  
  
  
  
  
  
  from tkinter import *
  class MyWindow:
      def __init__(self, win):
          self.lbl1=Label(win, text='First number')
          self.lbl2=Label(win, text='Second number')
          self.lbl3=Label(win, text='Result')
          self.t1=Entry(bd=3)
          self.t2=Entry()
          self.t3=Entry()
          self.btn1 = Button(win, text='Add')
          self.btn2=Button(win, text='Subtract')
          self.lbl1.place(x=100, y=50)
          self.t1.place(x=200, y=50)
          self.lbl2.place(x=100, y=100)
          self.t2.place(x=200, y=100)
          self.b1=Button(win, text='Add', command=self.add)
          self.b2=Button(win, text='Subtract')
          self.b2.bind('<Button-1>', self.sub)
          self.b1.place(x=100, y=150)
          self.b2.place(x=200, y=150)
          self.lbl3.place(x=100, y=200)
          self.t3.place(x=200, y=200)
      def add(self):
          self.t3.delete(0, 'end')
          num1=int(self.t1.get())
          num2=int(self.t2.get())
          result=num1+num2
          self.t3.insert(END, str(result))
      def sub(self, event):
          self.t3.delete(0, 'end')
          num1=int(self.t1.get())
          num2=int(self.t2.get())
          result=num1-num2
          self.t3.insert(END, str(result))
  
  window=Tk()
  mywin=MyWindow(window)
  window.title('Hello Python')
  window.geometry("400x300+10+10")
  window.mainloop()
  