473,626 Members | 3,198 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 5527
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.se t("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
9460
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 telemetry from a robot system. There are a bunch of packages out there, but many seem to provide only static graphs (e.g. for scientific, financial data, etc). Does anyone currently display real-time telemetry using Python? Can anyone provide any...
18
12577
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 about whether we should allow polymorphism. Our system is not embedded and does not need to be as real-time as, say, a pacemaker. But it does involve updating displays based on radar input. So a need for something close to real-time is desired...
3
3241
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 more than one instrument to control, I was thinking of writing a GUI using Tkinter (looked at Page, but it not have a debian package and I saw quite a few bugs listed - Tkinter seems mature). I have some questions : 1. In using matplotlib (my...
28
1929
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 the main and pass it to the function? thanks
0
1368
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 way... I would like to create an XML file which will store the different parameters of my webapp.
3
1756
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 database. I have a few plans in mind: - I could have an aspx page that would use GDI+ classes to generate the graphics and let the page refreshes the images at a regular interval. The drawback is though, there may be a dozen of images in a single...
10
3069
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 from a vehicle on a track. The data flow would be as follows: |-- Workstation 1
2
1443
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 recursively after every 2 secs. The web service accepts that accout number as an input parameter, invokes a stored procedure and returns the current balance of the input account no. My problem is with the performance. Invoking a webservice every 2...
0
1603
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 Python for audio-type worst case latencies (around 25 ms). I've done that in my PhD work, both with real-time requirements on dual-CPU
3
3656
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 application that needs
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
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
8637
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
6125
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
4092
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
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
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
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.