示例#1
0
文件: diagrams.py 项目: ogbash/astvis
class DiagramItemToolbox(object):
    def __init__(self, wTree, root):
        self.wTree = wTree
        self.root = root
        self.widget = Wrapbox()
        self.wTree.signal_autoconnect(self)

        action.manager.registerActionService(self)
        self.actionGroup = action.ActionGroup(action.manager, "toolbox", radioPrefix="toolbox-item")
        self.gtkActionGroup = self.actionGroup.createGtkActionGroup(self)
        for action_ in self.actionGroup.radioActions:
            if not action_.name.startswith("toolbox-item"):
                continue
            button = gtk.ToggleToolButton()
            gtkaction = self.gtkActionGroup.get_action(action_.name)
            gtkaction.connect_proxy(button)
            self.widget.add(button)

        # action.connectWidgetTree(self.actionGroup, self.wTree)

    @action.Action("toolbox-item-pointer", "pointer", icon="pointer")
    def item_pointer(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        view.tool = gaphasx.DefaultTool()

    @action.Action("toolbox-item-flow", "flow", icon="flow")
    def item_flow(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        def add():
            obj = concept.Flow()
            diagram.add(obj)
            return diagram.getItem(obj)

        view.tool = gaphas.tool.PlacementTool(add, gaphas.tool.HandleTool(), 0)

    @action.Action("toolbox-item-use", "use", icon="use")
    def item_use(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        def add():
            obj = concept.Use()
            diagram.add(obj)
            return diagram.getItem(obj)

        view.tool = gaphas.tool.PlacementTool(add, gaphas.tool.HandleTool(), 0)
示例#2
0
文件: toolbox.py 项目: Nyox/gaphor
 def _construct(self, toolboxdef):
     shortcuts = self.shortcuts
     for title, items in toolboxdef:
         wrapbox = Wrapbox()
         for action_name, label, stock_id, shortcut in items:
             button = self.toolbox_button(action_name, stock_id)
             if label:
                 button.set_tooltip_text('%s (%s)' % (label, shortcut))
             self.buttons.append(button)
             wrapbox.add(button)
             button.show()
             shortcuts[shortcut] = action_name
         if title:
             wrapbox_dec = self.make_wrapbox_decorator(title, wrapbox)
             self.pack_start(wrapbox_dec, expand=False)
         else:
             self.pack_start(wrapbox, expand=False)
             wrapbox.show()
示例#3
0
文件: diagrams.py 项目: ogbash/astvis
    def __init__(self, wTree, root):
        self.wTree = wTree
        self.root = root
        self.widget = Wrapbox()
        self.wTree.signal_autoconnect(self)

        action.manager.registerActionService(self)
        self.actionGroup = action.ActionGroup(action.manager, "toolbox", radioPrefix="toolbox-item")
        self.gtkActionGroup = self.actionGroup.createGtkActionGroup(self)
        for action_ in self.actionGroup.radioActions:
            if not action_.name.startswith("toolbox-item"):
                continue
            button = gtk.ToggleToolButton()
            gtkaction = self.gtkActionGroup.get_action(action_.name)
            gtkaction.connect_proxy(button)
            self.widget.add(button)
示例#4
0
文件: toolbox.py 项目: xqbumu/gaphor
 def _construct(self, toolboxdef):
     shortcuts = self.shortcuts
     for title, items in toolboxdef:
         wrapbox = Wrapbox()
         for action_name, label, stock_id, shortcut in items:
             button = self.toolbox_button(action_name, stock_id)
             if label:
                 button.set_tooltip_text('%s (%s)' % (label, shortcut))
             self.buttons.append(button)
             wrapbox.add(button)
             button.show()
             shortcuts[shortcut] = action_name
         if title:
             wrapbox_dec = self.make_wrapbox_decorator(title, wrapbox)
             self.pack_start(wrapbox_dec, expand=False)
         else:
             self.pack_start(wrapbox, expand=False)
             wrapbox.show()