Action Manager

Intr

method to add a new menu item

method 1

import imagect.api.actmgr
import imagect.core.actmgr
from imagect.api.actmgr import addAct, addActFun, renameAct

@addActFun("file.exampe.msg", text="&Message", index=1)
def apptest():
    win = get()
    win.showMessage("Test Message")

method 2

from imagect.api.actmgr import addActFetch, renameAct
@addActFetch("file.recent", "Recent File", index=2)
def recentMenu(qact : QAction):
    return [ QAction("Recent 1", qact), QAction("Recent 2", qact)]

method 3

import imagect.api.actmgr
import imagect.core.actmgr
from imagect.api.actmgr import addActWdg, renameAct

@addActWdg("file.exampe.wdg", text="Show Widget", index = 3)
class ActWdg(QSpinBox) :
    def __init__(self, parent):
        super().__init__(parent) 

API

interface imagect.api.actmgr.IActMgr[source]

Action Manager

要包含所有的命令节点,每个命令节点包含一个菜单用于显示全部子命令

file

file menu

edit

edit menu

image

image menu

test

test menu

topActions()
addAct(act)

add sub action parent | child

remAct(id)

remove action by id

renameAct(id, title, index=0)

set action title

queryChildren(self, pid)

query actions by parent id

queryAll(self)

query all actions

class imagect.api.actmgr.IAction(icon, id, pid, title, index=0, callable=None, widget=None, fetch=None, shortcut=None)[source]

Bases: object

imagect.api.actmgr.addAct(act: imagect.api.actmgr.IAction)[source]
imagect.api.actmgr.addActFetch(id: str, title: str, index=0, shortcut=None)[source]
imagect.api.actmgr.addActFun(id: str, text: str, index=0, shortcut=None)[source]
imagect.api.actmgr.addActWdg(id: str, text: str, index=0, shortcut=None)[source]
imagect.api.actmgr.creatchFecthAction(id, title, fetch, index=0, shortcut=None)[source]
imagect.api.actmgr.createAction(id, title, callable=None, index=0, shortcut=None)[source]
imagect.api.actmgr.createWAction(id, title, widget=None, index=0, shortcut=None)[source]
imagect.api.actmgr.get()[source]
imagect.api.actmgr.renameAct(id: str, title: str, index=0)[source]
imagect.api.actmgr.toQAction(act: imagect.api.actmgr.IAction, parent: PyQt5.QtCore.QObject)[source]

IMPL

class imagect.core.actmgr.ActMgr[source]

Bases: object

addAct(act: imagect.api.actmgr.IAction)[source]

add sub action parent | child

queryAll() → List[imagect.api.actmgr.IAction][source]
queryChildren(pid: str) → List[imagect.api.actmgr.IAction][source]

todo: sort by index

remAct(id: str)[source]
renameAct(id: str, title: str, index=0)[source]
sort(acts: List[imagect.api.actmgr.IAction]) → List[imagect.api.actmgr.IAction][source]
topActions() → List[PyQt5.QtWidgets.QAction][source]