zProblem

norseman norseman at hughes.net
Tue Apr 14 17:42:32 EDT 2009


Gabriel Genellina wrote:
> En Mon, 13 Apr 2009 15:13:53 -0300, norseman <norseman at hughes.net> 
> escribió:
>> Gabriel Genellina wrote:
>
...(snip)

>> I can't visualize that working properly in my current need.  The 
...(snip)

> Below there is an attempt to reproduce the layout you describe in the PDF:
> 
> from Tkinter import *
> root = Tk()
> pane = Frame(root, width=400, height=300)
> pane.pack(fill="both", expand=1)
> w1 = Label(pane, text="1", bg="white")
> w1.place(relwidth=0.1, relheight=0.5)
> w2 = Label(pane, text="2", bg="yellow")
> w2.place(relwidth=0.25, relheight=0.3, relx=0.1)
> w3 = Label(pane, text="3", bg="red")
> w3.place(relwidth=0.2, relheight=0.2, relx=0.1, rely=0.3)
> w4 = Label(pane, text="4", bg="cyan")
> w4.place(relwidth=0.05, relheight=0.2, relx=0.3, rely=0.3)
> w5 = Label(pane, text="5", bg="blue")
> w5.place(relwidth=0.35, relheight=0.5, rely=0.5)
> w6 = Label(pane, text="X", bg="gray")
> w6.place(relwidth=0.25, relheight=1, relx=0.35)
> w7 = Label(pane, text='Rest of master control parceled as "whatever"', 
> bg="white")
> w7.place(relwidth=0.40, relheight=1, relx=0.60)
> root.mainloop()
> 
...(snip)
> 
> The only mismatch with your dictionary definition of "grid" would be the 
> "uniform" part -- and from this Wikipedia article [1] you can see there 
> are rectangular grids in addition to square grids (and triangular, and 
> hexagonal, and...) so it's not just the idea of a crazy Tk designer...
> 

Grids are uniform! Same size, non-changing across whole backdrop. There 
is nothing in uniform that says X==Y. Units along axis need not be same. 
  Corners don't even have to be 90degrees. (Spherical) But they must 
measure as same size cells across the board. Just like any grid paper.
For those reading this that just said "AH-Hah!", Spherical (Lat./Long.) 
is not measured in Cartesian (distance like feet or meter) but in angles 
(like 7 and 1/2 minute USGS Quads). 7.5minutes of Longitude at the 
equator does not have the same arc length as 7.5minutes at the poles. 
But both are 7.5minutes and thus form a (polar) grid.
ENOUGH OF THIS - sorry for being long winded.

Whoever wrote Tk was not crazy. Just didn't use a dictionary. :)

>> Are there any other GUI's that run Python code unchanged on Linux and 
>> Windows?
> 
> Sure. I like wxPython. The question "Which is the best GUI toolkit?" 
> arises about once per month in this group, see past messages...
> 
I took a look before I wrote in.  Based on initial words used I chose 
Tkinter.  The upcomming PyGUI holds great promise.  I think they used a 
dictionary. :)

> [1] http://en.wikipedia.org/wiki/Grid_(spatial_index)
> 
> 
NOW - back to the program snippet Gabriel has so graciously provided.

Anyone having the same problem I have had needs to copy/paste the effort 
and play with it a bit.

WOW! - it's what I've been trying to do!!!!!  (much more YES than not)

One can substitute a Frame widget for the Label widget and see how it 
will work.  Do take note that as you traverse away from the 0,0 (here 
assumed to be top left) point the prior (sum) of the prior widget(s) 
relwidth (to left) goes into the relx and the same addition to the prior 
relheight(s) (above) goes into the rely displacements of the current. 
Also take note of how the parcels flush out at logical places.
Place is not a grid (it's parcelling) and it's based on units of "%" of 
Frame it is used in.  That is: Place uses a "%" value rather than a 
finite distance. Thus, to have two different, but same screen size, 
frames, each in a differently fixed sized frame of it own, YOU WILL HAVE 
TO REDO THE MATH. Even if both are hooked at the 0,0 of their respective 
masters.
A thought: If all frames are fixed size (at least at first) then the 
math is straight forward.  Make sure any text is accounted for early on 
or it won't work and becomes, as another Gabriel has noted -  ugly. 
Because when the text isn't fitting you will have some major refitting 
which means lots and lots of math to be redone.  And that's the ugly.


Gabriel - THANK YOU VERY MUCH!!!!!
May not be politically correct but:
Whatever your gender - Please give yourself a good hug for me.


Steve




More information about the Python-list mailing list