473,396 Members | 1,754 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.

array of Tkinter variables?

I want to build an array of entry widgets in python with Tkinter that
all have similar textvariables. I was hoping that I could use an array
of StringVar variables to attach to these widgets, so that I can loop
through the widget creation. But my simple minded approach failed:

for i in range(32):
self.dllAdjust[i] = StringVar()
self.dllAdjust[i].set('000')

gives me the following error:

File "./config.py", line 787, in setDefaultVals
self.dllAdjust[i] = StringVar()
AttributeError: Configurator instance has no attribute 'dllAdjust'
("Configurator" is the class in which this code fragment appears)

How does one define an array of StringVar? If that is not possible, what
would be an alternative approach to the idea in the code fragment above?

Jo
--
Dr Joachim Schambach
The University of Texas at Austin
Department of Physics
1 University Station C1600
Austin, Texas 78712-0264, USA
Phone: (512) 471-1303; FAX: (814) 295-5111
e-mail: js******@physics.utexas.edu
Nov 1 '05 #1
1 10462


Jo Schambach wrote:
I want to build an array of entry widgets in python with Tkinter that
all have similar textvariables. I was hoping that I could use an array
of StringVar variables to attach to these widgets, so that I can loop
through the widget creation. But my simple minded approach failed:

for i in range(32):
self.dllAdjust[i] = StringVar()
self.dllAdjust[i].set('000')

gives me the following error:

File "./config.py", line 787, in setDefaultVals
self.dllAdjust[i] = StringVar()
AttributeError: Configurator instance has no attribute 'dllAdjust'
("Configurator" is the class in which this code fragment appears)

How does one define an array of StringVar? If that is not possible, what
would be an alternative approach to the idea in the code fragment above?

Jo


I think what you want is something like:

self.dllAdjust=[]
for i in range(32):
sv=StringVar()
sv.set('000')
self.dllAdjust.append(sv)
(not tested)

Larry Bates
Nov 1 '05 #2

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

Similar topics

1
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles...
2
by: Marcus Schneider | last post by:
Sorry if this is an extremely stupid question: I produced some Python modules with TKinter stuff and now I want to use that from my main program. The windows have wuite some user interaction....
5
by: max(01)* | last post by:
hello. the following code: 1 from Tkinter import * 2 3 class MiaApp: 4 def __init__(self, genitore): 5 self.mioGenitore = genitore 6 self.i = IntVar()
3
by: Jim Anderson | last post by:
I have just installed Fedora Core 3 on my pc. Python runs fine, but when I try to run tkinter the tkinter library is not found. I tried installing python 2.4.1 and could not get tkinter to run...
11
by: William Gill | last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep references to them in a 2 dimensional list ( rBtns ). It works fine, and I can even make it so only one button per column can be...
3
by: William Gill | last post by:
Working with tkinter, I have a createWidgets() method in a class. Within createWidgets() I create several StringVars() and assign them to the textvariable option of several widgets. Effectively my...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
4
by: Kevin Walzer | last post by:
I'm trying to manage user preferences in a Tkinter application by initializing some values that can then be configured from a GUI. The values are set up as a dict, like so: self.prefs= {...
3
by: seanacais | last post by:
I'm trying to build an unknown number of repeating gui elements dynamically so I need to store the variables in a list of dictionaries. I understand that Scale "variable" name needs to be a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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
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
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...
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.