Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wx.lib.editor.Editor gets stuck in a loop generating "drawing failure for widget" messages #2633

Open
reticulatus opened this issue Oct 29, 2024 · 7 comments

Comments

@reticulatus
Copy link
Contributor

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):

editor_demo_1-2024-10-29_11 20 49

Code Example (click to expand)

This is the example from the demo, modified to run stand-alone:

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
@reticulatus
Copy link
Contributor Author

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.

@swt2c
Copy link
Collaborator

swt2c commented Nov 8, 2024

Interestingly, I can't reproduce it, at least on Fedora 40.

@reticulatus
Copy link
Contributor Author

reticulatus commented Nov 9, 2024

Is Fedora 40 using Wayland?

Edit: I have checked my other machines.

The bug occurs with:

  • wxPython 4.2.2 gtk3 (phoenix) wxWidgets 3.2.6 + Python 3.12.3 + Linux Mint 22
  • wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1 + Python 3.10.12 + Linux Mint 21.3

But not with:

  • wxPython 4.2.2 osx-cocoa (phoenix) wxWidgets 3.2.6 + Python 3.12.6 + macOS Sequoia 15.1

@swt2c
Copy link
Collaborator

swt2c commented Nov 11, 2024

Is Fedora 40 using Wayland?

Yes, my test was with Wayland. Are you using Wayland also?

@reticulatus
Copy link
Contributor Author

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.

@reticulatus
Copy link
Contributor Author

reticulatus commented Nov 12, 2024

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.

@swt2c
Copy link
Collaborator

swt2c commented Nov 14, 2024

Indeed, I can reproduce this under X11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants