OVERSTRIKE_BLOCK not found

I’m looking at the Scintilla Documentation website:

Scintilla Documentation

I’m using the StyledTextCtrl widget and trying to set the overstrike caret to a block type, but I am getting an Attribute error:

AttributeError: module ‘wx.stc’ has no attribute ‘STC_CARETSTYLE_OVERSTRIKE_BLOCK’

My code line:
self.richtext.SetCaretStyle(wx.stc.STC_CARETSTYLE_LINE | wx.stc.STC_CARETSTYLE_OVERSTRIKE_BLOCK)

Spec

Thank you for any help.

1 Like

Hi,

I’m not sure why we are missing these constants, but if you want to have a block overstrike caret, press the insert key and enter overstrike mode. The stc will display block style under-bar caret. Programmatically, type: ed.Overtype = True.

Thank you, I was aware of that…I was trying to get a full height caret block when I go to overstrike mode. So I need to try and set the caret style to wx.stc.STC_CARETSTYLE_OVERSTRIKE_BLOCK but it chokes on that constant for some reason.

I wonder if the wx or stc versions I am using are not up to date?

UPDATE: my wx.version() is 4.1.1 which is the latest.

UPDATE: print(wx.stc.StyledTextCtrl.GetLibraryVersionInfo()) returns:
<wx._core.VersionInfo object at 0x0000014C3A030E50>
How do I turn that into a readable version number?

StyledTextCtrl_1.zip (3.6 KB)

Hi, I tried some.

As you said, the full height block caret in overstrike mode seems to be impossible.
(Scintilla doc says that CARETSTYLE_OVERSTRIKE_BAR is the default,
but it seems that’s the only one we can choose.)

wx.stc.StyledTextCtrl.GetLibraryVersionInfo() is an instance, so you have to dig it more.
This snippet will help you! :slight_smile:

import re

def _apropos(rexpr, root, pred=None):
    """Put a list of objects having expression `rexpr in `root
    with predicates, e.g., is* functions imported from inspect
    """
    print("matching to {!r} in {} :{}".format(rexpr, root, pred))
    p = re.compile(rexpr, re.I)
    for key in sorted(filter(p.search, dir(root)), key=str.upper):
        value = getattr(root, key)
        if pred is None or pred(value):
            print("    {:<36s} {!r}".format(key, value))

def atom(x):
    return not hasattr(x, '__name__')

Usage:

>>> _apropos('', wx.stc.StyledTextCtrl.GetLibraryVersionInfo(), atom)
matching to '' in <wx._core.VersionInfo object at 0x000001FD9050FEE0> :<function atom at 0x000001FD90010F70>
    Copyright                            ''
    Description                          'Scintilla 3.7.2'
    Major                                3
    Micro                                2
    Minor                                7
    Name                                 'Scintilla'
    VersionString                        'Scintilla 3.7.2'
    __dict__                             {}
    __doc__                              'VersionInfo(name="", major=0, minor=0, micro=0, description=...
    __module__                           'wx._core'
    __weakref__                          None

Thanks for that. I ran your code and I too am running Scintilla 3.7.2

Using wx.Caret to set the caret size seems to have no effect in Scintilla. I thought I could keep track of the insert/overstrike modes and set the size myself.

It’s been a few years since wxSTC was updated with new Scintilla code.