12-18-2016, 06:12 PM | #16 |
Witchman
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. |
12-18-2016, 09:49 PM | #17 |
Witchman
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.
|
12-22-2016, 06:39 AM | #18 |
Witchman
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' |
01-27-2020, 04:50 PM | #19 |
Grand Sorcerer
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) Code:
app = QApplication(sys.argv) Code:
dark_palette(bk, app) 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. |
|
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 |