ekr-qt branch Leo Won't Start When pyqt6 installed

245 views
Skip to first unread message

tbp1...@gmail.com

unread,
Apr 12, 2021, 11:13:43 AM4/12/21
to leo-editor
I got a large number of messages as Leo tried to start.  Here is the last one before it quit:

  File "d:\Tom\git\leo-editor\leo\plugins\qt_text.py", line 413, in __init__
    self.setFrameStyle(self.StyledPanel | self.Sunken)

AttributeError: 'LeoLineTextWidget' object has no attribute 'StyledPanel'


Edward K. Ream

unread,
Apr 12, 2021, 11:17:10 AM4/12/21
to leo-editor
Thanks for the report. I'll fix it immediately.

Edward

tbp1...@gmail.com

unread,
Apr 12, 2021, 11:31:58 AM4/12/21
to leo-editor
Looks like the names of the constants have been changed to

label.setFrameStyle(QFrame::Panel | QFrame::Raised);

Edward K. Ream

unread,
Apr 12, 2021, 11:59:16 AM4/12/21
to leo-editor
On Mon, Apr 12, 2021 at 10:32 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Looks like the names of the constants have been changed to

label.setFrameStyle(QFrame::Panel | QFrame::Raised);


Rev d5a26c0 in ekr-qt attempts a fix.  The new code is:

Shadow = QtWidgets.QFrame.Shadow.Sunken if isQt6 else self.Sunken
self.setFrameStyle(self.StyledPanel | Shadow.Sunken)

I only tested that Shadow.Sunken exists on qt6. Please let me know if the fix works for you.

Edward

tbp1...@gmail.com

unread,
Apr 12, 2021, 12:55:03 PM4/12/21
to leo-editor
Without testing it I don't think that will work. StyledPanel has been replaced by RaisedI would expect something like this would do it -

Sunken = QtWidgets.QFrame.Shadow.Sunken if isQt6 else self.Sunken
Raised = QtWidgets.QFrame.Shadow.Raised if isQt6 else self.StyledPanel
self.setFrameStyle(Raised | Sunken)

Also, couldn't self.Shadow be used instead of QtWidgets.QFrame.Shadow?

Edward K. Ream

unread,
Apr 12, 2021, 1:00:25 PM4/12/21
to leo-editor
On Mon, Apr 12, 2021 at 11:55 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Without testing it I don't think that will work. StyledPanel has been replaced by RaisedI would expect something like this would do it -

Sunken = QtWidgets.QFrame.Shadow.Sunken if isQt6 else self.Sunken
Raised = QtWidgets.QFrame.Shadow.Raised if isQt6 else self.StyledPanel
self.setFrameStyle(Raised | Sunken)

Also, couldn't self.Shadow be used instead of QtWidgets.QFrame.Shadow?

The new code follows the pattern used throughout the conversion.

Please test the code, and we'll go from there.

Edward

Edward K. Ream

unread,
Apr 12, 2021, 1:03:57 PM4/12/21
to leo-editor
On Monday, April 12, 2021 at 11:55:03 AM UTC-5 tbp1...@gmail.com wrote:

Without testing it I don't think that will work.

From https://doc.qt.io/qt-6/qframe.html#details "The frame style is specified by a frame shape and a shadow style that is used to visually separate the frame from surrounding widgets. These properties can be set together using the setFrameStyle() function..."

The only way to know for sure is to test it. The qt6 documentation has proved unreliable in the past.

Edward

tbp1...@gmail.com

unread,
Apr 12, 2021, 1:26:41 PM4/12/21
to leo-editor
As a practical matter, how are you managing to edit one of these files when Leo won't start until the file has been fixed?  If you check out an earlier changeset, you won't have the current copy of the file to work on.

For VR3, I work on my own copy located elsewhere, and use a shortcut command to copy it to my repo working directory.  That works pretty well for one file, but it would be cumbersome for a lot of them.

tbp1...@gmail.com

unread,
Apr 12, 2021, 1:57:39 PM4/12/21
to leo-editor
It failed because
LeoLineTextWidget' object has no attribute 'StyledPanel

as expected ...

tbp1...@gmail.com

