Issue with 'unsigned char const *'

Hello,

I’m trying to use StyledTextCtrl_MarkerDefineRGBAImage function,
but I can’t find out how the image must be passed.

From scintilla documention I get that it is supposed to be

SCI_MARKERDEFINERGBAIMAGE(int markerNumber, const char *pixels)

so I thought it should work by providing a string

img = ‘\x00\x00\x00\x00’
editor.RGBAImageSetWidth(14)
editor.MarkerDefineRGBAImage(0,img)

``

then I tried passing a list

img = [0,0,0,0]
editor.MarkerDefineRGBAImage(0,img)

``

and finally I tried using ctypes with byte and ubyte

import ctypes
img = ctypes.c_ubyte*4
img.from_buffer_copy(’\x00\x00\x00\x00’)
<c_ubyte_Array_4 object at 0x7f9902a5c9e0>
for i in img():
print i

``

0
0
0
0

editor.MarkerDefineRGBAImage(0,img())

editor.MarkerDefineRGBAImage(0,ctypes.byref(img()))

editor.MarkerDefineRGBAImage(0,ctypes.pointer(img()))

``

but all returned the same error
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/stc.py”, line 6371, in MarkerDefineRGBAImage
return _stc.StyledTextCtrl_MarkerDefineRGBAImage(*args, **kwargs)TypeError: in method ‘StyledTextCtrl_MarkerDefineRGBAImage’, expected argument 3 of type 'unsigned char const *'

So, how do I provide a ‘unsigned char const *’?

Thank you
Claudia

By default sip is expecting an int or int-compatible object for unsigned char values, and it doesn’t know whether it should be a pointer to a single value or an array of values, so it just takes the safest choice. I can tweak some things in the wrappers to allow it to accept buffer-compatible objects, but in the meantime, is there any reason that MarkerDefineBitmap won’t work for you?

···

Robin Dunn

Software Craftsman

On Tuesday, January 30, 2018 at 6:41:29 AM UTC-8, cfrank2512@gmail.com wrote:

img = ‘\x00\x00\x00\x00’
editor.RGBAImageSetWidth(14)
editor.MarkerDefineRGBAImage(0,img)

``

img = [0,0,0,0]
editor.MarkerDefineRGBAImage(0,img)

``

import ctypes
img = ctypes.c_ubyte*4
img.from_buffer_copy(‘\x00\x00\x00\x00’)
<c_ubyte_Array_4 object at 0x7f9902a5c9e0>
for i in img():
print i

``

editor.MarkerDefineRGBAImage(0,img())

editor.MarkerDefineRGBAImage(0,ctypes.byref(img()))

editor.MarkerDefineRGBAImage(0,ctypes.pointer(img()))

``

Hello,
I’m trying to use StyledTextCtrl_MarkerDefineRGBAImage function,
but I can’t find out how the image must be passed.
From scintilla documention I get that it is supposed to be
SCI_MARKERDEFINERGBAIMAGE(int markerNumber, const char *pixels)
so I thought it should work by providing a string
then I tried passing a list
and finally I tried using ctypes with byte and ubyte
0
0
0
0
but all returned the same error
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/stc.py”, line 6371, in MarkerDefineRGBAImage
return _stc.StyledTextCtrl_MarkerDefineRGBAImage(*args, **kwargs)TypeError: in method ‘StyledTextCtrl_MarkerDefineRGBAImage’, expected argument 3 of type ‘unsigned char const *’

So, how do I provide a ‘unsigned char const *’?

Thank you
Claudia

https://github.com/wxWidgets/Phoenix/issues/716

···

Robin Dunn

Software Craftsman

http://wxPython.org

Hello Robin,

is there any reason that MarkerDefineBitmap won’t work for you?

probably not, to be honest, I’m just testing the functions provided by stc, one by one to get a better understanding how scintilla works

and this was the first function which wasn’t working as I expected.

Thank you for considering the buffers/arrays as an option.

Cheers

Claudia

That was quick - thank you very much and I can confirm it is working well with byte string.
And congratulation to the official 4.0 release - well done.

Cheers
Claudia

···

Am Dienstag, 30. Januar 2018 22:57:23 UTC+1 schrieb Robin Dunn:

https://github.com/wxWidgets/Phoenix/issues/716

Robin Dunn

Software Craftsman

http://wxPython.org

This was another one of those times where I surprised myself a little because something I did years ago for this project made implementing a new fix or feature very simple and easy. :slight_smile: Thanks for confirming.

···

On Tuesday, February 6, 2018 at 3:40:40 AM UTC-8, cfrank2512@gmail.com wrote:

That was quick - thank you very much and I can confirm it is working well with byte string.

Robin Dunn

Software Craftsman