TkScrollbox with horizontal scrollbar

Discussion in 'Ruby' started by Enrico Schwass, Jun 6, 2005.

  1. Hello

    I recently found this very useful widget TkScrollbar. It works great, if
    you need a listbox with vertical scrollbar.
    What I am missing is some more documentation. What, if i need a
    horizontal bar or in my case both?

    I think there is an easy way to achieve this. Some parameters I miss??

    Thanks in advance
    Enno
    Enrico Schwass, Jun 6, 2005
    #1
    1. Advertising

  2. From: Enrico Schwass <>
    Subject: TkScrollbox with horizontal scrollbar
    Date: Mon, 6 Jun 2005 15:59:06 +0900
    Message-ID: <>
    > I recently found this very useful widget TkScrollbar. It works great, if
    > you need a listbox with vertical scrollbar.
    > What I am missing is some more documentation. What, if i need a
    > horizontal bar or in my case both?


    Here you are. Please see "<ruby-src>/ext/tk/sample/tktextframe.rb" also.
    ----------------------------------------------------
    #
    require 'tk'

    class TkXYScrollbox<TkListbox
    include TkComposite
    def initialize_composite(keys=nil)
    list = TkListbox.new(@frame)

    xscr = TkScrollbar.new(@frame)
    yscr = TkScrollbar.new(@frame)

    @path = list.path

    list.xscrollbar(xscr)
    list.yscrollbar(yscr)

    TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
    TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)

    list.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
    xscr.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
    yscr.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')

    delegate('DEFAULT', list)
    delegate('foreground', list)
    delegate('background', list, xscr, yscr)
    delegate('borderwidth', @frame)
    delegate('relief', @frame)

    configure keys if keys
    end
    private :initialize_composite
    end

    ################################################
    # test
    ################################################
    if __FILE__ == $0
    lst = TkXYScrollbox.new:)height=>7).pack
    ('A'..'Z').each_with_index{|s, n| lst.insert:)end, s*(n+1))}
    Tk.mainloop
    end
    ----------------------------------------------------

    Of course, you can use a TkScrollbox with a horizontal scrollbar.
    However, probably you'll have some trouble on layouting them.
    It is better to define a new class which use grid geometry manager
    instead of pack geometry manager.
    --
    Hidetoshi NAGAI ()
    Hidetoshi NAGAI, Jun 6, 2005
    #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. Marco Liedekerken

    Panel with horizontal scrollbar

    Marco Liedekerken, Jun 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,932
    Rajesh.V
    Jun 26, 2003
  2. Jeremy Chapman
    Replies:
    1
    Views:
    897
    szabelin
    Aug 15, 2003
  3. Lundy
    Replies:
    0
    Views:
    680
    Lundy
    Oct 6, 2004
  4. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    force horizontal scrollbar display on div

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,188
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Sep 2, 2005
  5. Mirela
    Replies:
    2
    Views:
    12,058
    Mirela
    Oct 13, 2003
Loading...

Share This Page