[Tkinter-discuss] scrolling more widgets with one scrollbar
klappnase at web.de
Thu Feb 3 19:12:46 CET 2011
Thus spoketh "Martin B." <spooky.ln at tbs-software.com>
unto us on Thu, 3 Feb 2011 18:34:24 +0100:
> Thanks this helps a lot.
> Your code for keypress looks like you call internal Tcl/Tk commands ?
Yes, as I said these commands are defined in text.tcl (on linux this can
usually be found at /usr/lib/tk8.x or so), and the widget.tk.call()
mechanism is the magic that allows us to access Tcl/Tk's internal
commands from Python. Once you understood how to handle Tcl/Tk commands
from Python it is quite straightforward and a great and powerful way to
enhance Tkinter's capabilities, so I absolutely recommend to have a
closer look at it ;)
A great way to learn using tk.call() is to compare for example the button
widget's tcl man page (just try "man button") with the code from
"class Button" in Tkinter.py, you will easily see how this works.
> Seems like my for mousewheel.
> But <MouseWheel> dont generate any signal i must use Button-4 and
> Button-5 on linux.
I think <MouseWheel> is windows and OSX only.
> def mousewheel_cb(event):
> direction = 1 if event.num == 5 else -1
> for win in self.textwindows:
> win.yview('scroll', direction, 'units')
You should be careful here, according to text.tcl the default on X11 is
+/- 50 pixels , so your success here depends if one unit equals to 50
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
There's coffee in that nebula!
-- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud"
More information about the Tkinter-discuss