Quote:
Originally Posted by turbulent
In an output sigil plugin, is it possible to get the file name of the epub file currently opened by sigil? So it's convinient to name the generated file after the epub file.
|
If you have a Windows machine, you could use the win32gui library to find the Sigil title bar text. Here's a quick & dirty solution:
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'
Note that this simple code will return the title bar text of the Qt app that was opened last. I.e. if you open multiple Sigil windows, you'll only get the title bar text of the last window and if you open Calibre (or any other Qt5 app) after Sigil, you'll get the Calibre title bar text.
For a more robust solution, you'll need to enumerate all windows using win32gui.EnumWindows.