Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-12-2025, 04:36 PM   #586
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,818
Karma: 206879174
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by BeckyEbook View Post
But now it is defined, plus it is the same color as Base.
Are you sure? It was my understanding that AlternateBase (in plugin_utils.py) is being assigned the same color as the Window role from Sigil.

https://github.com/Sigil-Ebook/Sigil...unner.cpp#L244

https://github.com/dougmassay/sigil-..._utils.py#L264

https://github.com/dougmassay/sigil-..._utils.py#L272

Unless Base and Window are the same color.

I'm not opposed to your suggestion, but I would ultimately like the actual system alternateBase color to be used. With a hard-coded color in plugin_utils.py being embedded in tons of Qt plugins, that might not be a realistic hope.

I'd rather we didn't have to do this (match_dark_palette) on Windows at all, but...
DiapDealer is offline   Reply With Quote
Old 08-12-2025, 05:33 PM   #587
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 890
Karma: 3501166
Join Date: Jan 2017
Location: Poland
Device: Various
Of course – not Base, but Window.
BeckyEbook is online now   Reply With Quote
Old 08-13-2025, 03:27 PM   #588
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,818
Karma: 206879174
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I went ahead and updated plugin_utils.py (and the light version) with your suggested color. Thanks!
DiapDealer is offline   Reply With Quote
Old 08-14-2025, 11:27 AM   #589
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
Ok, I updated my copy of plugin_utils too.

One question for DiapDealer: the readme of the sigil-plugin-utils repository indicates the GPL v3 license but the notice at the top of each file shows the 2-clause BSD license. Is the latter the valid one or do you have another preference?
wrCisco is offline   Reply With Quote
Old 08-14-2025, 11:59 AM   #590
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,818
Karma: 206879174
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I prefer the 2-clause BSD (more permissive than GPLv3). I think GitHub might have just defaulted to GPLv3 when I quickly created the repo. I'll try to make them match. Thanks.

EDIT: I think I got everything updated to match on GitHub. Thanks again.

Last edited by DiapDealer; 08-14-2025 at 12:10 PM.
DiapDealer is offline   Reply With Quote
Old 08-25-2025, 05:34 PM   #591
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
I wanted to improve and generalize the first-words-then-everywhere wrapping of text for the plain text of QLabels, so I'm partially rewriting the code of my WrappingCheckBox widget to use QTextBoundaryFinder to split words and graphemes in a text, and I stumbled upon a small incompatibility between pyqt5 and pyside6: while in pyside6 you can iterate over qt enums, in pyqt5 you can't. Do you know if there is a more clever way to do what I'm doing with 'boundary_reasons' in the following function (an optional parameter which, if None, is assigned all the enumeration's values combined)?

Code:
from functools import reduce
from plugin_utils import QtCore

def tokenize_text(
            text: str,
            boundary_type: QtCore.QTextBoundaryFinder.BoundaryType,
            boundary_reasons: QtCore.QTextBoundaryFinder.BoundaryReason | None = None) -> list[str]:
        """
        Divide text in a list of tokens based on boundary_type.
        boundary types: Grapheme, Word, Line, Sentence
        """
        if boundary_reasons is None:
            try:
                # BreakOpportunity doesn't come up while iterating over BoundaryReason flags
                # (PySide 6.9), so I use it as the initializer of the reduce function
                boundary_reasons = reduce(
                    lambda x, y: x | y,
                    QtCore.QTextBoundaryFinder.BoundaryReason,
                    QtCore.QTextBoundaryFinder.BoundaryReason.BreakOpportunity
                )
            except TypeError:
                # PyQt5 doesn't allow iterations over Qt enums
                boundary_reasons = (
                    QtCore.QTextBoundaryFinder.BoundaryReason.StartOfItem
                    | QtCore.QTextBoundaryFinder.BoundaryReason.EndOfItem
                    | QtCore.QTextBoundaryFinder.BoundaryReason.MandatoryBreak
                    | QtCore.QTextBoundaryFinder.BoundaryReason.SoftHyphen
                    | QtCore.QTextBoundaryFinder.BoundaryReason.BreakOpportunity
                )
        tbf = QtCore.QTextBoundaryFinder(boundary_type, text)
        tokens = []
        pos = prev = tbf.position()
        while True:
            pos = tbf.toNextBoundary()
            if pos == -1:
                break
            if pos != prev and boundary_reasons & tbf.boundaryReasons():
                token = text[prev:pos]
                tokens.append(text[prev:pos])
                prev = pos
        return tokens
