0

I have an application made up of Frames, Frames in Frames and Labels in Frames. There is quite a lot of them and I am looking for a way to modify some of the default values.

I am particularly interested in modifying .columnconfigure() since I call .columnconfigure(0, weight=1) on each of the columns, in each frame. This does not help with the code cleanness.

Is there a way to set this behavior (ability to expand) globally?

WoJ
  • 27,165
  • 48
  • 180
  • 345

2 Answers2

3

No, there is no way to change the defaults. You can easily write your own grid function to automatically configure the weight of each column. You could do this by subclassing Frame, for instance.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Thank you - this is extremely useful. Reading further on the subject and particularly [one of your previous answers](http://stackoverflow.com/questions/7300072/tkinter-inherit-from-frame-or-not) I will completely redesign my application. – WoJ Jul 18 '14 at 06:23
-1

You can always do it in a loop

elements = [col0, col1, col2]
for element in elements:
    element.columnconfigure(0, weight=1)
k.rozycki
  • 635
  • 1
  • 5
  • 12
  • yes, that would work but my widgets are not organized in a list or dict - so there is no way to loop though them (the `Frame`s, for instance, are assigned to standalone variables) – WoJ Jul 17 '14 at 15:45