473,499 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter: visualizing parameters in real time

1 New Member
Hi, I'm writing an interactive program to fit some data quickly.
I would like to keep an eye on the actual value of the parameters of the fitting function which i plot on the same graph f the data while changing by <Key> binding the parameters value..
I was thinking about using multiple textbox but I'm not used yet to their syntax..
Is that an appropriate way of resolving this issue and if yes i could i work it out?
Is there any other better way of facing the problem?
Aug 13 '12 #1
1 5494
dwblas
626 Recognized Expert Contributor
Use a StringVar() or IntVar() in any container you choose, listbox, labels, etc. When you change it, the new value is displayed where ever it is displayed, so to update =
string_var_1.set("new value")

The following program changes the value in the Entry box. The same StringVar() is also displayed in the middle label on the top. It changes as the value in the entry box changes. The IntVar() is incremented by clicking the button.
Expand|Select|Wrap|Line Numbers
  1. import Tkinter
  2.  
  3. class EntryTest:
  4.    """ shows using the same StringVar in the second list box
  5.        and in the entry box
  6.    """
  7.    def __init__(self):
  8.       self.top = Tkinter.Tk()
  9.       self.top.title("Test of Entry")
  10.       self.top.geometry("200x150+10+10")
  11.  
  12.       self.str_1 = Tkinter.StringVar()
  13.       label_lit = Tkinter.StringVar()
  14.       self.int_lit = Tkinter.IntVar()
  15.       self.int_ctr = 0
  16.  
  17.       label_1 = Tkinter.Label(self.top, textvariable = label_lit )
  18.       label_1.pack()
  19.       label_lit.set( "Test of Label")
  20.  
  21.       Tkinter.Label(self.top, textvariable = self.str_1 ).pack()
  22.  
  23.       Tkinter.Label(self.top, textvariable = self.int_lit ).pack()
  24.       self.int_lit.set(self.int_ctr)
  25.  
  26.       self.entry_1=Tkinter.Entry(self.top, textvariable=self.str_1)
  27.       self.entry_1.pack()
  28.       self.str_1.set( "Entry Initial Value" )
  29.  
  30.       print_button = Tkinter.Button(self.top, text='INCREMENT INT VAR',
  31.                      command=self.getit, bg='blue', fg='white' )
  32.       print_button.pack(fill=Tkinter.X, expand=1)
  33.  
  34.       exit_button= Tkinter.Button(self.top, {"text":'EXIT',
  35.                    "command":self.top.quit, "bg":'red', "fg":'white'} )
  36.       exit_button.pack(fill=Tkinter.X, expand=1)
  37.  
  38.       self.entry_1.focus_set()
  39.  
  40.       self.top.mainloop()
  41.  
  42.    ##-----------------------------------------------------------------
  43.    def getit(self) :
  44.       self.int_ctr += 1
  45.       self.int_lit.set(self.int_ctr)
  46.  
  47.  
  48. ##===============================================================
  49. if "__main__" == __name__  :
  50.    ET=EntryTest()
  51.    print "under __main__ =", ET.str_1.get() 
Aug 13 '12 #2

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

Similar topics

12
9437
by: | last post by:
I've trolled the lists, FAQs, and Net as a whole, but can't find anything definitive to answer this. We're looking for real-time graph capability (bar, line, etc), so that we can display...
18
12550
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
3
3233
by: Madhusudan Singh | last post by:
Hi I am still a rookie at python (can do some basic programming with the language), and have been using python gpib and matplotlib to control my instruments and do real time plots. Since I have...
28
1903
by: marcpirat | last post by:
hi we create a real-time program on a embedded linux system. the program will run a few time by second i would like to know if it's better to create global variable or create the variable in...
0
1335
by: aure_bobo | last post by:
Hi all, I'm currently developing an ASP.NET 1.1 C# Webapp. I have some objects which contains the differents parameters of my web app. These objects are instanciated in my code, in a static...
3
1749
by: Ted Burhan | last post by:
Hi all, I'm trying to display a real-time data in one form or another (i.e. animation/graphic file, or just a text) in asp.net. The data for the images/text is retrieved from a SQL Server...
10
3051
by: Martin Hughes | last post by:
Hi guys, I was wondering if anyone could give me some advice. I am looking to develop an ASP.NET application that will enable several workstations to access real time telemetry data received...
2
1435
by: mm3178 | last post by:
Hello Mates, My case is slightly complicated....please help me In order to obtain real time current balance of an account, I have built a c# windows service that invokes a c# web service...
0
1593
by: Johannes Nix | last post by:
Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use...
3
3630
by: Kurt Mueller | last post by:
David, Am 07.10.2008 um 01:25 schrieb Blubaugh, David A.: As others mentioned before, python is not the right tool for "HARD REAL TIME". But: Maybe you can isolate the part of your...
0
7009
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...
0
7223
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...
1
6899
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
7390
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...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
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...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.