Тёмный

Learn Python tkinter GUI buttons easy 🛎️ 

Bro Code
Подписаться 2,1 млн
Просмотров 76 тыс.
50% 1

You guys don't need all the button.config() calls, you can place them within the constructor if you want. I like to add comments line-by-line for teaching purposes to help explain. Do what works for you.
Python Tkinter GUI button tutorial for beginners
#Python #Tkinter #GUI #button #buttons #tutorial #beginners
button = you click it, then it does stuff
from tkinter import *
count = 0
def click():
global count
count+=1
label.config(text=count)
#label2.pack()
window = Tk()
button = Button(window,text='Click me!!!')
button.config(command=click) #performs call back of function
button.config(font=('Ink Free',50,'bold'))
button.config(bg='#ff6200')
button.config(fg='#fffb1f')
button.config(activebackground='#FF0000')
button.config(activeforeground='#fffb1f')
image = PhotoImage(file='point_emoji.png')
button.config(image=image)
button.config(compound='bottom')
#button.config(state=DISABLED) #disabled button (ACTIVE/DISABLED)
label = Label(window,text=count)
label.config(font=('Monospace',50))
label.pack()
button.pack()
label2 = Label(window,image=image)
window.mainloop()

Опубликовано:

 

9 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 110   
@BroCodez
@BroCodez 4 года назад
# button = you click it, then it does stuff from tkinter import * count = 0 def click(): global count count+=1 label.config(text=count) #label2.pack() window = Tk() button = Button(window,text='Click me!!!') button.config(command=click) #performs call back of function button.config(font=('Ink Free',50,'bold')) button.config(bg='#ff6200') button.config(fg='#fffb1f') button.config(activebackground='#FF0000') button.config(activeforeground='#fffb1f') image = PhotoImage(file='point_emoji.png') button.config(image=image) button.config(compound='bottom') #button.config(state=DISABLED) #disabled button (ACTIVE/DISABLED) label = Label(window,text=count) label.config(font=('Monospace',50)) label.pack() button.pack() label2 = Label(window,image=image) window.mainloop()
@seemakadav7812
@seemakadav7812 3 года назад
Ok
@aeaeaeaeaeaeaeaeaeae7283
@aeaeaeaeaeaeaeaeaeae7283 2 года назад
Hey, can u show me all the packages u use? the function "Label" "Button" and a lot of functions aint working
@yaman09
@yaman09 2 года назад
hey how do i make the window 200,600 and how do i add multipule buttons and position them?
@aserramy_7
@aserramy_7 11 месяцев назад
can you tell me the editor you used in this video
@jstarandomracoon
@jstarandomracoon 9 месяцев назад
hey Bro look what I made import tkinter import tkinter as tk y = "" x = "" def click(): x="I know it""\U0001F923" label.config(text=x) def click1(): y="wrong! you are Gay bro""\U0001F923" label.config(text=y) root = tk.Tk() root.geometry("320x250") root.title("from ayman to U") label= tk.Label(root, text="are you Gay?""\U0001F642", font=("smart", 20)) label.pack() button = tk.Button(root, text="Yes") button.config(command=click) button.config(font=("Ink free",15,"bold")) button.config(bg="#f20587") button.config(activebackground="#ff0000") label = tk.Label(root, text=x) label.config(font=("Ink free",20,"bold")) label.pack() button.pack() button = tk.Button(root, text=" No") button.config(command=click1) button.config(font=("Ink free",15,"bold")) button.config(bg="#302e2f") button.config(activebackground="#34eb3d") label = tk.Label(root, text=y) label.config(font=("Ink free",20,"bold")) label.pack() button.pack() root.mainloop()
@iqpprevail5976
@iqpprevail5976 Год назад
Actually makes sense unlike the other tutorials that don't explain why.. I'm subscribing and liking now.
@billgreen9168
@billgreen9168 Год назад
Cause There Indian?
@FuzzyBlast
@FuzzyBlast 7 месяцев назад
great tutorial! helpful and fun!
@gurmit731
@gurmit731 2 года назад
Helped me a lot. Cheers!
@imihaita8913
@imihaita8913 Год назад
that''s really cool!!!
@SLASH-V0LT
@SLASH-V0LT 16 дней назад
This Was Seriously SUCH A USEFUL TUTORIAL. KEEP IT UP BRO!
@marshallwages5035
@marshallwages5035 2 года назад
Isnt there a way to set the color of the button when the other parameters are being filled out? Like: button(root, text=" " , bg= 'red' ) ?
@adnerremy2650
@adnerremy2650 2 года назад
Your video is very well explained. If I add a fews entries, then a value to each of them. How can I get each of the values and add them up? Here are the codes. Thanks from tkinter import * root=Tk() somme=0 def add_button(): global somme somme +=1 for i in range(somme): lab1=Label(root, text='lab1') lab1.grid(row=i, column=1) entry1=Entry(root) entry1.grid(row=i, column=2) bouton_add=Button(root, text='Create widget', command=add_button ) bouton_add.grid(row=5, column=0) root.mainloop()
@Supyisiscool
@Supyisiscool Месяц назад
Finally learned to use buttons, nice
@Naninigaw
@Naninigaw Месяц назад
oh thank you very much I will subscribe🎉
@moo_HU
@moo_HU 21 день назад
It was awesome, thnak you. btw, i tried, that the button.config arguments can write in one command, separate them with comma, like in your label video.
@BronzeBagel
@BronzeBagel 4 года назад
The professionalism is surprising, but welcome.
@narekeskandarian6404
@narekeskandarian6404 Год назад
He deserves the profile picture
@amegomusictv6535
@amegomusictv6535 3 месяца назад
Thanks to your tutorial I learned something logic
@mohamedselim6547
@mohamedselim6547 3 года назад
brief, to the point ... super keep it up
@Sheharyar69420
@Sheharyar69420 Месяц назад
Wow!
@BobNeverStop
@BobNeverStop 2 года назад
Thanks i learnt more commands!
@EquaTechnologies
@EquaTechnologies 2 года назад
*_Amazing video! I already am saying that before the tutorial began!_* 😀👍
@zed2000mc
@zed2000mc 2 года назад
lol then watch the tutorial youll like it more
@EquaTechnologies
@EquaTechnologies 2 года назад
@@zed2000mc Okay, but I don't want now.
@dumbaigd3863
@dumbaigd3863 3 года назад
print("cool vid")
@s.mohammedjunaith6152
@s.mohammedjunaith6152 2 года назад
And sooo good at teaching I can understand it very fast 😊😊😊
@SharpObject1990
@SharpObject1990 2 года назад
Nice concise guide. Simple.
@s.mohammedjunaith6152
@s.mohammedjunaith6152 2 года назад
Another one is amazing in the discription Thanks for easy writing of code 😃😃😃😃😃
@user-ev4xy4bi3s
@user-ev4xy4bi3s Год назад
relly helpful
@kleinerdiamant-bs
@kleinerdiamant-bs 2 года назад
10:40 OMG YOU ARE THE BEST. NEVER FOUND THIS ANYWHERE. Thank you so much. Like and sub!😱😱😱
@Lav_jeswani
@Lav_jeswani Год назад
Love this guy...😂
@TheFlashKageUzumaki
@TheFlashKageUzumaki 23 дня назад
could u explain how to make the button bigger or change its postion
@laniakea3487
@laniakea3487 Год назад
Gaw damn this was so much helpful, I’ve been looking for how to understand these buttons and labels n how to change the color too and you helped me a lot, thank you
@anokhautomation4453
@anokhautomation4453 3 года назад
Amazing. 🎉🎉🎉
@SLASH-V0LT
@SLASH-V0LT 16 дней назад
I'm Still New To tkinter So Can You Please Explain .pack()
@hadiaal-amine3244
@hadiaal-amine3244 2 года назад
Great video. Thank you for writing the code in the comment. It is very helpful
@nandikajayampathi3426
@nandikajayampathi3426 2 года назад
you are so good to teach :) thank you very much
@Zeroonezero527
@Zeroonezero527 2 года назад
thank you a lot a lot a lot
@nokta1190
@nokta1190 3 года назад
thank you 😊
@Ayushsharma-ly3wt
@Ayushsharma-ly3wt 9 месяцев назад
I want you to make a video about how to change button text also when clicked
@GalacticMurals
@GalacticMurals 10 месяцев назад
👍
@chimp6532
@chimp6532 2 года назад
This was so helpful thnxs
@vash0158
@vash0158 2 года назад
Thanks
@furyaj
@furyaj 2 года назад
very good video ty !
@redeye987
@redeye987 3 года назад
Thank you helped me a lot
@mohamedsalman6558
@mohamedsalman6558 2 года назад
think you
@catanja6891
@catanja6891 2 года назад
I dont want the counter. Can u show me how to put the text in the same window as the button when u press it?
@eyoel9141
@eyoel9141 2 года назад
bro i am havinf problem named.... Tk() is not defined plz help me dude
@guyon6
@guyon6 2 года назад
hi, I have a question, what program r u using? Great video btw, rlly helped
@guyon6
@guyon6 2 года назад
is it tkinter?
@guyon6
@guyon6 2 года назад
Nevermind, it's called Pycham, thanks for the video!
@jogusudhakar8421
@jogusudhakar8421 2 года назад
Thanks man that's awesome
@randomdude7386
@randomdude7386 3 года назад
Okay, but assuming I don't want a counter, but to switch with every button press between arrays of informations from a database that would be displayed on screen through the label, what would that be possible?
@NotSoz.
@NotSoz. 7 месяцев назад
i'm having trouble trying to run the code at 2:19. i try typing a tilde after "button.config(command=click)", but it gives me an error message. is there a solution to this?
@WildSpade
@WildSpade Год назад
I COMMECNTED OMG
@Bentleyloesch
@Bentleyloesch 8 месяцев назад
Would this be reasonable for creating a DAW?
@khitprod
@khitprod 2 года назад
Made beautiful angry chicken button
@emryscass7327
@emryscass7327 2 года назад
I have AttributeError when running button.config - The difference is I'm not using pack() because I'm setting up a TicTacToe game so I'm using grid. When I click the button, I'm calling a function that is supposed to update the text on the button.
@user-gz3eq7oi9y
@user-gz3eq7oi9y 3 года назад
does anyone know how to make it so that when the button is holded it calles the same function as the command one you wrote
@s.mohammedjunaith6152
@s.mohammedjunaith6152 2 года назад
Amazing but how to change the postion and size of the button and lable Also borders
@theclasherplays7265
@theclasherplays7265 2 года назад
Great video , thanks for the code i understood it so now i can make an app
@Motivational_but_smarter
@Motivational_but_smarter 2 года назад
Only on buttons?
@By.0ne__pala
@By.0ne__pala Год назад
I have a question if we are on android(Acode) do this will work
@he4-f2e
@he4-f2e 3 года назад
thank you bro🙏
@knownrobloxian3381
@knownrobloxian3381 2 года назад
What are you coding that on?
@imihaita8913
@imihaita8913 Год назад
😆😆😆😍🥰😇
@s.mohammedjunaith6152
@s.mohammedjunaith6152 2 года назад
One more question which module in python is best Sorry for soo many comments
@unkangkr
@unkangkr 2 года назад
Which extension pack should I download?
@toastvernascher4533
@toastvernascher4533 Год назад
for some reason only the folder the python file was in just opened and nothing else happened. can someone help me?
@abhishekchikane6451
@abhishekchikane6451 2 года назад
bro can you make file upload button with basic ui for a proper idea (Not for html)?
@sangeetharana4435
@sangeetharana4435 2 года назад
Noice thanks for the code
@salehninjax5583
@salehninjax5583 2 года назад
i just want to help you that is why a commented
@IceDragonBoy3
@IceDragonBoy3 2 года назад
Why do I get error window = Tk() NameError: name "Tk" is not defined :(
@Wallancey123
@Wallancey123 Год назад
Hi
@somyaranjanpatra4330
@somyaranjanpatra4330 3 года назад
Wows fantastic🤘😝🤘 code ya..
@hash261k
@hash261k Год назад
Bro help me how to import an image with a phone please i beg of you
@a_star_official_
@a_star_official_ Год назад
is this on virtual code studio
@toamna_7323
@toamna_7323 2 года назад
i don't understand,, how can i download this version of python??
@anubhav4830
@anubhav4830 4 года назад
Hey, I want to make a button . whose state =DISABLED , but when I enter something in textbox that button got enabled. from tkinter import * fenster = Tk() fenster.title("Window") def switch(): if b1["state"] == "normal": b1["state"] = "disabled" b2["text"] = "enable" else: b1["state"] = "normal" b2["text"] = "disable" #--Buttons b1 = Button(fenster, text="Button", height=5, width=7) b1.grid(row=0, column=0) b2 = Button(text="disable", command=switch) b2.grid(row=0, column=1) #copy the upper cody from stackflow and it's working but when i am going for same process in my project I am getting error on trace_add. Even I am not getting the code properly. Please reply
@BroCodez
@BroCodez 4 года назад
Do you have the textbox part of the code?
@anubhav4830
@anubhav4830 4 года назад
yes, the code I have provided you is perfect example how I want my button to work. You can copy and run it for better visualization. I didn't understand the code properly, so it will be helpful either you help me to understand the code or you can post any (video or code) in simple manner.
@BroCodez
@BroCodez 4 года назад
ok. that sounds difficult to do but I will research and see what I can find.
@thecodeitworks5874
@thecodeitworks5874 4 года назад
he can you get me a download link to the image please
@BroCodez
@BroCodez 4 года назад
There isn't a download link for this. I used photoshop to increase the size of standard emojis ad saved as a .png : 👆
@thecodeitworks5874
@thecodeitworks5874 4 года назад
@@BroCodez ok thanks
@ryce_jnes
@ryce_jnes 4 года назад
first to watch
@BroCodez
@BroCodez 4 года назад
Here ya go:🥇
@ryce_jnes
@ryce_jnes 4 года назад
can we be friends and share code when need
@dreadcannibal3395
@dreadcannibal3395 2 года назад
the image doesn't work for me
@MREditz170
@MREditz170 2 года назад
image directory is not found error pls help
@bartekgrechuta7691
@bartekgrechuta7691 Год назад
hello
@tecaiii
@tecaiii 3 года назад
how do you make it so when you click the button once, it plays a sound?
@haha_urfunny8211
@haha_urfunny8211 3 года назад
I was wondering the same thing
@guyincognito5614
@guyincognito5614 3 года назад
heres my comment
@randmusername68
@randmusername68 Год назад
from tkinter import * window = Tk() window.title("Error Generator") window.geometry("1000x1000") window.resizable(False, False) def click(): window=Tk() window.title("Error!") button=Button(window,text="GenerateError") button.config(command=click) button.pack() window.mainloop().
@sonatapiece
@sonatapiece 17 дней назад
i updated the error a bit from tkinter import * window = Tk() window.title("Error Generator") window.geometry("1000x1000") window.resizable(False, False) def click(): error_window = Toplevel(window) # Use Toplevel for creating a new window error_window.title("Error!") # Create a label with the critical message message_label = Label(error_window, text='Something critical happened! Fix it now!', bg='#FF0000', fg='#FFFFFF', font=('Arial', 12, 'bold')) message_label.grid(row=0, column=0, columnspan=3, padx=10, pady=10) # Create buttons button = Button(error_window, text='Fix', bg='#00FF00', fg='#000000', activebackground='#00FF00', activeforeground='#000000') button2 = Button(error_window, text='Do not fix', bg='#FF0000', fg='#000000', activebackground='#FF0000', activeforeground='#000000') # Grid buttons below the message label button.grid(row=1, column=0, padx=5, pady=5) button2.grid(row=1, column=1, padx=5, pady=5) button = Button(window, text="Generate Error", command=click) button.pack(pady=20) window.mainloop()
@KrewFams
@KrewFams 2 года назад
The back ground doesn't work
@prycereviews5690
@prycereviews5690 2 года назад
the count doesn't work for me nevermind
@damianplays4209
@damianplays4209 3 года назад
font dosn't work
@joshuahuang195
@joshuahuang195 Год назад
How do I do two commands at the same time?
@joshuahuang195
@joshuahuang195 Год назад
no, you can't do it
@joshuahuang195
@joshuahuang195 Год назад
?
@joshuahuang195
@joshuahuang195 Год назад
?
@joshuahuang195
@joshuahuang195 Год назад
why?
@joshuahuang195
@joshuahuang195 Год назад
because you can't do it
Далее
Learn Python tkinter GUI user input easy ⌨️
12:37
PyGame Beginner Tutorial in Python - Adding Buttons
18:55
Introducing iPhone 16 | Apple
02:00
Просмотров 2,9 млн
Learn Python tkinter GUI radiobuttons easy 🔘
12:22
Python tkinter setup a basic GUI 🐍
8:07
Просмотров 71 тыс.
Let's code a SNAKE GAME in python! 🐍
33:06
Просмотров 612 тыс.
Why You Shouldn't Nest Your Code
8:30
Просмотров 2,7 млн
Learn Python tkinter GUI scales easy 🌡️
10:20
Просмотров 13 тыс.
Electromagnetic Aircraft Launcher
15:09
Просмотров 1,1 млн
Modern Graphical User Interfaces in Python
11:12
Просмотров 1,5 млн