| 
			
			 | 
		#31 | 
| 
			
			
			
			 Calibre Plugins Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735 
				Karma: 2208556 
				Join Date: Oct 2010 
				Location: Australia 
				
				
				Device: Kindle Oasis 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thanks Kovid, that now works. I think I have the code changes figured out for my "static" menu plugins now, obviously I will have to wait for the next Calibre release before I can get someone to verify it.  
		
	
		
		
		
		
		
		
		
		
		
		
	
	Next on the list I need to work through the dynamic based ones like Search the Internet, where I have the extra complication of unregistering shortcuts for actions that no longer exist when the menu is rebuilt. What could possibly go wrong...  
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#32 | 
| 
			
			
			
			 Calibre Plugins Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735 
				Karma: 2208556 
				Join Date: Oct 2010 
				Location: Australia 
				
				
				Device: Kindle Oasis 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			The keyboard shortcut plugin upgrade mission slowly continues. So far I have managed to upgrade eight plugins which are all the non dynamic menus based ones (the "easy" cases), and that is all working fine. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	However on my way to attempting a dynamic menu, I tried to start with Quality Check. In this plugin, it is possible for the users to decide which menu items will appear on the menu. So to do things "properly" I need to cover for the situation where a user assigns a keyboard shortcut to a menu item, and then chooses to "hide" that menu item without them removing their shortcut first. So in this situation, I thought it might be as "simple" as calling gui.keyboard.unregister_shortcut for each menu item that the user is hiding when they click ok on the configuration dialog. That part of the code I have working, though it is a little messy as you can see below from this extract: Code: 
	                kb = self.plugin_action.gui.keyboard
                # Need to manually construct the menu name because at this point I have
                # no action at all as I am not creating them
                unique_name = '%s : menu action : %s'%(self.plugin_action.unique_name, menu_key)
                # Have to check for existence (same applies to replace_action call)
                if unique_name in kb.shortcuts:
                    kb.unregister_shortcut(unique_name)
Code: 
	calibre, version 0.8.17 ERROR: Unhandled exception: <b>KeyError</b>:u'Interface Action: Quality Check (Quality Check) : menu action : check_covers' Traceback (most recent call last): File "D:\CalibreDev\latest\calibre\src\calibre\gui2\preferences\main.py", line 282, in show_plugin File "D:\CalibreDev\latest\calibre\src\calibre\gui2\preferences\keyboard.py", line 27, in initialize File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 615, in initialize File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 179, in __init__ File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 178, in <dictcomp> File "D:\CalibreDev\latest\calibre\src\calibre\gui2\keyboard.py", line 178, in <lambda> KeyError: u'Interface Action: Quality Check (Quality Check) : menu action : check_covers' Now for this particular plugin I could just store the actions in a dictionary, creating them only once etc. However I believe the error I see is going to come up for plugins where that is not an option, so better to figure it all out now...  
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#33 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Fixed (I think) and added a function menu_action_unique_name
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		
 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#34 | 
| 
			
			
			
			 Calibre Plugins Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735 
				Karma: 2208556 
				Join Date: Oct 2010 
				Location: Australia 
				
				
				Device: Kindle Oasis 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thanks Kovid, that solved that one. Unfortunately I found another scenario which means I need to rethink my whole approach again - and revisit all the plugins I thought I had done so far. Darn it. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I see I hit 2000 posts, what was life like before Calibre took it over?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#35 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	|
| 
		
 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#36 | 
| 
			
			
			
			 Calibre Plugins Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735 
				Karma: 2208556 
				Join Date: Oct 2010 
				Location: Australia 
				
				
				Device: Kindle Oasis 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Hi Kovid, 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I’ve been sitting here for over an hour experimenting trying to work out the cause of an issue and finally figured out the symptoms at least. When my menu text that I pass into create_menu_action() starts with numeric digits (rather than alphabetic characters), AND if I have a triggered=xxx value assigned, then while everything works correctly, when I close Calibre it is taking around 30 seconds to actually exit the process (Win 7). The text I am trying to display in the menu is “450(w) x 680(h)” 
  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#37 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			That's weird, I can't think of anything that could cause that. Setting one of the builtin actions' menu items to 450(w) x 680(h) doesn't make any difference to shutdown times for me. Maybe prefix your menu item with Size:
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		
 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#38 | 
| 
			
			
			
			 Calibre Plugins Developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,735 
				Karma: 2208556 
				Join Date: Oct 2010 
				Location: Australia 
				
				
				Device: Kindle Oasis 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thx Kovid - you are right, it is very weird. Sadly, it seems that it was just a lucky fluke that renaming the text worked a couple of times in a row - that has now stopped working for me. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Back to the drawing board... sigh..  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Calibre keyboard shortcuts? | Clytie | Calibre | 29 | 08-25-2019 04:51 AM | 
| K3 keyboard shortcuts et al | btobw | Amazon Kindle | 25 | 10-15-2011 10:43 AM | 
| Keyboard shortcuts | VenturingSoul | enTourage Archive | 1 | 04-15-2010 11:21 PM | 
| keyboard shortcuts? | tashiegirl | Calibre | 5 | 04-12-2010 10:25 PM | 
| Keyboard Shortcuts | malkie13 | Calibre | 2 | 02-08-2009 04:21 PM |