Python swi.block contents
John Rickman (71) 646 posts |
I need to get the title of my python app main window.
the output is:
Python is printing out the class of the block object. |
Paolo Fabio Zaino (28) 1882 posts |
@ John
I am not on a RISC OS system to try the following code, so apologies if it may not work, however have your tried the following?
I added a comment to the line that looks a little suspicious to me. Where .tostring is to process the content of the buffer to a string and 3 is just the block index in the buffer from where to start, you can use 0 or wherever the window title might be located. Basically the issue is that you ARE refering to the full buffer object insted of its content, so you need to add a method to get to the content. Also, quick question, isn’t reason 12 = reserved? HTH |
John Rickman (71) 646 posts |
Easy answer first:
|
John Rickman (71) 646 posts |
tried .tostring method without conspicuous success. Here is a list of methods for ‘buffer’ reported by dir(buffer):
The ‘__getitem__’ method looks promising |
Paolo Fabio Zaino (28) 1882 posts |
wasn’t there a StrongHelp manual for Python? I think Andrew Conroy may have a copy of it, I don’t know, I usually read the C source here: https://github.com/c-jo/cpython/blob/riscos/RISCOS/swimodule.c |
Andrew Conroy (370) 740 posts |
One of the earlier versions of Python came with a SH manual, I’ve no idea how horribly out of date it will be now though. |
Paolo Fabio Zaino (28) 1882 posts |
Ha, thanks Andrew. Sorry, I didn’t know that. As I mentioned, I just look at the specific swimodule.c which contains the latest and greatest details. |
Matthew Phillips (473) 721 posts |
This excerpt from the Toolbox library might help:
|
John Rickman (71) 646 posts |
Thanks to everybody who has suggested solutions to this problem. The python Toobox has has seen a lot of changes since I uploaded it from PackMan. Unfortunately the changes have not been packaged for download so I am having a think about what to do. Meanwhile Lauren has just forked the repository in order to commit some more changes. Think I will wait a bit and see what comes along. |
Chris Johns (8262) 242 posts |
The main sticking point to the next Toolbox update is the signedness of the values returned by the various toolbox things. At the moment they are unsigned, but I’m now pretty sure at least one of them should be unsigned. The main issue with this is if you need to call the SWI yourself and the I/i doesn’t match, it all goes bang. TBH it might be easier to fix the swi module itself to handle either case. |