Python buttons 🛎️

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024
  • Python tkinter button buttons GUI tutorial beginners code
    #Python #tkinter #button #buttons #GUI #tutorial #beginners #code
    from tkinter import *
    button = you click it, then it does stuff
    count = 0
    def click():
    global count
    count+=1
    print(count)
    window = Tk()
    photo = PhotoImage(file='like.png')
    button = Button(window,
    text="click me!",
    command=click,
    font=("Comic Sans",30),
    fg="#00FF00",
    bg="black",
    activeforeground="#00FF00",
    activebackground="black",
    state=ACTIVE,
    image=photo,
    compound='bottom')
    button.pack()
    window.mainloop()

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

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

    from tkinter import *
    # button = you click it, then it does stuff
    count = 0
    def click():
    global count
    count+=1
    print(count)
    window = Tk()
    photo = PhotoImage(file='like.png')
    button = Button(window,
    text="click me!",
    command=click,
    font=("Comic Sans",30),
    fg="#00FF00",
    bg="black",
    activeforeground="#00FF00",
    activebackground="black",
    state=ACTIVE,
    image=photo,
    compound='bottom')
    button.pack()
    window.mainloop()

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

      how do you make it so a button disappears on click and another comes up, trying to do a golf thing where it goes through all moves per hole so displays buttons for things like hole number and clubs and saves each input for each hole

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

      For some reason it won't make the background of the button the colour I want, in fact, I doesn't even change it! I would like it to be blue

    • @hermit-p3x
      @hermit-p3x 7 месяцев назад

      @@PhoenixVids123 use a hex code

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

    great buttons tutorial, love it and love buttons !!

  • @AliciaThato-nd7js
    @AliciaThato-nd7js Год назад +1

    This video really helped me and I wish you can do more videos for beginners

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

    Thanks for including a copy of the code.

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

    Saved my life dude. Great tutorial!

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

    Hey I'm pass by Here jus to say that u is the best ever techear in python, thanks for help in this journey.

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

    Great video! But how do I adjust the photo’s size?

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

    Thank you.. you helped me a lot.. but can you make a video about how to select a interpreter pls ??
    🙏🙏

  • @syakirar2198
    @syakirar2198 Год назад +3

    Thanks so much! I did learn somthing from this video :D I was wondering can, you show how to add multiple buttons in a same window? I'm trying to create a calculator using python.

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

      well if you want a short cut he did a video on how to make a calculater in python it's called "python calculater program'.

  • @cream-caker_9999
    @cream-caker_9999 Год назад

    This really helped me, thanks for making an up-to-date video!!!

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

    amazing tutorials thanks!

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

    Thanks bro 😊

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

    this video has been very successful and useful for me. except for I've been unable to get the image to work any time I try. not sure what i'm doing wrong, wish I could find out so I can fix it!
    thanks for the tutorial!

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

    Ty bro this helped me so much with my school project! Keep up the good work

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

    Thank god I found your video. I was having a mental breakdown and struggling until I found this. Life of a beginner programmer🤣

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

    Thanks!

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

    Thanks a lot for this video, very helpful. I have made a few clickable backup programs to backup video games, but it's taking up so much space. I'm gonna use this to put it all in one programm. Thanks a lot!

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

    thanks

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

    Thanks

  • @TheDarkSide-s5t
    @TheDarkSide-s5t Год назад +1

    Python how to make Round Modern Button in less than 5 minutes 2023

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

    Thank you!

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

    nice one bro

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

      thank you again Oğuzhan

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

    Bro is awesome 👍

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

    thanks!

  • @iluha_mister
    @iluha_mister 5 месяцев назад

    here an button (to working)
    import tkinter as tk
    def button_clicked():
    print("Button clicked!")
    # Create the main window
    root = tk.Tk()
    # Create a button
    button = tk.Button(root, text="Click me!", command=button_clicked)
    button.pack()
    # Run the Tkinter event loop
    root.mainloop()

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

    Ty

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

    How can we increase or decrease the size of icon???

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

    nice

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

    "Let's pick a professional font such as Comic Sans."
    *Me: Professional?*
    "Very professional"
    "And now you can actually read what's on this button."
    Program: Proceeds to show a completely different font besides comic sans
    *I have so many questions that doesn't even have to do with the program*

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

      It's 'Comic Sans MS'. That's why his didn't display properly.

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

      @@prizepig Oh, thanks for telling me! :D

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

    cool

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

    Thanks bro!

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

    after running the program my image is been enlarged a lot. Is there any size specification? Can you tell me the error?

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

    good thank u bro

  • @CLyon-cc9jp
    @CLyon-cc9jp Год назад

    How would I make it so that the button has two modes / appearances - e.g. "selected" and "unselected"? I would like to have buttons that when you press them they are darkened so that they are "selected" and when you press them again they return to the normal appearance of "unselected". This is basically like a checkbox, but without the check. I looked at your checkbox video, but it seems the checkbox always has to be shown. I don't want that in my app.

  • @BrijmohanDubge
    @BrijmohanDubge 5 месяцев назад

    which version is needed

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

    a million of thanks

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

    Wow!

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

    I'm trying to code this into replit python, however it isn't working and I'm stuck on trying to import Tkinter. Plus other parts are just leaving syntax errors.

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

    COOL!

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

    is it possible to make the button toggleable?

    • @oximas-oe9vf
      @oximas-oe9vf 2 года назад

      you mean something like a check box or a radio button?

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

    Hi. Thanks for the video. I am making chess in python and I need some help. Do you maybe know how to set the background of the default button (none). Thanks!

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

    Thanks bro

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

      thanks for watching Joshy

  • @RichardMubalama-qj4fx
    @RichardMubalama-qj4fx Месяц назад

    Yo what should I do if i don't see the same cage for the buttom are they anythings to install

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

    but that's not the comic sans font i guess?

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

    _tkinter.TclError: couldn't recognize data in image file "clock.png"

  • @HussainAli-sb1dv
    @HussainAli-sb1dv 11 месяцев назад

    love u

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

    How to move the button

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

    thx :)

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

    Sir, can we automatically deactivate this button for 20 second after each click. After 20 second activate again Automaticaly. Please anyone help.

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

    I have image button how to hiden outside frame?

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

    how do i make it play sounds

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

    imma use this code, import pyautogui, and make it so that every time I click, it sends a message to someone saying the click number!

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

    شكرا

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

    How do i show the result of the console on the window? I need to put my code with "if, else, then" inside the gui but don't know how to do it

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

      i think you need to create a label and then modify the content(text) of the label inside the function

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

      you have to do it in the function

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

      if you wan to do this your program shud look like this:
      from tkinter import *
      window = Tk()
      count = 0
      def click():
      global count
      L.config(text=str(count))
      count += 1
      b = Button(window, text='lalalalal', command=click)
      b.pack()
      L = Label(window, text=str(count))
      L.pack()
      window.mainloop()

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

      if you wan to do this your program shud look like this:
      from tkinter import *
      window = Tk()
      count = 0
      def click():
      global count
      L.config(text=str(count))
      count += 1
      b = Button(window, text='lalalalal', command=click)
      b.pack()
      L = Label(window, text=str(count))
      L.pack()
      window.mainloop()

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

    drop a comment down below

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

    W channel

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

    meow meow moew~!

  • @kristijanlazarev
    @kristijanlazarev 8 месяцев назад

    wild

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

    ta

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

    thanks

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

    cool

  • @rubenc4696
    @rubenc4696 5 месяцев назад

    thanks

  • @NOTHING-en2ue
    @NOTHING-en2ue Год назад

    thanks