473,396 Members | 1,996 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,396 software developers and data experts.

Does changing a Tkinter Variable bound to a widget invoke its'command' callback function?

I am writing a simple (maybe a bit conveluded, but I just started
learning Tkinter) program that uses a 'notebook' code snippet from a
python cookbook. It creates a customizable frame and radio button for
each 'tab' and uses .forget to hide the frames that aren't 'current'.
I modified it to use a Scale slider bar instead of radio buttons.

What my program does is create a parent notebook object, and in each
notebook frame, child notebooks are created. All the sliders are
created with:

command=lambda x: self.display(int(x))

Which displays the contents of the associated notebook frame (via
forget/pack). All of this also works fine, but I wanted it to be a
little more user-friendly by linking all the sliders on the child
notebooks using a control IntVar so that each child notebook can be on
the same page while scrolling through them. The problem is that when
the currently displayed slider is moved, it updates the current child
notebook, but not the notebooks of the hidden frames. Their sliders
are moved when they are next displayed, but the associated frames are
not updated, so there is a mismatch between slider and frame until
that specific slider is moved.

I can't find much information on control variables with respect to
Scale widgets, so any insight, hints, or suggestions would be greatly
appreciated.

Some snippets of the involved routines:

def __init__(self, master, size, start=0, side=LEFT, choice=None):

self.active_fr = start
self.size = size
if(choice):
self.choice = choice
else:
self.choice = IntVar(value=start)

....

# create slider
self.slide = Scale(self.rb_fr, variable=self.choice,
orient=self.orient,
from_=start, to=(size-start+1), length=200,
command=lambda x: self.display(int(x)))
....

def display(self, fr):
self.frames[self.active_fr].forget()
self.frames[fr].pack(fill=BOTH, expand=1)
self.active_fr = fr
Nov 29 '07 #1
0 1101

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

Similar topics

2
by: John Pote | last post by:
Running my programme in Python 2.3.4 I received the following msg in the consol :- (Pent III running W2K prof) """ Exception in Tkinter callback Traceback (most recent call last): File...
2
by: IKdev | last post by:
What are my options to invoke function (method) in this case: myclass{ private DataSet _userData; //Property in the class: public DataSet UserData (string dsource){ get {return _userData;}...
2
by: Sean | last post by:
Hi all, I know that some variables are stored on heaps and some on stack in C++. How about functions? where does function reside on memory? Is it stack or heap? And are both function (not...
0
by: fb | last post by:
Hi, I have a page with left frame and right frame. From left frame page, I manage to code a script to invoke Button1_Click which resides in a right frame page, provided the Button_Click function...
4
by: arvind | last post by:
How to pass the variables defined inside the function to the another function on click event of the button in Tkinter? pleas send me a sample code if anybody has it. thanx
5
by: archana | last post by:
Hi all, I am having one confusion regarding invoking method through threading. I have delcared one delegate. and i have one class which has parameter of type delegate which i declared. I...
1
by: Horace Nunley | last post by:
I'm expecting this function to return the same value each time the page is hit within the same session: In other words i want to save the guid as a session variable Function TempImageGUID() As...
4
by: Curious | last post by:
Hi, I have a timer object that's launched as below: mTimer = new System.Threading.Timer (new TimerCallBack(SubscribeTrade), null, 15000, 15000); void SubscribeTrade (object state) {...
6
by: Max | last post by:
i have a event bind function like this(though it is not so robust): bind$=function(o,evt,fn,cb){ var aE='attachEvent'; var aEL='addEventListener'; if(!o&&o){ return o(evt,fn,!!cb); } return...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.