Tkinter, how to set state of some elements depending of checkbox statusHow to return multiple values from a function?How do I remove an element from a list by index in Python?How do I get the number of elements in a list in Python?How to get the state of multiple Checkbuttons in Tkinter?Reading variables for a set of Checkbuttons in TKinterSet style for Checkbutton or Labelframe in python tkinterPython - Tkinter - setting IntVar's in a listTkinter Checkbutton State Change using DictionariesChange state attributes to a group of widgets in TkinterCheckbox always reads 0 in popup window - Tkinter
How would a physicist explain this starship engine?
Keeping the dodos out of the field
Why is 'additive' EQ more difficult to use than 'subtractive'?
Is there any mention of ghosts who live outside the Hogwarts castle?
A nasty indefinite integral
Is the default 512 byte physical sector size appropriate for SSD disks under Linux?
How do I write real-world stories separate from my country of origin?
What pc resources are used when bruteforcing?
What is this dime sized black bug with white on the segments near Loveland Colorodao?
Does attacking (or having a rider attack) cancel Charge/Pounce-like abilities?
Why do testers need root cause analysis?
How to safely discharge oneself
Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?
Meaning of "half-crown enclosure"
How to create razor wire
Caught with my phone during an exam
One word for 'the thing that attracts me'?
Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?
Is there a solution to paying high fees when opening and closing lightning channels once we hit a fee only market?
How to tease a romance without a cat and mouse chase?
Download app bundles from App Store to run on iOS Emulator on Mac
nginx conf: http2 module not working in Chrome in ubuntu 18.04
Illustrating that universal optimality is stronger than sphere packing
How many wires should be in a new thermostat cable?
Tkinter, how to set state of some elements depending of checkbox status
How to return multiple values from a function?How do I remove an element from a list by index in Python?How do I get the number of elements in a list in Python?How to get the state of multiple Checkbuttons in Tkinter?Reading variables for a set of Checkbuttons in TKinterSet style for Checkbutton or Labelframe in python tkinterPython - Tkinter - setting IntVar's in a listTkinter Checkbutton State Change using DictionariesChange state attributes to a group of widgets in TkinterCheckbox always reads 0 in popup window - Tkinter
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have variable pliki
which is from checkbox
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
if pliki.get() == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
if pliki.get() == 0:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
This code don't work as I had meant to work.
I want if checkbox is checked set state of some elements to NORMAL but when not checked set to DISABLE
python tkinter
add a comment |
I have variable pliki
which is from checkbox
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
if pliki.get() == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
if pliki.get() == 0:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
This code don't work as I had meant to work.
I want if checkbox is checked set state of some elements to NORMAL but when not checked set to DISABLE
python tkinter
add a comment |
I have variable pliki
which is from checkbox
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
if pliki.get() == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
if pliki.get() == 0:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
This code don't work as I had meant to work.
I want if checkbox is checked set state of some elements to NORMAL but when not checked set to DISABLE
python tkinter
I have variable pliki
which is from checkbox
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
if pliki.get() == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
if pliki.get() == 0:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
This code don't work as I had meant to work.
I want if checkbox is checked set state of some elements to NORMAL but when not checked set to DISABLE
python tkinter
python tkinter
asked Mar 23 at 20:49
maxmarszmaxmarsz
376
376
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I've done something similar with a RadioButton()
by linking the command to a function that hides it:
v = tk.IntVar()
tk.Radiobutton(self.widget, text="Turn on", variable=v, value=1, command=self.show_other_widget).grid(row=0, column=0)
tk.Radiobutton(self.widget, text="Turn off", variable=v, value=2, command=self.hide_other_widget).grid(row=0, column=1)
Which links to:
def hide_other_widget(self):
self.other_widget.configure(state='disabled')
def show_other_widget(self):
self.other_widget.configure(state='normal')
I don't think you can do this with a single Checkbutton though because the command is only run when it is turned on and not when it is turned off (As described at http://effbot.org/tkinterbook/checkbutton.htm). You could instead use a thread to continually check the button status and adjust your widget accordingly though!
import threading
def check_button_status():
while True:
status = pliki.get()
if status == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
else:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
t = threading.Thread(target=check_button_status) # make our thread
t.start() # have it monitor the button status forever
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318239%2ftkinter-how-to-set-state-of-some-elements-depending-of-checkbox-status%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've done something similar with a RadioButton()
by linking the command to a function that hides it:
v = tk.IntVar()
tk.Radiobutton(self.widget, text="Turn on", variable=v, value=1, command=self.show_other_widget).grid(row=0, column=0)
tk.Radiobutton(self.widget, text="Turn off", variable=v, value=2, command=self.hide_other_widget).grid(row=0, column=1)
Which links to:
def hide_other_widget(self):
self.other_widget.configure(state='disabled')
def show_other_widget(self):
self.other_widget.configure(state='normal')
I don't think you can do this with a single Checkbutton though because the command is only run when it is turned on and not when it is turned off (As described at http://effbot.org/tkinterbook/checkbutton.htm). You could instead use a thread to continually check the button status and adjust your widget accordingly though!
import threading
def check_button_status():
while True:
status = pliki.get()
if status == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
else:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
t = threading.Thread(target=check_button_status) # make our thread
t.start() # have it monitor the button status forever
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
add a comment |
I've done something similar with a RadioButton()
by linking the command to a function that hides it:
v = tk.IntVar()
tk.Radiobutton(self.widget, text="Turn on", variable=v, value=1, command=self.show_other_widget).grid(row=0, column=0)
tk.Radiobutton(self.widget, text="Turn off", variable=v, value=2, command=self.hide_other_widget).grid(row=0, column=1)
Which links to:
def hide_other_widget(self):
self.other_widget.configure(state='disabled')
def show_other_widget(self):
self.other_widget.configure(state='normal')
I don't think you can do this with a single Checkbutton though because the command is only run when it is turned on and not when it is turned off (As described at http://effbot.org/tkinterbook/checkbutton.htm). You could instead use a thread to continually check the button status and adjust your widget accordingly though!
import threading
def check_button_status():
while True:
status = pliki.get()
if status == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
else:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
t = threading.Thread(target=check_button_status) # make our thread
t.start() # have it monitor the button status forever
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
add a comment |
I've done something similar with a RadioButton()
by linking the command to a function that hides it:
v = tk.IntVar()
tk.Radiobutton(self.widget, text="Turn on", variable=v, value=1, command=self.show_other_widget).grid(row=0, column=0)
tk.Radiobutton(self.widget, text="Turn off", variable=v, value=2, command=self.hide_other_widget).grid(row=0, column=1)
Which links to:
def hide_other_widget(self):
self.other_widget.configure(state='disabled')
def show_other_widget(self):
self.other_widget.configure(state='normal')
I don't think you can do this with a single Checkbutton though because the command is only run when it is turned on and not when it is turned off (As described at http://effbot.org/tkinterbook/checkbutton.htm). You could instead use a thread to continually check the button status and adjust your widget accordingly though!
import threading
def check_button_status():
while True:
status = pliki.get()
if status == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
else:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
t = threading.Thread(target=check_button_status) # make our thread
t.start() # have it monitor the button status forever
I've done something similar with a RadioButton()
by linking the command to a function that hides it:
v = tk.IntVar()
tk.Radiobutton(self.widget, text="Turn on", variable=v, value=1, command=self.show_other_widget).grid(row=0, column=0)
tk.Radiobutton(self.widget, text="Turn off", variable=v, value=2, command=self.hide_other_widget).grid(row=0, column=1)
Which links to:
def hide_other_widget(self):
self.other_widget.configure(state='disabled')
def show_other_widget(self):
self.other_widget.configure(state='normal')
I don't think you can do this with a single Checkbutton though because the command is only run when it is turned on and not when it is turned off (As described at http://effbot.org/tkinterbook/checkbutton.htm). You could instead use a thread to continually check the button status and adjust your widget accordingly though!
import threading
def check_button_status():
while True:
status = pliki.get()
if status == 1:
liczba_pE['state'] = NORMAL
nazwa_pE['state'] = NORMAL
tresc_pE['state'] = NORMAL
else:
liczba_pE['state'] = DISABLED
nazwa_pE['state'] = DISABLED
tresc_pE['state'] = DISABLED
pliki = IntVar()
plikiC = Checkbutton(secunderFrame, text="Twórz pliki",
font=("Bookman Old Style", 8, 'bold'),
variable=pliki, onvalue=True, offvalue=False)
t = threading.Thread(target=check_button_status) # make our thread
t.start() # have it monitor the button status forever
edited Mar 23 at 21:13
answered Mar 23 at 20:58
ReedinationerReedinationer
3,7121425
3,7121425
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
add a comment |
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I still don't know how to use it hah
– maxmarsz
Mar 23 at 21:04
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I understand what you had wrtitten but don't know how to implement it to my problem
– maxmarsz
Mar 23 at 21:06
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
I think it will be better if it be checkbutton. One button instead of two looks simpler for what I need to do
– maxmarsz
Mar 23 at 21:10
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
It works perfectly, thank you
– maxmarsz
Mar 23 at 21:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318239%2ftkinter-how-to-set-state-of-some-elements-depending-of-checkbox-status%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown