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 12-18-2016, 06:12 PM   #16
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer...That's strange. I haven't received your email yet. I've also checked my spam etc.

I'll send you another private email giving you my email address again, just in case I typed it wrong.
slowsmile is offline   Reply With Quote
Old 12-18-2016, 09:49 PM   #17
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
@DiapDealer...I received your second email without a problem and have just emailed you some info + plugin + test file. Much thanks for your help.
slowsmile is offline   Reply With Quote
Old 12-22-2016, 06:39 AM   #18
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
Here's another interesting BeautifulSoup snippet that I've just successfully used:

Code:
   # convert all html text to block text format        
    for tag in soup.findAll('p'):
        if tag.has_attr('style') and 'text-align: center' not in tag['style'].lower():
            del tag['style']
            tag['class'] = 'BlockText'
The above four lines of code will delete all 'style' attributes in p tags and then add the BlockText class - centered text will not be affected.
slowsmile is offline   Reply With Quote
Old 01-27-2020, 04:50 PM   #19
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,045
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Fairly self-contained Python code to make your PyQt5-based GUI plugin match Sigil's light/dark theme. It should be compatible with any version of Sigil that supports PyQt5 plugins. The dark theme just won't appear unless you're using Sigil 1.1.0 or higher.

Code:
def dark_palette(bk, app):
    supports_theming = (bk.launcher_version() >= 20200117)
    if not supports_theming:
        return
    if bk.colorMode() != "dark":
        return
    try:
        from PyQt5.QtCore import Qt
        from PyQt5.QtGui import QColor, QPalette
        from PyQt5.QtWidgets import QStyleFactory
    except ImportError:
        return

    p = QPalette()
    sigil_colors = bk.color
    dark_color = QColor(sigil_colors("Window"))
    disabled_color = QColor(127,127,127)
    dark_link_color = QColor(108, 180, 238)
    text_color = QColor(sigil_colors("Text"))
    p.setColor(p.Window, dark_color)
    p.setColor(p.WindowText, text_color)
    p.setColor(p.Base, QColor(sigil_colors("Base")))
    p.setColor(p.AlternateBase, dark_color)
    p.setColor(p.ToolTipBase, dark_color)
    p.setColor(p.ToolTipText, text_color)
    p.setColor(p.Text, text_color)
    p.setColor(p.Disabled, p.Text, disabled_color)
    p.setColor(p.Button, dark_color)
    p.setColor(p.ButtonText, text_color)
    p.setColor(p.Disabled, p.ButtonText, disabled_color)
    p.setColor(p.BrightText, Qt.red)
    p.setColor(p.Link, dark_link_color)
    p.setColor(p.Highlight, QColor(sigil_colors("Highlight")))
    p.setColor(p.HighlightedText, QColor(sigil_colors("HighlightedText")))
    p.setColor(p.Disabled, p.HighlightedText, disabled_color)

    app.setStyle(QStyleFactory.create("Fusion"))
    app.setPalette(p)
Then after you initialize your QApplication and before you show/exec it:

Code:
app = QApplication(sys.argv)
Add the following function call that takes the BookContainer object and QApplication object as parameters:

Code:
dark_palette(bk, app)
That's about it. Building your PyQt5 Application Widgets is up to you.

I may add some platform-specific tweaks and bug workarounds from time to time. I know for a fact there's some Mac color issues.

Last edited by DiapDealer; 01-28-2020 at 02:21 PM.
DiapDealer is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the selected category in the code of the gui plugin? esvorontsov Development 1 10-03-2015 01:52 AM
How to get the uuid of the book in the code of the gui plugin? esvorontsov Development 3 09-29-2015 12:15 PM
Fragment identifiers frisket ePub 19 04-02-2014 03:44 PM
Using image in plugin code Jellby Development 7 03-11-2014 11:56 PM
FRAGMENT ERROR MESSAGE dgbeig ePub 5 11-23-2013 08:21 PM


All times are GMT -4. The time now is 12:20 PM.


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