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

Tkinter: Dynamic entry widget

Hello !

I want to create entry widgets dynamically.
var = ["one", "two", "three"]
i=0
for x in var:
textbox = "t_", x
textbox = entry(frame)
textbox.grid(row=4+i, column=0)
i = i + 1
This works ok. On the window are the entries like I want.

When I want to get to entered data from the entry widget. I am not able to
get them.
The statement: t_one.get()
dosent work. I am getting an error message that t_one is not global defined.

How can I do this?

Arne
Apr 25 '06 #1
1 7725
"Arne" wrote:
I want to create entry widgets dynamically.
var = ["one", "two", "three"]
i=0
for x in var:
textbox = "t_", x
textbox = entry(frame)
textbox.grid(row=4+i, column=0)
i = i + 1
This works ok. On the window are the entries like I want.

When I want to get to entered data from the entry widget. I am not able to
get them.
The statement: t_one.get()
dosent work. I am getting an error message that t_one is not global defined.


there's no t_one variable in your program. assigning some stuff to
a variable doesn't create a variable with that name (if your python
tutorial told you that you could do that, make sure you get your
money back).

the usual way to store a list of values (widgets) is to use a list:

var = []
for x in range(3):
textbox = entry(frame)
textbox.grid(row=4+i, column=0)
var.append(textbox)

print var[0].get() # returns the content of the first textbox
print var[1].get() # same, for the second textbox
print var[2].get() # same, for the third textbox

</F>

Apr 25 '06 #2

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

Similar topics

3
by: Phil Schmidt | last post by:
I'm trying to make a custom entry widget, as in the code that follows. There are two problems I'm trying to fix: 1) I would like the widget to behave as myEntry.Escape() does now, except that it...
6
by: Elaine Jackson | last post by:
I've got a script where a button gets pushed over and over: to cut down on the carpal tunnel syndrome I'd like to have the button respond to presses of the Enter key as well as mouse clicks; can...
2
by: uri bushey | last post by:
Is there an easy way to have a label read from a variable, and update itself when the variable is changed? I have a dialogue that asks for a name, and a label that displays the name that is...
7
by: Harlin Seritt | last post by:
I was looking at the Tcl/Tk sourceforge page and found that there were a couple of new widgets being produced for Tcl 8.5. Does anyone know if there are any Tkinter wrappers somewhere? thanks, ...
6
by: William Gill | last post by:
I am trying to get & set the properties of a widget's parent widget. What I have works, but seems like a long way around the block. First I get the widget name using w.winfo_parent(), then i...
3
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using...
8
by: Lie | last post by:
Inspect the following code: --- start of code --- import Tkinter as Tk from Tkconstants import * root = Tk.Tk() e1 = Tk.Entry(root, text = 'Hello World') e2 = Tk.Entry(root, text = 'Hello...
1
by: C Martin | last post by:
What am I doing wrong in this code? The callback doesn't work from the Entry widget. ##start code import Tkinter tk = Tkinter.Tk() var = Tkinter.StringVar() print var._name def cb(name,...
0
by: lee.walczak | last post by:
Hi, I hope someone can help here. I have made lots of progress implementing a gui application which at present uses the TableList python wrapper to interface with Tcl TableList implemention. ...
0
by: Leonhard Vogt | last post by:
Hello I have the following problem in Python 2.5 on Windows XP. On Ubuntu I do not see the problem. I have a Tkinter application as in the following example The entry-widget is somehow...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...
0
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...

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.