zProblem

norseman norseman at hughes.net
Wed Apr 15 17:09:11 EDT 2009


Gabriel Genellina wrote:
> En Tue, 14 Apr 2009 18:42:32 -0300, norseman <norseman at hughes.net> 
> escribió:
> 
>> Gabriel Genellina wrote:
>>> En Mon, 13 Apr 2009 15:13:53 -0300, norseman <norseman at hughes.net> 
>>> escribió:
>>>> Gabriel Genellina wrote:
>>>
>>
>>> 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)
>>> [...]
> 
>> 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.
> 
> That's not really true. "place" takes a position and a size; both can be 
> relative (percent, based on its parent), absolute (in pixels, inches, or 
> other units), and you can even mix both types. x,y are absolute; 
> relx,rely are relative; same goes for height,width and relheight,relwidth.
> 
> The available absolute units are: 200 (an integer, *not* 200.0) means 
> 200 pixels; "200m" (a string) means 200 mm, "200p" means 200 points 
> (1/72"), "200i" means 200 inches, and finally "200c" means 200 cm. So 
> you can define the exact size and position for each element.
> 
I had tried these in "grid" and didn't get very far so I assumed things 
had changed since the docs were written. Good to know.

> Relative sizes and positions are automatically scaled when the container 
> is resized -- in my example, if you resize the window all the "parcels" 
> grow and shrink accordingly.
> 
YES - very nicely so.

> With absolute sizes, you don't have to redo the math each time, but 
> resizing isn't automatic. Perhaps absolute sizes are better suited for 
> your application.
>

Yes. Mine is rather like a dashboard that unfortunatly takes up more 
cockpit (screen) than I like. If the user shrinks it they will have a 
hard time trying to pick the selection of choice and if they expand it 
(unlikely) it will put enough off screen to cause another problem, 
omissions.

>> Gabriel - THANK YOU VERY MUCH!!!!!
>> May not be politically correct but:
>> Whatever your gender - Please give yourself a good hug for me.
> 
> Glad to be of any help. I'm a male, btw.
> 


Mucho obligó al Señor;


Steve



More information about the Python-list mailing list