473,320 Members | 1,713 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: spinbox command and percent substitutions

The spinbox widget in Tk 8.4 has an option to allow a command
to be specified that is invoked when either the up or down buttons
of the spinbox are pressed, as in:

...
self.sb = Tkinter.Spinbox( self, command = self.sbcmd )
...

def sbcmd( self, *args ):
print args

However, it seems that no parameters are passed to the command (the
print statement outputs "()"), and so it is not possible to tell
which button was pressed to invoke the command. The Tk man pages
say that the "%d" substitution will be either "up" or "down", but
I cannot see how to get at these substitutions.

The same applies to other command options, e.g. validatecommand,
where the Tk man page implies that percent substitutions are used
to pass info into the command. How does one do this?

I'd like to use the command option to implement a spinbox to select
from a large range of values that are not regular (so the 'to', 'from',
'step' and 'value' options can't be used or are very clunky.)

Can anyone help? (This is Python 2.3, Windows install, if it's
relevant.)

--
Tony
Jul 18 '05 #1
1 3085
You'll have to arrange for the Tk -command to contain %x and %y
substitutions, and similarly for the -validatecommand.

The sequence would look something like this:
tkcmd = self.register(self.sbcmd)
self.sb = Tkinter.Spinbox(self, command=(tkcmd, "%x", "%y"))
...
def sbcmd(self, x, y):
print x, y
I don't have 8.4, so I can't test this out exactly.

Jeff

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the...
2
by: Stewart Midwinter | last post by:
I would like to link the contents of three OptionMenu lists. When I select an item from the first list (call it continents), the contents of the 2nd list (call it countries) would update. And in...
1
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF...
0
by: Askari | last post by:
Hi, I search on google a example for Spinbox (with Tkinter module). Can't find! If someone have a basic example for with a Spinbox, send me him! Because? I don't know how use this widget! :-( ...
2
by: Paul A. Wilson | last post by:
I'm new to Tkinter programming and am having trouble creating a reusable button bar... I want to be able to feed my class a dictionary of button names and function names, which the class will make....
0
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust...
2
by: Stewart Midwinter | last post by:
this has me puzzled; I've created a small test app to show the problem I'm having. I want to use subprocess to execute system commands from inside a Tkinter app running under Cygwin. When I...
1
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that...
12
by: 5N1P3R | last post by:
Hi I need a spinbox which when created can read a variable (which is an integer) from another location and use that variable for the starting value. i also need to only allow integers be input...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.