From: Torsten B. <re...@ma...> - 2013-12-07 22:22:27
|
Hi, in my application (that should run on Tk 8.6) I use a paned window (or ttk::panedwindow, which makes no difference) to show some widgets and hide (or "forget") them again based on what the user wants to see (using a toolbar). I have the problem that the scrollbars begin to be unresponsive on moving with the mouse (= clicking on the scrollbar and trying to move it) while using the scroll function of the Magic Mouse (= swiping the finger up or down the mouse) always works. I have tried to make an example code that shows this behaviour. Run the script below with TkCocoa. First you will see a listbox on the left and text widget on the right. You can easily scroll the listbox clicking on the scrollbar handle and mowing it up and down. Now change the view by clicking on "step 1". Then click on "step 2" to get the original view back. Now I cannot move the scrollbar any more. Moving the main window around on the screen sometimes makes it responsive again, sometimes also clicking a lot into the scrollbar and the trough will do, but then later it locks again. This only helps in this example code, not in my actual application code. I have read that using some [after idle] or [update] will help, but I cannot figure out how. Is anybody able to make this scrollbar work all the time?? Thanks very much for any help, Torsten proc ScrolledWidget {widget parent args} { # create a standard widget with scrollbars around # # wigdet -> name of the widget to be created # parent -> path to the frame, in which the widget and the scrollbars should # be created # # returns: the path to the created widget (frame) # ttk::frame $parent # Create widget attached to scrollbars, pass thru $args $widget $parent.list # Create scrollbars attached to the child widget ttk::scrollbar $parent.sx -orient horizontal -command [list $parent.list xview] grid $parent.sx -column 0 -row 1 -sticky ew $parent.list configure -xscrollcommand [list $parent.sx set] ttk::scrollbar $parent.sy -orient vertical -command [list $parent.list yview] grid $parent.sy -column 1 -row 0 -sticky ns $parent.list configure -yscrollcommand [list $parent.sy set] # Arrange them in the parent frame grid $parent.list -column 0 -row 0 -sticky ewsn grid columnconfigure $parent 0 -weight 1 grid rowconfigure $parent 0 -weight 1 # hide the original widget command from the interpreter: interp hide {} $parent # Install the alias: interp alias {} $parent {} ScrolledWidgetCmd $parent.list # fix the bindings for the child widget: bindtags $parent.list [lreplace [bindtags $parent.list] 0 0 $parent] return $parent } proc ScrolledWidgetCmd {self cmd args} { switch -- $cmd { widgetPath {return "$self.list"} default {return [uplevel 1 [list $self $cmd] $args]} } } panedwindow .p pack .p -expand 1 -fill both ScrolledWidget listbox .p.l for {set i 0} {$i < 30} {incr i} {.p.l insert end $i} .p add .p.l text .p.t .p add .p.t ScrolledWidget listbox .p.l2 for {set i 0} {$i < 1000} {incr i} {.p.l2 insert end $i} button .b -command expose1 -text "step 1" pack .b button .bb -command expose2 -text "step 2" pack .bb proc expose1 {} { .p paneconfigure .p.l -hide 1 .p paneconfigure .p.t -hide 1 if {".p.l2" ni [.p panes]} {.p add .p.l2 -stretch always} else {.p paneconfigure .p.l2 -hide 0} } proc expose2 {} { .p paneconfigure .p.l2 -hide 1 .p paneconfigure .p.l -hide 0 .p paneconfigure .p.t -hide 0 } |