예제 #1
0
    def __init__(self, key, name, parent=None):
        QtWidgets.QFrame.__init__(self, parent)
        self.setBackgroundRole(QtGui.QPalette.AlternateBase)
        self.setAutoFillBackground(True)

        hlayout = QtWidgets.QHBoxLayout()
        hlayout.setContentsMargins(0, 0, 0, 0)
        color_key = ctrl.settings.get_node_setting('color_id', node_type=key)
        font_key = ctrl.settings.get_node_setting('font_id', node_type=key)

        self.key = key
        self.setPalette(ctrl.cm.palette_from_key(color_key))
        f = qt_prefs.get_font(font_key)
        self.setStyleSheet('font-family: "%s"; font-size: %spx;' % (f.family(), f.pointSize()))
        self.add_button = icon_button(ctrl.ui, self, hlayout,
                                      icon=qt_prefs.add_icon,
                                      text='Add ' + name,
                                      action='add_node',
                                      size=24,
                                      color_key=color_key,
                                      tooltip_suffix=name)
        self.add_button.data = key
        self.label = label(self, hlayout, text=name)
        self.label.setBuddy(self.add_button)

        self.conf_button = icon_button(ctrl.ui, self, hlayout,
                                       icon=qt_prefs.settings_pixmap,
                                       text='Modify %s behavior' % name,
                                       size=20,
                                       align=QtCore.Qt.AlignRight)
        self.setLayout(hlayout)
예제 #2
0
    def __init__(self, key, name, parent=None):
        QtWidgets.QFrame.__init__(self, parent)
        self.setBackgroundRole(QtGui.QPalette.AlternateBase)
        self.setAutoFillBackground(True)

        hlayout = QtWidgets.QHBoxLayout()
        hlayout.setContentsMargins(0, 0, 0, 0)
        color_key = ctrl.settings.get_node_setting('color_id', node_type=key)
        font_key = ctrl.settings.get_node_setting('font_id', node_type=key)

        self.key = key
        self.setPalette(ctrl.cm.palette_from_key(color_key))
        f = qt_prefs.get_font(font_key)
        self.setStyleSheet('font-family: "%s"; font-size: %spx;' %
                           (f.family(), f.pointSize()))
        self.add_button = icon_button(ctrl.ui,
                                      self,
                                      hlayout,
                                      icon=qt_prefs.add_icon,
                                      text='Add ' + name,
                                      action='add_node',
                                      size=24,
                                      color_key=color_key,
                                      tooltip_suffix=name)
        self.add_button.data = key
        self.label = label(self, hlayout, text=name)
        self.label.setBuddy(self.add_button)

        self.conf_button = icon_button(ctrl.ui,
                                       self,
                                       hlayout,
                                       icon=qt_prefs.settings_pixmap,
                                       text='Modify %s behavior' % name,
                                       size=20,
                                       align=QtCore.Qt.AlignRight)
        self.setLayout(hlayout)
예제 #3
0
    def __init__(self, name, default_position='right', parent=None, folded=False):
        """
        All of the panel constructors follow the same format so that the
        construction can be automated.
        :param name: Title of the panel and the key for accessing it
        :param default_position: 'bottom', 'right'...
        :param parent: self.main
        """
        Panel.__init__(self, name, default_position, parent, folded)
        inner = QtWidgets.QWidget(self)
        self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        layout = QtWidgets.QVBoxLayout()
        self.setMaximumWidth(220)
        self.setMaximumHeight(140)
        self._nodes_in_selection = []
        self._edges_in_selection = []
        self.cached_node_types = set()

        self.watchlist = ['selection_changed', 'forest_changed']
        # Other items may be temporarily added, they are defined as
        # class.variables
        ui = self.ui_manager
        # hlayout = box_row(layout)
        #
        # styles_data = []
        # current_style_i = 0
        # for i, value in enumerate(prefs.available_styles):
        #     if value == ctrl.settings.get('style'):
        #         current_style_i = i
        #     styles_data.append((value, value))
        # self.overall_style_box = selector(ui, self, hlayout,
        #                                   data=styles_data,
        #                                   action='change_master_style')
        # self.overall_style_box.setCurrentIndex(current_style_i)
        # #self.custom_overall_style = text_button(ui, hlayout,
        # #                                        text='customize',
        # #                                        action='customize_master_style',
        # #                                        checkable=True)
        # self.overall_style_box.hide()
        self.style_widgets = QtWidgets.QWidget(inner)
        sw_layout = QtWidgets.QVBoxLayout()
        sw_layout.setContentsMargins(0, 0, 0, 0)
        hlayout = box_row(sw_layout)
        self.scope_selector = selector(ui, self.style_widgets, hlayout,
                                       data=[],
                                       action='style_scope',
                                       label='Style for')
        self.scope_selector.setMinimumWidth(96)
        vline = QtWidgets.QFrame()
        vline.setFrameShape(QtWidgets.QFrame.VLine)
        hlayout.addWidget(vline)
        self.style_reset = mini_button(ui, self.style_widgets, hlayout,
                                       text='reset',
                                       action='reset_style_in_scope')
        hlayout = box_row(sw_layout)

        self.node_color_selector = color_selector(ui, self.style_widgets, hlayout,
                                                  action='change_node_color', role='node',
                                                  label='Node color')
        self.font_selector = font_selector(ui, self.style_widgets, hlayout,
                                           action='select_font',
                                           label='font')

        hlayout = box_row(sw_layout)
        self.shape_selector = shape_selector(ui, self.style_widgets, hlayout,
                                             action='change_edge_shape',
                                             label='Edge style')

        self.edge_color_selector = color_selector(ui, self.style_widgets, hlayout,
                                                  action='change_edge_color', role='edge')

        self.edge_options = icon_button(ui, self.style_widgets, hlayout,
                                        icon=qt_prefs.settings_icon,
                                        text='More edge options',
                                        action='toggle_panel_LineOptionsPanel',
                                        checkable=True)

        self.style_widgets.setLayout(sw_layout)
        layout.addWidget(self.style_widgets)
        inner.setLayout(layout)
        inner.setBackgroundRole(QtGui.QPalette.AlternateBase)
        #self.style_widgets.hide()
        self.setWidget(inner)

        self.finish_init()
