Hi all,
I just encountered another difference in wx 2.9 with regard to my
code, namely in wx.TextAttr.Merge,
it seems, that it now returns None (at least in the cases I tested),
which lets the further code crash, as SetStyle obviously expects
wx.TextAtrr ...
Have I missed some documented change? What would be the expected way
to use Merge?
For the snippet below, I get the following traceback in 2.9.2.1:
2.9.2.1 (msw-unicode) merged_style: None
Traceback (most recent call last):
File "C:\dokumenty\Vlasta\python-wx\TextCtrl--test-Merge-wx-2-9.py",
line 27, in <module>
testTxtCtrl.SetStyle(90, 131, merged_style)
File "C:\Python27\lib\site-packages\wx-2.9.2-msw\wx\_core.py", line
13330, in SetStyle
return _core_.TextAreaBase_SetStyle(*args, **kwargs)
ValueError: invalid null reference in method 'TextAreaBase_SetStyle',
expected argument 4 of type 'wxTextAttr const &'
TextCtrl–test-Merge-wx-2-9.py (946 Bytes)
···
======
with 2.8 the styling works as expected and the print output is:
2.8.12.1 (msw-unicode) merged_style: <wx._controls.TextAttr; proxy of
<Swig Object of type 'wxTextAttr *' at 0x18868a0> >
======
Thanks in advance for any hints,
vbr
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # #
#! Python
# -*- coding: utf-8 -*-
import wxversion
# wxversion.select('2.8')
wxversion.select('2.9.2')
import wx
appl = wx.App(redirect=False)
frm = wx.Frame(None, -1, "wx.TextAttr.Merge - test")
testTxtCtrl = wx.TextCtrl(frm, -1, style=wx.TE_MULTILINE | wx.TE_RICH2)
testTxtCtrl.SetValue(u"abcdef ghijklmn op rstu v Z\n" * 7)
sizerFrm = wx.BoxSizer(wx.HORIZONTAL)
sizerFrm.Add(testTxtCtrl, 1, wx.EXPAND)
frm.SetSizer(sizerFrm)
red_text_style = wx.TextAttr("RED", wx.NullColour)
yellow_bg_style = wx.TextAttr(wx.NullColour, "YELLOW")
merged_style = wx.TextAttr.Merge(red_text_style, yellow_bg_style)
print wx.version(), "merged_style: ", merged_style # >> None in wxPython 2.9.2.1
testTxtCtrl.SetStyle(5, 15, red_text_style)
testTxtCtrl.SetStyle(20, 30, yellow_bg_style)
testTxtCtrl.SetStyle(90, 131, merged_style)
frm.Show()
testTxtCtrl.SetInsertionPoint(0) # avoid highlighting the text
appl.MainLoop()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # #