Тёмный

Learn Python tkinter GUI radiobuttons easy 🔘 

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

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

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 50   
@BroCodez
@BroCodez 4 года назад
# radio button = similar to checkbox, but you can only select one from a group from tkinter import * food = ["pizza","hamburger","hotdog"] def order(): if(x.get()==0): print("You ordered pizza!") elif(x.get()==1): print("You ordered a hamburger!") elif(x.get()==2): print("You ordered a hotdog!") else: print("huh?") window = Tk() pizzaImage = PhotoImage(file='pizza.png') hamburgerImage = PhotoImage(file='hamburger.png') hotdogImage = PhotoImage(file='hotdog.png') foodImages = [pizzaImage,hamburgerImage,hotdogImage] x = IntVar() for index in range(len(food)): radiobutton = Radiobutton(window, text=food[index], #adds text to radio buttons variable=x, #groups radiobuttons together if they share the same variable value=index, #assigns each radiobutton a different value padx = 25, #adds padding on x-axis font=("Impact",50), image = foodImages[index], #adds image to radiobutton compound = 'left', #adds image & text (left-side) #indicatoron=0, #eliminate circle indicators #width = 375, #sets width of radio buttons command=order #set command of radiobutton to function ) radiobutton.pack(anchor=W) window.mainloop()
@gregoneill4391
@gregoneill4391 Год назад
I have a question about validation with radios with more indepth forms, how do you validate that you must chose an option( must select a choice)?
@qwertydadqwerty4528
@qwertydadqwerty4528 Год назад
ㅑ99ㅑ9999ㅑㅑㅑㅑ9ㅑㅏ899ㅑㅑㅑㅑㅑㅡ8899ㅑㅡㅑㅑㅑㅑㅡ8ㅡ99ㅑ9ㅑㅑㅡ😅😅 3:16 ㅑㅣㅑㅔ91
@lucyledezma709
@lucyledezma709 4 года назад
Hello Bro.. I always see your tutoriarls!!
@BroCodez
@BroCodez 4 года назад
thank you!
@noisyguest5249
@noisyguest5249 4 года назад
Keep it up love ur great why is ur channel so under ratted never mind i believe u will come in other people recommendations
@arpanshah355
@arpanshah355 Год назад
A simpler way to write his order function is: def order(): order = ["You bought the pizza!", "You bought the hamburger!", "You bought the hotdog!"] print(order[x.get()])
@pedroluiz2741
@pedroluiz2741 3 года назад
U should post a link of those images too, pretty cool therse ones
@aquasepwaterengineering4242
@aquasepwaterengineering4242 2 месяца назад
very nice way of teaching. Thanks BRO
@thePavuk
@thePavuk 10 месяцев назад
for me, even width 75 is very large. like 4-5 times more then in example. My screen is 2560x1440.
@alewyaside6326
@alewyaside6326 Год назад
Chef kiss perfection
@linussandwich8915
@linussandwich8915 6 месяцев назад
rahhhhh best code teacher
@noisyguest5249
@noisyguest5249 4 года назад
Thank you sometimes i wonder how many programming languages u know u should make ur own from Lex
@BroCodez
@BroCodez 4 года назад
not as many as what people might think lol
@eminem992i
@eminem992i 6 месяцев назад
@@BroCodez at first i thought you are nerd, in fact your nerd coz you know many languages AND you have a good tutorial
@kapibara2440
@kapibara2440 9 месяцев назад
Great stuff from the Bro❤❤❤
@truquichan
@truquichan 11 месяцев назад
Great!
@androtech1285
@androtech1285 Год назад
Great work
@piotrkopcewicz5227
@piotrkopcewicz5227 Год назад
Great !!
@Blazer50085
@Blazer50085 Год назад
Thanks this tutorial was really helpful
@beingzero7541
@beingzero7541 2 года назад
Wow!
@Amir_Plays_non_stop
@Amir_Plays_non_stop 3 года назад
Another cool video!
@artur0y95
@artur0y95 8 месяцев назад
I used f-string for the order function. It's even simplier and all in one line of code. def order(): print(f"You ordered {food[x.get()]}!")
@artur0y95
@artur0y95 8 месяцев назад
and there's a version if you want to be grammaticaly correct if food[x.get()] == "pizza": print(f"You ordered {food[x.get()]}!") #/ print(f"You ordered a slice of {food[x.get()]}!") else: print(f"You ordered a {food[x.get()]}!")
@activechaos128
@activechaos128 Год назад
why can I not find a png image that works?
@hasansolak23
@hasansolak23 3 года назад
You are the best.
@lw9954
@lw9954 2 года назад
Ty Bro!!!
@SandeepBudha-h6y
@SandeepBudha-h6y Месяц назад
Love you bro❤😂
@hanajoudyunicorn6199
@hanajoudyunicorn6199 2 года назад
Good
@uuhju7004
@uuhju7004 3 года назад
thank you very much, you are the best
@haurvatat2006
@haurvatat2006 2 года назад
In python 3.10 the indicatoron=0 is fine but the compiler expected it to be a boolean, in this case, it is False (Sorry if my English is bad)
@elevendarter112
@elevendarter112 Год назад
In python 3.11 it's probably the same. My pyCharm has highlighted that "indicatoron=0" too, but when I rewrote 0 to False it's ok now. It worked even with the 0, now it seems like pyCharm likes it more :-)
@thePavuk
@thePavuk 10 месяцев назад
@@elevendarter112 Visual studio code, p3.12 and it's ok.
@SuperStarEevee
@SuperStarEevee 2 года назад
Thank you!
@astroo0o0
@astroo0o0 Год назад
tysm bro
@rubenc4696
@rubenc4696 3 месяца назад
thanks
@haydenmcelmon6504
@haydenmcelmon6504 6 месяцев назад
Hey guys I know this is a comment on a 3-year old post but just want some help. I wrote all the code he used, then I wanted to change the background of the radio button to be blue, so I wrote "bg="blue"" after the width and before the command in the radio button variable. For some reason when I run the code only the hamburger and hot dog changes background to blue and the pizza's background stays as white. I asked ChatGPT 4.0 what could be the issue and they don't have a concrete answer. Are there any coding connoisseurs that might be able to identify my issue?
@bbong76
@bbong76 Год назад
Hi, just a quick question! When I follow the tutorial, I notice that the default selection is the first one. Is there anyway to deselect that? Thanks
@Dani-re7ki
@Dani-re7ki Год назад
window = Tk() x = IntVar() dummy = Radiobutton(window, text="", variable=x, value=0, indicatoron=False) for index in range(len(food)): radiobutton = Radiobutton(window, text=food[index], variable=x, value=index + 1, padx=10, pady=5, font=("Impact", 40), indicatoron=False, width=20, command=order) radiobutton.pack(anchor=W) window.mainloop() don't know i fyou still need it but that's my solution haha
@EissaAlahdul
@EissaAlahdul 2 года назад
شكرا
@maxxinev.pennelope7179
@maxxinev.pennelope7179 2 года назад
So is there a reason why "im looking i just dont know if its cause obscure.. that when i use .place and coordinates that i am only getting the last Item in the list appearing and thus only hhave 1 radio button? apposed to how pack automatically works with the full list and for:loop ?
@minpyaesoesan7563
@minpyaesoesan7563 2 года назад
What is the difference between padx and width? I didn"t get it Bro.
@gustavoaponte1814
@gustavoaponte1814 Год назад
meow meow meow~!
@hamzazad5258
@hamzazad5258 5 месяцев назад
every time i add images its gets all messed up!
@MoreBilaINoFilter
@MoreBilaINoFilter 2 года назад
huh?
@mariaangelineadajar1248
@mariaangelineadajar1248 2 года назад
How about in pysimplegui?
@MrEdoben
@MrEdoben Год назад
I ordered pizza but never comes???? Bro you are best...
@marknunes8444
@marknunes8444 2 года назад
I tried creating the image in the for loop because I needed to resize it I added it to a single variable called photo and added the image to the image argument: image=photo, . When I did it messed up the program so that only the last image (the hotdog) showed up . Does it just point to the image in the array you've created rather than copying the image to the radio button? I'll try deleting the array after the for loop and see what happens.
@philtoa334
@philtoa334 3 года назад
Miam.
@jhassee
@jhassee Год назад
hi
Далее
Learn Python tkinter GUI scales easy 🌡️
10:20
Просмотров 13 тыс.
Learn Python tkinter GUI listboxes easy 📋
15:00
Просмотров 21 тыс.
The grid layout method in tkinter
22:44
Просмотров 30 тыс.
Coding Was HARD Until I Learned These 5 Things...
8:34
Python 101: Learn the 5 Must-Know Concepts
20:00
Просмотров 1,2 млн
Learn Python tkinter GUI frames easy ⚰️
6:50
Просмотров 13 тыс.
If __name__ == "__main__" for Python Developers
8:47
Просмотров 402 тыс.
5 Useful F-String Tricks In Python
10:02
Просмотров 305 тыс.
Tkinter Beginner Course - Python GUI Development
38:59
Просмотров 528 тыс.