예제 #4
0
    def __init__(self,
                 name,
                 default_position='right',
                 parent=None,
                 folded=False):
        """
        All of the panel constructors follow the same format so that the
        construction can be automated.
        :param name: Title of the panel and the key for accessing it
        :param default_position: 'bottom', 'right'...
        :param parent: self.main
        """
        Panel.__init__(self, name, default_position, parent, folded)
        inner = QtWidgets.QWidget(self)
        self.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                           QtWidgets.QSizePolicy.Preferred)
        layout = QtWidgets.QVBoxLayout()
        self.setMaximumWidth(220)
        self.setMaximumHeight(140)
        self._nodes_in_selection = []
        self._edges_in_selection = []
        self.cached_node_types = set()

        self.watchlist = ['selection_changed', 'forest_changed']
        # Other items may be temporarily added, they are defined as
        # class.variables
        ui = self.ui_manager
        # hlayout = box_row(layout)
        #
        # styles_data = []
        # current_style_i = 0
        # for i, value in enumerate(prefs.available_styles):
        #     if value == ctrl.settings.get('style'):
        #         current_style_i = i
        #     styles_data.append((value, value))
        # self.overall_style_box = selector(ui, self, hlayout,
        #                                   data=styles_data,
        #                                   action='change_master_style')
        # self.overall_style_box.setCurrentIndex(current_style_i)
        # #self.custom_overall_style = text_button(ui, hlayout,
        # #                                        text='customize',
        # #                                        action='customize_master_style',
        # #                                        checkable=True)
        # self.overall_style_box.hide()
        self.style_widgets = QtWidgets.QWidget(inner)
        sw_layout = QtWidgets.QVBoxLayout()
        sw_layout.setContentsMargins(0, 0, 0, 0)
        hlayout = box_row(sw_layout)
        self.scope_selector = selector(ui,
                                       self.style_widgets,
                                       hlayout,
                                       data=[],
                                       action='style_scope',
                                       label='Style for')
        self.scope_selector.setMinimumWidth(96)
        vline = QtWidgets.QFrame()
        vline.setFrameShape(QtWidgets.QFrame.VLine)
        hlayout.addWidget(vline)
        self.style_reset = mini_button(ui,
                                       self.style_widgets,
                                       hlayout,
                                       text='reset',
                                       action='reset_style_in_scope')
        hlayout = box_row(sw_layout)

        self.node_color_selector = color_selector(ui,
                                                  self.style_widgets,
                                                  hlayout,
                                                  action='change_node_color',
                                                  role='node',
                                                  label='Node color')
        self.font_selector = font_selector(ui,
                                           self.style_widgets,
                                           hlayout,
                                           action='select_font',
                                           label='font')

        hlayout = box_row(sw_layout)
        self.shape_selector = shape_selector(ui,
                                             self.style_widgets,
                                             hlayout,
                                             action='change_edge_shape',
                                             label='Edge style')

        self.edge_color_selector = color_selector(ui,
                                                  self.style_widgets,
                                                  hlayout,
                                                  action='change_edge_color',
                                                  role='edge')

        self.edge_options = icon_button(ui,
                                        self.style_widgets,
                                        hlayout,
                                        icon=qt_prefs.settings_icon,
                                        text='More edge options',
                                        action='toggle_panel_LineOptionsPanel',
                                        checkable=True)

        self.style_widgets.setLayout(sw_layout)
        layout.addWidget(self.style_widgets)
        inner.setLayout(layout)
        inner.setBackgroundRole(QtGui.QPalette.AlternateBase)
        #self.style_widgets.hide()
        self.setWidget(inner)

        self.finish_init()