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;








2















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










share|improve this question




























    2















    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










    share|improve this question
























      2












      2








      2








      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 20:49









      maxmarszmaxmarsz

      376




      376






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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





          share|improve this answer

























          • 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











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



          );













          draft saved

          draft discarded


















          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









          1














          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





          share|improve this answer

























          • 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















          1














          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





          share|improve this answer

























          • 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













          1












          1








          1







          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





          share|improve this answer















          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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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

















          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현