Finding a panel's size and/or storing extra data with the panel.

I

Ian Hobson

Hi all,

I am trying to write (Ruby and Tk 8.3) a TkPanel containing two TkPanels
where the sash between the panels can be dragged by the mouse to move
the border between the panels.

I have my sub panels placed with 'width'=>-1 making a small gap between.
I have used bind to call procedures at the correct times. (And set up
'cursor'=>??? On the panels, so that is correct).

How can I find out the size of the panels, and convert the x,y to parent
panel coordinates, so I can calculate the new 'relheight'=> values?

panel.height gives me 0 for all heights ?????

What are the x and y passed into the do_motionY call here?

@panel.bind('B1-Motion', proc{|x,y| do_motionY(x,y)}, "%x %y")

Are they screen co-ordinates? If so how can I get the top top of @Panel?

This effort is starting to look like there is a need for a decent TK in
Ruby book. TCL/Tk and Perl/Tk are all very well, but.... I don't know
them.

Regards - and thanks for your help.

Ian
 
H

Hidetoshi NAGAI

Hi,

From: Ian Hobson <[email protected]>
Subject: Finding a panel's size and/or storing extra data with the panel.
Date: Sun, 7 Dec 2003 07:42:14 +0900
Message-ID: said:
I am trying to write (Ruby and Tk 8.3) a TkPanel containing two TkPanels
where the sash between the panels can be dragged by the mouse to move
the border between the panels.

'ext/tk/sample/tkmultilistbox.rb' (included in 1.8.1-preview3) maybe
help you. It shows 3 panes without Panedwindow (Tk8.4 feature). Each
pane has one listbox with a horizontal scrollbar. And all listboxes
are controlled simultaneously by only one vertical scrollbar.
How can I find out the size of the panels, and convert the x,y to parent
panel coordinates, so I can calculate the new 'relheight'=> values?

panel.height gives me 0 for all heights ?????

Probably you must use TkWinfo.height(panel) or panel.winfo_height.
However, you will not be able to get the exact value before the panel
is mapped on your window.
What are the x and y passed into the do_motionY call here?

@panel.bind('B1-Motion', proc{|x,y| do_motionY(x,y)}, "%x %y")

Are they screen co-ordinates? If so how can I get the top top of @Panel?

The screen coordinates are given by %X and %Y.
The top corner coordinates of the widget are given by
TkWinfo.rootx(@Panel) (@Panel.winfo_rootx) and
TkWinfo.rooty(@Panel) (@Panel.winfo_rooty).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top