Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Tkinter, scale widget, and mouse clicks

Reply
Thread Tools

Tkinter, scale widget, and mouse clicks

 
 
John Fouhy
Guest
Posts: n/a
 
      06-21-2004
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.
 
Reply With Quote
 
 
 
 
klappnase
Guest
Posts: n/a
 
      06-22-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (John Fouhy) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
 
 
 
John Fouhy
Guest
Posts: n/a
 
      06-25-2004
(E-Mail Removed) (klappnase) wrote in message news:<(E-Mail Removed). com>...
> (E-Mail Removed) (John Fouhy) wrote in message news:<(E-Mail Removed). 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RowCancelingEdit and RowEditing take two mouse-clicks to work? dev648237923 ASP .Net Datagrid Control 3 11-17-2006 01:21 AM
Heres a mouse theres a mouse what a mouse do? unholy Gaming 37 09-17-2006 08:59 AM
The Definitive Chord & Scale Bible - Literally EVERY chord and scale! Kind of Blue2 Digital Photography 1 02-08-2005 10:14 PM
Clicks and double-clicks PontiMax ASP .Net Datagrid Control 2 07-14-2004 11:00 AM
phantom mouse clicks (laptop, win2k) news.bwsys.net Computer Support 2 04-24-2004 06:39 PM



Advertisments