[EMAIL PROTECTED] wrote:
I am trying to prevent a user from resizing a frame beyond its
"natural" size as given by winfo_reqwidth and winfo_reqheight, without
any success. Can anyone make any suggestions, based on my code below?

Thanks!

from Tkinter import *

class Table(Frame):
    def __init__(self, master,
                 rows=['row 1'], cols=['col 1'],
                 row_labels=True,
                 col_labels=True,
                 row_buttons=True,
                 col_buttons=True):
        Frame.__init__(self, master)
        self.rows = rows
        self.cols = cols
        self.row_labels = row_labels
        self.col_labels = col_labels
        self.row_buttons = row_buttons
        self.col_buttons = col_buttons
        self.col_width = 6
        self.draw()
        self.bind('<Configure>', self.changed)
    def changed(self, ev):
        w, h = self.winfo_reqwidth(), self.winfo_reqheight()
        cfg = {}
        if ev.height > h:
            cfg['height'] = h
        if ev.width > w:
            cfg['width'] = w
        if cfg:
            self.config(**cfg)   ######## this has no effect ########

I'm not sure I follow your code but this method is bound to the <Configure> event *but* needs to return the string "break" so that it does not pass that event on to the default event handler.



     def changed(self, ev):
         w, h = self.winfo_reqwidth(), self.winfo_reqheight()
         cfg = {}
         if ev.height > h:
             cfg['height'] = h
         if ev.width > w:
             cfg['width'] = w
         if cfg:
             self.config(**cfg)   ######## this has no effect ########
         return "break"

This may do what you want.....

Cheers
Martin

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to