473,320 Members | 2,004 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.

How to get PMW counter to call a function when value changes

2
Hi,
I have implemented a number of megawidget counters, and I would like them to call a function when their values change. Is this possible?

So far, I have only been able to get the counters to call my function when I enter keystrokes in the entryfield (excluding the up and down arrow keys, which do nothing). Here's a snippet:
Expand|Select|Wrap|Line Numbers
  1. myCounter.component('entryfield').bind("<Key>",myFunc)
  2.  
I would like the function to also be called when I click the uparrow and downarrow objects. However, if I do:
Expand|Select|Wrap|Line Numbers
  1. myCounter.component('uparrow').bind("<Button 1>",myFunc)
  2.  
then the uparrow loses its normal operation (I can put myCounter.increment() in myFunc, but when I click and hold the button, the counter only increments once, unlike the normal PMW counter behavior)

I also tried using entryfield_command, but that only handles <Enter> key events.
Expand|Select|Wrap|Line Numbers
  1. myCounter = Pmw.Counter(myFrame,
  2.     datatype = {'counter': 'real'},
  3.     entryfield_validate = {'validator': 'real', 'min': 0.0, 'max': 10.0},
  4.     entryfield_value = 2.0,
  5.     entryfield_command = myFunc,
  6.     entry_justify = 'center',
  7.     entry_width = 4,
  8.     orient = 'vertical',
  9.     increment = 0.1,
  10.     labelpos = 'w',
  11.     label_text = 'My text')
  12.  
So, is there a way for the PMW counter to call a function when its value changes?

Thanks in advance for your help
Nov 7 '11 #1

✓ answered by bvdet

Try this:
Expand|Select|Wrap|Line Numbers
  1. myCounter.component('uparrow').bind("<Button 1>",myFunc, add="+")

3 2226
bvdet
2,851 Expert Mod 2GB
Try this:
Expand|Select|Wrap|Line Numbers
  1. myCounter.component('uparrow').bind("<Button 1>",myFunc, add="+")
Nov 7 '11 #2
DaveJ
2
Bvdet,
Thank you; I'm extremely impressed! That works perfectly. Can you tell me how you figured that out so I know where to look in the future? I just ran help(Button.bind), and it mentions add, but it doesn't say anything about the values that add can take. Thanks again.
Nov 8 '11 #3
bvdet
2,851 Expert Mod 2GB
Check the Python documentation "Tkinter — Python interface to Tcl/Tk" section "24.1.6.7. Bindings and Events".
Nov 8 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jack | last post by:
Hello, <%@ Language=VBScript %> <% Response.Write "<form name=form1>" Response.Write "<SELECT id=select1 name=select1>" Response.Write "<OPTION value=1>One</OPTION>" Response.Write "<OPTION...
5
by: Lucy Randles | last post by:
I've written a VBA function that I then need to call in a form. Previously to do this I have written the call procedure in the same module as the function - i.e. Function callfunctionname() Call...
8
by: Michel Rouzic | last post by:
I'm sure that it's a dumb problem where i surely did something dumb, but, I got a problem, I got a variable that we'll call var1. in the main() function, this variable var1 (of type unsigned) of a...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
1
by: Rodger Dusatko | last post by:
In VB .NET I am having problems setting breaks. I want the break to be independant of any single function: for example: err.number or global variables When I try to set a break with the 'Data'...
3
by: mast2as | last post by:
hi guys I wonder if there's a way of doing something like that in C++ which is more elegant then the "basic" approach. I have lets say a class TOptions1 which has a few member variables. It is...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
2
by: Giridhara | last post by:
hi can any one help me in a text field im featching value from database,if i change the value in same i need to show alert msg
1
by: Gino Dicandio | last post by:
Hello, I actually use a counter on a webpage (This is an external script that reads and increments a value - It actually works) To do it, I use an inline javascript but I would like to unify the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: 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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.