470,591 Members | 2,313 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Tkinter, scale widget, and mouse clicks

So I've got a horizontal scale widget in my GUI. When I click the
mouse in the area to the right of the GUI, the scale advances by 1.

13
+-------------------------+
|<| [===] X |>|
+-------------------------+

||
\/

14
+-------------------------+
|<| [===] |>|
+-------------------------+

I want to change this, so it jumps by a larger amount (and likewise if
I click to the left of the slider).

Any clues?
(setting 'bigincrement' only works for CTRL-left / CTRL-right when the
widget has keyboard focus)

--
John.
Jul 18 '05 #1
2 3560
jf****@paradise.net.nz (John Fouhy) wrote in message news:<c0**************************@posting.google. com>...
So I've got a horizontal scale widget in my GUI. When I click the
mouse in the area to the right of the GUI, the scale advances by 1.

13
+-------------------------+
|<| [===] X |>|
+-------------------------+

||
\/

14
+-------------------------+
|<| [===] |>|
+-------------------------+

I want to change this, so it jumps by a larger amount (and likewise if
I click to the left of the slider).

Any clues?
(setting 'bigincrement' only works for CTRL-left / CTRL-right when the
widget has keyboard focus)


You can address the part of the scale widget you clicked on with
event.x/event.y, so maybe something like this might do what you want
(untested):

var = IntVar()
var.set(0)
sb = Scrollbar(master, variable=var)
sb.bind('<1>', jump)

def jump(event):
if sb.identify(event.x, event.y) == 'trough1':
var.set(var.get()-5)
return 'break'
elif sb.identify(event.x, event.y) == 'trough2':
var.set(var.get()+5)
return 'break'

I hope this helps

Michael
Jul 18 '05 #2
kl*******@web.de (klappnase) wrote in message news:<a7**************************@posting.google. com>...
jf****@paradise.net.nz (John Fouhy) wrote in message news:<c0**************************@posting.google. com>...
So I've got a horizontal scale widget in my GUI. When I click the
mouse in the area to the right of the GUI, the scale advances by 1.
I want to change this, so it jumps by a larger amount (and likewise if
I click to the left of the slider).
Any clues?

You can address the part of the scale widget you clicked on with
event.x/event.y, so maybe something like this might do what you want
(untested):

var = IntVar()
var.set(0)
sb = Scrollbar(master, variable=var)
sb.bind('<1>', jump)

def jump(event):
if sb.identify(event.x, event.y) == 'trough1':
var.set(var.get()-5)
return 'break'
elif sb.identify(event.x, event.y) == 'trough2':
var.set(var.get()+5)
return 'break'

I hope this helps

Michael


I had an idea of doing something like that, but I didn't know about
the 'identify' function.

Also, I am using the Scale widget, not the Scrollbar widget, but it
seems Scale has that function too.

(I wish Tkinter had better documentation)

Anyawy, your solution worked perfectly :-)

Thanks a lot,

--
John.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Elaine Jackson | last post: by
8 posts views Thread by Harlin Seritt | last post: by
2 posts views Thread by William Gill | last post: by
8 posts views Thread by rahulnag22 | last post: by
7 posts views Thread by =?iso-8859-1?q?Xavier_B=E9rard?= | last post: by
44 posts views Thread by bg_ie | last post: by
1 post views Thread by Helmut Jarausch | last post: by
7 posts views Thread by Peter Pearson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.