title: Tkinter conditional display from previous page's checkBoxes/checkVars values
body: <p>I am currently working on an GUI using tkinter and I am encountering an issue.</p>
  <p>I want the user to be able :</p>
  <ol>
  <li>To select within page 'sensors_history_homepage' an arbitrary number of columns from checkbuttons (1 per column name),</li>
  <li>Then when clicking a button, a new page 'sensors_custom_history' pops up, displaying some stuff for each selected column.</li>
  </ol>
  <p>Please find below the minimal reproducible example :</p>
  <pre><code>import tkinter as tk
  import configparser, pickle
  
  class UI_demo:
  
    def __init__(self, master=None):
          &quot;&quot;&quot;
          # Load config_back.ini parameters
          config = configparser.ConfigParser()
          config.read('setup_front.ini')
          self.output_folder = config['DEFAULT']['path_to_output_folder']
          print(&quot;config_front.ini file was successfully loaded ! \n&quot;)
          
          # Load in-scope columns
          with open(self.output_folder+&quot;headers_inscope&quot;, 'rb') as f:
              self.columns = pickle.load(f)
          &quot;&quot;&quot;
          self.columns = [&quot;Var1&quot;, &quot;Var2&quot;, &quot;Var3&quot;, &quot;Var4&quot;, &quot;Var5&quot;] # Simple sample as the actual dataset is private
          super().__init__()
          self.master = master
          self.master.geometry(&quot;1650x1000&quot;)
          self.master.state('zoomed')
          
          self.initHomePageUI()
  
    def initHomePageUI(self):
  
          self.master.title(&quot;Homepage&quot;)
          
          # Some stuff....
          
          # Menu buttons
          frame1 = tk.Frame(self.master)
          frame1.pack(side=&quot;top&quot;, fill=&quot;both&quot;, pady=20, expand=True)        
          
          but3 = tk.Button(frame1, text=&quot;History&quot;, font=('Courier',12), 
                           bd=3, width=36, command = self.sensors_history_homepage)
          but3.pack(side=&quot;top&quot;, pady=12)
  
    def sensors_history_homepage(self):
          
          # Open new window
          window = tk.Toplevel(self.master)
          window.title(&quot;Sensors selection&quot;)
          window.state('zoomed')
          
          # Top empty frame
          top_frame = tk.Frame(window, height=80)
          top_frame.pack(side='top', fill='x')
          
          # Page header
          title0 = tk.Label(window, borderwidth=1, text=&quot;Please select sensor(s) you wish to consult&quot;)
          title0.config(font=('Courier',14))
          title0.pack(side='top')
          
          # List of sensors as check-buttons (10 sensors per column as in real-case I have 200+ sensors to display)
          frame0 = tk.Frame(window, borderwidth=1)
          frame0.pack(side='top', fill='x')
          
          l_frames = []
          l_checkvar = []
          l_checkb = []
          
          for i in range(int(len(self.columns)/10)):
              
              l_frames = l_frames + [tk.Frame(frame0, borderwidth=1)]
              l_frames[i].pack(side='left')
              
              l_checkvar = l_checkvar +[tk.BooleanVar(master=window) for l in range(10)]
              
              l_checkb = l_checkb + [tk.Checkbutton(l_frames[i], text=self.columns[10*i+l], variable=l_checkvar[10*i+l],
                                                    onvalue=True, offvalue=False, height=2, width=10) for l in range(10)]
              
              for j in range(10*i,10*i+9):
                  
                  l_checkb[j].pack(side='top')
                  l_checkb[j].toggle()
          
          tmp_residual = int(len(self.columns)%10)
          
          if not tmp_residual==0:
             
              i = int(len(self.columns)/10)
              
              l_checkvar += [tk.BooleanVar(master=window) for l in range(10*i,10*i+tmp_residual)]
              
              l_frames += [tk.Frame(frame0, borderwidth=1)]
              l_frames[i].pack(side='left')
              
              l_checkb += [tk.Checkbutton(l_frames[i], text=self.columns[10*i+l], variable=l_checkvar[10*i+l], 
                                                    onvalue=True, offvalue=False, height=2, width=10) for l in range(0,tmp_residual)]
              
              for l in range(0,tmp_residual):
                  l_checkb[10*i+l].pack(side='top')
                  l_checkb[10*i+l].toggle()
                  
          
          # Check all / Uncheck all buttons
          def check_all():
              self.checkvars = [x.set(True) for x in self.checkvars]
          
          def uncheck_all():
              self.checkvars = [x.set(False) for x in self.checkvars]
          
          frame1 = tk.Frame(window, borderwidth=1)
          frame1.pack(side='top', fill='x')
          
          but_ca = tk.Button(frame1, text=&quot;Check all&quot;, font=('Courier',10), bd=3,
                             command=check_all)
          but_ca.pack(side='left', padx=5)
          
          but_ua = tk.Button(frame1, text=&quot;Uncheck all&quot;, font=('Courier',10), bd=3,
                             command=uncheck_all)
          but_ua.pack(side='left', padx=5)
          
          self.checkvars = l_checkvar
          
          # Button to display selected sensors' signal history
          refresh_frame = tk.Frame(window, borderwidth=1)
          refresh_frame.pack(side='top', fill='x')
          
          refresh_but = tk.Button(refresh_frame, text=&quot;Display \n for selected sensors&quot;, font=('Courier',12), 
                           bd=3, width=30, command=self.sensors_custom_history)
          refresh_but.pack(side='top')
          
    def sensors_custom_history(self):
        
          # Open new window
          window = tk.Toplevel(self.master)
          window.title(&quot;Display of...&quot;)
          window.geometry(&quot;1500x970&quot;)
          window.state('zoomed')
          
          # Page header
          title0 = tk.Label(window, borderwidth=1, text=&quot;Sensors history&quot;)
          title0.config(font=('Courier',14))
          title0.pack(side='top')
          
          # List of previously selected sensors 
          l_cols = []
          l_checkvalues = list(map(lambda x: x.get(), self.checkvars))
          
          for i in range(len(l_checkvalues)):
              if l_checkvalues[i]==True:
                  l_cols = l_cols + [self.columns[i]]
          
          # Some display on the page....
  
          # Debugging console display
          print(&quot;checkvars : length = &quot;+str(len(l_checkvalues))+&quot;, nb of true = &quot;+str(sum(l_checkvalues))+'\n')
          print(l_checkvalues)
          print('\n'+&quot;columns selected : length = &quot;+str(len(l_cols))+'\n')
          print(l_cols)
  
  if __name__ == '__main__':
      root = tk.Tk()
      app = UI_demo(master=root)
      root.mainloop() 
  </code></pre>
  <p>My issue is regarding the &quot;passing&quot; of the checkVar values from the 'sensors_history_homepage' page to the 'sensors_custom_history' page :</p>
  <ol>
  <li>It seems that no matter which CheckBoxes are selected in 'sensors_history_homepage', the print from 'sensors_custom_history' give the same results.</li>
  <li>Trying to fetch the checkVars values from the 2nd page gives the following error :</li>
  </ol>
  <pre><code>File &quot;&lt;ipython-input-3-8b450e7f0e91&gt;&quot;, line 149, in sensors_custom_history
      l_checkvalues = list(map(lambda x: x.get(), self.checkvars))
  File &quot;&lt;ipython-input-3-8b450e7f0e91&gt;&quot;, line 149, in &lt;lambda&gt;
    l_checkvalues = list(map(lambda x: x.get(), self.checkvars))
  AttributeError: 'NoneType' object has no attribute 'get'
  </code></pre>
  <p>I am wondering how to properly pass the checkVars values to the 'sensors_custom_history' page in order to display only the information the user selected in previous 'sensors_history_homepage'.</p>
  <p>Any help will be much appreciated.</p>