unread,
Apr 12, 2021, 2:59:44 PM4/12/21
to leo-editor
I got qt_text to work - at least on the surface - with these changes:

            Sunken = QtWidgets.QFrame.Shadow.Sunken if isQt6 else self.Sunken

        Raised = QtWidgets.QFrame.Shadow.Raised if isQt6 else self.StyledPanel
        NoFrame = QtWidgets.QFrame.Shape.NoFrame if isQt6 else self.noFrame
        self.setFrameStyle(Raised | Sunken)
        self.edit = e  # A QTextEdit
        e.setFrameStyle(NoFrame)


Then I also needed to change in update():

                   #width = self.fm.width(str(max(1000, self.highest_line))) + self.w_adjust
        if isQt6:
            width = self.fm.boundingRect(str(max(1000, self.highest_line))).width()
        else:
            width = self.fm.width(str(max(1000, self.highest_line))) + self.w_adjust
        if self.width() != width:
            self.setFixedWidth(width
)

With these changes. Leo opens outlines without crashing.  I notice that the gutter numbers have too much padding-left, so they are cut off on the right.  I don't know where that is set, so I didn't do anything about it.

If you want, I can push these changes to my branch and do a PR.  It's probably easier for you to jsut copy them into yours.  Just let me know if you want the PR.

Next up: VR3 won't load because

viewrendered3.py requires QtWebKitWidgets.QWebView
pip install PyQtWebEngine

But how to get this without stepping on the one for qt5?  Hmmm.

Edward K. Ream

unread,
Apr 12, 2021, 3:30:18 PM4/12/21
to leo-editor
On Mon, Apr 12, 2021 at 12:26 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
As a practical matter, how are you managing to edit one of these files when Leo won't start until the file has been fixed? 

No problem: it works for me. I assume some plugin or setting is activating the code.
If you check out an earlier changeset, you won't have the current copy of the file to work on.

Nah. When Leo is hosed I just make the needed change in the scite editor.

Edward

Edward K. Ream

unread,
Apr 12, 2021, 3:31:50 PM4/12/21
to leo-editor
On Mon, Apr 12, 2021 at 1:59 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I got qt_text to work - at least on the surface - with these changes:

Thanks.  I'll make them in the ekr-qt branch later today.

Edward

tbp1...@gmail.com

unread,
Apr 12, 2021, 3:42:52 PM4/12/21
to leo-editor
That's what I did with qt_text, except for using EditPlus instead.

tbp1...@gmail.com

unread,
Apr 12, 2021, 3:46:35 PM4/12/21
to leo-editor
On Monday, April 12, 2021 at 2:59:44 PM UTC-4 tbp1...@gmail.com wrote:
I got qt_text to work - at least on the surface - with these changes:
                   #width = self.fm.width(str(max(1000, self.highest_line))) + self.w_adjust
        if isQt6:
            width = self.fm.boundingRect(str(max(1000, self.highest_line))).width()
        else:
            width = self.fm.width(str(max(1000, self.highest_line))) + self.w_adjust
        if self.width() != width:
            self.setFixedWidth(width
)

It's possible that self.setFixedWidth(width) has had an API change - I didn't look it up to see.  Perhaps this line didn't get executed so an error didn't show up.

tbp1...@gmail.com

unread,
Apr 12, 2021, 3:58:32 PM4/12/21
to leo-editor
Major problem - in the body pane, when I highlight a line of text, then press <CNTL>, the line vanishes.  I can get it back with <CTRL-C>.  Sometimes it left a residue of strange non-ascii characters, but I'm not sure what else I did to cause that (see attached screenshot).
leo_qt6_weirdness.png

tbp1...@gmail.com

unread,
Apr 12, 2021, 4:49:25 PM4/12/21
to leo-editor
The shift and ALT keys also do the same thing - delete the selection.  The strange characters get inserted when I press <SHIFT>.  This is using qt6, of course.

tbp1...@gmail.com

unread,
Apr 12, 2021, 5:09:14 PM4/12/21
to leo-editor
AS best as I can tell, QtWebEngine isn't available yet for qt6.  The github site for it only refers to qt5.15 as the latest reference I see.  I maybe had better remove qt6 from my everyday Python installation.

On Monday, April 12, 2021 at 2:59:44 PM UTC-4 tbp1...@gmail.com wrote:

