def install_menus(arguments: argparse.Namespace) -> int: """ Installs Beancounttant context menus. """ beancounttant_menu = menus.ContextMenu(MENU_TITLE, type=MENU_TYPE) beancounttant_menu.add_items([ menus.ContextCommand('Generate Transaction', params=Path(arguments.config_file).as_posix(), python=generate_transaction)]) beancounttant_menu.compile() return 0
def foo2(filenames): print('foo2') print(filenames) input() def foo3(filenames): print('foo3') print(filenames) input() if __name__ == '__main__': from context_menu import menus cm = menus.ContextMenu('Foo menu', type='FILES') cm2 = menus.ContextMenu('Foo Menu 2') cm3 = menus.ContextMenu('Foo Menu 3') cm3.add_items([ menus.ContextCommand('Foo One', command='echo hello > example.txt'), ]) cm2.add_items([ menus.ContextCommand('Foo Two', python=foo2), cm3, ]) cm.add_items([cm2, menus.ContextCommand('Foo Three', python=foo3)]) cm.compile()
def foo2(filenames): print('foo2') print(filenames) input() def foo3(filenames): print('foo3') print(filenames) input() if __name__ == '__main__': from context_menu import menus cm = menus.ContextMenu('Foo menu', type='DIRECTORY_BACKGROUND') cm.add_items([ menus.ContextCommand('Foo One', command='echo hello > example.txt'), menus.ContextCommand('Foo Two', python=foo2), menus.ContextCommand('Foo Three', python=foo3) ]) cm.compile()