Example #1
0
    def _build_show_menu(self):
        """Build the menu to select which object types are shown in the output.

        Returns:
            QtGui.QMenu: The visibilities "show" menu.

        """

        menu = QtWidgets.QMenu(self)
        menu.setObjectName("ShowShapesMenu")
        menu.setWindowTitle("Show")
        menu.setFixedWidth(180)
        menu.setTearOffEnabled(True)

        # Show all check
        toggle_all = QtWidgets.QAction(menu, text="All")
        toggle_none = QtWidgets.QAction(menu, text="None")
        menu.addAction(toggle_all)
        menu.addAction(toggle_none)
        menu.addSeparator()

        # add plugin shapes if any
        for shape in self.show_types:
            action = QtWidgets.QAction(menu, text=shape)
            action.setCheckable(True)
            # emit signal when the state is changed of the checkbox
            action.toggled.connect(self.options_changed)
            menu.addAction(action)
            self.show_type_actions.append(action)

        # connect signals
        toggle_all.triggered.connect(self.toggle_all_visbile)
        toggle_none.triggered.connect(self.toggle_all_hide)

        return menu
    def _build_show_menu(self):
        """Build the menu to select which object types are shown in the output.
        
        Returns:
            QtGui.QMenu: The visibilities "show" menu.
            
        """

        menu = QtWidgets.QMenu(self)
        menu.setObjectName("ShowShapesMenu")
        menu.setWindowTitle("Show")
        menu.setFixedWidth(150)
        menu.setTearOffEnabled(True)

        # Show all check
        toggle_all = QtWidgets.QAction(menu, text="All")
        toggle_none = QtWidgets.QAction(menu, text="None")
        menu.addAction(toggle_all)
        menu.addAction(toggle_none)
        menu.addSeparator()

        # add standard object shapes
        for obj_type in OBJECT_TYPES.keys():
            action = QtWidgets.QAction(menu, text=obj_type)
            action.setCheckable(True)

            # Add to menu and list of instances
            menu.addAction(action)
            self.show_types_list.append(action)

        menu.addSeparator()

        # add plugin shapes if any
        plugin_shapes = self.plugin_shapes.keys()
        if plugin_shapes:
            for plugin_shape in plugin_shapes:
                action = QtWidgets.QAction(menu, text=plugin_shape)
                action.setCheckable(True)

                menu.addAction(action)
                self.show_types_list.append(action)

        # connect signals
        toggle_all.triggered.connect(self.toggle_all_visbile)
        toggle_none.triggered.connect(self.toggle_all_hide)

        return menu
Example #3
0
    def token_menu(self):
        """
        Build the token menu based on the registered tokens

        :returns: Menu
        :rtype: QtWidgets.QMenu
        """
        menu = QtWidgets.QMenu(self)
        registered_tokens = tokens.list_tokens()

        for token, value in registered_tokens.items():
            label = "{} \t{}".format(token, value['label'])
            action = QtWidgets.QAction(label, menu)
            fn = partial(self.file_path.insert, token)
            action.triggered.connect(fn)
            menu.addAction(action)

        return menu