473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 3707
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Elaine Jackson | last post by:
I've got a script where a button gets pushed over and over: to cut down on the carpal tunnel syndrome I'd like to have the button respond to presses of the Enter key as well as mouse clicks; can...
8
by: Harlin Seritt | last post by:
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget root =...
2
by: William Gill | last post by:
I am trying to make a simple data editor in Tkinter where each data element has a corresponding Entry widget. I have tried to use the FocusIn/FocusOut events to set a 'hasChanged' flag (if a...
4
by: peter | last post by:
I've come across a weird difference between the behaviour of the Tkinter checkbox in Windows and Linux. The issue became apparent in some code I wrote to display an image in a fixed size canvas...
8
by: rahulnag22 | last post by:
I have created a button widget with a button click binding. The button initially has a state=disabled. I can see the greyed out version of the button in the GUI. But If I click on the button it...
7
by: =?iso-8859-1?q?Xavier_B=E9rard?= | last post by:
Hello everyone, I am wondering if there is a way to use custom drawing in Tkinter. I've been using it for few months, and all I know about custom drawing is to draw directly on a Canvas with...
44
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file...
1
by: Helmut Jarausch | last post by:
Hi, I don't want to reinvent the wheel but I cannot find it so far. Many editors have a so-called incremental search feature. As you type characters, elements of a set of strings which fit so...
7
by: Peter Pearson | last post by:
Tkinter makes it very easy to drag jpeg images around on a canvas, but I would like to have a "target" change color when the cursor dragging an image passes over it. I seem to be blocked by the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.