Open reticulatus opened 3 weeks ago
Further experiments with the Code Example indicate that the OnPaint()
method is repeatedly being called.
If I drag the editor's vertical scrollbar to the bottom and the horizontal scrollbar to the right, then the messages stop being generated. However, the text is never displayed.
Interestingly, I can't reproduce it, at least on Fedora 40.
Is Fedora 40 using Wayland?
Edit: I have checked my other machines.
The bug occurs with:
But not with:
Is Fedora 40 using Wayland?
Yes, my test was with Wayland. Are you using Wayland also?
Is Fedora 40 using Wayland?
Yes, my test was with Wayland. Are you using Wayland also?
No, I'm using X11 which is standard on Mint.
If I add a call to self.Layout()
in TestFrame.__init__()
, the the program only outputs a small number of Gtk-WARNING messages (i.e. it doesn't get stuck in a loop). However, the Editor control is still not displayed.
In wx/lib/editor/editor.py
the following method is defined:
def DrawSimpleCursor(self, xp, yp, dc = None, old=False):
if not dc:
dc = wx.ClientDC(self)
if old:
xp = self.sco_x
yp = self.sco_y
szx = self.fw
szy = self.fh
x = xp * szx
y = yp * szy
dc.Blit(x,y, szx,szy, dc, x,y, wx.XOR)
self.sco_x = xp
self.sco_y = yp
If I comment out the call to dc.Blit()
then the Gtk-WARNING messages are not output and the Editor control and its content are displayed as expected.
If I comment out the dc.Blit()
call without adding the call to self.Layout()
to TestFrame.__init__()
then the Editor control does appear, but the text contents flicker rapidly until I click in the control.
Indeed, I can reproduce this under X11.
Operating system: Linux Mint 22 wxPython version & source: wxPython 4.2.2 gtk3 (phoenix) wxWidgets 3.2.6 from pypi Python version & source: 3.12.3 from distro
It also occurs with wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1 + Python 3.10.12 + Linux Mint 21.3
Description of the problem:
In the wxPython demo, the Editor control never fully appears. Continuous warning messages are output to the command line.
As a side effect, entries in the demo's tree control for other recently used examples turn invisible on a grey background.
See this animated gif (click the play button, if necessary):
Code Example (click to expand)
This is the example from the demo, modified to run stand-alone: ```python import wx import wx.lib.editor as editor class TestFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent) win = wx.Panel(self, -1) ed = editor.Editor(win, -1, style=wx.SUNKEN_BORDER) box = wx.BoxSizer(wx.VERTICAL) box.Add(ed, 1, wx.ALL|wx.GROW, 1) win.SetSizer(box) win.SetAutoLayout(True) ed.SetText(["", "This is a simple text editor, the class name is", "Editor. Type a few lines and try it out.", "", "It uses Windows-style key commands that can be overridden by subclassing.", "Mouse select works. Here are the key commands:", "", "Cursor movement: Arrow keys or mouse", "Beginning of line: Home", "End of line: End", "Beginning of buffer: Control-Home", "End of the buffer: Control-End", "Select text: Hold down Shift while moving the cursor", "Copy: Control-Insert, Control-C", "Cut: Shift-Delete, Control-X", "Paste: Shift-Insert, Control-V", ""]) if __name__ == '__main__': app = wx.App() frame = TestFrame(None) frame.Show() app.MainLoop() ``` The first few error message on the command line: ``` (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.814: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.815: drawing failure for widget 'GtkScrolledWindow': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.815: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.815: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.815: drawing failure for widget 'GtkBox': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.815: drawing failure for widget 'GtkWindow': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.824: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.824: drawing failure for widget 'GtkScrolledWindow': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.824: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.824: drawing failure for widget 'wxPizza': invalid value for an input cairo_format_t (Editor_2.py:8883): Gtk-WARNING **: 13:25:30.824: drawing failure for widget 'GtkBox': invalid value for an input cairo_format_t ```