473,466 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Entry Widget problem

Hi,

I am new in Python and I have no experience in object-oriented programming.
I want to make an easy GUI for my application. What is my problem? I have
the data-file like this (file ETab_H1.dan):
16
1 13 10 1 0.9 1.1 1 0 0.0 0.0 0.0
2 14 50 2 0.9 1.1 4 2 0.0 0.0 0.0
3 15 10 2 0.9 1.1 1 0 0.0 0.0 0.0
4 16 10 1 0.9 1.1 1 0 0.0 0.0 0.0
5 17 50 2 0.9 1.1 4 2 0.0 0.0 0.0
6 18 10 2 0.9 1.1 1 0 0.0 0.0 0.0
7 19 10 1 0.4 0.9 1 0 0.0 0.0 0.0
8 20 5 2 0.4 0.8 1 0 0.0 0.0 0.0
9 21 40 2 0.2 1.1 0 0 0.0 0.0 0.0
10 22 40 2 0.4 1.5 0 0 0.0 0.0 0.0
11 23 5 2 3.7 1.1 1 0 0.0 0.0 0.0
12 24 10 2 0.9 1.1 1 0 0.0 0.0 0.0
13 25 10 2 0.9 1.1 1 0 0.0 0.0 0.0
14 26 10 2 0.9 1.1 1 0 0.0 0.0 0.0
15 31 10 2 0.9 1.1 1 0 0.0 0.0 0.0
16 32 10 2 0.9 1.1 1 0 0.0 0.0 0.0

The first number is a number of rows in data-block below. These numbers are
the coefficients for my functions in FORTRAN program. Before I run my
program
I must read this file, change some of these coefficients and write this file
again in the same form. In the file ETab.py
I wrote:

file ETab.py:
-----------------------------------------------------------------

from Tkinter import *
import tkFont
import string

class ETab(Frame):
def __init__(self):
Frame.__init__(self,height="40",width="600",relief =RAISED)
self.master.title('Data for grid generation')
self.grid()
ELista=["nr","Egde","nCell","nFun","P","Q","Metoda","WBTyp ","Left","Right","sigma"]
for icol in range(len(ELista)):
self.Etykieta(icol,irow=0,EText=ELista[icol])

f=open('ETab_H1.dan', 'r');
self.c=f.readline()
c1=int(self.c)

self.FieldList=[]
self.FieldList.append(c1)

k=1
for i in range(c1):
c=f.readline()
s=c.split()
dl=len(s)
for j in range(dl):
self.Pola(k,j,i,DefaultValue=s[j])
k=k+1

f.close()

self.applyBotton = Button(self,text="Apply",command=self.addEntry)
self.applyBotton.grid(column=dl-2,row=c1+1)
self.quitButton = Button(self, text="Quit",command=self.quit)
self.quitButton.grid(column=dl-1,row=c1+1)
def addEntry(self):
nElem=len(self.FieldList)
print nElem
ff=open('ETab_H1.spr', 'w');
ff.write(self.c)
LL=StringVar()
for k in range(nElem):
LL=self.FieldList[k]
print k,LL

ff.close()
def Etykieta(self,icol,irow,EText):
lab=Label(self,text=EText)
lab.grid(column=icol,row=irow)
return

def Pola(self,k,icol,irow,DefaultValue):
self.Tab=StringVar()
WLista=[5,5,5,5,10,10,10,10,10,10,10]

self.pole=Entry(self,highlightcolor="BLUE",textvar iable=self.Tab,justify=RIGHT,width=WLista[icol])
self.pole.grid(column=icol,row=irow+1)
self.pole.insert(0,DefaultValue)
self.FieldList.append(self.Tab)
return self.Tab

ETab().mainloop()

-----------------------------------------------------------------

This script connects all numbers in my data-file with Entry Widget, but
the results are:

177
0 16
1 PY_VAR0
2 PY_VAR1
3 PY_VAR2
....
174 PY_VAR173
175 PY_VAR174
176 PY_VAR175
And when I change LL into LL.get():

177
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "ETab.py", line 107, in addEntry
print k,LL.get()
AttributeError: 'int' object has no attribute 'get'

What is wrong? And, how can I take the value of self.Tab?

Sorry for my English.

M.S.


Jun 30 '06 #1
0 1097

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

Similar topics

0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
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...
3
by: bigbinc | last post by:
I have used the 'entry' tk widget to get text values, I am now using 'Text' but I cant seem to use 'get' method. The TK docs say use get(index1, index2), I tried numbers and get an error ...
4
by: Clara | last post by:
Hi, can somebody help me,..I have an assignment due next week but now I'm stuck with this problem.... I tried to get values from entry widget using the widgetcontrolvariable.get(),..but it seems...
2
by: Dustan | last post by:
How do I limit what the user can enter in an Entry Widget? I know I can set it to display '*' to hide a password, but what I want to do is limit the contents to numeric characters. What is the...
3
Elias Alhanatis
by: Elias Alhanatis | last post by:
Hello to everybody!! I am running Python 2.5.1 on Windows Vista and i have a problem with the "Entry" widget of Tkinter. Take a look at this code: from Tkinter import * def fetch(): ...
3
by: asit | last post by:
from Tkinter import * def callback(): print e.get() master=Tk() e=Entry(master) e.pack(anchor=CENTER)
2
Strider1066
by: Strider1066 | last post by:
Is it a bug or a feature? I'm trying to sub-class an Entry widget that displays a template (i.e. '____-__-__') for users and does keystroke validation. It is starting to work but with one problem....
2
by: lee.walczak | last post by:
Hi, I am using Tkinter & the Kevin Walzer's TableList Wrapper for python implemented GUI: http://tkinter.unpythonic.net/wiki/TableListWrapper The TableList has been extremely useful in...
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...
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...
1
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.