View Single Post
Old 12-28-2010, 12:34 AM   #143
darrenlee
Member
darrenlee began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Dec 2010
Location: China
Device: none
Quote:
Originally Posted by kiwidude View Post
This plugin is an enhanced alternative to the "Open ePub in Editor" plugin intended to supercede it. It allows you to configure and launch a combination of a specific application (e.g. Sigil) for a specified format (e.g. EPUB) via a sub-menu. The advantage over the previous ePub only plugin is that you can configure multiple format/application combinations to appear in the submenu, each of which can have icons and keyboard shortcuts.

Special Notes:
  • Requires Calibre v0.7.34 or later.
  • Tested under Windows only by myself, though it should work on other platforms.
  • If you edit the book using the external application, no information is updated in the Calibre database (such as the CRC for this file). I'm not aware of any downside to doing this and it is fairly common for users to directly edit formats of files.
Installation Steps:
  1. Follow installation steps as per first post in this thread
  2. Add a custom tweak value in Preferences->Tweaks reflecting the path to your application for each format. If you configure a keyboard shortcut, be sure not to conflict with one of the existing Calibre ones documented here. In the snippet below (Windows 7 32-bit) I have configured EPUB files to open in Sigil with an icon and Alt+E shortcut, and PDF files to open in Acrobat with no icon or shortcut as follows:
    Code:
    # Specify the submenus to appear on the 'Search the internet' plugin menu.
    # Menu items are specified as a tuple of: ('TEXT', 'FORMAT', 'PATH', [ARGS], 'IMAGE', SHORTCUT)
    # 'TEXT'   - The menu text to display for this menu item entry.
    #            Specify None for a separator row in the submenu.
    # 'FORMAT' - The Calibre format name, such as 'EPUB', 'PDF', 'TXT' etc.
    # 'PATH'   - Path to the external application to launch for this format.
    # [ARGS]   - Optional command line arguments between the app path and book filename.
    #            Specify None or [] for no arguments required.
    #            To specify arguments list in an array like ['arg1', 'arg2']
    # 'IMAGE'  - Name of the image file to use as a menu icon. Specify None if no image.
    #            Image .png files should be placed in the (your config)\resources\images folder if
    #            they are not already contained in the plugin zip file or Calibre's resources directory.
    # SHORTCUT - Keyboard shortcut to use to launch this menu item. Specify None for no shortcut.
    #            e.g. Ctrl+Shift+1 would be Qt.ControlModifier+Qt.ShiftModifier+Qt.Key_1
    # An example menu for EPUB and Adobe Acrobat on a Windows 32-bit machine is below.
    from PyQt4.Qt import Qt
    ofep_open_format_menus = [('EPUB (Sigil)', 'EPUB', 'C:\\Program Files\\Sigil\\Sigil.exe', None, 'sigil.png', Qt.AltModifier+Qt.Key_E),
        ('PDF (Acrobat)', 'PDF',  'C:\\Program Files\\Adobe\\Acrobat 10.0\\Acrobat\\Acrobat.exe', None, None, None)]
  3. Restart Calibre and add the command to your context menu or toolbar as appropriate.
Feedback/suggestions welcomed. Refer to the readme.txt file in the zip file if you require more information about where to place images for your menu items.
Thanks for your work,kiwidude.I have been expecting this function for a long time.
But this plugin doesn't work on my system.Here is the info.

Error message:
Traceback (most recent call last):
File "/usr/lib/calibre/calibre/gui2/main.py", line 251, in initialize
self.initialize_db()
File "/usr/lib/calibre/calibre/gui2/main.py", line 232, in initialize_db
self.initialize_db_stage2(db, None)
File "/usr/lib/calibre/calibre/gui2/main.py", line 201, in initialize_db_stage2
self.start_gui()
File "/usr/lib/calibre/calibre/gui2/main.py", line 156, in start_gui
main.initialize(self.library_path, self.db, self.listener, self.actions)
File "/usr/lib/calibre/calibre/gui2/ui.py", line 134, in initialize
ac.do_genesis()
File "/usr/lib/calibre/calibre/gui2/actions/__init__.py", line 91, in do_genesis
self.genesis()
File "<string>", line 45, in genesis
File "<string>", line 62, in read_icon_resources
File "/usr/lib/calibre/calibre/gui2/actions/__init__.py", line 133, in load_resources
with ZipFile(self.plugin_path, 'r') as zf:
AttributeError: ZipFile instance has no attribute '__exit__'
zsh: terminated calibre

OS:Gentoo
Python version:2.6.6-r1 and 3.1.2-r4
Calibre version:0.7.35
Working plugins:add/remove to/from user category,open epub in editor.

Since I know little about Python language,I can't figure out the problem.Instead,I managed to modify open_epub_in_editor plugin to open pdf format with custom viewer.It works fine for me.But it's just a temporary solution.
darrenlee is offline