This is very simple script example from Blender templates:
import bpy
class SimpleCustomMenu(bpy.types.Menu):
bl_label = "Simple Custom Menu"
bl_idname = "OBJECT_MT_simple_custom_menu"
def draw(self, context):
layout = self.layout
layout.operator("wm.open_mainfile")
layout.operator("wm.save_as_mainfile")
def register():
bpy.utils.register_class(SimpleCustomMenu)
def unregister():
bpy.utils.unregister_class(SimpleCustomMenu)
if __name__ == "__main__":
register()
# The menu can also be called from scripts
bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)
All I care about is the ability opening the menu in separate floating window without need to go thru menu all the time, as I have my own code (add-on) and trying to implement this (no success yet - I am still scripting newbie, so you know).
Thus merit of my question is: how can we make what line bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)
is doing with hardcoded keyboard shortcut right in the script itslef?
Like: when I press, let's say, Shift+Q it would open that small floating window with my menu - anyone with a working example script based on the code above?
I DID TRY several ways, but still I was unable making it work, that is reason why I would like to see actual working code, not just some kind of statement (I saw such statements already and they were of no help at all to me).
EDIT: I reformated my question so it would be clear to everyone what I mean (sorry, english is not my native language)