Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 01-02-2022, 10:32 PM   #31
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@jackie_w: Thanks, fixed by: https://github.com/kovidgoyal/calibr...3d57adaa187c3c
kovidgoyal is offline   Reply With Quote
Old 01-03-2022, 04:00 AM   #32
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Released version 5.99.1 with fixes for all issues reported so far (other than thiago's checkbox shadows)
kovidgoyal is offline   Reply With Quote
Advert
Old 01-03-2022, 08:11 AM   #33
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 921
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by kovidgoyal View Post
Released version 5.99.1 with fixes for all issues reported so far (other than thiago's checkbox shadows)
My issues are caused by Qt's new High DPI Scaling policy. It only affects those using a non-integer scale factor. In my case, I use 125%. This is a known issue of Qt6, as pointed here.

This causes some graphical glitches. In my case:

- Kind of a shadow on some checkboxes
- Missing separators
- Small icons are drawed with poor quality (the same ones that looked ok on Qt5).
- The whole calibre interface got "bigger". I have bigger icons, bigger line spaces, etc.

For the icons on my plugins, I just used larger ones, but the rest of the problems remained. So, I dealed with it by setting this environment variable:
Code:
QT_ENABLE_HIGHDPI_SCALING = 0
This is the standard look. Bigger interface, missing separators on plugin menu.
Click image for larger version

Name:	Standard.png
Views:	179
Size:	230.7 KB
ID:	191308

After setting the environment variable.
Click image for larger version

Name:	Changed.png
Views:	175
Size:	227.6 KB
ID:	191309
thiago.eec is offline   Reply With Quote
Old 01-03-2022, 05:51 PM   #34
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 720
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
Excellent. Is the beta? in the beta section?
dunhill is offline   Reply With Quote
Old 01-03-2022, 07:21 PM   #35
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@DNSB reported to me an error on some of the plugins I look after. The error was:

Code:
ModuleNotFoundError: No module named 'PyQt4'
Which is being triggered by one of the imports from the Qt5 not loading and attempts to load Qt4 happen.

When I looked the original error was:


Code:
Traceback (most recent call last):
  File "calibre_plugins.goodreads.config", line 16, in <module>
ImportError: cannot import name 'Qt' from 'qt' (E:\CalibrePortable599\Calibre Portable\Calibre\app\bin\python-lib.bypy.frozen\qt\__init__.pyc)
Which comes from the line:

Code:
    from PyQt5 import Qt as QtGui
Is this something missed or do we need to change this? Looking through the code, "QtGui" is used mainly for some enums/type but, also a few classes that were not explicitly imported.
davidfor is offline   Reply With Quote
Advert
Old 01-03-2022, 07:59 PM   #36
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 6,494
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
Quote:
Originally Posted by kovidgoyal View Post
@jackie_w You need to use fully qualified names for enums in PyQt6, as thiago pointed out. I have added compatibility layers for the most common enums in calibre so they can continue to be used as before, but not for all of them.
One I use that no longer works in the beta is QTextEdit.NoWrap.

Should I change this to QTextEdit.LineWrapMode.NoWrap or will you add that to the compatibility layer?

If I change it to the fully qualified enum will it be backward compatible with older versions of calibre?

Last edited by jhowell; 01-03-2022 at 08:18 PM.
jhowell is online now   Reply With Quote
Old 01-03-2022, 09:33 PM   #37
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@davidfor: The PyQt5.Qt module was a shortcut module for importing other Qt classes from a common namespace that was removed in PyQt6. It should not be used and and definitely not aliased as QtGui which is a different module altogether.

Indeed, from calibre 5.13 onwards you can simply do all Qt related imports as

from qt.core import whatever

It works on qt 5 and qt 6. This is what is used in calibre source code itself.

@jhowell: Yes, QTextEdit is rather too specialised for me too add a compat layer for it. Ans yes, the fully qualified names work with calibre 5.x as well. Not sure about even earlier versions though.
kovidgoyal is offline   Reply With Quote
Old 01-03-2022, 09:34 PM   #38
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by dunhill View Post
Excellent. Is the beta? in the beta section?
The link to the betas is in the first post of this thread.
kovidgoyal is offline   Reply With Quote
Old 01-04-2022, 12:31 AM   #39
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kovidgoyal View Post
@davidfor: The PyQt5.Qt module was a shortcut module for importing other Qt classes from a common namespace that was removed in PyQt6. It should not be used and and definitely not aliased as QtGui which is a different module altogether.

Indeed, from calibre 5.13 onwards you can simply do all Qt related imports as

from qt.core import whatever

It works on qt 5 and qt 6. This is what is used in calibre source code itself.
The example I was looking at was the Goodreads Metadata source plugin. Which was one of @kiwidudes. The code for importing Qt is:

Code:
try:
    from PyQt5 import Qt as QtGui
    from PyQt5.Qt import (QTableWidgetItem, QVBoxLayout, Qt, QGroupBox, QTableWidget,
                          QCheckBox, QAbstractItemView, QHBoxLayout, QIcon,
                          QInputDialog)
except ImportError:
    from PyQt4 import QtGui
    from PyQt4.Qt import (QTableWidgetItem, QVBoxLayout, Qt, QGroupBox, QTableWidget,
                          QCheckBox, QAbstractItemView, QHBoxLayout, QIcon,
                          QInputDialog)
And then used like:

Code:
        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        button_layout.addItem(spacerItem1)
        remove_mapping_button = QtGui.QToolButton(self)

And that's pretty common in the plugins. I assume the first line was a cheat so that we didn't have to change the code that was using QtGui from Qt4. I'll have a look to see how easy it is to change, but, it might be time to drop the Qt4 support.
davidfor is offline   Reply With Quote
Old 01-04-2022, 12:38 AM   #40
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes, its definitely time to drop Qt4 support. Though if you dont want to, you could in theory do this:

Code:
try:
    import qt.core as QtGui
except ImportError:
    try:
        from PyQt5 import Qt as QtGui
    except ImportError:
        from PyQt4 import QtGui
kovidgoyal is offline   Reply With Quote
Old 01-04-2022, 04:38 AM   #41
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by thiago.eec View Post
Not tested, but a suggestion based on the problems I found porting my plugins... maybe you should use:
Code:
QTableWidgetItem.ItemType.UserType
https://doc.qt.io/qt-6/qtablewidgeti...#ItemType-enum
That didn't work here. I had to use:

Code:
QTableWidgetItem.ItemType.UserType.value
And that doesn't work with Qt5. I get:

Code:
AttributeError: 'ItemType' object has no attribute 'value'
for the lines that use the above.

And with out the ".value", with Qt6, the error is:


Code:
TypeError: QTableWidgetItem(): arguments did not match any overloaded call:
  overload 1: argument 1 has unexpected type 'str'
  overload 2: argument 2 has unexpected type 'ItemType'
  overload 3: argument 1 has unexpected type 'str'
  overload 4: argument 1 has unexpected type 'str'
The line is:

Code:
super(ReadOnlyTableWidgetItem, self).__init__(text, QTableWidgetItem.ItemType.UserType)
With the ".value" for the Qt6 version.

What have I missed?
davidfor is offline   Reply With Quote
Old 01-04-2022, 05:53 AM   #42
rcentros
eReader Wrangler
rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.rcentros ought to be getting tired of karma fortunes by now.
 
rcentros's Avatar
 
Posts: 7,425
Karma: 48453105
Join Date: Mar 2013
Location: Boise, ID
Device: PB HD3, GL3, Tolino Vision 4, Voyage, Clara HD
Quote:
Originally Posted by kovidgoyal View Post
calibre comes with its own copy of Qt, it doesn't care what Qt is on the host system. You do however need a recent enough version of glibc, which for calibre 6 is IIRC 2.31 which will be about two years old at the time of calibre 6 release.
Quote:
Originally Posted by Moonbase59 View Post
Thanks! Yes, my glibc is 2.31 (Linux Mint 20.2).
It looks like I'll be using Calibre 5.x through April, 2023 when my Linux Mint 19.3 goes to EOL. 19.3 is still at glib 2.27. I just recently upgraded from 4.x to 5.x because I wanted to use a specific plugin (DeASCM). I don't mind being on the trailing edge.
rcentros is offline   Reply With Quote
Old 01-04-2022, 06:11 AM   #43
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,826
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@davidfor: That's a bug in PyQt6. Just use the literal 1000 it should work in both. Or if you want to be elegant:

Code:
try:
    MyType = QTableWidgetItem.ItemType.UserType.value
except AttributeError:
    MyType = QTableWidgetItem.UserType
Sadly, Phil decided to move PyQt to using python enums in PyQt6 and caused endless bugs and breakage in the process. There are literally hundreds of commits I've had to make to fix all the breakage this decision has caused.
kovidgoyal is offline   Reply With Quote
Old 01-04-2022, 07:34 AM   #44
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kovidgoyal View Post
@davidfor: That's a bug in PyQt6. Just use the literal 1000 it should work in both. Or if you want to be elegant:

Code:
try:
    MyType = QTableWidgetItem.ItemType.UserType.value
except AttributeError:
    MyType = QTableWidgetItem.UserType
Sadly, Phil decided to move PyQt to using python enums in PyQt6 and caused endless bugs and breakage in the process. There are literally hundreds of commits I've had to make to fix all the breakage this decision has caused.
I was afraid of that. And that is a bad decision. It defeats the purpose of the types if you can't just use them.
davidfor is offline   Reply With Quote
Old 01-04-2022, 08:26 AM   #45
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,197
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by kovidgoyal View Post
@davidfor: That's a bug in PyQt6. Just use the literal 1000 it should work in both. Or if you want to be elegant:

Code:
try:
    MyType = QTableWidgetItem.ItemType.UserType.value
except AttributeError:
    MyType = QTableWidgetItem.UserType
I'd already realised that this works:
Code:
QTableWidgetItem.__init__(self, text, 1000)
but thanks for the elegant option which also works.

I'm fairly sure the code both @davidfor and myself are using originates from @kiwidude's early plugins. Sorry if this is a dumb question, is there a good reason why a UserType needs to be specified at all, because this also appears to work? Presumably it defaults to a UserType of zero:
Code:
QTableWidgetItem.__init__(self, text)
jackie_w is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestion for PI Devs BetterRed Plugins 11 09-27-2020 06:18 PM
Attn plugin devs: porting to python 3 kovidgoyal Plugins 129 06-16-2020 01:31 AM
Attention All Plugin Devs: Remove vestiges from python 2? KevinH Plugins 11 05-29-2020 03:16 PM
Plugin Devs: Should we include a License or COPYING file? KevinH Plugins 3 08-15-2017 01:09 PM
New Plugin Features in the upcoming Sigil 0.8.900 KevinH Plugins 6 09-14-2015 02:48 PM


All times are GMT -4. The time now is 08:22 AM.


MobileRead.com is a privately owned, operated and funded community.