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

Discussion in 'Ruby' started by Ian Hobson, Dec 6, 2003.

  1. Ian Hobson

    Ian Hobson Guest

    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
    --
    Ian - posting to a Newsgroup. Please remove everything to reply.
     
    Ian Hobson, Dec 6, 2003
    #1
    1. Advertising

  2. Re: Finding a panel's size and/or storing extra data with thepanel.

    Hi,

    From: Ian Hobson <>
    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: <2AmQ1jLmql0$>
    > 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).
    --
    Hidetoshi NAGAI ()
     
    Hidetoshi NAGAI, Dec 7, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Merek
    Replies:
    0
    Views:
    1,982
    Merek
    Dec 3, 2003
  2. toton
    Replies:
    11
    Views:
    722
    toton
    Oct 13, 2006
  3. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,661
    Michael Jung
    May 25, 2008
  4. Jonathan Wood
    Replies:
    1
    Views:
    522
    Jonathan Wood
    Jun 2, 2008
  5. mathieu
    Replies:
    3
    Views:
    609
    Bo Persson
    Sep 4, 2009
Loading...

Share This Page