On Mon, Mar 18, 2013 at 5:18 PM, Jim Byrnes <jf_byr...@comcast.net> wrote:
> I am trying to script Calligra Sheets (formerly KSpread) with python. I > have gotten some of the included example scripts to run so I know python > scripting is running. > > I found the following snippet on their website: > > import KSpread > sheet = KSpread.view().sheet() > # swap text of B5 and C6 > t1 = sheet.text("B5") > t2 = sheet.text(6,3) > sheet.setText("B5", t2) > sheet.setText(6, 3, t1) > # swap value of D7 and E8 > v1 = sheet.value("D7") > v2 = sheet.value(8,5) > sheet.setValue("D7", v2) > sheet.setValue(8, 5, v1) > > Error: 'str' object has no attribute 'text' > File "file:///usr/share/kde4/apps/**sheets/scripts/extensions/**myswap.py", > line 4, in <module> > > > This error message appeared in a dialog box. > > I've taught myself some Python but I don't understand what is happening > here. Shouldn't t1 be a sheet object? What would cause it to be a str > instead? > You'd be much better off asking the Calligra guys directly I think, somewhere at http://www.calligra.org/get-help/. It looks like KSpread.view().sheet() is returning a str object, as you correctly diagnose, but I'm not familiar enough with their API to say anything about the root cause. There will be a lot more expertise and knowledge available from their website than from this mailing list since this list's topic is far more general. I'd check the forums. Hugo
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor