def color_theme_fragment(panel, layout): hlayout = QtWidgets.QHBoxLayout() f = qt_prefs.get_font(g.MAIN_FONT) panel.selector = SelectionBox(panel) panel.selector.setMaximumWidth(120) panel.selector_items = ctrl.cm.list_available_themes() panel.selector.add_items(panel.selector_items) panel.ui_manager.connect_element_to_action(panel.selector, 'set_color_theme') hlayout.addWidget(panel.selector) panel.randomise = RandomiseButton() ctrl.ui.connect_element_to_action(panel.randomise, 'randomise_palette') hlayout.addWidget(panel.randomise, 1, QtCore.Qt.AlignRight) panel.remove_theme = QtWidgets.QPushButton('Remove') #panel.remove_theme.setFixedSize(40, 20) ctrl.ui.connect_element_to_action(panel.remove_theme, 'remove_theme') panel.remove_theme.hide() hlayout.addWidget(panel.remove_theme, 1, QtCore.Qt.AlignRight) panel.store_favorite = QtWidgets.QPushButton('★') panel.store_favorite.setStyleSheet( 'font-family: "%s"; font-size: %spx;' % (f.family(), f.pointSize())) panel.store_favorite.setFixedSize(26, 20) panel.store_favorite.setEnabled(False) ctrl.ui.connect_element_to_action(panel.store_favorite, 'remember_palette') hlayout.addWidget(panel.store_favorite, 1, QtCore.Qt.AlignRight) layout.addLayout(hlayout)
def __init__(self, parent): UIEmbed.__init__(self, parent, None, 'Create new node') self.marker = None self.guess_mode = True layout = QtWidgets.QVBoxLayout() layout.addLayout(self.top_row_layout) hlayout = box_row(layout) ui = self.ui_manager self.new_arrow_button = icon_text_button(ui, hlayout, self, '', '', " &Arrow", 'new_arrow', size=QtCore.QSize(48, 20), draw_method=arrow) self.divider_button = icon_text_button(ui, hlayout, self, '', '', " &Divider", 'new_divider', size=QtCore.QSize(48, 20), draw_method=divider) self.new_arrow_button.setFlat(False) self.divider_button.setFlat(False) self.new_arrow_button.hide() self.divider_button.hide() tt = 'Text for new node' smaller_font = qt_prefs.get_font(g.MAIN_FONT) big_font = QtGui.QFont(smaller_font) big_font.setPointSize(big_font.pointSize() * 2) self.input_line_edit = ExpandingLineEdit(self, tip=tt, big_font=big_font, smaller_font=smaller_font, prefill='label', on_edit=self.guess_type_for_input) layout.addWidget(self.input_line_edit) hlayout = QtWidgets.QHBoxLayout() self.node_type_selector = SelectionBox(self) self.node_type_selector.currentIndexChanged.connect(self.changed_node_type) self.node_types = [('Guess from input', g.GUESS_FROM_INPUT)] for key in classes.node_types_order: # we have dedicated buttons for arrows and dividers #if key not in (g.ARROW, g.DIVIDER): node_class = classes.nodes.get(key, None) if (not node_class) or node_class.is_syntactic and not ctrl.free_drawing_mode: continue self.node_types.append(('New %s' % node_class.display_name[0].lower(), key)) self.node_types.append(('New arrow', g.ARROW)) #self.node_types.append(('New divider', g.DIVIDER)) self.node_type_selector.add_items(self.node_types) hlayout.addWidget(self.node_type_selector) hlayout.addStretch(0) self.enter_button = QtWidgets.QPushButton("Create ↩") # U+21A9 ↩ ui.connect_element_to_action(self.enter_button, 'create_new_node_from_text') hlayout.addWidget(self.enter_button) layout.addLayout(hlayout) self.setLayout(layout) self.assumed_width = 200 self.assumed_height = 117
def __init__(self, name, default_position='bottom', 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 :param ui_manager: pass a dictionary where buttons from this panel will be added """ Panel.__init__(self, name, default_position, parent, folded) inner = QtWidgets.QWidget() inner.setMinimumHeight(40) inner.setMaximumHeight(50) inner.preferred_size = QtCore.QSize(220, 40) inner.sizeHint = self.sizeHint layout = QtWidgets.QVBoxLayout() hlayout = QtWidgets.QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) selector = SelectionBox(self) self.selector = selector for key, item in []: selector.addItem('%s (%s)' % (key, item.shortcut), key) self.ui_manager.connect_element_to_action(selector, 'set_visualization') hlayout.addWidget(selector) self.toggle_options = PanelButton(pixmap=qt_prefs.settings_pixmap, tooltip='Visualization settings', parent=self, size=20) self.toggle_options.setFixedSize(26, 26) self.toggle_options.setCheckable(True) ctrl.ui.connect_element_to_action(self.toggle_options, 'toggle_panel_%s' % g.VIS_OPTIONS) hlayout.addWidget(self.toggle_options, 1, QtCore.Qt.AlignRight) layout.addLayout(hlayout) inner.setLayout(layout) self.watchlist = ['forest_changed'] self.preferred_size = inner.preferred_size self.setWidget(inner) self.widget().setAutoFillBackground(True) self.finish_init()
def mini_selector(ui_manager, panel, layout, data=None, action=''): """ :param ui_manager: :param panel: :param layout: :param data: :param action: :return: """ if data is None: data = [] selector = SelectionBox(panel) selector.add_items(data) selector.setMinimumSize(QSize(40, 20)) selector.setMaximumSize(QSize(40, 20)) ui_manager.connect_element_to_action(selector, action) layout.addWidget(selector) return selector
def selector(ui_manager, parent, layout, data=None, action='', label=''): """ :param ui_manager: :param parent: :param layout: :param data: :param action: :return: """ selector = SelectionBox(parent) if data is None: data = [] selector.add_items(data) ui_manager.connect_element_to_action(selector, action) if label: labelw = QtWidgets.QLabel(label, parent) layout.addWidget(labelw) layout.addWidget(selector) return selector
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() #inner.preferred_size = QtCore.QSize(220, 130) inner.setMinimumSize(160, 130) inner.setMaximumSize(220, 400) inner.setMinimumWidth(160) layout = QtWidgets.QVBoxLayout() self.selector = SelectionBox(self) self.selector.add_items([(table_dict[item], item) for item in table_names]) self.selector.activated.connect(self.change_symbol_set) self.selector.setFocusPolicy(QtCore.Qt.TabFocus) layout.addWidget(self.selector) self.symlist = QtWidgets.QListWidget() self.symlist.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.symlist.setSpacing(8) self.symlist.setMouseTracking(True) self.symlist.setFocusPolicy(QtCore.Qt.NoFocus) self.symlist.setViewMode(QtWidgets.QListWidget.IconMode) f = qt_prefs.get_font(g.MAIN_FONT) self.symlist.setStyleSheet('font-family: "%s"; font-size: %spx;' % (f.family(), int(f.pointSize() * 1.5))) self.symlist.itemEntered.connect(self.item_entered) self.symlist.itemClicked.connect(self.item_clicked) layout.addWidget(self.symlist) hlayout = box_row(layout) self.info = QtWidgets.QLabel('') hlayout.addWidget(self.info) self.resize_grip = QtWidgets.QSizeGrip(self) self.resize_grip.hide() hlayout.addWidget(self.resize_grip, 0, QtCore.Qt.AlignRight) inner.setLayout(layout) self.tables = {} keys = list(latex_to_unicode.keys()) for name in table_names: self.tables[name] = [] keys.sort() for key in keys: char, description, table_key = latex_to_unicode[key] self.tables[table_key].append(key) self.tables['greek'] = greek_letters self.tables['arrows'] = arrows self.tables['more arrows'] = more_arrows self.tables['common'] = common # self.tables['arrows'] = arrows self.prepare_symbols('common') self.setWidget(inner) self.finish_init()
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() inner.preferred_size = QtCore.QSize(200, 70) inner.setMaximumWidth(220) inner.setMaximumHeight(80) inner.sizeHint = self.sizeHint layout = QtWidgets.QVBoxLayout() hlayout = QtWidgets.QHBoxLayout() self.selector = SelectionBox(self) self.selector.add_items([('%s (%s)' % (key, item.shortcut), key) for key, item in VISUALIZATIONS.items()]) self.ui_manager.connect_element_to_action(self.selector, 'set_visualization') hlayout.addWidget(self.selector) self.toggle_options = PanelButton(pixmap=qt_prefs.settings_pixmap, parent=self, size=20) self.toggle_options.setFixedSize(26, 26) self.toggle_options.setCheckable(True) ctrl.ui.connect_element_to_action( self.toggle_options, 'toggle_panel_VisualizationOptionsPanel') hlayout.addWidget(self.toggle_options, 1, QtCore.Qt.AlignRight) layout.addLayout(hlayout) hlayout = QtWidgets.QHBoxLayout() w = 36 b1 = PanelButton(pixmap=qt_prefs.shape_icon_plain, parent=self, size=24) b1.setFixedWidth(w) b1.setCheckable(True) ctrl.ui.connect_element_to_action(b1, 'set_no_frame_node_shape') hlayout.addWidget(b1) b2 = PanelButton(pixmap=qt_prefs.shape_icon_scope, parent=self, size=24) b2.setFixedWidth(w) b2.setCheckable(True) ctrl.ui.connect_element_to_action(b2, 'set_scopebox_node_shape') hlayout.addWidget(b2) b3 = PanelButton(pixmap=qt_prefs.shape_icon_brackets, parent=self, size=24) b3.setFixedWidth(w) b3.setCheckable(True) ctrl.ui.connect_element_to_action(b3, 'set_bracketed_node_shape') hlayout.addWidget(b3) b4 = PanelButton(pixmap=qt_prefs.shape_icon_box, parent=self, size=24) b4.setFixedWidth(w) b4.setCheckable(True) ctrl.ui.connect_element_to_action(b4, 'set_box_node_shape') hlayout.addWidget(b4) b5 = PanelButton(pixmap=qt_prefs.shape_icon_card, parent=self, size=24) b5.setFixedWidth(w) b5.setCheckable(True) ctrl.ui.connect_element_to_action(b5, 'set_card_node_shape') hlayout.addWidget(b5) layout.addLayout(hlayout) #layout.setContentsMargins(0, 0, 0, 0) inner.setLayout(layout) self.watchlist = ['visualization'] self.preferred_size = inner.preferred_size self.setWidget(inner) inner.setAutoFillBackground(True) self.finish_init()