473,804 Members | 4,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3115
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(s elf.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
4021
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 extra step is necessary. This causes the "graph" function to execute when the button is created: Button(root, text='OK', command=graph(canvas))) However, this waits until the button is pressed (the desired behavior): def doit(): graph(canvas)
2
4639
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 turn the contents of the 3rd list (call it states would be updated by a change in the 2nd list. If anyone can share a recipe or some ideas, I'd be grateful! Here's some sample code that displays three OptionMenus, but doesn't update the list...
1
6378
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 image in the central area of a simple menu-bar app as shown below in the first code sample. But, when I set up my app with a class, as shown below in the second code sample, the image disappears. How can I correct this? I'm sure the answer would...
0
1387
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! :-( I can put a Spinbox on my canvas, I see it but can't change the "value" with up/down button. How I must do for that the "value" change? Askari N.B. My public e-mail adresse is invalid.
2
3252
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. My button bar is implemented a Frame subclass, which takes the button dictionary as an argument and displays the buttons on the screen: class OptionsBar(Frame): def __init__(self, buttonDict, parent=None) Frame.__init__(self, parent)
0
3589
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 accordingly. However, what I really want to happen is that the area of the canvas that the scrollbars show (the Scrollregion) should expand as the window grows. It doesn't currently do this. although, if the window shrinks smaller than the...
2
4089
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 open a python interpreter and run my subprocess command, all is well. But when I run the same command from inside a Tkinter app, I'm getting errors.
1
3604
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 I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that?
12
8665
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 into the text field by keyboard (and only has high as 999). lastly, whenever the spinbox value is changed (either by keyboard input or by clicking on the arrows) i need to be able to verify that it is an integer and then save its value into another...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.