title: How to know how many rows/columns are taken in a Tkinter.Frame
body: <h2>Preliminaries</h2>
  
  <p>In my <code>Tkinter</code> application I frequently need to align columns of <code>Tkinter.Frame</code> with the <code>grid_columnconfigure</code> method. I use simple uniform approach to place widgets in the frame:</p>
  
  <ol>
  <li>I have custom-made frame-classes inherited from the <code>Tkinter.Frame</code> class</li>
  <li>I place widgets in custom-made frame with the <code>grid</code> manager and every column has the same weight</li>
  </ol>
  
  <h2>Code</h2>
  
  <h3>Custom-made frame</h3>
  
  <p>Here is the code of one of my custom-made frames. <code>SFrame</code> is just a class-wrapper for a <code>Tkinter.Frame</code> with a style:</p>
  
  <pre><code>class GroupFrame( SFrame ) :
      """
          This class represents a frame with a title at the top
      """
      def __init__( self, parent, style, title, **kwargs ) :
          SFrame.__init__( self, parent, style, **kwargs )
          self.config( borderwidth=5, relief=tk.SUNKEN )
  
          self.style = style
          self.title = title.upper()
  
          self.CreateFrames()
          self.FillFrames()
  
  
      def CreateFrames( self ) :
          self.titleFrame = SFrame( self, self.style ) 
          self.titleFrame.pack( side="top", pady=10 )
  
          self.contentFrame = SFrame( self, self.style )
          self.contentFrame.pack( side="bottom", pady=(0, 10), fill='x' )
  
  
      def FillFrames( self ) :
          self.titleLabel = SLabel( self.titleFrame, self.style, text=str( self.title ) )
          self.titleLabel.config( font=self.style.groupTitleFont, borderwidth=3, relief=tk.SUNKEN , padx=3)
          self.titleLabel.pack( pady=(1, 5) )
  
  
      def AlignColumns( self, nCols ): #&lt;----- Look at this function
          for i in range( nCols ):
              self.contentFrame.grid_columnconfigure( i, weight=1 )
  </code></pre>
  
  <h3>Usage example</h3>
  
  <p>Here is how I use it and the result (<code>SButton</code> is a class-wrapper for a <code>Tkinter.Button</code> with a style):</p>
  
  <pre><code>#button to go to the common settings' page: settings for all channels
  self.settingsFrame = GroupFrame( self.midFrame, self.style, "SETTINGS" )
  self.settingsFrame.grid( row=0, column=0, pady=10, padx=10, sticky="ew" )
  
  self.commonButton = SButton( self.settingsFrame.contentFrame, self.style,
                               text="Common Settings",
                               command=lambda: self.controller.ShowPage( "Common" ),
                               height=2 )
  self.commonButton.grid( row=0, column=0, padx=10, sticky="ew" )
  #button to go to the individual settings' page: settings per channel
  self.individButton = SButton( self.settingsFrame.contentFrame, self.style,
                                text="Individual Settings",
                                command=lambda: self.controller.ShowPage( "Individual" ),
                                height=2 )
  self.individButton.grid( row=0, column=1, padx=10, sticky="ew" )
  #button to go to the terminal page
  self.terminalButton = SButton( self.settingsFrame.contentFrame, self.style,
                                 text="Terminal",
                                 command=lambda: self.controller.ShowPage( "Terminal" ),
                                 height=2 )
  self.terminalButton.grid( row=0, column=2, padx=10, sticky="ew" )
  #Set the same weight to each column
  self.settingsFrame.AlignColumns( 3 )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/flWVn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/flWVn.png" alt="enter image description here"></a></p>
  
  <h2>Problem</h2>
  
  <p>I wish columns of each frame had the same weight. As you can see I use the <code>AlignColumns</code> method for this purpose. And it is not as generic as I want it to be because I have to know the exact number of columns I use in the frame. I wonder if there is a way to know how many columns are already taken in <code>Tkinter.Frame</code>?</p>