Learn Python tkinter GUI checkboxes easy ✔️

  Рет қаралды 5,414

Bro Code

Bro Code

Күн бұрын

You guys don't need all the 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 GUI tkinter checkbutton/checkbox tutorial for beginners
#Python #GUI #tkinter #checkbutton #checkbox #tutorial #beginners
from tkinter import *
def display():
if(x.get()==1)&(y.get()==0):
print("I like Python")
elif(x.get()==0)&(y.get()==1):
print("I like Java")
elif(x.get()==1)&(y.get()==1):
print("I like both Python & Java")
else:
print("I don't like either")
window = Tk()
x = IntVar()
y = IntVar()
checkbox = Checkbutton(window,text='Python',variable=x,onvalue=1,offvalue=0,command=display)
checkbox.pack()
checkbox.config(font=('Arial',20)) #changes the font
checkbox.config(fg='#00FF00') #foreground color
checkbox.config(bg='#000000') #background color
checkbox.config(activeforeground='#0000FF') #active foreground color
checkbox.config(activebackground='#000000') #active background color
photo = PhotoImage(file='python_logo.png')
checkbox.config(image=photo,compound='left') #sets image to photoimage
checkbox.config(padx=25,pady=10,width=250,height=50)
checkbox.config(anchor='w') #anchors widget to relative cardinal direction
checkbox2 = Checkbutton(window,text='Java',variable=y,onvalue=1,offvalue=0,command=display)
#checkbox2.pack()
checkbox2.config(font=('Arial',20)) #changes the font
checkbox2.config(fg='#0000FF') #foreground color
checkbox2.config(bg='#000000') #background color
checkbox2.config(activeforeground='#0000FF') #active foreground color
checkbox2.config(activebackground='#000000') #active background color
photo2 = PhotoImage(file='Java_logo.png')
checkbox2.config(image=photo2,compound='left') #sets image to photoimage
checkbox2.config(padx=25,pady=10,width=250,height=50)
checkbox2.config(anchor='w')
window.mainloop()
Coding boot camps hate him! See how he can teach you to code with this one simple trick...
Bro Code is the self-proclaimed #1 best tutorial series on coding in the known universe.

Пікірлер: 20
@BroCodez
@BroCodez 4 жыл бұрын
from tkinter import * def display(): if(x.get()==1)&(y.get()==0): print("I like Python") elif(x.get()==0)&(y.get()==1): print("I like Java") elif(x.get()==1)&(y.get()==1): print("I like both Python & Java") else: print("I don't like either") window = Tk() x = IntVar() y = IntVar() checkbox = Checkbutton(window,text='Python',variable=x,onvalue=1,offvalue=0,command=display) checkbox.pack() checkbox.config(font=('Arial',20)) #changes the font checkbox.config(fg='#00FF00') #foreground color checkbox.config(bg='#000000') #background color checkbox.config(activeforeground='#0000FF') #active foreground color checkbox.config(activebackground='#000000') #active background color photo = PhotoImage(file='python_logo.png') checkbox.config(image=photo,compound='left') #sets image to photoimage checkbox.config(padx=25,pady=10,width=250,height=50) checkbox.config(anchor='w') #anchors widget to relative cardinal direction checkbox2 = Checkbutton(window,text='Java',variable=y,onvalue=1,offvalue=0,command=display) #checkbox2.pack() checkbox2.config(font=('Arial',20)) #changes the font checkbox2.config(fg='#0000FF') #foreground color checkbox2.config(bg='#000000') #background color checkbox2.config(activeforeground='#0000FF') #active foreground color checkbox2.config(activebackground='#000000') #active background color photo2 = PhotoImage(file='Java_logo.png') checkbox2.config(image=photo2,compound='left') #sets image to photoimage checkbox2.config(padx=25,pady=10,width=250,height=50) checkbox2.config(anchor='w') #anchors widget to relative cardinal direction window.mainloop()
@wavyrenac
@wavyrenac 3 жыл бұрын
i love you dude i was searching for something for ages ty dude
@ryce_jnes
@ryce_jnes 4 жыл бұрын
checkbox is check, check ur first like, good tutorial
@krepic6472
@krepic6472 Жыл бұрын
Thank you!
@darind2158
@darind2158 4 жыл бұрын
ok whait it works but i cant see the checkbox
@ashutoshbehera4283
@ashutoshbehera4283 Ай бұрын
where do you download these icon images?
@Cilakka1
@Cilakka1 Жыл бұрын
Thanks.
@abhishekdas2512
@abhishekdas2512 4 жыл бұрын
Python videos only 🔥. Pls
@BroCodez
@BroCodez 4 жыл бұрын
I'll be focusing mostly on Python for a while
@deepdaddy1208
@deepdaddy1208 4 жыл бұрын
good vid
@darind2158
@darind2158 4 жыл бұрын
tk not defined WTF IT ALWAYS DIES THAT
@BroCodez
@BroCodez 4 жыл бұрын
post your code, I'll take a look. It might be your imports
@tanvirsahrierjishan778
@tanvirsahrierjishan778 Ай бұрын
Most helpful videos on your channel when some day scroll for videos your python video also appered after watch excited to learn programming
@hydarhydar2338
@hydarhydar2338 2 күн бұрын
@hydarhydar2338
@hydarhydar2338 4 күн бұрын
@lucyledezma709
@lucyledezma709 4 жыл бұрын
Hey Bro!!!... I like your videos!!!... really ; I wanna learn Python and your videos helps me!!
@darind2158
@darind2158 4 жыл бұрын
when i do the intvar thing its not define???
@RipperRoo92
@RipperRoo92 4 жыл бұрын
Bro I appreciate these tutorials.
Learn Python tkinter GUI radiobuttons easy 🔘
12:22
Bro Code
Рет қаралды 23 М.
Learn Python tkinter GUI listboxes easy 📋
15:00
Bro Code
Рет қаралды 21 М.
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 1,8 МЛН
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 7 МЛН
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 55 МЛН
Making a Game in Python with No Experience
5:57
Goodgis
Рет қаралды 1,7 МЛН
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 136 М.
I tried 10 code editors
10:28
Fireship
Рет қаралды 3 МЛН
Making a Game with Java with No Experience
8:41
Goodgis
Рет қаралды 373 М.
Learn Python tkinter GUI messageboxes easy 💭
13:19
Bro Code
Рет қаралды 17 М.
Learn Python tkinter labels easy 🏷️
10:28
Bro Code
Рет қаралды 37 М.
Learn Python tkinter GUI scales easy 🌡️
10:20
Bro Code
Рет қаралды 14 М.
Learn Python tkinter GUI checkboxes easy ✔️
9:36
Bro Code
Рет қаралды 21 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,5 МЛН
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 1,8 МЛН