Hi,
I have a Tktable object (self.table) and when I click on a row the
whole row is selected.
If I click of a button to get the row contents then
self.table.curselection() fails with a traceback of:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/lib-tk/Tkinter.py",
line 1345, in __call__
return self.func(*args)
File "/Users/jerry/python/PyPgExplorerUni/Resources/editor.py", line
159, in deleteRow
print self.table.curselection()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 139, in curselection
return self._getCells(self.tk.call(self._w, 'curselection'))
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 106, in _getCells
for i in string.split(cellString):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py",
line 292, in split
return s.split(sep, maxsplit)
AttributeError: 'tuple' object has no attribute 'split'
It is my reading that curselection will return the indices of the
selected cells...
Help,
Jerry 3 2044 je*********@gmail.com wrote:
Hi,
I have a Tktable object (self.table) and when I click on a row the
whole row is selected.
If I click of a button to get the row contents then
self.table.curselection() fails with a traceback of:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/lib-tk/Tkinter.py",
line 1345, in __call__
return self.func(*args)
File "/Users/jerry/python/PyPgExplorerUni/Resources/editor.py", line
159, in deleteRow
print self.table.curselection()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 139, in curselection
return self._getCells(self.tk.call(self._w, 'curselection'))
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 106, in _getCells
for i in string.split(cellString):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py",
line 292, in split
return s.split(sep, maxsplit)
AttributeError: 'tuple' object has no attribute 'split'
It is my reading that curselection will return the indices of the
selected cells...
Help,
Jerry
looking into Tktable the curselection function is defined by:
def curselection(self, setValue = None):
if setValue != None:
self.tk.call(self._w, 'curselection', 'set', setValue)
else:
return self._getCells(self.tk.call(self._w, 'curselection'))
looking at getCells we see:
def _getCells(self, cellString):
#JHL
print cellString
res = []
for i in string.split(cellString):
res.append(tuple(map(int, string.split(i, ','))))
return res
When I run my program and select a row the value of cellString is
('3,0', '3,1', '3,2', '3,3', '3,4', '3,5', '3,6')
Which is the correct results...( ie the "fourth" row is selected and
there are six
columns...
Unfortunately the above is *not* a string and hence the "for" statement
fails.
It is hard to believe that I am the first person to attempt to retrieve
a selection
from a Tktable object....
Am I overlooking something obvious?
Jerry je*********@gmail.com wrote:
je*********@gmail.com wrote:
Hi,
I have a Tktable object (self.table) and when I click on a row the
whole row is selected.
If I click of a button to get the row contents then
self.table.curselection() fails with a traceback of:
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/lib-tk/Tkinter.py",
line 1345, in __call__
return self.func(*args)
File "/Users/jerry/python/PyPgExplorerUni/Resources/editor.py", line
159, in deleteRow
print self.table.curselection()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 139, in curselection
return self._getCells(self.tk.call(self._w, 'curselection'))
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 106, in _getCells
for i in string.split(cellString):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py",
line 292, in split
return s.split(sep, maxsplit)
AttributeError: 'tuple' object has no attribute 'split'
It is my reading that curselection will return the indices of the
selected cells...
Help,
Jerry
looking into Tktable the curselection function is defined by:
def curselection(self, setValue = None):
if setValue != None:
self.tk.call(self._w, 'curselection', 'set', setValue)
else:
return self._getCells(self.tk.call(self._w, 'curselection'))
looking at getCells we see:
def _getCells(self, cellString):
#JHL
print cellString
res = []
for i in string.split(cellString):
res.append(tuple(map(int, string.split(i, ','))))
return res
When I run my program and select a row the value of cellString is
('3,0', '3,1', '3,2', '3,3', '3,4', '3,5', '3,6')
Which is the correct results...( ie the "fourth" row is selected and
there are six
columns...
Unfortunately the above is *not* a string and hence the "for" statement
fails.
It is hard to believe that I am the first person to attempt to retrieve
a selection
from a Tktable object....
Am I overlooking something obvious?
Jerry
I think I have found a bug in the Tktable.py wrapper.
It appears that if a row is selected in a Tktable (in Python)
then any attempt to fetch the selection with curselection
fails when a string operation is performed on a "tuple"
the relevant routines in Tktable.py are:
def curselection(self, setValue = None):
if setValue != None:
self.tk.call(self._w, 'curselection', 'set', setValue)
else:
return self._getCells(self.tk.call(self._w, 'curselection'))
curselection will call _getCells
def _getCells(self, cellString):
res = []
#JHL
if type(cellString) == type(()) : return cellString
for i in string.split(cellString):
res.append(tuple(map(int, string.split(i, ','))))
return res
I added the "if type( ...." line to prevent the error.
If a table row is selected cellString will look like
('3,0', '3,1', '3,2', '3,3', '3,4', '3,5', '3,6')
which is of type "tuple" which fails the string.split command ;(
I suspect it is probably best to just short circuit the call to
_getCells.
The following routine (with the above patch )will correctly retrieve
the contents
of a selected row.
def deleteRow(self):
res = self.table.curselection()
for index in res :
print self.table.get(index)
Tain't clear to me where this should be reported
Jerry je*********@gmail.com wrote:
je*********@gmail.com wrote:
je*********@gmail.com wrote:
Hi,
I have a Tktable object (self.table) and when I click on a row the
whole row is selected.
>
If I click of a button to get the row contents then
>
self.table.curselection() fails with a traceback of:
>
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/lib-tk/Tkinter.py",
line 1345, in __call__
return self.func(*args)
File "/Users/jerry/python/PyPgExplorerUni/Resources/editor.py", line
159, in deleteRow
print self.table.curselection()
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 139, in curselection
return self._getCells(self.tk.call(self._w, 'curselection'))
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Tktable.py",
line 106, in _getCells
for i in string.split(cellString):
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/string.py",
line 292, in split
return s.split(sep, maxsplit)
AttributeError: 'tuple' object has no attribute 'split'
>
It is my reading that curselection will return the indices of the
selected cells...
>
Help,
>
Jerry
looking into Tktable the curselection function is defined by:
def curselection(self, setValue = None):
if setValue != None:
self.tk.call(self._w, 'curselection', 'set', setValue)
else:
return self._getCells(self.tk.call(self._w, 'curselection'))
looking at getCells we see:
def _getCells(self, cellString):
#JHL
print cellString
res = []
for i in string.split(cellString):
res.append(tuple(map(int, string.split(i, ','))))
return res
When I run my program and select a row the value of cellString is
('3,0', '3,1', '3,2', '3,3', '3,4', '3,5', '3,6')
Which is the correct results...( ie the "fourth" row is selected and
there are six
columns...
Unfortunately the above is *not* a string and hence the "for" statement
fails.
It is hard to believe that I am the first person to attempt to retrieve
a selection
from a Tktable object....
Am I overlooking something obvious?
Jerry
I think I have found a bug in the Tktable.py wrapper.
It appears that if a row is selected in a Tktable (in Python)
then any attempt to fetch the selection with curselection
fails when a string operation is performed on a "tuple"
the relevant routines in Tktable.py are:
def curselection(self, setValue = None):
if setValue != None:
self.tk.call(self._w, 'curselection', 'set', setValue)
else:
return self._getCells(self.tk.call(self._w, 'curselection'))
curselection will call _getCells
def _getCells(self, cellString):
res = []
#JHL
if type(cellString) == type(()) : return cellString
for i in string.split(cellString):
res.append(tuple(map(int, string.split(i, ','))))
return res
I added the "if type( ...." line to prevent the error.
If a table row is selected cellString will look like
('3,0', '3,1', '3,2', '3,3', '3,4', '3,5', '3,6')
which is of type "tuple" which fails the string.split command ;(
I suspect it is probably best to just short circuit the call to
_getCells.
The following routine (with the above patch )will correctly retrieve
the contents
of a selected row.
def deleteRow(self):
res = self.table.curselection()
for index in res :
print self.table.get(index)
Tain't clear to me where this should be reported
Jerry
It would not be any fun for my app users if I had to change the
Tktable.py
source all by myself....
Here is another fix that involves calling Tk directly
instead of :
res = self.table.curselection()
I can do:
res = self.root.tk.call(self.table,'curselection')
root is the app top level ( self.table works also...)
for a row the above call will return something like
('2,0', '2,1', '2,2', '2,3', '2,4', '2,5', '2,6')
the "co-ordinate" strings in the above tuple can be used
as indices into the table to retreive the selection.
Jerry This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lawrence |
last post by:
Is this the correct way to test for a method before I use it?
createRange() is, I believe, an IE only method.
function wrapSelectionInTag(selection, tag) {
if (document.selection.createRange)...
|
by: kimimaro |
last post by:
hi I wonder if array can be work along with structure?
Below are the declaration of my structure
struct employee{
char ID;
char Name;
char Department;
|
by: jw56578 |
last post by:
is there a way to automatically generate properties from fields in
vs.net
|
by: Gary Wessle |
last post by:
Hi
I just finished with 1.5 tutorials about Tkinter, my thought is to use
a table "maybe TkTable" to gather info from the user as to what file
to chart data from, as well as info provided by the...
|
by: jerry.levan |
last post by:
Hi,
I have a python app that runs fine on MacOS X and Fedora Core 5.
This evening I dragged the folder over to my windows partition and
tried to run the rascal.
The program starts up fine but...
|
by: jerry.levan |
last post by:
Hi,
I am using a Tktable in my python database browser program to hold the
results of a query.
I have declared an ArrayVar like (IntVar) to hold the table contents.
In Tcl/Tk programs
I have...
|
by: Abdhul Saleem |
last post by:
Hi,
I am recieving error ActiveX component can't create object in the following
line in the asp page.
set ExcelApp = CreateObject("Excel.Application")
Previously this code was working fine....
|
by: etuncer |
last post by:
Hello All,
I have Access 2003, and am trying to build a database for my small
company. I want to be able to create a word document based on the data
entered through a form. the real question is...
|
by: info |
last post by:
Has anyone used Tktable on python 3.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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |