How can I make the scrollbar work properly ???
Hi all of you guys,
Actually Im trying to make a browser tab with scrollbar (because in my situation, there are many widgets in the browser tab so we dont have enough space for them), however I could not make it work properly...!!!
If anybody who know how to do it, please help me to solve the problem.
here I attached my code for your convenience
your help will be appreciated
Thanks
------------------------------------
# making tab in the browser
proc Make_TAB { } {
lappend auto_path{<path to the folder containing hwt folder>}
package require hwt; #to import the hwt package
set tabName 'System_Parameters';
hw browser delete $tabName;
hw browser add $tabName end [ hw browser get frame $tabName ];
hw browser select $tabName;
set frm [ hw browser get frame $tabName ];
set bclose [::hwt::CanvasButton $frm.bclose [::hwt::DluWidth 8] [ ::hwt::DluHeight 8 ] \
icon msclose iconH 1 iconV 1 \
relief flat help 'Exit Program' takefocus 1 \
command 'hw browser delete $tabName' ];
pack $bclose -side top -anchor ne -padx 5 -pady 5 ;
#---- how can I make the scrollbar work properly ??? --------
set scrb [scrollbar $frm.scrb -command '$frm yview']
pack $scrb -side right -anchor nw;
#------------------------------------------------------------
set labelWidth 27;
set entryWidth 15;
#section label
set section1 [label $frm.section1 \
-text 'SYSTEM PARAMETERS' \
-justify left \
-anchor nw \
-font [hwt::AppFont]];
pack $section1 -side top -anchor nw;
hwt::AddPadding $frm -side top -height [hwt::DluHeight 5];
# frame1
set frame1 [frame $frm.frame1];
pack $frame1 -side top -anchor nw;
hwt::AddPadding $frame1 -side left -width [hwt::DluWidth 15];
set entry11 [ hwt::AddEntry $frame1.entry11 \
-label 'Mass (kg)' \
-labelWidth $labelWidth \
-entryWidth $entryWidth \
-text '' \
-textvariable mass_rocket \
-validate real \
-state normal \
-withoutPacking];
pack $entry11 -side top -anchor nw;
set entry12 [ hwt::AddEntry $frame1.entry12 \
-label 'Force (N)' \
-labelWidth $labelWidth \
-entryWidth $entryWidth \
-text '' \
-textvariable mass_b2 \
-validate real \
-state normal \
-withoutPacking];
pack $entry12 -side top -anchor nw;
hwt::AddPadding $frame1 -side bottom -height [hwt::DluWidth 380];
# buttons Load_Initial_Model, Run
set btn1 [button $frm.btn1 -width 16 -height 2 -text {Load Initial Model} -command {Open_Model}];
pack $btn1 -side left -padx 22 -pady 5 -anchor nw;
set btn2 [button $frm.btn2 -width 16 -height 2 -text {Analysis Setting} -command {Analysis}];
pack $btn2 -side left -padx 16 -pady 5 -anchor nw;
}
# end proc Make_TAB
# main code
set isFirst True;
Make_TAB;
# end main code
---------------------------
Answers
-
Hi
Maybe we cannot scroll a frame
Try using a textbox with scrollbar, and put your widgets on it
using hwt::CheckScrollBars $textName $textWidth $textHeight to add scrollbars to the textbox
0 -
Dear tinh,
First Im greatly appreciated your kindness reply. Actually, I tried many times for making the textbox with scrollbar on the browser tab, however it still can not work properly ... here I attached my tcl code, if you dont mind please help me to add scrollbar so that it work properly.
your help will be highly appreciatedbest regards
MDD
------------------------------
lappend auto_path{<path to the folder containing hwt folder>}
package require hwt; #to import the hwt package
set tabName 'System_Parameters';
hw browser delete $tabName;
hw browser add $tabName end [hw browser get frame $tabName];
hw browser select $tabName;
set frm [ hw browser get frame $tabName ];
set bclose [::hwt::CanvasButton $frm.bclose [::hwt::DluWidth 8] [ ::hwt::DluHeight 8 ] \
icon msclose iconH 1 iconV 1 \
relief flat help 'Exit Program' takefocus 1 \
command 'hw browser delete $tabName' ];
pack $bclose -side top -anchor ne -padx 5 -pady 5;
# -----please help me to add scrollbar with the box-----------
set box [hwt::AddCanvasBox $frm withbothScrolls]
pack $box -anchor nw -fill both -expand 1 -padx 4 -pady 4;
#-------------------------------------------------------------
# buttons Load_Initial_Model, Run
set btn1 [button $frm.btn1 -width 16 -height 2 -text {Load Initial Model} -command {Open_Model}];
pack $btn1 -side left -padx 22 -pady 5 -anchor nw;
set btn2 [button $frm.btn2 -width 16 -height 2 -text {Analysis Setting} -command {Analysis}];
pack $btn2 -side left -padx 16 -pady 5 -anchor nw;
----------------------
0 -
Hi, did you overcome the problem?
try download bwidget package and put it in hw/tcl folder
below is sample code
#set up tabset tabname tinhset frmname .tinhdestroy $frmnamehm_framework removetab $tabnameframe $frmnamehm_framework addtab $tabname $frmname#set up scrollable frameset frmgrand [frame $frmname.frmgrand]set frmparent $frmgrand.frmparentpackage require BWidgetScrollableFrame $frmparentset frmscroll [$frmparent getframe]set hscroll [scrollbar $frmgrand.hscroll -orient h -command '$frmparent xview']set vscroll [scrollbar $frmgrand.vscroll -orient v -command '$frmparent yview']$frmparent configure -xscrollcommand '$hscroll set' -yscrollcommand '$vscroll set'#set up layoutgrid $frmparent $vscroll -row 0 -sticky newsgrid $frmparent $hscroll -col 0 -sticky newsgrid rowconfigure $frmparent 0 -weight 1grid columnconfigure $frmparent 0 -weight 1pack $frmgrand -anchor nw -fill both -expand 1bind $frmgrand <Configure> '$frmparent configure -width \[expr %w - \[winfo width $vscroll\]\] \-height \[expr %h - \[winfo height $hscroll\]\]'#just for testfor {set i 0} {$i < 10} {incr i} {set frm$i [frame $frmscroll.frmtest$i]pack [set frm$i] -side left -anchor nwfor {set j 0} {$j < 50} {incr j} {set btn$j [button [set frm$i].btn$j -text Button$i$j]pack [set btn$j] -side top -anchor nw}}0 -
Dear tinh,
by following your code & advices, finally my problem has solved.
Im greatly appreciated your kindness help, especially spending your time and effort for making the demo script.
again, thanks you very much for your kindness help.
best regards
Mai Duc Dai
0