class qlabeled_entry(QWidget): def __init__(self, var, text, pos = "side", max_size = 200): QWidget.__init__(self) self.setContentsMargins(1, 1, 1, 1) if pos == "side": self.layout1=QHBoxLayout() else: self.layout1 = QVBoxLayout() self.layout1.setContentsMargins(1, 1, 1, 1) self.layout1.setSpacing(1) self.setLayout(self.layout1) self.efield = QLineEdit("Default Text") # self.efield.setMaximumWidth(max_size) self.efield.setFont(QFont('SansSerif', 12)) self.label = QLabel(text) # self.label.setAlignment(Qt.AlignLeft) self.label.setFont(QFont('SansSerif', 12)) self.layout1.addWidget(self.label) self.layout1.addWidget(self.efield) self.var = var self.efield.textChanged.connect(self.when_modified) def when_modified(self): self.var.set(self.efield.text()) def hide(self): QWidget.hide(self)
def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) self.transformationView.setAttribute(Qt.WA_MacShowFocusRect, False) self.transformationView.clicked.connect(self.clickedTransformation) self._transformCount = 0 layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) removeButton.setToolTip("Remove the last transformation") self.actionContainer.addButton(removeButton)
def __init__(self, title=None): super(TitleWidget, self).__init__() if sys.platform.startswith("darwin"): color1 = QColor(230, 230, 230, 255) color2 = QColor(177, 177, 177, 255) gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, TitleWidget.TitleHeight) gradient.setColorAt(0, color1) gradient.setColorAt(1, color2) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setPalette(palette) self.setAutoFillBackground(True) self.setMaximumHeight(TitleWidget.TitleHeight) self.setMinimumHeight(TitleWidget.TitleHeight) self.titleLabel = QLabel("", parent=self) font = self.titleLabel.font() font.setPixelSize(11) self.titleLabel.setFont(font) self.titleLabel.setAlignment(Qt.AlignCenter) self.titleLabel.setText(title) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.titleLabel) self.setLayout(layout)
def __init__( self, parent ): QScrollArea.__init__(self, parent) self.setFrameShape(QScrollArea.NoFrame) self.setAutoFillBackground(False) self.setWidgetResizable(True) self.setMouseTracking(True) #self.verticalScrollBar().setMaximumWidth(10) widget = QWidget(self) # define custom properties self._rolloutStyle = AccordionWidget.Rounded self._dragDropMode = AccordionWidget.NoDragDrop self._scrolling = False self._scrollInitY = 0 self._scrollInitVal = 0 self._itemClass = AccordionItem layout = QVBoxLayout() layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(2) layout.addStretch(1) widget.setLayout(layout) self.setWidget(widget)
def __init__(self, parent, *args, **kw): super(_FilterTableView, self).__init__(*args, **kw) layout = QVBoxLayout() layout.setSpacing(2) self.table = table = _myFilterTableView(parent) table.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # table.setMinimumHeight(100) # table.setMaximumHeight(50) table.setFixedHeight(50) # table.setFixedWidth(50) hl = QHBoxLayout() self.button = button = QPushButton() button.setIcon(icon('delete').create_icon()) button.setEnabled(False) button.setFlat(True) button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button.setFixedWidth(25) self.text = text = QLineEdit() hl.addWidget(text) hl.addWidget(button) layout.addLayout(hl) layout.addWidget(table) self.setLayout(layout)
class qLabeledCheck(QWidget): def __init__(self, name, arg_dict, pos = "side", max_size = 200): QWidget.__init__(self) self.setContentsMargins(1, 1, 1, 1) if pos == "side": self.layout1=QHBoxLayout() else: self.layout1 = QVBoxLayout() self.layout1.setContentsMargins(1, 1, 1, 1) self.layout1.setSpacing(1) self.setLayout(self.layout1) self.cbox = QCheckBox() # self.efield.setMaximumWidth(max_size) self.cbox.setFont(QFont('SansSerif', 12)) self.label = QLabel(name) # self.label.setAlignment(Qt.AlignLeft) self.label.setFont(QFont('SansSerif', 12)) self.layout1.addWidget(self.label) self.layout1.addWidget(self.cbox) self.arg_dict = arg_dict self.name = name self.mytype = type(self.arg_dict[name]) if self.mytype != bool: self.cbox.setChecked(bool(self.arg_dict[name])) else: self.cbox.setChecked(self.arg_dict[name]) self.cbox.toggled.connect(self.when_modified) self.when_modified() def when_modified(self): self.arg_dict[self.name] = self.cbox.isChecked() def hide(self): QWidget.hide(self)
class aLabeledPopup(QWidget): def __init__(self, var, text, item_list, pos = "side", max_size = 200): QWidget.__init__(self) self.setContentsMargins(1, 1, 1, 1) if pos == "side": self.layout1=QHBoxLayout() else: self.layout1 = QVBoxLayout() self.layout1.setContentsMargins(1, 1, 1, 1) self.layout1.setSpacing(1) self.setLayout(self.layout1) self.item_combo = QComboBox() self.item_combo.addItems(item_list) self.item_combo.setFont(QFont('SansSerif', 12)) self.label = QLabel(text) # self.label.setAlignment(Qt.AlignLeft) self.label.setFont(QFont('SansSerif', 12)) self.layout1.addWidget(self.label) self.layout1.addWidget(self.item_combo) self.var = var self.item_combo.textChanged.connect(self.when_modified) self.item_combo.currentIndexChanged.connect(self.when_modified) self.when_modified() def when_modified(self): self.var.set(self.item_combo.currentText()) def hide(self): QWidget.hide(self)
def __init__(self, group_name, name_list, param_dict, help_instance = None, handler = None, help_dict = None): QGroupBox.__init__(self, group_name) the_layout = QVBoxLayout() the_layout.setSpacing(5) the_layout.setContentsMargins(1, 1, 1, 1) self.setLayout(the_layout) self.widget_dict = {} self.is_popup = False self.param_dict = param_dict for txt in name_list: qh = QHBoxLayout() cb = QCheckBox(txt) qh.addWidget(cb) cb.setFont(QFont('SansSerif', 12)) param_widgets = {} for key, val in param_dict.items(): if type(val) == list: # param_widgets[key] = qHotField(key, type(val[0]), val[0], value_list=val, pos="top") else: param_widgets[key] = qHotField(key, type(val), val, pos="top") qh.addWidget(param_widgets[key]) qh.addStretch() the_layout.addLayout(qh) if handler != None: cb.toggled.connect(handler) self.widget_dict[txt] = [cb, param_widgets] if (help_dict != None) and (help_instance != None): if txt in help_dict: help_button_widget = help_instance.create_button(txt, help_dict[txt]) qh.addWidget(help_button_widget) return
def __init__(self, group_name, name_list, param_type = int, default_param = None, help_instance = None, handler = None, help_dict = None): QGroupBox.__init__(self, group_name) the_layout = QVBoxLayout() the_layout.setSpacing(5) the_layout.setContentsMargins(1, 1, 1, 1) self.setLayout(the_layout) self.widget_dict = OrderedDict([]) self.mytype= param_type self.is_popup = False if default_param == None: default_param = "" self.default_param = default_param for txt in name_list: qh = QHBoxLayout() cb = QCheckBox(txt) cb.setFont(QFont('SansSerif', 12)) efield = QLineEdit(str(default_param)) efield.setFont(QFont('SansSerif', 10)) efield.setMaximumWidth(25) qh.addWidget(cb) qh.addStretch() qh.addWidget(efield) the_layout.addLayout(qh) if handler != None: cb.toggled.connect(handler) self.widget_dict[txt] = [cb, efield] if (help_dict != None) and (help_instance != None): if txt in help_dict: help_button_widget = help_instance.create_button(txt, help_dict[txt]) qh.addWidget(help_button_widget) return
def __init__( self, accordion, title, widget ): QGroupBox.__init__(self, accordion) # create the layout layout = QVBoxLayout() layout.setContentsMargins(6, 6, 6, 6) layout.setSpacing(0) layout.addWidget(widget) self._accordianWidget = accordion self._rolloutStyle = 2 self._dragDropMode = 0 self.setAcceptDrops(True) self.setLayout(layout) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.showMenu) # create custom properties self._widget = widget self._collapsed = False self._collapsible = True self._clicked = False self._customData = {} # set common properties self.setTitle(title)
class CheckGroupNoParameters(QGroupBox): def __init__(self, group_name, name_list, default=None, help_instance=None, handler=None, help_dict=None): QGroupBox.__init__(self, group_name) self.handler = handler self.help_dict = help_dict self.help_instance = help_instance self.the_layout = QVBoxLayout() self.the_layout.setSpacing(5) self.the_layout.setContentsMargins(1, 1, 1, 1) self.setLayout(self.the_layout) self.widget_dict = OrderedDict([]) self.is_popup = False self.create_check_boxes(name_list) if default is not None: self.set_myvalue([default]) return def reset(self): for cb in self.widget_dict.values(): cb.setChecked(False) def create_check_boxes(self, name_list): for txt in name_list: qh = QHBoxLayout() cb = QCheckBox(txt) cb.setFont(regular_small_font) qh.addWidget(cb) qh.addStretch() self.the_layout.addLayout(qh) if self.handler != None: cb.toggled.connect(self.handler) self.widget_dict[txt] = cb if (self.help_dict != None) and (self.help_instance != None): if txt in self.help_dict: help_button_widget = self.help_instance.create_button(txt, self.help_dict[txt]) qh.addWidget(help_button_widget) def recreate_check_boxes(self, new_name_list): for cb in self.widget_dict.values(): cb.hide() cb.deleteLater() del cb self.widget_dict = {} self.create_check_boxes(new_name_list) # returns a list where each item is [name, parameter value] def get_myvalue(self): result = [] for (fe, val) in self.widget_dict.items(): if val.isChecked(): result.append(fe) return result # Takes a lists where each item is [name, parameter value] def set_myvalue(self, true_items): self.reset() for fe in true_items: self.widget_dict[fe].setChecked(True) value = property(get_myvalue, set_myvalue)
def __init__(self): QWidget.__init__(self) self.title = u"页面" # Search condition widget self.__wid_search_cond = ViewSearch(def_view_page_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() # Column widget self.__wid_page_def = ViewPageDefMag() self.__wid_page_det = ViewPageDetMag() # Bottom layout _layout_bottom = QHBoxLayout() _layout_bottom.addWidget(self.__wid_page_def) _layout_bottom.addWidget(self.__wid_page_det) # Main layout _layout_main = QVBoxLayout() _layout_main.addWidget(self.__wid_search_cond) _layout_main.addLayout(_layout_bottom) _layout_main.setContentsMargins(0, 0, 0, 0) _layout_main.setSpacing(0) self.setLayout(_layout_main) self.__wid_page_def.sig_selected.connect( self.__wid_page_det.set_page_id) self.__wid_page_def.sig_search.connect(self.search_definition) self.__wid_page_def.sig_delete.connect(self.__wid_page_det.clean) self.__wid_page_det.sig_selected[str].connect(self.sig_selected.emit)
def _init_widgets(self): state = self._state if state is None: return if state.arch.name not in self.ARCH_REGISTERS: l.error( "Architecture %s is not listed in QRegisterViewer.ARCH_REGISTERS.", state.arch.name) return layout = QVBoxLayout() area = QScrollArea() area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) regs = self.ARCH_REGISTERS[state.arch.name] # common ones common_regs = regs['common'] for reg_name in common_regs: sublayout = QHBoxLayout() lbl_reg_name = QLabel(self) lbl_reg_name.setProperty('class', 'reg_viewer_label') lbl_reg_name.setText(reg_name) lbl_reg_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sublayout.addWidget(lbl_reg_name) sublayout.addSpacing(10) reg_value = QASTViewer(None, parent=self) self._registers[reg_name] = reg_value sublayout.addWidget(reg_value) layout.addLayout(sublayout) layout.setSpacing(0) layout.addStretch(0) layout.setContentsMargins(2, 2, 2, 2) # the container container = QFrame() container.setAutoFillBackground(True) palette = container.palette() palette.setColor(container.backgroundRole(), Qt.white) container.setPalette(palette) container.setLayout(layout) area.setWidget(container) base_layout = QVBoxLayout() base_layout.addWidget(area) self.setLayout(base_layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) layout = QVBoxLayout(self) layout.setSpacing(0) self.visualization = Visualization() # The edit_traits call generates the widget to embed. self.ui = self.visualization.edit_traits( parent=self, kind='subpanel').control layout.addWidget(self.ui) self.ui.setParent(self)
def __init__(self, parent=None): QWidget.__init__(self, parent) layout = QVBoxLayout(self) layout.setSpacing(0) self.visualization = Visualization() # The edit_traits call generates the widget to embed. self.ui = self.visualization.edit_traits(parent=self, kind='subpanel').control layout.addWidget(self.ui) self.ui.setParent(self)
def _init_ui(self, txt): self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) pal = QPalette() color = QColor() color.setNamedColor(self._window_bgcolor) color.setAlpha(255 * self._opacity) pal.setColor(QPalette.Background, color) self.setAutoFillBackground(True) self.setPalette(pal) wm, hm = 5, 5 spacing = 8 layout = QVBoxLayout() layout.setSpacing(spacing) layout.setContentsMargins(wm, hm, wm, hm) nlines, ts = self._generate_text(txt) qlabel = QLabel('\n'.join(ts)) ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color, self._font, self._fontsize) qlabel.setStyleSheet(ss) layout.addWidget(qlabel) hlabel = QLabel('double click to dismiss') hlabel.setStyleSheet('QLabel {font-size: 10px}') hlayout = QHBoxLayout() hlayout.addStretch() hlayout.addWidget(hlabel) hlayout.addStretch() layout.addLayout(hlayout) self.setLayout(layout) font = QFont(self._font, self._fontsize) fm = QFontMetrics(font) pw = max([fm.width(ti) for ti in ts]) ph = (fm.height() + 2) * nlines w = pw + wm * 2 h = ph + (hm + spacing + 1) * 2 self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setFixedWidth(w) self.setFixedHeight(h) self.setMask(mask(self.rect(), 10))
class PluginDialog(QWidget): def __init__(self, pluginManager): super(PluginDialog, self).__init__() self.view = PluginView(pluginManager, self) self.vbLayout = QVBoxLayout(self) self.vbLayout.setContentsMargins(0, 0, 0, 0) self.vbLayout.setSpacing(0) self.vbLayout.addWidget(self.view) self.hbLayout = QHBoxLayout() self.vbLayout.addLayout(self.hbLayout) self.hbLayout.setContentsMargins(0, 0, 0, 0) self.hbLayout.setSpacing(6) self.detailsButton = QPushButton("Details", self) self.errorDetailsButton = QPushButton("Error Details", self) self.detailsButton.setEnabled(False) self.errorDetailsButton.setEnabled(False) self.hbLayout.addWidget(self.detailsButton) self.hbLayout.addWidget(self.errorDetailsButton) self.hbLayout.addStretch(5) self.resize(650, 300) self.setWindowTitle("Installed Plugins") self.view.currentPluginChanged.connect(self.updateButtons) self.view.pluginActivated.connect(self.openDetails) self.detailsButton.clicked.connect(self.openDetails) self.errorDetailsButton.clicked.connect(self.openErrorDetails) @Slot() def updateButtons(self): # todo pass @Slot() def openDetails(self): # todo pass @Slot() def openDetails(self, spec): # todo print("TODO open details") pass @Slot() def openErrorDetails(self): # todo pass
def __init__(self, parent=None): """ Default class constructor. :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ super(CmdPrompt, self).__init__(parent) qDebug("CmdPrompt Constructor") self.setObjectName("Command Prompt") self.promptInput = promptInput = CmdPromptInput(self) self.promptHistory = CmdPromptHistory() self.promptDivider = QFrame(self) promptVBoxLayout = QVBoxLayout(self) self.promptSplitter = CmdPromptSplitter(self) self.setFocusProxy(promptInput) self.promptHistory.setFocusProxy(promptInput) self.promptDivider.setLineWidth(1) self.promptDivider.setFrameStyle(QFrame.HLine) QWIDGETSIZE_MAX = 1 # TODO/FIXME. What is QWIDGETSIZE_MAX??? self.promptDivider.setMaximumSize(QWIDGETSIZE_MAX, 1) promptVBoxLayout.addWidget(self.promptSplitter) promptVBoxLayout.addWidget(self.promptHistory) promptVBoxLayout.addWidget(self.promptDivider) promptVBoxLayout.addWidget(promptInput) promptVBoxLayout.setSpacing(0) promptVBoxLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(promptVBoxLayout) #TODO# self.styleHash = QHash<QString, QString>() #TODO# self.styleHash.insert("color", "#000000") # Match -------| #TODO# self.styleHash.insert("background-color", "#FFFFFF") # | #TODO# self.styleHash.insert("selection-color", "#FFFFFF") # | #TODO# self.styleHash.insert("selection-background-color", "#000000") # Match -------| #TODO# self.styleHash.insert("font-family", "Monospace") #TODO# self.styleHash.insert("font-style", "normal") #TODO# self.styleHash.insert("font-size", "12px") # self.updateStyle() self.blinkState = False self.blinkTimer = QTimer(self) self.blinkTimer.timeout.connect(self.blink) self.show()
def layoutWidgets(self): layout = QHBoxLayout() layout.addWidget(self.pane, 1) vbox = QVBoxLayout() vbox.addWidget(self.scrollbar) vbox.addWidget(self.square) vbox.setSpacing(0) vbox.setContentsMargins(0, 0, 0, 0) layout.addLayout(vbox) layout.setSpacing(0) layout.setContentsMargins(5, 5, 5, 5) self.setLayout(layout)
def new_tab(self): """Open new tab.""" tasklist = QTreeView() tasklist.hide() tasklist.setObjectName('taskList') tasklist.setMinimumWidth(100) tasklist.setMaximumWidth(250) new_tab = QWebView() new_tab.setObjectName('webView') inspector = QWebInspector(self) inspector.setObjectName('webInspector') inspector.hide() page_layout = QVBoxLayout() page_layout.setSpacing(0) page_layout.setContentsMargins(0, 0, 0, 0) page_layout.addWidget(new_tab) page_layout.addWidget(inspector) page_widget = QFrame() page_widget.setObjectName('pageWidget') page_widget.setLayout(page_layout) complete_tab_layout = QHBoxLayout() complete_tab_layout.setSpacing(0) complete_tab_layout.setContentsMargins(0, 0, 0, 0) complete_tab_layout.addWidget(tasklist) complete_tab_layout.addWidget(page_widget) complete_tab_widget = QFrame() complete_tab_widget.setLayout(complete_tab_layout) new_tab.load(QUrl(self.startpage)) self.tabs.setUpdatesEnabled(False) if self.new_tab_behavior == "insert": self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget, unicode(new_tab.title())) elif self.new_tab_behavior == "append": self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title())) self.tabs.setCurrentWidget(complete_tab_widget) self.tabs.setTabText(self.tabs.currentIndex(), unicode(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).title())) self.tabs.setUpdatesEnabled(True) # tab.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) # tab.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) new_tab.titleChanged.connect(self.change_tab) new_tab.urlChanged.connect(self.change_tab) new_tab.loadStarted.connect(self.load_start) new_tab.loadFinished.connect(self.load_finish) new_tab.loadProgress.connect(self.pbar.setValue) new_tab.page().linkHovered.connect(self.linkHover) inspector.setPage(new_tab.page())
class XMLFileSelector(QGroupBox): def __init__(self, var_name, default_folder, project_root_dir = "", help_instance=None): QGroupBox.__init__(self, "data selector") self.project_root_dir = project_root_dir self.setContentsMargins(1, 1, 1, 1) self.my_layout = QVBoxLayout() self.my_layout.setSpacing(1) self.setLayout(self.my_layout) self.var_name = var_name self.current_folder = default_folder self.my_folder_selector = FolderSelector(var_name, default_folder, project_root_dir, handler = self.new_folder_selected) self.my_layout.addWidget(self.my_folder_selector) self.concatenate = qHotField("concatenate", bool, False) self.my_layout.addWidget(self.concatenate) self.read_schema() self.check_group = CheckGroupNoParameters("body blocks", self.block_list, self.block_list[0]) self.my_layout.addWidget(self.check_group) def read_schema(self): the_etree = None full_path = add_slash(self.project_root_dir + self.current_folder) f = open(full_path + "schema.xml") raw_text = f.read() f.close() raw_text = re.sub(r"\[.*?\]", r"", raw_text) the_etree = ElementTree.XML(raw_text) if the_etree is None: return else: bl = [subtree.tag for subtree in list(the_etree.find("{transcript}BODY"))] self.block_list = [] for block_name in bl: self.block_list.append(re.search("\{transcript\}(.*)", block_name).group(1)) def new_folder_selected(self): self.current_folder = self.my_folder_selector.value self.read_schema() self.check_group.recreate_check_boxes(self.block_list) def get_myvalue(self): return (self.my_folder_selector.value, self.check_group.value, self.concatenate.value) def set_myvalue(self, new_value): if new_value != "": self.my_folder_selector.value = add_slash(new_value[0]) self.new_folder_selected() self.check_group.value = new_value[1] self.concatenate.value = new_value[2] value = property(get_myvalue, set_myvalue)
def setupTopGroup(self): topGroup = QGroupBox("Simulation Results") self.resultsPathLineEdit = SimpleOption('resultsPath','Results Path','/home/thomas/Dropbox/Keio/research/results/') topGroupLayout = QVBoxLayout() topGroupLayout.setSpacing(0) topGroupLayout.setAlignment(Qt.AlignTop) topGroupLayout.addWidget(self.resultsPathLineEdit) self.loadResultsLabel = QLabel() self.loadResultsLabel.setAlignment(Qt.AlignHCenter) topGroupLayout.addWidget(self.loadResultsLabel) self.loadResultsButton = QPushButton("Load the results") self.loadResultsButton.clicked.connect(self.loadResults) topGroupLayout.addWidget(self.loadResultsButton) topGroup.setLayout(topGroupLayout) self.topLeftLayout.addWidget(topGroup)
def setupFilterGroup(self): filterGroup = QGroupBox('Filter the results') filterGroupLayout = QVBoxLayout() filterGroupLayout.setSpacing(0) filterGroupLayout.setAlignment(Qt.AlignTop) # Distribution Model self.filterDistribution = SimpleComboboxOption('dis','Speed Distribution Model',3, True, 'Uniform','Exponential','Normal','Log Normal') filterGroupLayout.addWidget(self.filterDistribution) self.filterDistribution.setVisible(False) # Number of results per point self.filterNb = SimpleSpinOption('simuNbMin', 'Minimum results for a given setting', 10, integer=True, checkable=True) self.filterNb.checkBox.setChecked(True) filterGroupLayout.addWidget(self.filterNb) # Filter the date dateWidget = QWidget() dateWidget.setLayout(QHBoxLayout()) self.filterDate = QCheckBox('After') self.filterDate.setChecked(QSettings().value('filterDate','0')=='1') dateWidget.layout().addWidget(self.filterDate) self.filterDateYear = QComboBox() for m in xrange(2010,2012): self.filterDateYear.addItem(str(m)) self.filterDateYear.setCurrentIndex(int(QSettings().value('dateYear', 1))) dateWidget.layout().addWidget(self.filterDateYear) dateWidget.layout().addWidget(QLabel('Year')) self.filterDateMonth = QComboBox() for m in xrange(1,13): self.filterDateMonth.addItem(str(m)) self.filterDateMonth.setCurrentIndex(int(QSettings().value('dateMonth', 4))) dateWidget.layout().addWidget(self.filterDateMonth) dateWidget.layout().addWidget(QLabel('Month')) self.filterDateDay = QComboBox() for d in xrange(1,32): self.filterDateDay.addItem(str(d)) self.filterDateDay.setCurrentIndex(int(QSettings().value('dateDay', 0))) dateWidget.layout().addWidget(self.filterDateDay) dateWidget.layout().addWidget(QLabel('Day')) filterGroupLayout.addWidget(dateWidget) filterGroup.setLayout(filterGroupLayout) self.topLeftLayout.addWidget(filterGroup) # Filter the scenario self.filterScenar = SimpleComboboxOption('scenar','Scenario',1, True, 'vanet-highway-test-thomas','vanet-highway-scenario2') filterGroupLayout.addWidget(self.filterScenar) # Filter gap self.filterGap = SimpleSpinOption('avgdistanalyze','Average Distance (m)',100, checkable=True) filterGroupLayout.addWidget(self.filterGap)
def __init__(self, *args, **kwargs): super(Widget_referenceFiles, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(8) treeWidget = QTreeWidget() headerItem = treeWidget.headerItem() checkBox_allItems = QCheckBox(treeWidget) checkBox_allItems.setFixedWidth(20) checkBox_allItems.setChecked(True) checkBox_allItems.setStyleSheet("margin: 6px 6px") treeWidget.setItemWidget(headerItem, 0, checkBox_allItems) headerItem.setText(0, "") headerItem.setText(1, "Reference File Name") treeWidget.setRootIsDecorated(False) treeWidget.setStyleSheet( "QTreeWidget::item { border-left: 1px solid gray;border-bottom: 1px solid gray; padding: 3px}\ QTreeWidget{ font-size:13px;}") treeWidget.header().setStyleSheet("font-size:12px;") treeWidget.setColumnWidth(0, 22) w_buttons = QWidget() lay_buttons = QHBoxLayout(w_buttons) lay_buttons.setContentsMargins(0, 0, 0, 0) buttonReference = QPushButton("REFERENCE") buttonCleanExceptSelected = QPushButton("CLEAN EXCEPT SELECTED") lay_buttons.addWidget(buttonCleanExceptSelected) lay_buttons.addWidget(buttonReference) mainLayout.addWidget(treeWidget) mainLayout.addWidget(w_buttons) self.treeWidget = treeWidget self.treeWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.treeWidget.checkBox_allItems = checkBox_allItems checkBox_allItems.stateChanged.connect(self.cmd_setCheckAsset) treeWidget.itemPressed.connect(self.cmd_selectItems) buttonReference.clicked.connect(self.referenceFiles) buttonCleanExceptSelected.clicked.connect(self.cmd_cleanScene) self.cmd_loadList()
def add_command_tab(self, command_list, tab_name = "Commands"): outer_widget = QWidget() outer_layout = QVBoxLayout() outer_widget.setLayout(outer_layout) outer_layout.setContentsMargins(2, 2, 2, 2) outer_layout.setSpacing(1) for c in command_list: new_command = qButtonWithArgumentsClass(c[1], c[0], c[2], self.help_instance, max_field_size = 100) outer_layout.addWidget(new_command) outer_layout.setAlignment(new_command,QtCore.Qt.AlignTop ) outer_layout.addStretch() scroller = QScrollArea() scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroller.setWidget(outer_widget) scroller.setWidgetResizable(True) self.addTab(scroller, tab_name)
def __init__(self, *args, **kwrgs): existing_widgets = Window.mayaWin.findChildren(QDialog, Window.objectName) if existing_widgets: map(lambda x: x.deleteLater(), existing_widgets) super(Window, self).__init__(*args, **kwrgs) self.installEventFilter(self) self.setObjectName(Window.objectName) self.setWindowTitle(Window.title) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) self.resize(Window.defaultWidth, Window.defaultHeight) self.load_shapeInfo(Window.path_uiInfo)
class ParameterWidget(QWidget): """ Widget that displays parameters. Holds buttons for acting on the parameters. """ def __init__(self): super(ParameterWidget, self).__init__() self.initUI() def initUI(self): # Create container for action buttons self.actionContainer = ButtonContainer() self.parameterModel = ParameterModel() self.parameterView = ParameterListView() self.parameterView.setAttribute(Qt.WA_MacShowFocusRect, False) self.parameterView.setRootIsDecorated(False) self.parameterView.setModel(self.parameterModel) # Create a main layout (vertical) for this widget self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.parameterView) self.layout.addWidget(self.actionContainer) self.setLayout(self.layout) # Add a button to the container addButton = QPushButton() addButton.setIcon(QIcon(AppVars.imagePath() + "AddButton.png")) addButton.clicked.connect(self.addButtonClicked) self.actionContainer.addButton(addButton) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton) def addButtonClicked(self): self.parameterView.addParameter() def removeButtonClicked(self): self.parameterView.removeSelectedParameter()
def __init__(self, *args, **kwrgs): existing_widgets = Window.mayaWin.findChildren(QDialog, Window.objectName) if existing_widgets: map(lambda x: x.deleteLater(), existing_widgets) super(Window, self).__init__(*args, **kwrgs) self.installEventFilter(self) self.setObjectName(Window.objectName) self.setWindowTitle(Window.title) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) w_controller = Widget_Controller() w_separator1 = Widget_Separator() w_objectList = Widget_objectList() w_separator2 = Widget_Separator() w_connectionType = Widget_ConnectionType() w_buttons = QWidget() w_buttons.setStyleSheet("font:14px") lay_buttons = QHBoxLayout(w_buttons) lay_buttons.setSpacing(0) button_connect = QPushButton("CONNECT") button_close = QPushButton("CLOSE") lay_buttons.addWidget(button_connect) lay_buttons.addWidget(button_close) mainLayout.addWidget(w_controller) mainLayout.addWidget(w_separator1) mainLayout.addWidget(w_objectList) mainLayout.addWidget(w_separator2) mainLayout.addWidget(w_connectionType) mainLayout.addWidget(w_buttons) self.resize(Window.defaultWidth, Window.defaultHeight) self.load_shapeInfo(Window.path_uiInfo) button_connect.clicked.connect(self.cmd_connect) button_close.clicked.connect(self.deleteLater) self.w_controller = w_controller self.w_objectList = w_objectList self.w_connectionType = w_connectionType
def _load_tmps(self): state = self._state layout = QVBoxLayout() self._tmps.clear() if state is None: tmps = {} else: tmps = state.scratch.temps # tmps for tmp_id, tmp_value in tmps.iteritems(): sublayout = QHBoxLayout() lbl_tmp_name = QLabel(self) lbl_tmp_name.setProperty('class', 'reg_viewer_label') lbl_tmp_name.setText("tmp_%d" % tmp_id) lbl_tmp_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sublayout.addWidget(lbl_tmp_name) sublayout.addSpacing(10) tmp_viewer = QASTViewer(tmp_value, parent=self) self._tmps[tmp_id] = tmp_viewer sublayout.addWidget(tmp_viewer) layout.addLayout(sublayout) layout.setSpacing(0) layout.addStretch(0) layout.setContentsMargins(2, 2, 2, 2) # the container container = QFrame() container.setAutoFillBackground(True) palette = container.palette() palette.setColor(container.backgroundRole(), Qt.white) container.setPalette(palette) container.setLayout(layout) self._area.setWidget(container)
def __init__(self, *args, **kwargs): super(Widget_ConnectionType, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setSpacing(0) self.setStyleSheet("font-size:12px;") w_comboBox = QWidget() lay_comboBox = QHBoxLayout(w_comboBox) lay_comboBox.setContentsMargins(5, 5, 5, 5) lay_comboBox.setSpacing(0) label = QLabel("Connection Type : ") comboBox = QComboBox() comboBox.setStyleSheet("padding:2px; padding-left:5px") comboBox.addItem("Long Type") comboBox.addItem("Enum Type") lay_comboBox.addWidget(label) lay_comboBox.addWidget(comboBox) w_enumAttrName = QWidget() lay_enumAttrName = QHBoxLayout(w_enumAttrName) lay_enumAttrName.setContentsMargins(5, 5, 5, 5) lay_enumAttrName.setSpacing(0) label_enumName = QLabel("Enum Attribute Name : ") lineEdit = QLineEdit() lineEdit.setStyleSheet("padding:2px") lay_enumAttrName.addWidget(label_enumName) lay_enumAttrName.addWidget(lineEdit) w_enumAttrName.setEnabled(False) mainLayout.addWidget(w_comboBox) mainLayout.addWidget(w_enumAttrName) self.comboBox = comboBox self.w_enumAttrName = w_enumAttrName self.lineEdit = lineEdit self.comboBox.currentIndexChanged.connect(self.cmd_attrTypeCondition) self.readData() lineEdit.textEdited.connect(self.writeData) comboBox.currentIndexChanged.connect(self.writeData) self.readData()
def __init__(self, *args, **kwargs): super(Widget_connectionList, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(5, 5, 5, 5) mainLayout.setSpacing(0) treeWidget = QTreeWidget() treeWidget.setColumnCount(3) headerItem = treeWidget.headerItem() headerItem.setText(0, "Attribute") headerItem.setText(1, "Target Node") headerItem.setText(2, "Target Attr") treeWidget.setRootIsDecorated(False) self.treeWidget = treeWidget treeWidget.setStyleSheet( "QTreeWidget::item { border-bottom: 1px solid gray; padding:1px}\ QTreeWidget{ font-size:13px;}") treeWidget.header().setStyleSheet("font-size:12px;") w_buttons = QWidget() lay_buttons = QHBoxLayout(w_buttons) lay_buttons.setContentsMargins(0, 0, 0, 0) lay_buttons.setSpacing(5) button_add = QPushButton("Add Line") button_remove = QPushButton("Remove Line") lay_buttons.addWidget(button_add) lay_buttons.addWidget(button_remove) mainLayout.addWidget(treeWidget) mainLayout.addWidget(w_buttons) button_add.clicked.connect(self.cmd_addLine) button_remove.clicked.connect(self.cmd_removeLine) treeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) QtCore.QObject.connect( treeWidget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.loadContextMenu) self.treeWidget = treeWidget self.readData()
def create_box_layout(self, is_vertical=True, align=""): """ Returns a new GUI toolkit neutral 'box' layout manager. """ if is_vertical: layout = QVBoxLayout() alignment = Qt.AlignTop if align == "bottom": alignment = Qt.AlignBottom layout.setAlignment(alignment) else: layout = QHBoxLayout() alignment = Qt.AlignLeft if align == "right": alignment = Qt.AlignRight layout.setAlignment(alignment) layout.setSpacing(0) ### PYSIDE: layout.setMargin( 0 ) return layout_adapter(layout, is_vertical)
def __init__(self, name=None): super(SensorDisplay, self).__init__() self.graph = pg.PlotWidget(name=name) self.plots = [] title = QLabel(name) title.setStyleSheet('color: white; background-color: black') title.setAlignment(Qt.AlignCenter) self.setFixedHeight(150) mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0,0,0,0) mainLayout.setSpacing(0) self.setLayout(mainLayout) self.dataLayout = QHBoxLayout() self.dataLayout.setContentsMargins(0,0,0,0) self.dataLayout.setSpacing(0) mainLayout.addWidget(title) mainLayout.addWidget(self.graph) mainLayout.addLayout(self.dataLayout)
def __init__(self, *args, **kwrgs): existing_widgets = Window.mayaWin.findChildren( QDialog, Window.objectName ) if existing_widgets: map( lambda x: x.deleteLater(), existing_widgets ) super( Window, self ).__init__( *args, **kwrgs ) self.installEventFilter( self ) self.setObjectName( Window.objectName ) self.setWindowTitle( Window.title ) mainLayout = QVBoxLayout( self ); mainLayout.setContentsMargins( 0,0,0,0 ); mainLayout.setSpacing(0) w_controller = Widget_loadObject( title="Controller", saveInfo=False ) w_separator1 = Widget_Separator() w_target = Widget_target() w_attrName = Widget_attributeName() w_startIndex = Widget_startIndex() w_buttons = QWidget() lay_buttons = QHBoxLayout( w_buttons ); lay_buttons.setContentsMargins( 10,0,10,10 ); lay_buttons.setSpacing( 0 ) button_connect = QPushButton( "Connect" ); button_connect.setFixedHeight( 25 ) button_close = QPushButton( "Close" ); button_close.setFixedHeight( 25 ) lay_buttons.addWidget( button_connect ) lay_buttons.addWidget( button_close ) mainLayout.addWidget(w_controller) mainLayout.addWidget(w_separator1) mainLayout.addWidget( w_target ) mainLayout.addWidget(w_attrName) mainLayout.addWidget(w_startIndex) mainLayout.addWidget( w_buttons ) self.resize( Window.defaultWidth, Window.defaultHeight ) self.load_shapeInfo( Window.path_uiInfo ) button_connect.clicked.connect( self.cmd_connect ) button_close.clicked.connect( self.deleteLater ) self.w_controller = w_controller self.w_target = w_target self.w_attrName = w_attrName self.w_startIndex = w_startIndex
def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton)
def __init__(self, p_data): QWidget.__init__(self) _step_no = p_data["no"] _step_id = p_data["id"] self.title = _step_no self._wid_step = StepView(_step_id) self._wid_item = ItemView() _layout = QVBoxLayout() _layout.addWidget(self._wid_step) _layout.addWidget(self._wid_item) _layout.setSpacing(0) self.setLayout(_layout) self._wid_step.sig_select.connect(self._wid_item.set_step_id) self._wid_step.sig_delete.connect(self._wid_item.clean)
def __init__(self): super(HighwayAnalyzeWidget,self).__init__() self.averageSimulationTime = 325.0 mainLayout = QVBoxLayout() mainLayout.setAlignment(Qt.AlignTop|Qt.AlignHCenter) mainLayout.setSpacing(0) self.setLayout(mainLayout) topWidget = QWidget() self.topLayout = QHBoxLayout() self.topLayout.setSpacing(0) topWidget.setLayout(self.topLayout) topLeftWidget = QWidget() self.topLeftLayout = QVBoxLayout() topLeftWidget.setLayout(self.topLeftLayout) self.setupTopGroup() self.setupFilterGroup() self.topLayout.addWidget(topLeftWidget) self.layout().addWidget(topWidget) # Button and log buttonAndLogWidget = QWidget() buttonAndLogWidget.setLayout(QVBoxLayout()) # Analyze the results BUTTON self.analyzeResultsButton = QPushButton('Analyze the results') self.analyzeResultsButton.clicked.connect(self.analyzeResults) self.analyzeResultsButton.setEnabled(False) buttonAndLogWidget.layout().addWidget(self.analyzeResultsButton) # LOG self.logText = QTextBrowser() self.logText.setFont(QFont('Century Gothic', 7)) self.logText.setWordWrapMode(QTextOption.NoWrap) buttonAndLogWidget.layout().addWidget(self.logText) self.topLayout.addWidget(buttonAndLogWidget) self.results = [] self.logFile = os.path.join(self.resultsPath(), 'analyze_'+os.uname()[1]+'.log') # Image self.picLabel = QLabel() self.picLabel.setAlignment(Qt.AlignHCenter) #self.picLabel.resize(800,600) self.picLabel.setMinimumSize(800,600) self.layout().addWidget(self.picLabel)
class qLabeledEntry(QWidget): def __init__(self, name, arg_dict, pos = "side", max_size = 200): QWidget.__init__(self) self.setContentsMargins(1, 1, 1, 1) if pos == "side": self.layout1=QHBoxLayout() else: self.layout1 = QVBoxLayout() self.layout1.setContentsMargins(1, 1, 1, 1) self.layout1.setSpacing(1) self.setLayout(self.layout1) self.efield = QLineEdit("Default Text") # self.efield.setMaximumWidth(max_size) self.efield.setFont(QFont('SansSerif', 12)) self.label = QLabel(name) # self.label.setAlignment(Qt.AlignLeft) self.label.setFont(QFont('SansSerif', 12)) self.layout1.addWidget(self.label) self.layout1.addWidget(self.efield) self.arg_dict = arg_dict self.name = name self.mytype = type(self.arg_dict[name]) if self.mytype != str: self.efield.setText(str(self.arg_dict[name])) self.efield.setMaximumWidth(50) else: self.efield.setText(self.arg_dict[name]) self.efield.setMaximumWidth(100) self.efield.textChanged.connect(self.when_modified) def when_modified(self): if self.mytype == int: if self.efield.text != None: self.arg_dict[self.name] = int(self.efield.text()) else: self.arg_dict[self.name] = self.efield.text() def hide(self): QWidget.hide(self)
def __init__(self, *args, **kwargs ): self.index = 0 if kwargs.has_key( 'index' ): self.index = kwargs.pop( 'index' ) QWidget.__init__( self, *args, **kwargs ) mainLayout = QVBoxLayout( self ); mainLayout.setContentsMargins(0,0,0,0) mainLayout.setSpacing(0) treeWidget = QTreeWidget() treeWidget.setColumnCount(1) headerItem = treeWidget.headerItem() headerItem.setText( 0, 'Controller list'.decode('utf-8') ) button = QPushButton( 'Load Controllers'.decode('utf-8') ) mainLayout.addWidget( treeWidget ) mainLayout.addWidget( button ) self.treeWidget = treeWidget QtCore.QObject.connect( button, QtCore.SIGNAL("clicked()"), self.loadControllers ) self.uiInfoPath = Window.infoBaseDir + '/Widget_ctlList_%d.json' % self.index self.loadInfo()
def __init__(self, parent, *args, **kw): super(_FilterTableView, self).__init__(*args, **kw) layout = QVBoxLayout() # layout.setSpacing(1) self.table = table = _myTableView(parent) hl = QHBoxLayout() hl.setSpacing(10) self.button = button = QPushButton() button.setIcon(icon('delete').create_icon()) button.setEnabled(False) button.setFlat(True) button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) button.setFixedWidth(25) self.text = text = QLineEdit() self.cb = cb = QCheckBox() text.setEnabled(False) button.setEnabled(False) table.setEnabled(False) # cb.setSizePolicy(QSizePolicy.Fixed, # QSizePolicy.Fixed) # cb.setFixedWidth(20) # cb.setFixedHeight(20) hl.addWidget(cb) hl.addWidget(text) hl.addWidget(button) # hl.addStretch() layout.addLayout(hl) layout.addWidget(table) layout.setSpacing(1) self.setLayout(layout)
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) self.installEventFilter(self) self.setObjectName(Window.objectName) self.setWindowTitle(Window.title) self.resize(*Window.size) WidgetInfo(self).loadTransform(Window.infoTransformPath, "Window") sep1 = QFrame() sep1.setFrameShape(QFrame.HLine) sep2 = QFrame() sep2.setFrameShape(QFrame.HLine) menubar = MenuBar() wdg_mesh_orig = Widget_mesh(title="Original Mesh : ") wdg_mesh_modified = Widget_mesh(title="Modified Mesh : ") gb_targets = GroupBox_targetMeshs(title="Target Meshs") bt_transform = QPushButton("Transform") mainLayout = QVBoxLayout(self) mainLayout.setSpacing(5) mainLayout.addWidget(menubar) mainLayout.addWidget(sep1) mainLayout.addWidget(wdg_mesh_orig) mainLayout.addWidget(wdg_mesh_modified) mainLayout.addWidget(sep2) mainLayout.addWidget(gb_targets) mainLayout.addWidget(bt_transform) QtCore.QObject.connect(bt_transform, QtCore.SIGNAL('clicked()'), self.cmd_transform) self.wdg_mesh_orig = wdg_mesh_orig self.wdg_mesh_modified = wdg_mesh_modified self.gb_targets = gb_targets
def __init__(self, *args, **kwargs): title = "" if kwargs.has_key("title"): title = kwargs.pop("title") super(GroupBox_targetMeshs, self).__init__(*args, **kwargs) self.setTitle(title) listWidget = QListWidget() button = QPushButton("Load Selected") mainLayout = QVBoxLayout(self) mainLayout.setSpacing(0) mainLayout.addWidget(listWidget) mainLayout.addWidget(button) self.title = title self.listWidget = listWidget QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), self.loadSelected) WidgetInfo(self.listWidget).loadItems( Window.infoPath, "GroupBox_targetMeshs_%s_listWidget" % title)
def __init__(self): super(DataInspector, self).__init__() self.slider_width = +300 self.main_widget = QWidget(self) self.setCentralWidget(self.main_widget) self.render_widget = RenderWidget() # Create interface actions self.action_load_data = QAction('Load data set', self, shortcut='Ctrl+O') self.action_load_data.setIcon(QIcon("images/AddButton.png")) self.action_load_data.triggered.connect(self.load_file) self.action_show_simple = QAction('Switch to simple rendering', self, shortcut='Ctrl+1') self.action_show_simple.setText("Simple") self.action_show_simple.triggered.connect(self.switch_to_simple) self.action_show_ct = QAction('Switch to CT rendering', self, shortcut='Ctrl+2') self.action_show_ct.setText("CT") self.action_show_ct.triggered.connect(self.switch_to_ct) self.action_show_mip = QAction('Switch to MIP rendering', self, shortcut='Ctrl+3') self.action_show_mip.setText("MIP") self.action_show_mip.triggered.connect(self.switch_to_mip) # Align the dock buttons to the right with a spacer widget spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # Add buttons to container on top self.toolbar = self.addToolBar('Main tools') self.toolbar.addAction(self.action_show_simple) self.toolbar.addAction(self.action_show_ct) self.toolbar.addAction(self.action_show_mip) self.toolbar.addWidget(spacer) self.toolbar.addAction(self.action_load_data) self.setUnifiedTitleAndToolBarOnMac(True) # Slider for simple visualization self.sliders_simple_widget = QSlider(Qt.Horizontal) self.sliders_simple_widget.setMinimumWidth(self.slider_width) self.sliders_simple_widget.setMaximumWidth(self.slider_width) self.sliders_simple_widget.setMinimum(0) self.sliders_simple_widget.setMaximum(1000) self.sliders_simple_widget.valueChanged.connect( self.simple_slider_value_changed) self.sliders_simple_widget.setHidden(True) # Create sliders for CT transfer function sliders_layout = QVBoxLayout() sliders_layout.setContentsMargins(0, 0, 0, 0) sliders_layout.setSpacing(0) self.sliders = [] for _ in range(0, 7): slider = QSlider(Qt.Horizontal) slider.setMinimum(0) slider.setMaximum(1000) slider.valueChanged.connect(self.ct_slider_value_changed) self.sliders.append(slider) sliders_layout.addWidget(slider) self.sliders_ct_widget = QWidget() self.sliders_ct_widget.setMinimumWidth(self.slider_width) self.sliders_ct_widget.setMaximumWidth(self.slider_width) self.sliders_ct_widget.setLayout(sliders_layout) self.sliders_ct_widget.setHidden(True) self.min_slider = QSlider(Qt.Horizontal) self.min_slider.setMinimum(0) self.min_slider.setMaximum(1000) self.min_slider.valueChanged.connect(self.mip_slider_value_changed) self.max_slider = QSlider(Qt.Horizontal) self.max_slider.setMinimum(0) self.max_slider.setMaximum(1000) self.max_slider.setValue(1000) self.max_slider.valueChanged.connect(self.mip_slider_value_changed) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.min_slider) layout.addWidget(self.max_slider) self.sliders_mip_widget = QWidget() self.sliders_mip_widget.setMinimumWidth(self.slider_width) self.sliders_mip_widget.setMaximumWidth(self.slider_width) self.sliders_mip_widget.setLayout(layout) self.sliders_mip_widget.setHidden(True) layout = QHBoxLayout(self.main_widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.render_widget) layout.addWidget(self.sliders_mip_widget) layout.addWidget(self.sliders_ct_widget) layout.addWidget(self.sliders_simple_widget) self.main_widget.setLayout(layout) self.resize(800, 500)
class ButtonContainer(QWidget): Height = 21 def __init__(self, orientation=Qt.Horizontal): """ Sets up the button container. """ super(ButtonContainer, self).__init__() self.orientation = orientation # Perform custom painting on OS X self._osx = sys.platform.startswith("darwin") self.initUI() # Keep track of the number of buttons self._buttonCount = 0 def initUI(self): """ Initializes UI. Creates a horizontal layout to which buttons can be added. """ if self._osx: # Mimic the style of buttons underneath a list view gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, self.Height) colorTop = QColor(250, 250, 250, 255) colorMid = QColor(244, 244, 244, 255) colorInBetween = QColor(238, 238, 238, 255) colorMidLow = QColor(234, 234, 234, 255) colorLow = QColor(239, 239, 239, 255) gradient.setColorAt(0, colorTop) gradient.setColorAt(0.45, colorMid) gradient.setColorAt(0.5, colorInBetween) gradient.setColorAt(0.55, colorMidLow) gradient.setColorAt(1, colorLow) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setAutoFillBackground(True) self.setPalette(palette) # Use a horizontal layout in which to keep # buttons. Initialize with an empty QWidget to # make the buttons align to the left if self.orientation == Qt.Horizontal: self.layout = QHBoxLayout() else: self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(QWidget()) self.setLayout(self.layout) # Public methods def addButton(self, button): """ Adds a button to the container. The button is styled and resized to fit in the container widget. Assumes that the button has no name and has an icon (preferably in the right size) :type button: QPushButton """ # Make sure that the button won't disturb the layout button.setMaximumHeight(ButtonContainer.Height) button.setMaximumWidth(ButtonContainer.Height) button.setFlat(True) # Insert button into the horizontal layout. Make sure # that the empty QWidget stays on the right self.layout.insertWidget(self._buttonCount, button) self._buttonCount += 1 # Overwritten from QWidget def paintEvent(self, ev): if not self._osx: return size = self.size() height = size.height()-1 width = size.width()-1 painter = QPainter(self) painter.setPen(QColor(165, 165, 165, 255)) painter.drawLine(QPoint(0, 0), QPoint(0, height)) painter.drawLine(QPoint(0, height), QPoint(width, height)) painter.drawLine(QPoint(width, height), QPoint(width, 0)) for index in range(self._buttonCount): xCoord = (index + 1) * 21 - 1 painter.drawLine(QPoint(xCoord, 0), QPoint(xCoord, height)) def sizeOfButtons(self): return self._buttonCount * ButtonContainer.Height def sizeOfContainer(self): if self._buttonCount == 0: return 0 return ButtonContainer.Height def maximumWidth(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return 0 else: return self.sizeOfContainer() def minimumWidth(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfButtons() else: return self.sizeOfContainer() def maximumHeight(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfContainer() else: return 0 def minimumHeight(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfContainer() else: return self.sizeOfButtons() def sizeHint(self): """ :rtype: QtCore.QSize """ width = 150 height = ButtonContainer.Height if self._buttonCount == 0: height = 0 if self.orientation == Qt.Horizontal: sizeHint = QtCore.QSize(width, height) else: sizeHint = QtCore.QSize(height, width) return sizeHint
def __init__(self, parent=None): super(MassAttribute_UI, self).__init__(parent) # Abstract self.applier = self.Applikator(self) self.selection = [] self.callback = None self.ctx = None # storing found attributes' types to avoid double check self.solved = {} self.setLocale(QLocale.C) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_QuitOnClose) self.setFixedWidth(300) self.setWindowTitle('Massive Attribute Modifier') # UI L_main = QVBoxLayout() self.WV_title = QLabel('') self.WV_title.setVisible(False) self.WV_title.setFont(QFont('Verdana', 10)) self.WV_title.setContentsMargins(0, 0, 0, 7) self.WB_select = QPushButton('Select') self.WB_select.setVisible(False) self.WB_select.setFixedWidth(50) self.WB_select.clicked.connect(lambda: cmds.select(self.selection)) self.WB_update = QPushButton('Update') self.WB_update.setFixedWidth(50) self.WB_update.clicked.connect( lambda: self.update_attributes(cmds.ls(sl=True))) self.WV_search = Filter() self.WV_search.textChanged.connect(self.filter) self.WC_cases = QCheckBox('Case sensitive') self.WC_cases.stateChanged.connect(self.filter) self.WC_types = QCheckBox('Type filtering') self.WL_attrtype = QComboBox() self.WL_attrtype.setEnabled(False) for i, ctx in enumerate(sorted(self.ctx_wide)): self.WL_attrtype.addItem(ctx.title()) self.WL_attrtype.setItemIcon(i, self.ctx_icons[ctx]) L_attrtype = line(self.WC_types, self.WL_attrtype) self.WC_types.stateChanged.connect( partial(self.update_attributes, self.selection)) self.WC_types.stateChanged.connect(self.WL_attrtype.setEnabled) self.WL_attrtype.currentIndexChanged.connect(self.filter) self.WC_liveu = QCheckBox('Live') self.WC_liveu.stateChanged.connect(self.WB_update.setDisabled) self.WC_liveu.stateChanged.connect(self.set_callback) self.WC_histo = QCheckBox('Load history') self.WC_histo.setChecked(True) self.WC_histo.stateChanged.connect( partial(self.update_attributes, self.selection)) self.WC_child = QCheckBox('Children') self.WC_child.stateChanged.connect( partial(self.update_attributes, self.selection)) options = group( 'Options', line(self.WC_cases, L_attrtype), line(self.WC_child, self.WC_histo, self.WC_liveu, self.WB_update)) options.layout().setSpacing(2) self.WL_attributes = QTreeWidget() self.WL_attributes.setStyleSheet( 'QTreeView {alternate-background-color: #1b1b1b;}') self.WL_attributes.setAlternatingRowColors(True) self.WL_attributes.setHeaderHidden(True) self.WL_attributes.setRootIsDecorated(False) self.objs_attr = set() self.shps_attr = set() self.W_EDI_float = FloatBox() self.W_EDI_int = IntBox() self.W_EDI_enum = QComboBox() self.W_EDI_bool = QCheckBox() self.W_EDI_str = QLineEdit() self.W_EDI_d3 = Double3() self.W_EDI_d4 = Double4() self.W_EDI_color = ColorPicker() # Final layout L_title = line(self.WV_title, self.WB_select) L_title.setStretch(0, 1) L_main.addLayout(L_title) L_main.setAlignment(Qt.AlignLeft) L_main.addWidget(self.WV_search) L_main.addWidget(options) L_main.addWidget(self.WL_attributes) L_edits = col(self.W_EDI_bool, self.W_EDI_int, self.W_EDI_float, self.W_EDI_enum, self.W_EDI_str, self.W_EDI_d3, self.W_EDI_d4, self.W_EDI_color) L_edits.setContentsMargins(0, 8, 0, 0) L_main.addLayout(L_edits) L_main.setStretch(3, 1) L_main.setSpacing(2) self.appliers = { 'float': self.applier.apply_float, 'enum': self.applier.apply_enum, 'bool': self.applier.apply_bool, 'time': self.applier.apply_float, 'byte': self.applier.apply_int, 'angle': self.applier.apply_float, 'string': self.applier.apply_str, 'float3': self.applier.apply_d3, 'float4': self.applier.apply_d4, 'color': self.applier.apply_color } self.setLayout(L_main) # final settings self.WL_attributes.itemSelectionChanged.connect(self.update_setter) self.applier.unset_editors()
def __create_ui(self): """ Create main UI """ self.setWindowTitle(CREATE_NODE_TITLE) # remove window decoration if path and type is set if self.defined_path and self.defined_type: self.setWindowFlags(Qt.FramelessWindowHint | Qt.Popup) main_layout = QVBoxLayout(self) main_layout.setSpacing(1) main_layout.setContentsMargins(2, 2, 2, 2) # content layout content_layout = QVBoxLayout() self.files_model = QFileSystemModel() self.files_model.setNameFilterDisables(False) self.files_list = MTTFileList() self.files_list.setAlternatingRowColors(True) self.files_list.setSelectionMode(QAbstractItemView.ExtendedSelection) self.files_list.selectionValidated.connect(self.do_validate_selection) self.files_list.goToParentDirectory.connect(self.on_go_up_parent) self.files_list.doubleClicked.connect(self.on_double_click) self.files_list.setModel(self.files_model) buttons_layout = QHBoxLayout() content_layout.addLayout(self.__create_filter_ui()) content_layout.addWidget(self.files_list) content_layout.addLayout(buttons_layout) self.files_list.filter_line = self.filter_line if not self.defined_path: # path line path_layout = QHBoxLayout() # bookmark button bookmark_btn = QPushButton('') bookmark_btn.setFlat(True) bookmark_btn.setIcon(QIcon(':/addBookmark.png')) bookmark_btn.setToolTip('Bookmark this Folder') bookmark_btn.setStatusTip('Bookmark this Folder') bookmark_btn.clicked.connect(self.on_add_bookmark) # path line edit self.path_edit = QLineEdit() self.path_edit.editingFinished.connect(self.on_enter_path) # parent folder button self.parent_folder_btn = QPushButton('') self.parent_folder_btn.setFlat(True) self.parent_folder_btn.setIcon( QIcon(':/SP_FileDialogToParent.png')) self.parent_folder_btn.setToolTip('Parent Directory') self.parent_folder_btn.setStatusTip('Parent Directory') self.parent_folder_btn.clicked.connect(self.on_go_up_parent) # browse button browse_btn = QPushButton('') browse_btn.setFlat(True) browse_btn.setIcon(QIcon(':/navButtonBrowse.png')) browse_btn.setToolTip('Browse Directory') browse_btn.setStatusTip('Browse Directory') browse_btn.clicked.connect(self.on_browse) # parent widget and layout path_layout.addWidget(bookmark_btn) path_layout.addWidget(self.path_edit) path_layout.addWidget(self.parent_folder_btn) path_layout.addWidget(browse_btn) main_layout.addLayout(path_layout) # bookmark list bookmark_parent_layout = QHBoxLayout() bookmark_frame = QFrame() bookmark_frame.setFixedWidth(120) bookmark_layout = QVBoxLayout() bookmark_layout.setSpacing(1) bookmark_layout.setContentsMargins(2, 2, 2, 2) bookmark_frame.setLayout(bookmark_layout) bookmark_frame.setFrameStyle(QFrame.Sunken) bookmark_frame.setFrameShape(QFrame.StyledPanel) self.bookmark_list = MTTBookmarkList() self.bookmark_list.bookmarkDeleted.connect(self.do_delete_bookmark) self.bookmark_list.setAlternatingRowColors(True) self.bookmark_list.dragEnabled() self.bookmark_list.setAcceptDrops(True) self.bookmark_list.setDropIndicatorShown(True) self.bookmark_list.setDragDropMode(QListView.InternalMove) self.bookmark_list_sel_model = self.bookmark_list.selectionModel() self.bookmark_list_sel_model.selectionChanged.connect( self.on_select_bookmark) bookmark_layout.addWidget(self.bookmark_list) bookmark_parent_layout.addWidget(bookmark_frame) bookmark_parent_layout.addLayout(content_layout) main_layout.addLayout(bookmark_parent_layout) self.do_populate_bookmarks() else: main_layout.addLayout(content_layout) if not self.defined_type: # type layout self.types = QComboBox() self.types.addItems(self.supported_node_type) self.types.currentIndexChanged.connect(self.on_node_type_changed) if cmds.optionVar(exists='MTT_lastNodeType'): last = cmds.optionVar(query='MTT_lastNodeType') if last in self.supported_node_type: self.types.setCurrentIndex( self.supported_node_type.index(last)) buttons_layout.addWidget(self.types) if not self.defined_path or not self.defined_type: create_btn = QPushButton('C&reate') create_btn.clicked.connect(self.accept) cancel_btn = QPushButton('&Cancel') cancel_btn.clicked.connect(self.reject) buttons_layout.addStretch() buttons_layout.addWidget(create_btn) buttons_layout.addWidget(cancel_btn)
def __init__(self, parent=None): """Initialize the parent class of this instance.""" super(window, self).__init__(parent) app.aboutToQuit.connect(self.myExitHandler) self.style_sheet = self.styleSheet('style') # app.setStyle(QStyleFactory.create('Macintosh')) #app.setStyleSheet(self.style_sheet) self.layout().setSpacing(0) self.layout().setContentsMargins(0,0,0,0) app.setOrganizationName("Eivind Arvesen") app.setOrganizationDomain("https://github.com/eivind88/raskolnikov") app.setApplicationName("Raskolnikov") app.setApplicationVersion("0.0.1") settings = QSettings() self.data_location = QDesktopServices.DataLocation self.temp_location = QDesktopServices.TempLocation self.cache_location = QDesktopServices.CacheLocation self.startpage = "https://duckduckgo.com/" self.new_tab_behavior = "insert" global bookmarks global saved_tabs print "Currently saved_tabs:\n", saved_tabs global menubar menubar = QMenuBar() # Initialize a statusbar for the window self.statusbar = self.statusBar() self.statusbar.setFont(QFont("Helvetica Neue", 11, QFont.Normal)) self.statusbar.setStyleSheet(self.style_sheet) self.statusbar.setMinimumHeight(15) self.pbar = QProgressBar() self.pbar.setMaximumWidth(100) self.statusbar.addPermanentWidget(self.pbar) self.statusbar.hide() self.setMinimumSize(504, 235) # self.setWindowModified(True) # app.alert(self, 0) self.setWindowTitle("Raskolnikov") # toolbar = self.addToolBar('Toolbar') # toolbar.addAction(exitAction) # self.setUnifiedTitleAndToolBarOnMac(True) self.setWindowIcon(QIcon("")) # Create input widgets self.bbutton = QPushButton(u"<") self.fbutton = QPushButton(u">") self.hbutton = QPushButton(u"⌂") self.edit = QLineEdit("") self.edit.setFont(QFont("Helvetica Neue", 12, QFont.Normal)) self.edit.setPlaceholderText("Enter URL") # self.edit.setMinimumSize(400, 24) self.rbutton = QPushButton(u"↻") self.dbutton = QPushButton(u"☆") self.tbutton = QPushButton(u"⁐") # ↆ ⇧ √ ⌘ ⏎ ⏏ ⚠ ✓ ✕ ✖ ✗ ✘ ::: ❤ ☮ ☢ ☠ ✔ ☑ ♥ ✉ ☣ ☤ ✘ ☒ ♡ ツ ☼ ☁ ❅ ✎ self.nbutton = QPushButton(u"+") self.nbutton.setObjectName("NewTab") self.nbutton.setMinimumSize(35, 30) self.nbutton.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) self.edit.setTextMargins(2, 1, 2, 0) # create a horizontal layout for the input input_layout = QHBoxLayout() input_layout.setSpacing(4) input_layout.setContentsMargins(0, 0, 0, 0) # add the input widgets to the input layout input_layout.addWidget(self.bbutton) input_layout.addWidget(self.fbutton) input_layout.addWidget(self.hbutton) input_layout.addWidget(self.edit) input_layout.addWidget(self.rbutton) input_layout.addWidget(self.dbutton) input_layout.addWidget(self.tbutton) # create a widget to hold the input layout self.input_widget = QFrame() self.input_widget.setObjectName("InputWidget") self.input_widget.setStyleSheet(self.style_sheet) # set the layout of the widget self.input_widget.setLayout(input_layout) self.input_widget.setVisible(True) # CREATE BOOKMARK-LINE HERE self.bookmarks_layout = QHBoxLayout() self.bookmarks_layout.setSpacing(0) self.bookmarks_layout.setContentsMargins(0, 0, 0, 0) for i in bookmarks: link = QToolButton() link.setDefaultAction(QAction(unicode(i), link)) link.setObjectName(unicode(i)) link.setFont(QFont("Helvetica Neue", 11, QFont.Normal)) link.clicked.connect(self.handleBookmarks) self.bookmarks_layout.addWidget(link) self.bookmarks_widget = QFrame() self.bookmarks_widget.setObjectName("BookmarkWidget") self.bookmarks_widget.setStyleSheet(self.style_sheet) self.bookmarks_widget.setLayout(self.bookmarks_layout) if not bookmarks: self.bookmarks_widget.hide() # Task list self.tasklist = QStandardItemModel() #parentItem = self.tasklist.invisibleRootItem() #self.tasklist.header().hide() self.tasklist.setHorizontalHeaderItem(0, QStandardItem('Tasks')) parentItem = QStandardItem("Parent") self.tasklist.appendRow(parentItem) for i in range(4): item = QStandardItem("Item %d" % i) parentItem.appendRow(item) #parentItem = item #self.list.activated[str].connect(self.handleBookmarks) #self.list.view().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) # create tabs self.tabs = QTabWidget() self.tabs.setDocumentMode(True) self.tabs.setTabsClosable(True) self.tabs.setMovable(True) self.tabs.tabBar().hide() self.tabs.setFont(QFont("Helvetica Neue", 11, QFont.Normal)) self.tabs.setCornerWidget(self.nbutton) self.tabs.cornerWidget().setObjectName("CornerWidget") self.tabs.cornerWidget().setMinimumSize(10, 24) self.tabs.cornerWidget().setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) if saved_tabs: for tab in saved_tabs['tabs']: tasklist = QTreeView() tasklist.hide() tasklist.setObjectName('taskList') tasklist.setMinimumWidth(100) tasklist.setMaximumWidth(250) new_tab = QWebView() new_tab.setObjectName('webView') inspector = QWebInspector(self) inspector.setObjectName('webInspector') inspector.hide() page_layout = QVBoxLayout() page_layout.setSpacing(0) page_layout.setContentsMargins(0, 0, 0, 0) page_layout.addWidget(new_tab) page_layout.addWidget(inspector) page_widget = QFrame() page_widget.setObjectName('pageWidget') page_widget.setLayout(page_layout) complete_tab_layout = QHBoxLayout() complete_tab_layout.setSpacing(0) complete_tab_layout.setContentsMargins(0, 0, 0, 0) complete_tab_layout.addWidget(tasklist) complete_tab_layout.addWidget(page_widget) complete_tab_widget = QFrame() complete_tab_widget.setLayout(complete_tab_layout) #for page in tab['history']: # new_tab.load(QUrl(page['url'])) #print tab['current_history'] #for item in new_tab.history().items(): # print item #new_tab.history().goToItem(new_tab.history().itemAt(tab['current_history'])) new_tab.load(QUrl(tab['history'][tab['current_history']]['url'])) tab['current_history'] self.tabs.setUpdatesEnabled(False) if self.new_tab_behavior == "insert": self.tabs.insertTab(self.tabs.currentIndex()+1, complete_tab_widget, unicode(new_tab.title())) elif self.new_tab_behavior == "append": self.tabs.appendTab(complete_tab_widget, unicode(new_tab.title())) self.tabs.setUpdatesEnabled(True) new_tab.titleChanged.connect(self.change_tab) new_tab.urlChanged.connect(self.change_tab) new_tab.loadStarted.connect(self.load_start) new_tab.loadFinished.connect(self.load_finish) new_tab.loadProgress.connect(self.pbar.setValue) new_tab.page().linkHovered.connect(self.linkHover) inspector.setPage(new_tab.page()) for index, tab in enumerate(saved_tabs['tabs']): self.tabs.setTabText(index, tab['history'][tab['current_history']]['title']) self.tabs.setCurrentIndex(saved_tabs['current_tab']) else: self.new_tab() tabs_layout = QVBoxLayout() tabs_layout.setSpacing(0) tabs_layout.setContentsMargins(0, 0, 0, 0) tabs_layout.addWidget(self.tabs) self.tabs_widget = QFrame() self.tabs_widget.setObjectName("TabLine") self.tabs_widget.setStyleSheet(self.style_sheet) self.tabs_widget.setLayout(tabs_layout) self.tabs_widget.setVisible(True) # Webkit settings gsettings = self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).settings().globalSettings() # Basic settings gsettings.setAttribute(QWebSettings.AutoLoadImages, True) gsettings.setAttribute(QWebSettings.JavascriptEnabled, True) gsettings.setAttribute(QWebSettings.JavascriptCanOpenWindows, False) gsettings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, False) gsettings.setAttribute(QWebSettings.PluginsEnabled, False) # Flash isn't stable at present gsettings.setAttribute(QWebSettings.JavaEnabled, False) # Java applet's aren't supported by PySide gsettings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True) # Performace settings gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True) gsettings.setAttribute(QWebSettings.AcceleratedCompositingEnabled, True) gsettings.setAttribute(QWebSettings.DnsPrefetchEnabled, True) # Other settings gsettings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False) # Create a vertical layout and add widgets vlayout = QVBoxLayout() vlayout.setSpacing(0) vlayout.setContentsMargins(0, 0, 0, 0) # toolbar.addWidget(self.input_widget) vlayout.addWidget(self.input_widget) vlayout.addWidget(self.bookmarks_widget) vlayout.addWidget(self.tabs_widget) # create a widget to hold the vertical layout wrapper_widget = QWidget() wrapper_widget.setLayout(vlayout) self.setCentralWidget(wrapper_widget) self.bbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).back) self.fbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).forward) self.hbutton.clicked.connect(self.goHome) self.edit.returnPressed.connect(self.set_url) # Add button signal to "go" slot self.rbutton.clicked.connect(self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload) self.dbutton.clicked.connect(self.bookmark) self.tbutton.clicked.connect(self.toggleTaskBar) self.nbutton.clicked.connect(self.new_tab) self.tabs.tabCloseRequested.connect(self.tabs.removeTab) self.tabs.currentChanged.connect(self.change_tab) widgets = (input_layout.itemAt(i).widget() for i in range( input_layout.count())) for widget in widgets: if isinstance(widget, QPushButton): widget.setFixedSize(33, 21) widget.setFont(QFont("Helvetica Neue", 12, QFont.Normal)) widget.pressed.connect(self.press_button) widget.released.connect(self.release_button) # make a ctrl+q quit sequence = QKeySequence(Qt.CTRL + Qt.Key_Q) QShortcut(sequence, self, SLOT("close()")) # make an accelerator to toggle fullscreen sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_F) QShortcut(sequence, self, self.toggle_fullscreen) # make an accelerator to toggle input visibility sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_L) QShortcut(sequence, self, self.toggle_input) # make an accelerator to focus adress-bar sequence = QKeySequence(Qt.CTRL + Qt.Key_L) QShortcut(sequence, self, self.focus_adress) # make an accelerator to reload page sequence = QKeySequence(Qt.CTRL + Qt.Key_R) QShortcut(sequence, self, self.tabs.currentWidget().findChild(QFrame, unicode('pageWidget')).findChild(QWebView, unicode('webView')).reload) # make an accelerator to create new tab sequence = QKeySequence(Qt.CTRL + Qt.Key_T) QShortcut(sequence, self, self.new_tab) # make an accelerator to close tab sequence = QKeySequence(Qt.CTRL + Qt.Key_W) QShortcut(sequence, self, self.close_tab) # make an accelerator to navigate tabs sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Left) QShortcut(sequence, self, self.previous_tab) sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Right) QShortcut(sequence, self, self.next_tab) # make an accelerator to toggle inspector sequence = QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_U) QShortcut(sequence, self, self.handleShowInspector) # make an accelerator to toggle bookmark sequence = QKeySequence(Qt.CTRL + Qt.Key_D) QShortcut(sequence, self, self.bookmark) # make an accelerator to toggle task/project-list sequence = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_L) QShortcut(sequence, self, self.toggleTaskBar) # finally set the attribute need to rotate # try: # self.setAttribute(Qt.WA_Maemo5AutoOrientation, True) # except: # print "not maemo" self.statusbar.show()
class ButtonContainer(QWidget): Height = 21 def __init__(self, orientation=Qt.Horizontal): """ Sets up the button container. """ super(ButtonContainer, self).__init__() self.orientation = orientation # Perform custom painting on OS X self._osx = sys.platform.startswith("darwin") self.initUI() # Keep track of the number of buttons self._buttonCount = 0 def initUI(self): """ Initializes UI. Creates a horizontal layout to which buttons can be added. """ if self._osx: # Mimic the style of buttons underneath a list view gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, self.Height) colorTop = QColor(250, 250, 250, 255) colorMid = QColor(244, 244, 244, 255) colorInBetween = QColor(238, 238, 238, 255) colorMidLow = QColor(234, 234, 234, 255) colorLow = QColor(239, 239, 239, 255) gradient.setColorAt(0, colorTop) gradient.setColorAt(0.45, colorMid) gradient.setColorAt(0.5, colorInBetween) gradient.setColorAt(0.55, colorMidLow) gradient.setColorAt(1, colorLow) brush = QBrush(gradient) palette = QPalette() palette.setBrush(QPalette.Background, brush) self.setAutoFillBackground(True) self.setPalette(palette) # Use a horizontal layout in which to keep # buttons. Initialize with an empty QWidget to # make the buttons align to the left if self.orientation == Qt.Horizontal: self.layout = QHBoxLayout() else: self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(QWidget()) self.setLayout(self.layout) # Public methods def addButton(self, button): """ Adds a button to the container. The button is styled and resized to fit in the container widget. Assumes that the button has no name and has an icon (preferably in the right size) :type button: QPushButton """ # Make sure that the button won't disturb the layout button.setMaximumHeight(ButtonContainer.Height) button.setMaximumWidth(ButtonContainer.Height) button.setFlat(True) # Insert button into the horizontal layout. Make sure # that the empty QWidget stays on the right self.layout.insertWidget(self._buttonCount, button) self._buttonCount += 1 # Overwritten from QWidget def paintEvent(self, ev): if not self._osx: return size = self.size() height = size.height() - 1 width = size.width() - 1 painter = QPainter(self) painter.setPen(QColor(165, 165, 165, 255)) painter.drawLine(QPoint(0, 0), QPoint(0, height)) painter.drawLine(QPoint(0, height), QPoint(width, height)) painter.drawLine(QPoint(width, height), QPoint(width, 0)) for index in range(self._buttonCount): xCoord = (index + 1) * 21 - 1 painter.drawLine(QPoint(xCoord, 0), QPoint(xCoord, height)) def sizeOfButtons(self): return self._buttonCount * ButtonContainer.Height def sizeOfContainer(self): if self._buttonCount == 0: return 0 return ButtonContainer.Height def maximumWidth(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return 0 else: return self.sizeOfContainer() def minimumWidth(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfButtons() else: return self.sizeOfContainer() def maximumHeight(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfContainer() else: return 0 def minimumHeight(self): """ :rtype: int """ if self.orientation == Qt.Horizontal: return self.sizeOfContainer() else: return self.sizeOfButtons() def sizeHint(self): """ :rtype: QtCore.QSize """ width = 150 height = ButtonContainer.Height if self._buttonCount == 0: height = 0 if self.orientation == Qt.Horizontal: sizeHint = QtCore.QSize(width, height) else: sizeHint = QtCore.QSize(height, width) return sizeHint
def __init__(self, *args, **kwargs ): super(Widget_target, self).__init__(*args, **kwargs ) mainLayout = QVBoxLayout( self ); mainLayout.setContentsMargins( 10,0,10,0 ); mainLayout.setSpacing(0) w_loadObject = Widget_loadObject( title="Target" ) listWidget = QListWidget() mainLayout.addWidget( w_loadObject ) mainLayout.addWidget( listWidget ) self.w_loadObject = w_loadObject self.listWidget = listWidget w_loadObject.button.clicked.connect( self.load_textures )
def __init__(self, parent=None): """ Default class constructor. :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ super(CmdPrompt, self).__init__(parent) qDebug("CmdPrompt Constructor") self.setObjectName("Command Prompt") self.promptInput = promptInput = CmdPromptInput(self) self.promptHistory = promptHistory = CmdPromptHistory() self.promptDivider = QFrame(self) promptVBoxLayout = QVBoxLayout(self) self.promptSplitter = CmdPromptSplitter(self) self.setFocusProxy(promptInput) self.promptHistory.setFocusProxy(promptInput) self.promptDivider.setLineWidth(1) self.promptDivider.setFrameStyle(QFrame.HLine) self.promptDivider.setMaximumSize(self.QWIDGETSIZE_MAX(), 1) promptVBoxLayout.addWidget(self.promptSplitter) promptVBoxLayout.addWidget(self.promptHistory) promptVBoxLayout.addWidget(self.promptDivider) promptVBoxLayout.addWidget(promptInput) promptVBoxLayout.setSpacing(0) promptVBoxLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(promptVBoxLayout) self.styleHash = {} # QHash<QString, QString>() self.styleHash["color"] = "#000000" # Match -------| self.styleHash["background-color"] = "#FFFFFF" # | self.styleHash["selection-color"] = "#FFFFFF" # | self.styleHash["selection-background-color"] = "#000000" # Match -------| self.styleHash["font-family"] = "Monospace" self.styleHash["font-style"] = "normal" self.styleHash["font-size"] = "12px" self.updateStyle() self.blinkState = False self.blinkTimer = QTimer(self) self.blinkTimer.timeout.connect(self.blink) self.show() self.connect(promptInput, SIGNAL("stopBlinking()"), self, SLOT("stopBlinking()")) self.connect(promptInput, SIGNAL("appendHistory(QString, int)"), promptHistory, SLOT("appendHistory(const QString&, int)")) self.connect(self, SIGNAL("appendTheHistory(QString, int)"), promptHistory, SLOT("appendHistory(const QString&, int)")) # For use outside of command prompt self.connect(promptInput, SIGNAL("startCommand(QString)"), self, SIGNAL("startCommand(QString)")) self.connect(promptInput, SIGNAL("runCommand(QString, QString)"), self, SIGNAL("runCommand(QString, QString)")) self.connect(promptInput, SIGNAL("deletePressed()"), self, SIGNAL("deletePressed()")) self.connect(promptInput, SIGNAL("tabPressed()"), self, SIGNAL("tabPressed()")) self.connect(promptInput, SIGNAL("escapePressed()"), self, SIGNAL("escapePressed()")) self.connect(promptInput, SIGNAL("upPressed()"), self, SIGNAL("upPressed()")) self.connect(promptInput, SIGNAL("downPressed()"), self, SIGNAL("downPressed()")) self.connect(promptInput, SIGNAL("F1Pressed()"), self, SIGNAL("F1Pressed()")) self.connect(promptInput, SIGNAL("F2Pressed()"), self, SIGNAL("F2Pressed()")) self.connect(promptInput, SIGNAL("F3Pressed()"), self, SIGNAL("F3Pressed()")) self.connect(promptInput, SIGNAL("F4Pressed()"), self, SIGNAL("F4Pressed()")) self.connect(promptInput, SIGNAL("F5Pressed()"), self, SIGNAL("F5Pressed()")) self.connect(promptInput, SIGNAL("F6Pressed()"), self, SIGNAL("F6Pressed()")) self.connect(promptInput, SIGNAL("F7Pressed()"), self, SIGNAL("F7Pressed()")) self.connect(promptInput, SIGNAL("F8Pressed()"), self, SIGNAL("F8Pressed()")) self.connect(promptInput, SIGNAL("F9Pressed()"), self, SIGNAL("F9Pressed()")) self.connect(promptInput, SIGNAL("F10Pressed()"), self, SIGNAL("F10Pressed()")) self.connect(promptInput, SIGNAL("F11Pressed()"), self, SIGNAL("F11Pressed()")) self.connect(promptInput, SIGNAL("F12Pressed()"), self, SIGNAL("F12Pressed()")) self.connect(promptInput, SIGNAL("cutPressed()"), self, SIGNAL("cutPressed()")) self.connect(promptInput, SIGNAL("copyPressed()"), self, SIGNAL("copyPressed()")) self.connect(promptInput, SIGNAL("pastePressed()"), self, SIGNAL("pastePressed()")) self.connect(promptInput, SIGNAL("selectAllPressed()"), self, SIGNAL("selectAllPressed()")) self.connect(promptInput, SIGNAL("undoPressed()"), self, SIGNAL("undoPressed()")) self.connect(promptInput, SIGNAL("redoPressed()"), self, SIGNAL("redoPressed()")) self.connect(promptInput, SIGNAL("shiftPressed()"), self, SIGNAL("shiftPressed()")) self.connect(promptInput, SIGNAL("shiftReleased()"), self, SIGNAL("shiftReleased()")) self.connect(promptHistory, SIGNAL("historyAppended(QString)"), self, SIGNAL("historyAppended(QString)"))
toolButtonLeft1 = CreateFlatButton(QAction(icon, "Left", mainWindow)) toolButtonLeft2 = CreateFlatButton(QAction(icon, "2nd left", mainWindow)) toolButtonRight = CreateFlatButton(QAction(icon, "Right", mainWindow)) toolButtonCenter = QPushButton() toolButtonCenter.setIcon(QIcon(basePath + "LandmarkTransformButton.png")) toolButtonCenter.setText("Center") toolButtonCenter.setMinimumWidth(200) barWidget = ToolbarWidget() barWidget.addLeftItem(toolButtonLeft1) barWidget.addLeftItem(toolButtonLeft2) barWidget.addCenterItem(toolButtonCenter) barWidget.addRightItem(toolButtonRight) toolbar.addWidget(barWidget) layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) layout.addWidget(QLabel("Test toolbar widget")) widget = QWidget() widget.setLayout(layout) mainWindow.setCentralWidget(widget) mainWindow.setGeometry(100, 100, 500, 300) mainWindow.show() app.exec_()