I found a couple of Stack Overflow answers that address the issue, but the solution proposed seems way too complex for my limited use case (https://stackoverflow.com/questions/...representation, https://stackoverflow.com/questions/...-typedef-for-q).
wrCisco is offline   Reply With Quote
Old 08-25-2025, 07:23 PM   #592
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,990
Karma: 6361444
Join Date: Nov 2009
Device: many
Given it is only one enum and given PyQt5/Qt5 has no further development and therefore the enum will never be changed, your approach seems like the simplest and best.

That said, PyQt5 had a long life. Are there any earlier versions of this enum in Qt5 that changed? Maybe eyeball the history of the Qt source file that defines the Qt5 enum on github to see if it ever changed over its life. If not, you should be golden.

Update: It did change very early in Qt 5.0 from the final Qt 4.x series as per:
https://github.com/qt/qtbase/commit/...41ecc95fa976e9

But since that change happened to make Qt 5.0.0 you should be quite safe.

Here is the enum as stated in Qt 5.15.x. You should be good to go.

Code:
   enum BoundaryReason {
        NotAtBoundary = 0,
        BreakOpportunity = 0x1f,
        StartOfItem = 0x20,
        EndOfItem = 0x40,
        MandatoryBreak = 0x80,
        SoftHyphen = 0x100
    };

Last edited by KevinH; 08-25-2025 at 07:45 PM.
KevinH is online now   Reply With Quote
Old 08-25-2025, 07:46 PM   #593
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,818
Karma: 206879174
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I knowingly punted on trying to attain enum compatibility between PyQt5 and PySide6 with plugin_utils.

I agree with Kevin here. No need to get overly clever/complex for one enum. You could check to see if PySide6 is already in sys.modules rather than try/except, but there's no real advantage either approach would have over the other in my opinion.
DiapDealer is offline   Reply With Quote
Old 08-26-2025, 04:41 AM   #594
wrCisco
Connoisseur
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 50
Karma: 605108
Join Date: Apr 2016
Device: none
Ok, thank you both!
wrCisco is offline   Reply With Quote
Old Yesterday, 01:43 AM   #595
mrprobert
Connoisseur
mrprobert began at the beginning.
 
Posts: 73
Karma: 46
Join Date: Mar 2017
Device: None
Writing plugins with a chatbot

Hi,

Long ago I wrote a tiny sed script to translate font units like small, medium, etc. into ems and rems. It worked well enough but it was getting to be a pain to use as it runs outside of the Sigil environment. Just for fun I used Claude AI to write a plugin based my script. I've attached the result along with documentation. I am interested in hearing about:

1. Any issues with the algorithm?
2. Is it a "conforming" plugin?
3. What do you think of the code?

Thanks for your time.
Attached Files
File Type: zip NewUnit.zip (14.9 KB, 9 views)
File Type: zip Docs.zip (36.3 KB, 8 views)
mrprobert is offline   Reply With Quote
Old Yesterday, 05:23 AM   #596
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,756
Karma: 24032915
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by mrprobert View Post
2. Is it a "conforming" plugin?
No really, because Tk support will be removed in future Sigil versions.

BTW, you might want to add the following line to plugin.xml:

Code:
<autostart>true</autostart>
I'm curious about the use case. What kind of tool generates epubs that use:

Code:
font-size: small;
Doitsu is offline   Reply With Quote
Old Yesterday, 06:14 AM   #597
mrprobert
Connoisseur
mrprobert began at the beginning.
 
Posts: 73
Karma: 46
Join Date: Mar 2017
Device: None
Quote:
Originally Posted by Doitsu View Post
No really, because Tk support will be removed in future Sigil versions.
Good to know, thanks.


Quote:
I'm curious about the use case. What kind of tool generates epubs that use:

Code:
font-size: small;
I've seen this kind of construct in older files, mostly ancient epub2 epubs.
mrprobert is offline   Reply With Quote
Old Yesterday, 08:06 PM   #598
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 47,665
Karma: 172313956
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
One genius at one of the big publishers about 12 years back generated ePubs with the body font size set to large and the base paragraph font size set to small. This came up with a base paragraph font size just over 1em. Oddly, several newer books use the same except for the body size being set to 1.09em and the base paragraph being set to 0.917em with same result of an ~1em base paragraph size.
DNSB is offline   Reply With Quote
Old Yesterday, 09:38 PM   #599
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,818
Karma: 206879174
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
The markup in mobi files was full of small, medium, large, x-small, xx-large, and normal font sizes.

The mobi2xhtml script in the kindleinport plugin has a routine that tried to make some sort of sense out of it:

https://github.com/dougmassay/kindle...2xhtml.py#L358
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 06:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-04-2012 11:33 PM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 09:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 12:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 12:44 PM


All times are GMT -4. The time now is 01:00 PM.


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