Button In Tkinter

Button – Tkinter In Hindi #5

Python

Button In Tkinter:- Gui App Banane Ke Liye Button Ki Bahut Jarurat Hoti Hain And Aapne Jyada Tar Dekha Hoga Ki Button Har GUI App Ya Desktop Application Jarur Hota Hain. Isliye Aaj Ham Tkinter Button Ke Bare Main Janne Wale Hain |

Tkinter In Hindi

Python Tkinter Ek PowerFul Gui Banane Wala Module Hai Jis se ham GUI Application Bana Sakte Hai Python Tkinter se Bahut Se Bade Bade GUI Application Banaye Gye Hai Or Iski Sabse Acchi Baat Ye Hai Ki Ye Bahut Easy hai Jise Ham Bilkul Aashan Tarike Se Learn Kar Sakte Hai |

Button Create Karne Ke Liye Aapko Sabse Pahle Tkinter Ko Import Karna Hoga |

from tkinter import *
import tkinter as tk
from tkinter import ttk

Upper Diye Gye Code Me Hamne tkinter Ko import kiya hai |Uske Bad Ham Tkinter Python ko Istemal Kar Sakte Hai |

Import Karne Ke Bad Ab Hame object ka name or fir hame tkinter loop ko closed karna hoga |

For Example:-

import tkinter as tk
from tkinter import ttk

win = tk.Tk()

win.mainloop()

Aap Code Ko Dekh Sakte Hai Hamne Sabse Pahle tkinter Ko Import Kiya Or Fir Hamne ek object win Name banaya hai ye hamne isliye banaya hai taki ham bar bar tk.Tk() na likh kar keval win likh sikhe isse ham program aashan ho jata hai | uske bad hamne win.mainloop() ko closed kiya hai iska matlab hai ki jo bhi ham program write karenge to ham iske under hi karenge |

win.mainloop() ka work hota hai ki jab tak mouse se GUI ko closed nhi kiya jaye tab tak ye bar bar chalti rahegi ye ek loop hoti hai |

Output:-

Abhi Tak Jo Hamne Code Likha Hai Usse Keval Ye Gui Application bani hai |

Tkinter Button In Hindi

Ab Ham Tkinter Main Button Create Karte Hain Or Dekhte Hain Ki Button Main Kiya Functionality Hoti Hain.

Syntax :

Aap Niche Diye Gaye Syntax Ko Dekh Kar Program Ko Understand Kar Sakte Hain Ki Button ko Kaise Create Kiya Jata Hain |

#Create Button
Variable_name = Button(window_obj_name , text="Button_name" , bg="background_color")

#Closed Button 

Variable_name.grid(row , column )

Example:-

from tkinter import *
import tkinter as tk
from tkinter import ttk

win = tk.Tk()  

btn = Button(win , text="Button" , bg="red" , fg='yellow')
btn.grid(row=1 , column = 0)


win.mainloop()

Output:

Python Tkinter

Leave a Reply

Your email address will not be published. Required fields are marked *