Jump to content
Sagar Desai

How to create vertical scroll bar for window

Recommended Posts

hello everyone I have created a window using  hwt::CreateWindow win

 

I have added only one row now to reduce size of Quote. Number of rows in actual script are in loop so my number of rows sometimes exceeds 100. So I need scroll to window.

 

So how can I add scroll to it

 

And I seardched for  hwt::CreateWindow win help for all pther commands help is easily available in HM  help but I didnt find any help related to these commands, So anybody direct me to proper help for hwt commands and specifically  hwt::CreateWindow win

 

Quote

proc ::compQuery::window {} {
    variable str_slave;
    variable str_master1 "";
    variable str_master2 "";
    variable str_master3 "";
    variable str_master4 "";
    variable str_master5 "";
    variable str_master6 "";
    variable str_master7 "";
    variable str_master8 "";
    variable e1; 
    variable e2;
    variable l1; 
    variable l2;
    variable e3;
    variable l3; 
    variable e4;
    variable l4; 
    variable e5;
    variable l5;
    variable e6;
    variable l6;
    variable e7;
    variable l7;
    variable e8;
    variable l8;
    variable ang_incr;
    variable def_val;

 

    set dlgWidth  [ hwt::DluWidth 100 [ hwt::AppFont ]];
    set dlgHeight [ hwt::DluHeight  250 [ hwt::AppFont ]];

    set min_dlgWidth  [ hwt::DluWidth  250 [ hwt::AppFont ]];
    set min_dlgHeight [ hwt::DluHeight  200 [ hwt::AppFont ]];

    hwt::CreateWindow win \
        -minsize 200 100\
        -maxsize 2000 2000 \
        -noGeometrySaving \
        -geometry ${dlgWidth}x${dlgHeight} \
        -cancelButton Cancel \
        -defaultButton Cancel \
        -acceptButton Accept \
        -minSize $min_dlgWidth $min_dlgHeight \
        -acceptFunc "::compQuery::GetcompVar" \
        -cancelFunc "::compQuery::Cancel_func" \
        -windowtitle "Stress contour capture script" \
        -post;

    #Create recess to hold frames
    set recess [hwt::WindowRecess win];
        

    grid columnconfigure $recess 1 -weight 1 ;

    set l1 [::hwtk::label $recess.l1 -text "Evaluation criteria for Max principal stress:"]
    set e1 [::hwtk::entry $recess.e1 -width 200 -takefocus 1 -help "Entered value is max limit above this shown as grey colour" -textvariable  ::compQuery::str_master1];
    grid $l1 -row 1 -col 0 -sticky w -padx 4 -pady 4;
    grid $e1 -row 1 -col 1 -sticky e -padx 4 -pady 4;
    #default value $recess.e1 set 315;

  
    hwt::KeepOnTop win
   }

Share this post


Link to post
Share on other sites

Hi

There is no option to scroll a toplevel

You have to use text box or canvas widget to do it

Another way, use package BWidget which has tk classes to create scrollable frame and toplevel

Share this post


Link to post
Share on other sites

Hello, 

I studied some help on web now I am able to get scroll bar but not able to fix content in  between scroll bar

 

Now I am doing trial and error to get final out come

 

mean while can anybody look at my script and suggest improvement

Quote

namespace eval ::compQuery {
variable str_master1 "";
    variable str_master2 "";
    variable str_master3 "";
    variable str_master4 "";
    variable str_master5 "";
    variable str_master6 "";
    variable str_master7 "";
    variable str_master8 "";
    variable ang_incr;
    variable def_val;
}


