Re: Parse input file and create widgets
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Parse input file and create widgets

From: Ani <anilby@gmail.com>
Date: Mon May 30 2005 - 07:17:38 CEST

Donald Arseneau wrote:
> anil writes:
>
> > | One List box here | and one more list box here
> > -------------------------------------------------------------------
> > |<this is a frame>
> >
> > The number of widgets in the bottom frame depends on the input file.
> > I am able to create all the widgets but the frame is not scrollable.
> > I tried the methods posted in comp.lang.tcl to create a scrolled frame.
> > But I couldn't get the frmae scrolled.
>
> .... code snipped.
>
> Your code shows only scrollbars for the listboxes, and no attempt
> to make a scrollable frame below them. I would say to replace
> frame#1 with a scrollable frame, as found on Tcl wiki pages and
> "posted in comp.lang.tcl", but you say you tried that. Why don't
> you post your best attempt, and people can correct it.
>
> It probably is hard to make a scrolled frame completely within
> specTcl, because you can't drag a frame onto a canvas, but you
> could set up the scrolling in your other code.
>
> By the way, your listboxes of height 1 don't allow much room
> for the corresponding scrollbars! I would give a bigger window
> into the listbox by specifying more height.
>
> --
> Donald Arseneau asnd@triumf.ca

Here goes the code that I tried:

---------------------------------------------------------
    toplevel $base.top1
    frame $base.top1.new_frame -bd 4
    canvas $base.top1.new_frame.canvas1 -width 30 -height 30 \
      -yscrollcommand [list $base.top1.new_frame.sc1 set]
    scrollbar $base.top1.new_frame.sc1 -orient vertical \
        -command [list $base.top1.new_frame.canvas1 yview]

    menubutton $base.menubutton#1 \
        -menu "$base.menubutton#1.m" \
        -borderwidth 2 \
        -justify left \
        -relief groove \
        -text File

    menubutton $base.menubutton#2 \
        -menu "$base.menubutton#2.m" \
        -borderwidth 2 \
        -justify left \
        -relief groove \
        -text Edit

    message $base.testcases \
        -background white \
        -text Protocol \
        -width 60

    message $base.teststatus \
        -background white \
        -text Messages \
        -width 70

    listbox $base.listboxprotocols \
        -background white \
        -height 10 \
        -width 10 \
        -selectmode single \
        -yscrollcommand "$base.protocolscroll set"

    scrollbar $base.protocolscroll \
        -command "$base.listboxprotocols yview"

    listbox $base.listboxmessages \
        -background white \
        -height 10 \
        -width 10 \
        -yscrollcommand "$base.messagesscroll set"

    scrollbar $base.messagesscroll \
        -command "$base.listboxmessages yview"

    button $base.button#3 \
           -text --> \
           -command show_messages
...
.
.
.
    grid $base.top1.new_frame -in $root -row 13 -column 1 \
        -columnspan 50 \
        -rowspan 78 \
        -sticky nw
    grid $base.top1.new_frame.canvas1 -in $root -row 13 -column 1 \
        -columnspan 50 \
        -rowspan 78 \
        -sticky nwes
    grid $base.top1.new_frame.sc1 -in $root -row 13 -column -20 \
        -rowspan 20 \
        -sticky ns
.
.
.
set fr1 [frame $base.top1.new_frame.canvas1.fr -relief raised
-borderwidth 10]
$base.top1.new_frame.canvas1 create window 0 0 -anchor sw -window $fr1

------------------------------------------------------
Now .top1.new_frame.canvas1.fr should be made scrollable.
Received on Thu Sep 29 14:19:37 2005