tbp1...@gmail.com

unread,
Apr 12, 2021, 5:24:50 PM4/12/21
to leo-editor
Typo:
NoFrame = QtWidgets.QFrame.Shape.NoFrame if isQt6 else self.noFrame

should be

NoFrame = QtWidgets.QFrame.Shape.NoFrame if isQt6 else self.NoFrame

With this correction, it runs when only qt5 is available.
On Monday, April 12, 2021 at 2:59:44 PM UTC-4 tbp1...@gmail.com wrote:

tbp1...@gmail.com

unread,
Apr 12, 2021, 6:00:22 PM4/12/21
to leo-editor
Here is how I configured my installation to let me either use or not use pyqt6. Obviously it's a Windows computer:

1. Create new directory.  I used %USERPROFILE%\.python\site-packages
2. Cut all the installed pyqt6 directories from the standard Lib\site-packages directory.
3. Paste the pyqy6 directories into the new .python\site-packages directory.

To run without pyqt6, I just launch Leo as usual.  To run using pyqt6, I set the PYTHONPATH environmental variable:

set PYTHONPATH=%USERPROFILE%\.python\site-packages

Now Leo will launch using pyqt6.

If you have copied all the pyqt6 install directories also, then pip will find them and be able to properly list pyqt6 as well as the pyqt5  that is in the standard location.

Jacob Peck

unread,
Apr 12, 2021, 7:17:37 PM4/12/21
to leo-e...@googlegroups.com
Sounds like a situation that virtualenv would solve.

On Apr 12, 2021, at 6:00 PM, tbp1...@gmail.com <tbp1...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/3f9f3c39-678b-4b22-b1a2-183ab0e04cb9n%40googlegroups.com.

tbp1...@gmail.com

unread,
Apr 12, 2021, 7:55:36 PM4/12/21
to leo-editor
It would, but this is simpler and doesn't require one to keep various venvs straight.  I tend to forget which is for what and what state they are in.

Edward K. Ream

unread,
Apr 13, 2021, 10:14:03 AM4/13/21
to leo-editor
On Mon, Apr 12, 2021 at 1:59 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I got qt_text to work - at least on the surface - with these changes:
... 
If you want, I can push these changes to my branch and do a PR. 

Please do that. I find PR's are good records. I'll approve the PR immediately

Edward

Edward K. Ream

unread,
Apr 13, 2021, 11:09:16 AM4/13/21
to leo-editor
On Mon, Apr 12, 2021 at 2:58 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Major problem - in the body pane, when I highlight a line of text, then press <CNTL>, the line vanishes.  I can get it back with <CTRL-C>.  Sometimes it left a residue of strange non-ascii characters, but I'm not sure what else I did to cause that (see attached screenshot).

I don't see this behavior.

I wonder, are you using an alternate keyboard?  I got similar behavior when using the us-international keyboard on windows.

Edward

Edward K. Ream

unread,
Apr 13, 2021, 11:10:38 AM4/13/21
to leo-editor
On Mon, Apr 12, 2021 at 3:49 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
The shift and ALT keys also do the same thing - delete the selection.  The strange characters get inserted when I press <SHIFT>.  This is using qt6, of course.

Again, I see nothing like this. I've been using the qt6 code long enough that I would be surprised if there were any key-related problems.

Edward

tbp1...@gmail.com

unread,
Apr 13, 2021, 11:31:27 AM4/13/21
to leo-editor
No.  My keyboard is a logitech wireless one.  I don't have any other to try out.  I haven't changed the Windows keyboard settings.

tbp1...@gmail.com

unread,
Apr 13, 2021, 11:39:46 AM4/13/21
to leo-editor
This behavior makes it impossible to do any editing in Leo/pyqt6.  I can read the text, I can type into the body, but I can't use the ALT, SHIFT, or CNTRL keys if anything has been selected, and pressing the SHIFT key also inserts those strange glyphs so I can't type capitals.  The right and left shift keys do the same things.

I was going to capture the version/build info from the log pane, but pressing CNTRL-C actually inserted thes glyphs into the log pane, and only one line was copied.

tbp1...@gmail.com