proc ::compQuery::window {} {
    variable str_slave;
    variable str_master1 "";
    variable str_master2 "";
    variable str_master3 "";
    variable str_master4 "";
    variable str_master5 "";
    variable str_master6 "";
    variable str_master7 "";
    variable str_master8 "";
    variable e1; 
    variable e2;
    variable k1; 
    variable k2;
    variable k3; 
    variable k4;
    variable k5; 
    variable k6;
    variable l1; 
    variable l2;
    variable e3;
    variable l3; 
    variable e4;
    variable l4; 
    variable e5;
    variable l5;
    variable e6;
    variable l6;
    variable e7;
    variable l7;
    variable e8;
    variable l8;
    variable ang_incr;
    variable def_val;

    set dlgWidth  [ hwt::DluWidth 100 [ hwt::AppFont ]];
    set dlgHeight [ hwt::DluHeight  250 [ hwt::AppFont ]];

    set min_dlgWidth  [ hwt::DluWidth  250 [ hwt::AppFont ]];
    set min_dlgHeight [ hwt::DluHeight  200 [ hwt::AppFont ]];

    hwt::CreateWindow win \
        -minsize 200 100\
        -maxsize 1000 100 \
        -noGeometrySaving \
        -geometry ${dlgWidth}x${dlgHeight} \
        -cancelButton Cancel \
        -defaultButton Cancel \
        -acceptButton Accept \
        -minSize $min_dlgWidth $min_dlgHeight \
        -acceptFunc "::compQuery::GetcompVar" \
        -cancelFunc "::compQuery::Cancel_func" \
        -windowtitle "Stress contour capture script" \
        -post;

    #Create recess to hold frames
    set recess [hwt::WindowRecess win];
    
    set types {
        {{H3D File}      {".h3d" }        }
        {{OP2 File}      {".op2" }        }
        {{All Files}             * }
    }    

    grid columnconfigure $recess 1 -weight 1 ;
    
    set z [tk::listbox $recess.z -yscrollcommand ".ss set" -xscrollcommand ".s set" -height 5 -width 20]
    set y [ttk::scrollbar $recess.ss -command ".y$ yview" -orient vertical ]
    set x [ttk::scrollbar $recess.s -command ".x xview" -orient horizontal ]
    grid [set z] -column 0 -row 0 -sticky nwes;
    grid [set y] -column 1 -row 0 -sticky ns;
    grid [set x] -column 0 -row 1 -sticky ew
     
     for {set j 1} {$j <= 4 } {incr j} {
     
    insert end set l$j [::hwtk::label $recess.l$j -text "Evaluation criteria for Max principal stress:"]
    insert end set e$j [::hwtk::entry $recess.e$j -width 200 -takefocus 1 -help "Entered value is max limit above this shown as grey colour" -textvariable  ::compQuery::str_master1];
    insert end set k$j [::hwtk::label $recess.k$j -text "fuck"]
    
    $recess.z grid [set l$j] -row $j -col 0 -sticky w -padx 4 -pady 4;
    $recess.z grid [set e$j] -row $j -col 1 -sticky e -padx 4 -pady 4;
    $recess.z grid [set k$j] -row $j -col 2 -sticky e -padx 4 -pady 4;

    #default value $recess.e1 set 315;
    }
    hwt::KeepOnTop win
    
    
}

proc ::compQuery::Cancel_func {args} {
         catch {destroy .win};
}

::compQuery::window
 

 

Share this post


Link to post
Share on other sites

Hi,

This is a sample using textbox as scrollable window, that you don't need to care about scrollbars

set w .myToplevelWindow
::hwtk::toplevel $w -title "Sample scrollable window"
pack [::hwtk::text $w.t -width 80 -height 25] -side top -fill both -expand 1
pack [::hwtk::frame $w.f] -side top -fill x
pack [::hwtk::button $w.f.btnCancel -text Cancel -command ::p_btnCancel_Invoke] -side right -anchor e
pack [::hwtk::button $w.f.btnOK -text OK -command ::p_btnOK_Invoke] -side right -anchor e
set f $w.t.text.f
$w.t.text window create end -window [::hwtk::frame $f]
for {set i 0} {$i<100} {incr i} {
    set lbl [::hwtk::label $f.lbl$i -text "label [expr 1+$i]"]
    set ent [::hwtk::entry $f.ent$i -width 20]
    grid $lbl $ent -row $i
}

 

Share this post


Link to post
Share on other sites
On 6/28/2017 at 11:42 AM, tinh said:

Hi,

This is a sample using textbox as scrollable window, that you don't need to care about scrollbars


set w .myToplevelWindow
::hwtk::toplevel $w -title "Sample scrollable window"
pack [::hwtk::text $w.t -width 80 -height 25] -side top -fill both -expand 1
pack [::hwtk::frame $w.f] -side top -fill x
pack [::hwtk::button $w.f.btnCancel -text Cancel -command ::p_btnCancel_Invoke] -side right -anchor e
pack [::hwtk::button $w.f.btnOK -text OK -command ::p_btnOK_Invoke] -side right -anchor e
set f $w.t.text.f
$w.t.text window create end -window [::hwtk::frame $f]
for {set i 0} {$i<100} {incr i} {
    set lbl [::hwtk::label $f.lbl$i -text "label [expr 1+$i]"]
    set ent [::hwtk::entry $f.ent$i -width 20]
    grid $lbl $ent -row $i
}

 

Can you modify this, so i create a  subframe inside which is scrollable. @tinh

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...