Mark Summerfield | 28 Jun 2012 15:41

setting a minsize for gridded windows

Hi,

I want to set a minsize for a window. Sometimes the window is gridded
and sometimes not. When it is gridded its winfo_reqwidth() is in
characters not pixels and vice versa.

Is there any way to tell whether it is using characters or pixels so
that I can call minsize() with sensible values (e.g., minsize(100, 100)
if pixels but minsize(10, 10) if characters).

Thanks!

--

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html
Michael Lange | 28 Jun 2012 18:55
Picon

Re: setting a minsize for gridded windows

Hi Mark,

Thus spoketh Mark Summerfield <list <at> qtrac.plus.com> 
unto us on Thu, 28 Jun 2012 14:41:12 +0100:

> Hi,
> 
> I want to set a minsize for a window. Sometimes the window is gridded
> and sometimes not. When it is gridded its winfo_reqwidth() is in
> characters not pixels and vice versa.
> 
> Is there any way to tell whether it is using characters or pixels so
> that I can call minsize() with sensible values (e.g., minsize(100, 100)
> if pixels but minsize(10, 10) if characters).

According to man wm:

(...) the return value is a Tcl list containing four elements
corresponding to the current baseWidth, baseHeight, widthInc, and
heightInc; if window is not currently gridded, then an empty string is
returned.

So you should be able to check the window's "grid state" easily with
wm_grid(), if it's None, the window is not gridded:

>>> root = Tk()
>>> print root.wm_grid()
None
>>> print root.wm_grid(100, 100, 10, 10)
None
(Continue reading)

Mark Summerfield | 29 Jun 2012 10:27

Re: setting a minsize for gridded windows

Hi Michael,

On Thu, 28 Jun 2012 18:55:40 +0200
Michael Lange <klappnase <at> web.de> wrote:
> Hi Mark,
> 
> Thus spoketh Mark Summerfield <list <at> qtrac.plus.com> 
> unto us on Thu, 28 Jun 2012 14:41:12 +0100:
> 
[snip]
> So you should be able to check the window's "grid state" easily with
> wm_grid(), if it's None, the window is not gridded:
> 
> >>> root = Tk()
> >>> print root.wm_grid()
> None
> >>> print root.wm_grid(100, 100, 10, 10)
> None
> >>> print root.wm_grid()
> (100, 100, 10, 10)

That worked great---thanks!

--

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Rapid GUI Programming with Python and Qt" - ISBN 0132354187
            http://www.qtrac.eu/pyqtbook.html

Gmane