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 01-18-2016, 03:19 AM   #181
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
Unhappy

Hello everyone !
I want to use Qt5 instead of Tkinter in plugin but thats not working correctly. Any idea of doing this ?
hantsaniala is offline   Reply With Quote
Old 01-18-2016, 06:32 AM   #182
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by khadafi View Post
Hello everyone !
I want to use Qt5 instead of Tkinter in plugin but thats not working correctly. Any idea of doing this ?
Not possible right now (unless you package all of PyQt with your plugin).

EDIT: I take that back. If you want to use an externally installed Python interpreter you can use whatever python gui framework you have at your disposal. But if you wanted to share your plugin, you'd have to instruct users how to set up their python environment to match yours.

Last edited by DiapDealer; 01-18-2016 at 06:44 AM.
DiapDealer is offline   Reply With Quote
Advert
Old 01-18-2016, 06:52 AM   #183
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
We supposed that there is already PyQt5 installed on the client computer.
I've these files plugin.py and Formulaire.py.
Can you help me please ? Thanks for answer.
hantsaniala is offline   Reply With Quote
Old 01-18-2016, 07:01 AM   #184
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
If you already have PyQt5 installed (and you've verified that you can, in fact, do PyQt stuff outside of Sigil), then it should work. You just have to make sure you've unchecked "Use Bundled Python" in Sigil's Plugin Manager dialog, and configured your external Python interpreter.
DiapDealer is offline   Reply With Quote
Old 01-18-2016, 07:16 AM   #185
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
Quote:
If you already have PyQt5 installed (and you've verified that you can, in fact, do PyQt stuff outside of Sigil), then it should work.
Yes, PyQt5 run correctly outside of Sigil

Quote:
You just have to make sure you've unchecked "Use Bundled Python" in Sigil's Plugin Manager dialog, and configured your external Python interpreter.
There is no checkbox called "Use Bundled Python" on my Sigil (Sigil 0.8.7)

Any idea ?
hantsaniala is offline   Reply With Quote
Advert
Old 01-18-2016, 07:25 AM   #186
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by khadafi View Post
Yes, PyQt5 run correctly outside of Sigil


There is no checkbox called "Use Bundled Python" on my Sigil (Sigil 0.8.7)
Have you configured the correct Python interpreter? If PyQt is installed to work with Python3, then you need to make sure you've configured Sigil with the Python3 interpreter (or vice-versa). Also make sure the "engine" tag in the plugin.xml file has the correct PyQt-enabled entry (python34 or python27).
DiapDealer is offline   Reply With Quote
Old 01-18-2016, 07:37 AM   #187
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
Quote:
Originally Posted by DiapDealer View Post
Have you configured the correct Python interpreter? If PyQt is installed to work with Python3, then you need to make sure you've configured Sigil with the Python3 interpreter (or vice-versa). Also make sure the "engine" tag in the plugin.xml file has the correct PyQt-enabled entry (python34 or python27).
Yes, there is "/usr/local/bin/python3", and other plugins work correctly. Only this test with PyQt5 doesn't work. I'm a beginner too with PyQt5 so I'm trying new stuff.
hantsaniala is offline   Reply With Quote
Old 01-18-2016, 08:11 AM   #188
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm not near my computer right now, so everything I'm mentioning is off the top of my head. Let me check on this when I get home and make sure I'm not leading you astray on what is possible.
DiapDealer is offline   Reply With Quote
Old 01-18-2016, 08:33 AM   #189
hantsaniala
Member
hantsaniala began at the beginning.
 
hantsaniala's Avatar
 
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
Okay, let me know if you found some solution.
Now, It's work, the widget is working now but it's very slow compared to Tkinter (I don't know why).

PS : Can you help me to delete the post number #184 ?
hantsaniala is offline   Reply With Quote
Old 01-18-2016, 08:53 AM   #190
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'd rather not delete it. It may help someone in the future who's looking to do something similar.
DiapDealer is offline   Reply With Quote
Old 01-18-2016, 09:04 AM   #191
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by DiapDealer View Post
I'd rather not delete it. It may help someone in the future who's looking to do something similar.
He meant his on of his double responses.
Toxaris is offline   Reply With Quote
Old 01-18-2016, 09:27 AM   #192
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,607
Karma: 204624552
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Toxaris View Post
He meant his on of his double responses.
Oh! Duh.
DiapDealer is offline   Reply With Quote
Old 01-20-2016, 07:53 AM   #193
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,731
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
JavaScript in the Preview window console

I've found out by chance that it's possible to run JavaScript code in the Preview console window.
Of course, since the read-only Preview window doesn't allow edits, you can only use it for temporary changes. For example, you can highlight certain words.

You can test this with the following simple script, which will highlight all search terms. (BTW, only the first line is by me.)

Spoiler:
Code:
// Highlight text example
enteredText = prompt("What do want to search for?");

findAndReplace('(' + enteredText + ')', '<span style="background-color: #FFFF00;">$1</span>')

// code by James Padolsey; http://james.padolsey.com/javascript/find-and-replace-text-with-javascript/
function findAndReplace(searchText, replacement, searchNode) {
    if (!searchText || typeof replacement === 'undefined') {
        // Throw error here if you want...
        return;
    }
    var regex = typeof searchText === 'string' ?
                new RegExp(searchText, 'g') : searchText,
        childNodes = (searchNode || document.body).childNodes,
        cnLength = childNodes.length,
        excludes = 'html';
    while (cnLength--) {
        var currentNode = childNodes[cnLength];
        if (currentNode.nodeType === 1 &&
            (excludes + ',').indexOf(currentNode.nodeName.toLowerCase() + ',') === -1) {
            arguments.callee(searchText, replacement, currentNode);
        }
        if (currentNode.nodeType !== 3 || !regex.test(currentNode.data) ) {
            continue;
        }
        var parent = currentNode.parentNode,
            frag = (function(){
                var html = currentNode.data.replace(regex, replacement),
                    wrap = document.createElement('div'),
                    frag = document.createDocumentFragment();
                wrap.innerHTML = html;
                while (wrap.firstChild) {
                    frag.appendChild(wrap.firstChild);
                }
                return frag;
            })();
        parent.insertBefore(frag, currentNode);
        parent.removeChild(currentNode);
    }
}


(To display the console window, click Console in the grey menu bar below the Preview window; press Enter to run the code.)

EDIT: This script doesn't work with all ePubs. With some ePubs you might get the following error:

Code:
Error: SyntaxError: DOM Exception 12
and I haven't got the faintest idea what's causing this.

If it doesn't work with your book, you can test it with Sigil_python_plugins.html from the Plugin Framework guide.

Last edited by Doitsu; 01-09-2018 at 02:41 AM.
Doitsu is offline   Reply With Quote
Old 01-24-2016, 06:36 AM   #194
rubeus
Banned
rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.
 
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
Hi,

as far as i can see there is no method available in the API to just rename a file. I need to delete it and insert it again - but then its position is gone in the spine and i have to add id there again - in the right position.

Did i miss something or is it so complicated?

//rubeus

PS thinking again deleting/adding is not an option (even if i would be able to handle the spine) as it will disrupt any other links pointing to this file.

Last edited by rubeus; 01-24-2016 at 07:01 AM.
rubeus is offline   Reply With Quote
Old 01-24-2016, 08:23 AM   #195
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,805
Karma: 6000000
Join Date: Nov 2009
Device: many
Renaming means having to do a universal update to find everything that points to it. That code exists in Sigil so renaming is best done inside Sigil itself and not in a plugin to prevent huge duplication of url/href/src and etc link updating code. The purpose of the plugin is to extend Sigil, not duplicate Sigil's functionality.
KevinH 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 05:27 AM.


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