Learn Python tkinter GUI buttons easy 🛎️

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 111

  • @BroCodez
    @BroCodez  4 года назад +35

    # 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 Год назад

      can you tell me the editor you used in this video

    • @jstarandomracoon
      @jstarandomracoon 10 месяцев назад

      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 2 года назад +5

    Actually makes sense unlike the other tutorials that don't explain why..
    I'm subscribing and liking now.

  • @ServerInFrench
    @ServerInFrench 2 месяца назад

    This Was Seriously SUCH A USEFUL TUTORIAL. KEEP IT UP BRO!

  • @gurmit731
    @gurmit731 2 года назад +2

    Helped me a lot. Cheers!

  • @adnerremy2650
    @adnerremy2650 2 года назад +1

    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()

  • @marshallwages5035
    @marshallwages5035 2 года назад +6

    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' ) ?

  • @FuzzyBlast
    @FuzzyBlast 8 месяцев назад +1

    great tutorial! helpful and fun!

  • @Naninigaw
    @Naninigaw 2 месяца назад +1

    oh thank you very much I will subscribe🎉

  • @moo_HU
    @moo_HU 2 месяца назад

    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 года назад +3

    The professionalism is surprising, but welcome.

  • @imihaita8913
    @imihaita8913 Год назад +1

    that''s really cool!!!

  • @Supyisiscool
    @Supyisiscool 3 месяца назад

    Finally learned to use buttons, nice

  • @laniakea3487
    @laniakea3487 Год назад +4

    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

  • @EquaTechnologies
    @EquaTechnologies 2 года назад +1

    *_Amazing video! I already am saying that before the tutorial began!_* 😀👍

    • @zed2000mc
      @zed2000mc 2 года назад +1

      lol then watch the tutorial youll like it more

    • @EquaTechnologies
      @EquaTechnologies 2 года назад

      @@zed2000mc Okay, but I don't want now.

  • @mohamedselim6547
    @mohamedselim6547 3 года назад +1

    brief, to the point ... super
    keep it up

  • @BobNeverStop
    @BobNeverStop 2 года назад

    Thanks i learnt more commands!

  • @s.mohammedjunaith6152
    @s.mohammedjunaith6152 2 года назад

    And sooo good at teaching
    I can understand it very fast 😊😊😊

  • @amegomusictv6535
    @amegomusictv6535 4 месяца назад

    Thanks to your tutorial I learned something logic

  • @s.mohammedjunaith6152
    @s.mohammedjunaith6152 2 года назад

    Another one is amazing in the discription
    Thanks for easy writing of code
    😃😃😃😃😃

  • @SharpObject1990
    @SharpObject1990 2 года назад

    Nice concise guide. Simple.

  • @Xyz_xyz712
    @Xyz_xyz712 Месяц назад

    The code I’m being told to use is tk.Button(text=“Click me!”, width=25,height=5, bg=“blue” , fg=“yellow” I type it exactly as my assignment tells me but nothing shows up . Btw I’m new to python so I’m obviously missing something I just don’t know what tho

    • @Xyz_xyz712
      @Xyz_xyz712 Месяц назад

      Figured it out . I forgot to use Button.pack()

  • @kleinerdiamant-bs
    @kleinerdiamant-bs 2 года назад

    10:40 OMG YOU ARE THE BEST. NEVER FOUND THIS ANYWHERE. Thank you so much. Like and sub!😱😱😱

  • @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!

  • @hadiaal-amine3244
    @hadiaal-amine3244 3 года назад

    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

  • @Sheharyar69420
    @Sheharyar69420 2 месяца назад

    Wow!

  • @אריאלברון-ו5ג
    @אריאלברון-ו5ג Год назад

    relly helpful

  • @TheFlashKageUzumaki
    @TheFlashKageUzumaki 2 месяца назад

    could u explain how to make the button bigger or change its postion

  • @furyaj
    @furyaj 2 года назад

    very good video ty !

  • @ServerInFrench
    @ServerInFrench 2 месяца назад

    I'm Still New To tkinter So Can You Please Explain .pack()

  • @chimp6532
    @chimp6532 2 года назад

    This was so helpful thnxs

  • @jogusudhakar8421
    @jogusudhakar8421 2 года назад

    Thanks man that's awesome

  • @redeye987
    @redeye987 3 года назад

    Thank you helped me a lot

  • @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?

  • @Bentleyloesch
    @Bentleyloesch 10 месяцев назад

    Would this be reasonable for creating a DAW?

  • @nokta1190
    @nokta1190 3 года назад +1

    thank you 😊

  • @NotSoz.
    @NotSoz. 9 месяцев назад

    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?

  • @Lav_jeswani
    @Lav_jeswani Год назад

    Love this guy...😂

  • @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?

  • @unkangkr
    @unkangkr 2 года назад

    Which extension pack should I download?

  • @theclasherplays7265
    @theclasherplays7265 2 года назад

    Great video , thanks for the code i understood it so now i can make an app

  • @eyoel9141
    @eyoel9141 2 года назад +1

    bro i am havinf problem named.... Tk() is not defined plz help me dude

  • @knownrobloxian3381
    @knownrobloxian3381 2 года назад +1

    What are you coding that on?

  • @By.0ne__pala
    @By.0ne__pala Год назад

    I have a question if we are on android(Acode) do this will work

  • @WildSpade
    @WildSpade Год назад

    I COMMECNTED OMG

  • @Ayushsharma-ly3wt
    @Ayushsharma-ly3wt 11 месяцев назад

    I want you to make a video about how to change button text also when clicked

  • @dumbaiii
    @dumbaiii 3 года назад +1

    print("cool vid")

  • @vash0158
    @vash0158 2 года назад

    Thanks

  • @s.mohammedjunaith6152
    @s.mohammedjunaith6152 2 года назад

    Amazing but how to change the postion and size of the button and lable
    Also borders

  • @he4-f2e
    @he4-f2e 3 года назад

    thank you bro🙏

  • @user-i7x3d
    @user-i7x3d Год назад

    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 2 месяца назад

      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()

  • @s.mohammedjunaith6152
    @s.mohammedjunaith6152 2 года назад

    One more question which module in python is best
    Sorry for soo many comments

  • @GalacticMurals
    @GalacticMurals 11 месяцев назад

    👍

  • @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.

  • @IceDragonBoy3
    @IceDragonBoy3 2 года назад

    Why do I get error window = Tk()
    NameError: name "Tk" is not defined
    :(

  • @mohamedsalman6558
    @mohamedsalman6558 3 года назад

    think you

  • @abhishekchikane6451
    @abhishekchikane6451 3 года назад

    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

  • @ThomasMultiMedia-l8m
    @ThomasMultiMedia-l8m 3 года назад +1

    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

  • @khitprod
    @khitprod 2 года назад

    Made beautiful angry chicken button

  • @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.

  • @somyaranjanpatra4330
    @somyaranjanpatra4330 3 года назад

    Wows fantastic🤘😝🤘 code ya..

  • @imihaita8913
    @imihaita8913 Год назад +1

    😆😆😆😍🥰😇

  • @toamna_7323
    @toamna_7323 3 года назад

    i don't understand,, how can i download this version of python??

  • @toastvernascher4533
    @toastvernascher4533 Год назад

    for some reason only the folder the python file was in just opened and nothing else happened. can someone help me?

  • @a_star_official_
    @a_star_official_ Год назад

    is this on virtual code studio

  • @tecaiii
    @tecaiii 3 года назад +2

    how do you make it so when you click the button once, it plays a sound?

  • @ryce_jnes
    @ryce_jnes 4 года назад +1

    first to watch

    • @BroCodez
      @BroCodez  4 года назад +2

      Here ya go:🥇

    • @ryce_jnes
      @ryce_jnes 4 года назад +1

      can we be friends and share code when need

  • @joshuahuang195
    @joshuahuang195 Год назад

    How do I do two commands at the same time?

  • @Wallancey123
    @Wallancey123 Год назад

    Hi

  • @salehninjax5583
    @salehninjax5583 3 года назад

    i just want to help you that is why a commented

  • @dreadcannibal3395
    @dreadcannibal3395 3 года назад

    the image doesn't work for me

  • @hash261k
    @hash261k Год назад

    Bro help me how to import an image with a phone please i beg of you

  • @KrewFams
    @KrewFams 2 года назад

    The back ground doesn't work

  • @thecodeitworks5874
    @thecodeitworks5874 4 года назад +1

    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

  • @bartekgrechuta7691
    @bartekgrechuta7691 Год назад

    hello

  • @MREditz170
    @MREditz170 2 года назад

    image directory is not found error pls help

  • @damianplays4209
    @damianplays4209 3 года назад

    font dosn't work

  • @guyincognito5614
    @guyincognito5614 3 года назад

    heres my comment

  • @prycereviews5690
    @prycereviews5690 2 года назад

    the count doesn't work for me
    nevermind