unread,
Apr 13, 2021, 11:59:35 AM4/13/21
to leo-editor
OK, done.

tbp1...@gmail.com

unread,
Apr 13, 2021, 3:20:49 PM4/13/21
to leo-editor
I have written a very simple QT edit app using QTextEdit (attached).  It works with both Qt5 and Qt6, and typing Shift, Control, and Alt keys does not cause any unexpected behavior.  So whatever is happening is coming from Leo somehow.

BTW, you said that you've been using Leo/Qt6 for some time.  But I couldn't get it to run until I fixed qt_text.  How did you manage it?  I don't know what qt_text does, really, but it's imported even though it's not in my enabled plugins list.
basic_editor.py

Edward K. Ream

unread,
Apr 13, 2021, 4:16:22 PM4/13/21
to leo-editor
On Tue, Apr 13, 2021 at 2:20 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
BTW, you said that you've been using Leo/Qt6 for some time.  But I couldn't get it to run until I fixed qt_text.  How did you manage it? 

Apparently my installation did not execute the affected code.
I don't know what qt_text does, really, but it's imported even though it's not in my enabled plugins list.

It's part of Leo's qt gui code, which is all in the plugins directory because Leo can also use other guis.

Edward

Edward K. Ream

unread,
Apr 13, 2021, 4:25:26 PM4/13/21
to leo-editor
On Tue, Apr 13, 2021 at 10:39 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
This behavior makes it impossible to do any editing in Leo/pyqt6. 

I can imagine.

Just now I want to move on to the sabbatical. Feel free to investigate, or not, as you like. We can revisit this in a month or more if need be.

Edward

tbp1...@gmail.com

unread,
Apr 13, 2021, 5:38:56 PM4/13/21
to leo-editor
Right.

tbp1...@gmail.com

unread,
Apr 13, 2021, 10:51:29 PM4/13/21
to leo-editor
If I rpess a modifier key in the Nav or Console panes, nothing gets inserted, but in the log pane, I get this (gotten by copy-paste from the log pane - the "ctrl" + glyphs were added when I copied the "shift" + glyphs with CNTRL-C):

ctrl+ៀ?shift+ៀ?

In the body pane, I get the odd glyphs but not the words "ctrl" or "shift"

In a headline, I get what seem to be the same glyphs.  I'm thinking illegal o broken utf-8 byte arrays instead of strings, maybe.

Edward K. Ream

unread,
Apr 14, 2021, 5:35:41 AM4/14/21
to leo-editor
On Tue, Apr 13, 2021 at 9:51 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

If I rpess a modifier key in the Nav or Console panes, nothing gets inserted, but in the log pane, I get this (gotten by copy-paste from the log pane - the "ctrl" + glyphs were added when I copied the "shift" + glyphs with CNTRL-C):

ctrl+ៀ?shift+ៀ?

In the body pane, I get the odd glyphs but not the words "ctrl" or "shift"

In a headline, I get what seem to be the same glyphs. 

I just saw something similar after a Ctrl-Shift-C (paste-node).
 
I'm thinking illegal o broken utf-8 byte arrays instead of strings, maybe.

A reasonable hypothesis.

Edward

tbp1...@gmail.com

unread,
Apr 14, 2021, 11:55:33 PM4/14/21
to leo-editor
A possible clue:  When I press <SHIFT> for the first time after launching Leo, I get the following error message:

  OpenType support missing for "Consolas", script 32
  OpenType support missing for "DejaVu Sans Mono", script 32
  OpenType support missing for "Arial", script 32
  OpenType support missing for "MS UI Gothic", script 32
  OpenType support missing for "SimSun", script 32
  OpenType support missing for "Segoe UI Emoji", script 32
  OpenType support missing for "Segoe UI Symbol", script 32


I haven't gotten this behavior when pressing <CNTRL> or <ALT>.

If there is a problem with the type system, perhaps it's not a surprise if strange glyphs get inserted. In addition, my list of fonts in my font-family setting does not include some of these. 

In the configuration of this particular Leo instance I'm not using a Leo theme at all;  I have some settings in in MyLeoSettings for font-family, etc.  To avoid invoking the default theme, I'm specifying a non-existent theme name.
Reply all
Reply to author
Forward
0 new messages