12-03-2014, 07:30 AM | #61 | |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Code:
import win32gui from win32gui import GetWindowText class_name = 'Qt5QWindowIcon' window_name = None hwnd = win32gui.FindWindow(class_name, window_name) if hwnd: print GetWindowText(hwnd) # returns 'untitled.epub - Sigil' For a more robust solution, you'll need to enumerate all windows using win32gui.EnumWindows. |
|
12-03-2014, 09:11 AM | #62 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi,
You can of course get the title from the opf or doctitle from the ncx. One of the routines in the libgui I posted will give you a valid filename from a title, and you can use that to initialize the fileSaveAs gui element and let the user easily specify the location and change the name for your output file. The ePub3-itizer plugin uses that approach if you are looking for an example. Kevin |
Advert | |
|
12-03-2014, 09:45 AM | #63 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
@KevinH: I also think that the book title would make for a better file name and I use it as the file name in my Kindlegen wrapper. My file name generation method is not as elegant as your method, though, but it works.
I merely mentioned the the win32gui library, because the OP specifically asked for a method of getting the file name. (Since this method cannot be easily ported to Linux/OSX and all Sigil plugins should ideally work on all three platforms, I wouldn't use it for plugins uploaded to MR.) |
12-03-2014, 04:52 PM | #64 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi All,
I have updated the first two posts with links to a new pre-release version of the launcher code for Sigil that will support Preferences. All thanks to DiapDealer for designing and implementing these new launcher features! He has nicely created Plugin examples that illustrate their use. I have included a launcher_updater python program that will install the updates for you. This updater should only be run with stock Sigil 0.8.2. If you have any questions just ask. As new features are added to the launcher code, we will periodically making these pre-releases so that plugin developers can more easily test things out before the next Sigil Release is made. Take care, KevinH |
12-03-2014, 06:00 PM | #65 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
I've just tested the launcher updater with DiapDealer's inofficial 0.8.2 Linux build and the official 64bit Windows 0.8.2 version. I got a 'Sigil launcher code updated successfully' message, but the Python files in /usr/local/share/sigil/plugin_launchers/python and C:\Program Files\Sigil\plugin_launchers\python weren't updated.
|
Advert | |
|
12-03-2014, 06:08 PM | #66 | |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi Doitsu,
Well that's not good. It works on my Mac OS X build. On Mac it looks here: _DIRS_TO_SEARCH.append("/Applications/Sigil.app/Contents/plugin_launchers/python") On linux it will look in the following locations and can overide via an environment var: _DIRS_TO_SEARCH.append("/usr/share/sigil/plugin_launchers/python") _DIRS_TO_SEARCH.append("/usr/local/share/sigil/plugin_launchers/python") _DIRS_TO_SEARCH.append("/opt/share/sigil/plugin_launchers/python") On Windows it looks here: Code:
programfiles = os.environ.get("ProgramFiles") programfilesx86 = os.environ.get("ProgramFiles(x86)") if programfiles is not None: _DIRS_TO_SEARCH.append(os.path.join(programfiles,"Sigil","plugin_launchers","python")) if programfilesx86 is not None: _DIRS_TO_SEARCH.append(os.path.join(programfilesx86,"Sigil","plugin_launchers","python")) You might try an sudo on Linux to see if that fixes things or being Admin on Linux. If that doesn't help, your best bet until I figure this out is manually copy the files. Don't forget the completely new file preferences.py. Kevin Quote:
Last edited by KevinH; 12-03-2014 at 06:19 PM. |
|
12-03-2014, 06:14 PM | #67 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
|
12-03-2014, 06:20 PM | #68 |
Grand Sorcerer
Posts: 27,968
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
@KevinH:
Yeah, it's not copying any files on Windows either. It's only succeeding because technically ... nothing went wrong. I've got it narrowed down to the call to unipath.walk("./payload") in __main__.py. It's returning an empty list instead of the files in the payload folder. Is it possible that something's different with accessing a folder "relatively" (./payload) inside a zipfile on Windows/Linux? |
12-03-2014, 06:31 PM | #69 | |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi DiapDealer,
Forget about it. I just tried again and now it doesn't work on Macs either. I bet I ran it once from inside the directory and then tried it after zipping it up and it said successful and I looked and the files were there. I don't think this is ever going to work the way I want it to. So can you please try one thing: Unzip the launcher_updater_20141204.zip but do not cd into it. Then try doing the following: python launcher_updater_20141204 And yes we are just passing the folder name into python, but that is supposed to work as well. This does work on my Mac. Kevin Quote:
Last edited by KevinH; 12-03-2014 at 07:13 PM. |
|
12-03-2014, 07:28 PM | #70 | |
Grand Sorcerer
Posts: 27,968
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
It SAYS everything went OK, but nothing gets copied and flist is empty. |
|
12-03-2014, 07:35 PM | #71 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi DiapDealer,
Okay I tried one more time and put up a new version that uses full paths instead of relative paths. This one now feeds back as it is copying files as well. So unzip it then try running: python launcher_updater_20141204 So please give the new version a try (there is a new md5 sum as well). If that doesn't work then I am going back to the drawing board! |
12-03-2014, 09:11 PM | #72 |
Grand Sorcerer
Posts: 27,968
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
That worked!
Permission denied errors on Windows, but that's not surprising. Opening a command-prompt as Administrator takes care of that problem. I imagine Linux users would need to use sudo as well. |
12-03-2014, 09:43 PM | #73 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi DiapDaler,
Whew! I am glad this one worked. I would rather it worked from the zip but that seems impossible. I will add info on the need to open a command prompt as Administrator on Windows, and use sudo on Linux. Thanks so much for testing it and tracking down the error! KevinH |
12-03-2014, 11:42 PM | #74 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
What about something like these, at least for linux?
https://codereview.stackexchange.com...ot-from-python https://gist.github.com/davejamesmiller/1965559 Or at least do an euid check and error out with an appropriate message. Last edited by eschwartz; 12-03-2014 at 11:54 PM. |
12-04-2014, 06:59 AM | #75 | |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Hi eschwartz,
I guess I could use it, but they only would work for unix/linux and not Windows. I'll think about it for the next time. Thanks, Kevin Quote:
|
|
|
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 |