def __init__(self,title,parent,right_layout=None): super(SubTitleWidget,self).__init__(parent) self.title = QLabel() self.title.setObjectName("subtitle") self.title.setScaledContents(True) self.set_title(title) hlayout = QHBoxLayout() hlayout.setAlignment(Qt.AlignTop) # hlayout.addWidget(TitleBox(self)) hlayout.addWidget(self.title) hlayout.addStretch() if right_layout: if isinstance(right_layout,QLayout): hlayout.addLayout(right_layout) else: hlayout.addWidget(right_layout) # hlayout.setStretch(1,1) top_layout = QVBoxLayout() top_layout.addLayout(hlayout) top_layout.addSpacing(10) top_layout.setContentsMargins(0,0,0,0) self.setLayout(top_layout) self.setContentsMargins(0,0,0,0)
def __init__(self, table_prototype, parent): super(QuickPrototypedFilter, self).__init__(parent) self.list_model = PrototypedModelView(table_prototype, self) self.list_model_filtered = FilteringModel(self) self.list_model_filtered.setSourceModel(self.list_model) self.line_in = FilterLineEdit() self.line_in.key_down.connect(self._focus_on_list) self.line_in.textChanged.connect(self._filter_changed) self.list_view = PrototypedQuickView(table_prototype, self) self.list_view.setTabKeyNavigation(False) self.list_view.horizontalHeader().hide() self.list_view.verticalHeader().hide() self.list_view.horizontalHeader().setStretchLastSection(True) self.list_view.setModel(self.list_model_filtered) vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addWidget(self.line_in) vlayout.addWidget(self.list_view) self.setLayout(vlayout) self.list_view.selectionModel().currentChanged.connect( self._selected_item_changed) # FIXME Clear ownership issue self.last_selected_object = None self.line_in.setFocus() QWidget.setTabOrder(self.line_in, self.list_view)
def setupUI(self): # self.bttnAddEmployee.setMinimumSize(100, 30) # self.bttnCancel.setMinimumSize(100, 30) # self.id.setMaximumWidth(800) # self.name.setMaximumWidth(800) # self.designation.setMaximumWidth(800) # self.originalPay.setMaximumWidth(800) # self.originalPayGrade.setMaximumWidth(800) # self.DOJ.setMaximumWidth(800) # self.pan.setMaximumWidth(800) layout = QVBoxLayout() layout.setContentsMargins(20, 20, 20, 10) form = QFormLayout() form.setSpacing(20) form.addRow(QLabel("ID No."), self.id) form.addRow(QLabel("Name"), self.name) form.addRow(QLabel("Designation"), self.designation) form.addRow(QLabel("Original Pay"), self.originalPay) form.addRow(QLabel("Original Pay Grade"), self.originalPayGrade) form.addRow(QLabel("Date of joining"), self.DOJ) form.addRow(QLabel("Pan No."), self.pan) layout.addLayout(form) layout.addStretch() bttnLayout = QHBoxLayout() bttnLayout.addStretch() bttnLayout.addWidget(self.bttnCancel) bttnLayout.addWidget(self.bttnAddEmployee) layout.addLayout(bttnLayout) self.setLayout(layout)
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 setupUI(self): """Arranges GUI elements inside the widget properly""" layout = QVBoxLayout() layout.setContentsMargins(20, 20, 20, 10) form = QFormLayout() form.setSpacing(20) form.addRow(QLabel("Deignation"), self.designation) form.addRow(QLabel("Dearness Allowance"), self.da) form.addRow(QLabel("House Rent Allowance"), self.hra) form.addRow(QLabel("Transport Allowance"), self.ta) form.addRow(QLabel("Income Tax"), self.it) form.addRow(QLabel("Professional Tax"), self.pt) layout.addLayout(form) layout.addStretch() bttnLayout = QHBoxLayout() bttnLayout.addStretch() bttnLayout.addWidget(self.bttnCancel) bttnLayout.addWidget(self.bttnAddDesignation) layout.addLayout(bttnLayout) self.setLayout(layout)
def addTab(self, label ): layoutWidget = QWidget() vLayout = QVBoxLayout(layoutWidget) vLayout.setContentsMargins(5,5,5,5) setFolderLayout = QHBoxLayout() listWidget = QListWidget() listWidget.setSelectionMode( QAbstractItemView.ExtendedSelection ) vLayout.addLayout( setFolderLayout ) vLayout.addWidget( listWidget ) lineEdit = QLineEdit() setFolderButton = QPushButton( 'Set Folder' ) setFolderLayout.addWidget( lineEdit ) setFolderLayout.addWidget( setFolderButton ) QtCore.QObject.connect( setFolderButton, QtCore.SIGNAL( 'clicked()' ), Functions.setFolder ) QtCore.QObject.connect( listWidget, QtCore.SIGNAL( 'itemSelectionChanged()' ), Functions.loadImagePathArea ) QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged()' ), Functions.lineEdited ) listWidget.setObjectName( Window_global.listWidgetObjectName ) lineEdit.setContextMenuPolicy( QtCore.Qt.NoContextMenu ) lineEdit.setObjectName( Window_global.lineEditObjectName ) lineEdit.returnPressed.connect( Functions.lineEdited ) super( Tab, self ).addTab( layoutWidget, label )
def _init_widgets(self): layout = QVBoxLayout() # address lbl_addr = QLabel() lbl_addr.setText("Address") txt_addr = QLineEdit() txt_addr.returnPressed.connect(self._on_address_entered) self._txt_addr = txt_addr top_layout = QHBoxLayout() top_layout.addWidget(lbl_addr) top_layout.addWidget(txt_addr) self._view = QMemoryView(self.workspace) area = QScrollArea() self._scrollarea = area area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) area.setWidgetResizable(True) area.setWidget(self._view) layout.addLayout(top_layout) layout.addWidget(area) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self, parent=None): ''' Constructor ''' QDialog.__init__(self, parent) self._ui = Ui_CreditsDialog() self._ui.setupUi(self) creditsTab = QTabWidget() creditSections = info.CREDITS.keys() for creditSection in creditSections: creditTab = QWidget() creditsTab.addTab(creditTab, creditSection) vbox = QVBoxLayout(creditTab) creditList = "" for person in info.CREDITS[creditSection]: creditList += ("\n%s [%s]" % (person['name'], person['email'])) creditLabel = QLabel() creditLabel.setStyleSheet("QLabel { background-color : white}") creditLabel.setText(creditList) creditLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft) vbox.addWidget(creditLabel) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(creditsTab) self._ui.frame_CreditsTab.setLayout(vbox)
def __init__(self): QWidget.__init__(self) self.title = "报告" self.__path = None self.__service = ReportDetService() # report view self.__wid_display = QWebView() # buttons _wid_buttons = ViewButtons( [dict(id="refresh", name=u'更新'), dict(id="export", name=u'导出')]) _wid_buttons.align_back() # main layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) _layout.setContentsMargins(0, 0, 0, 0)
def addTab(self, label): layoutWidget = QWidget() vLayout = QVBoxLayout(layoutWidget) vLayout.setContentsMargins(5, 5, 5, 5) setFolderLayout = QHBoxLayout() listWidget = QListWidget() listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) vLayout.addLayout(setFolderLayout) vLayout.addWidget(listWidget) lineEdit = QLineEdit() setFolderButton = QPushButton('Set Folder') setFolderLayout.addWidget(lineEdit) setFolderLayout.addWidget(setFolderButton) QtCore.QObject.connect(setFolderButton, QtCore.SIGNAL('clicked()'), Functions.setFolder) QtCore.QObject.connect(listWidget, QtCore.SIGNAL('itemSelectionChanged()'), Functions.loadImagePathArea) QtCore.QObject.connect(lineEdit, QtCore.SIGNAL('textChanged()'), Functions.lineEdited) listWidget.setObjectName(Window_global.listWidgetObjectName) lineEdit.setContextMenuPolicy(QtCore.Qt.NoContextMenu) lineEdit.setObjectName(Window_global.lineEditObjectName) lineEdit.returnPressed.connect(Functions.lineEdited) super(Tab, self).addTab(layoutWidget, label)
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, title, *args, **kwargs ): QWidget.__init__( self, *args ) self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_loadJoints_%s.txt" % title sgCmds.makeFile( self.infoPath ) layout = QVBoxLayout( self ); layout.setContentsMargins(0,0,0,0) groupBox = QGroupBox( title ) layout.addWidget( groupBox ) baseLayout = QVBoxLayout() groupBox.setLayout( baseLayout ) listWidget = QListWidget() hl_buttons = QHBoxLayout(); hl_buttons.setSpacing( 5 ) b_addSelected = QPushButton( "Add Selected" ) b_clear = QPushButton( "Clear" ) hl_buttons.addWidget( b_addSelected ) hl_buttons.addWidget( b_clear ) baseLayout.addWidget( listWidget ) baseLayout.addLayout( hl_buttons ) self.listWidget = listWidget QtCore.QObject.connect( listWidget, QtCore.SIGNAL( "itemClicked(QListWidgetItem*)" ), self.selectJointFromItem ) QtCore.QObject.connect( b_addSelected, QtCore.SIGNAL("clicked()"), self.addSelected ) QtCore.QObject.connect( b_clear, QtCore.SIGNAL( "clicked()" ), self.clearSelected ) self.otherWidget = None self.loadInfo()
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
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)
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, 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 TooltipPositioningWithArrow(TooltipPositioning): ARROW_MARGIN = 7 ARROW_SIZE = 11 ARROW_ODD_SIZE = 15 def _getTopOrBottomArrow(self, alignment, tooltip, main_window): arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).x() - alignment + \ tooltip.hoveredWidget().width() / 2 - self.ARROW_ODD_SIZE / 2 if arrow_alignment > tooltip.widget().width(): arrow_alignment = tooltip.widget().width() - self.ARROW_ODD_SIZE self._arrow = QWidget() self._arrow.setLayout(self._getTopOrBottomArrowLayout(arrow_alignment)) self._label_arrow = QLabel() self._label_arrow.setStyleSheet( self._getArrowStylesheet(tooltip.color())) self._label_arrow.setFixedWidth(self.ARROW_ODD_SIZE) self._label_arrow.setFixedHeight(self.ARROW_SIZE) self._arrow.layout().addWidget(self._label_arrow) return self._arrow def _getTopOrBottomArrowLayout(self, arrow_alignment): self._arrow_layout = QHBoxLayout() self._arrow_layout.setAlignment(Qt.AlignLeft) self._arrow_layout.setContentsMargins(arrow_alignment, 0, 0, 0) return self._arrow_layout def _getLeftOrRightArrow(self, alignment, tooltip, main_window): arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).y() \ - alignment + tooltip.hoveredWidget().height() / 2 - self.ARROW_ODD_SIZE / 2 if arrow_alignment > tooltip.widget().height(): arrow_alignment = tooltip.widget().height() - self.ARROW_ODD_SIZE self._arrow = QWidget() self._arrow.setLayout(self._getLeftOrRightArrowLayout(arrow_alignment)) self._label_arrow = QLabel() self._label_arrow.setStyleSheet( self._getArrowStylesheet(tooltip.color())) self._label_arrow.setFixedWidth(self.ARROW_SIZE) self._label_arrow.setFixedHeight(self.ARROW_ODD_SIZE) self._arrow.layout().addWidget(self._label_arrow) return self._arrow def _getLeftOrRightArrowLayout(self, arrow_alignment): self._arrow_layout = QVBoxLayout() self._arrow_layout.setAlignment(Qt.AlignTop) self._arrow_layout.setContentsMargins(0, arrow_alignment, 0, 0) return self._arrow_layout def _getArrowStylesheet(self, color="rgb(255, 255, 255)"): raise NotImplementedError("Subclass responsibility") def showTooltip(self, tooltip, align, main_window): raise NotImplementedError("Subclass responsibility")
def __init__(self, mainWindow): super(FolderBrowser, self).__init__() self.mainWindow = mainWindow self.config = fileUtils.loadConfig() self.movieFiles = [] mainlayout = QVBoxLayout(self) mainlayout.setContentsMargins(0, 0, 0, 0) buttonlayout = QHBoxLayout() buttonlayout.setAlignment(Qt.AlignLeft) buttonlayout.setContentsMargins(0, 0, 0, 0) mainlayout.addLayout(buttonlayout) addFolderBtn = customWidgets.IconButton( fileUtils.getIcon("addFolder.png"), "Add Folder", size=40) removeFolderBtn = customWidgets.IconButton( fileUtils.getIcon("removeFolder.png"), "Remove Folder", size=40) addFolderBtn.clicked.connect(self.addFolderAction) removeFolderBtn.clicked.connect(self.removeFolderAction) buttonlayout.addWidget(addFolderBtn) buttonlayout.addWidget(removeFolderBtn) self.folderList = FolderList(self) if "folders" in self.config: self.folderList.refresh() mainlayout.addWidget(self.folderList) self.folderList.itemClicked.connect(self.getFiles)
def __init__(self, parent, chart, caption=""): super(ChartWidget, self).__init__(parent) self.setStyleSheet("background:black") l = QVBoxLayout() l.setContentsMargins(0, 0, 0, 0) self.chart = chart self.chart.set_title(caption) self.value_label = QLabel(caption) # self.setSizePolicy(QSizePolicy(QSizePolicy.Policy.MinimumExpanding,QSizePolicy.Policy.MinimumExpanding)) # self.chart.setMinimumSize(QSize(100,50)) # self.chart.setSizePolicy(QSizePolicy(QSizePolicy.Policy.MinimumExpanding,QSizePolicy.Policy.MinimumExpanding)) # self.chart.setFrameStyle(QFrame.Box | QFrame.Raised) self.chart.setMouseTracking(True) h = QHBoxLayout() h.addWidget(self.chart) l.addLayout(h) # l.addWidget( self.value_label,0,Qt.AlignHCenter) self.setLayout(l) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
def __init__(self): QWidget.__init__(self) self.title = u"执行" # View RunDef self.__wid_run_def = ViewRunDef() # View ReportDet self.__wid_report_det = ViewReportDet() # Search condition widget self.__wid_search_cond = ViewSearch(def_view_run_def) self.__wid_search_cond.create() # 底部 layout _layout_bottom = QSplitter() _layout_bottom.addWidget(self.__wid_run_def) _layout_bottom.addWidget(self.__wid_report_det) # main layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_layout_bottom) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) self.__wid_run_def.sig_search.connect(self.search) self.__wid_run_def.sig_selected.connect( self.__wid_report_det.usr_refresh)
def __init__(self, *args, **kwargs ): QWidget.__init__( self, *args ) title = "" if kwargs.has_key( 'title' ): title = kwargs['title'] self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_LoadVertex_%s.txt" % title sgCmds.makeFile( self.infoPath ) vLayout = QVBoxLayout( self ); vLayout.setContentsMargins(0,0,0,0) groupBox = QGroupBox( title ) groupBox.setAlignment( QtCore.Qt.AlignCenter ) vLayout.addWidget( groupBox ) hLayout = QHBoxLayout() lineEdit = QLineEdit() button = QPushButton("Load"); button.setFixedWidth( 50 ) hLayout.addWidget( lineEdit ) hLayout.addWidget( button ) groupBox.setLayout( hLayout ) self.lineEdit = lineEdit QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.loadVertex ) self.loadInfo()
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, parameter, parent=None): _ParameterWidget.__init__(self, parameter, parent) # Variables model = _LayerModel() self._material_class = Material # Actions act_add = QAction(getIcon("list-add"), "Add layer", self) act_remove = QAction(getIcon("list-remove"), "Remove layer", self) act_clean = QAction(getIcon('edit-clear'), "Clear", self) # Widgets self._cb_unit = UnitComboBox('m') self._cb_unit.setUnit('um') self._tbl_layers = QTableView() self._tbl_layers.setModel(model) self._tbl_layers.setItemDelegate(_LayerDelegate()) header = self._tbl_layers.horizontalHeader() header.setResizeMode(QHeaderView.Stretch) header.setStyleSheet('color: blue') self._tlb_layers = QToolBar() spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._tlb_layers.addWidget(spacer) self._tlb_layers.addAction(act_add) self._tlb_layers.addAction(act_remove) self._tlb_layers.addAction(act_clean) # Layouts layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) sublayout = QHBoxLayout() sublayout.addStretch() sublayout.addWidget(QLabel('Thickness unit')) sublayout.addWidget(self._cb_unit) layout.addLayout(sublayout) layout.addWidget(self._tbl_layers) layout.addWidget(self._tlb_layers) self.setLayout(layout) # Signals self.valuesChanged.connect(self._onChanged) self.validationRequested.connect(self._onChanged) act_add.triggered.connect(self._onAdd) act_remove.triggered.connect(self._onRemove) act_clean.triggered.connect(self._onClear) self._tbl_layers.doubleClicked.connect(self._onDoubleClicked) model.dataChanged.connect(self.valuesChanged) model.rowsInserted.connect(self.valuesChanged) model.rowsRemoved.connect(self.valuesChanged) self.validationRequested.emit()
def setupUI(self): layout = QVBoxLayout() layout.setContentsMargins(20, 20, 20, 10) selectGroup = QGroupBox("Select") form1 = QFormLayout() form1.addRow(QLabel("Name"), self.nameSearch) form1.addRow(QLabel("ID No."), self.id) selectGroup.setLayout(form1) editGroup = QGroupBox("Edit below") form = QFormLayout() form.setSpacing(20) form.addRow(QLabel("Name"), self.nameEdit) form.addRow(QLabel("Designation"), self.designation) form.addRow(QLabel("Original Pay"), self.originalPay) form.addRow(QLabel("Original Pay Grade"), self.originalPayGrade) form.addRow(QLabel("Date of joining"), self.DOJ) form.addRow(QLabel("Pan No."), self.pan) editGroup.setLayout(form) layout.addWidget(selectGroup) layout.addWidget(editGroup) layout.addStretch() bttnLayout = QHBoxLayout() bttnLayout.addStretch() bttnLayout.addWidget(self.bttnCancel) bttnLayout.addWidget(self.bttnSave) layout.addLayout(bttnLayout) self.setLayout(layout)
def __init__(self): super(FolderBrowser, self).__init__() self.setMaximumWidth(300) mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(mainLayout) self.browser = BrowserView() mainLayout.addWidget(self.browser) buttonLayout = QHBoxLayout() mainLayout.addLayout(buttonLayout) addFolder_btnn = QPushButton("Add Folder") addFolder_btnn.clicked.connect(self.addFolder) removeFolder_bttn = QPushButton("Remove Folder") removeFolder_bttn.clicked.connect(self.removeFolder) buttonLayout.addWidget(addFolder_btnn) buttonLayout.addWidget(removeFolder_bttn) # Load config file self.config = fileUtils.load_config() self.browser.refreshView(self.config)
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)
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__(self, folderBrowser): super(MovieList, self).__init__() mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(mainLayout) filterLayout = QHBoxLayout() mainLayout.addLayout(filterLayout) self.setWatchedButton = customWidgets.IconButton( "icon_watchList.png", "Set as watched") filterLayout.addWidget(self.setWatchedButton) self.setHideWatchedButton = customWidgets.IconButton( "filter_icon.png", "Set as watched") filterLayout.addWidget(self.setHideWatchedButton) self.filterField = QLineEdit() self.filterField.setObjectName("filterField") filterLayout.addWidget(self.filterField) self.movieList = MovieBrowser(folderBrowser) mainLayout.addWidget(self.movieList) self.progressBar = customWidgets.MyProgress() mainLayout.addWidget(self.progressBar) self.progressBar.setVisible(True) self.setWatchedButton.clicked.connect(self.movieList.setWatched) self.setHideWatchedButton.clicked.connect(self.movieList.hideWatched)
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_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 setupUI(self): layout = QVBoxLayout() layout.setContentsMargins(20, 20, 20, 10) datelayout = QHBoxLayout() datelayout.addWidget(QLabel("Salary for month of ")) datelayout.addWidget(self.month) datelayout.addWidget(self.year) datelayout.addStretch() layout.addLayout(datelayout) form = QFormLayout() form.setSpacing(10) form.addRow(QLabel("Name"), self.name) form.addRow(QLabel("ID No."), self.id) form.addRow(QLabel("Designation"), self.designation) form.addRow(QLabel("Original Pay"), self.originalPay) form.addRow(QLabel("Original Pay Grade"), self.originalPayGrade) form.addRow(QLabel("Date of joining"), self.DOJ) form.addRow(QLabel("Pan No."), self.pan) infoGroup = QGroupBox("Basic Info") infoGroup.setLayout(form) layout.addWidget(infoGroup) leftForm = QFormLayout() leftForm.addRow(QLabel("Dearness Allowance"), self.da_percent) leftForm.addRow(QLabel("Housing Rent Allowance"), self.hra_percent) leftForm.addRow(QLabel("Transport Allowance"), self.ta_percent) leftGroup = QGroupBox("Allowances") leftGroup.setLayout(leftForm) rightForm = QFormLayout() rightForm.addRow(QLabel("Income Tax"), self.it_percent) rightForm.addRow(QLabel("Profession Tax"), self.pt_percent) rightGroup = QGroupBox("Deductions") rightGroup.setLayout(rightForm) table = QHBoxLayout() table.addWidget(leftGroup) table.addWidget(rightGroup) layout.addLayout(table) layout.addStretch() bttnLayout = QHBoxLayout() bttnLayout.addStretch() bttnLayout.addWidget(self.bttnCancel) bttnLayout.addWidget(self.bttnCalculate) layout.addLayout(bttnLayout) self.setLayout(layout)
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))
def __init__(self, parent): super(FormPage, self).__init__(parent) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) formframe = QGroupBox(self) self.vbox = QVBoxLayout(formframe) self.form = PropertyFormLayout() self.vbox.addLayout(self.form) self.vbox.addStretch(1) self._has_stretch = True layout.addWidget(formframe)
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 __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 _init_widgets(self): self._flow_graph = QDisasmGraph(self.workspace, self) self._statusbar = QDisasmStatusBar(self, parent=self) hlayout = QVBoxLayout() hlayout.addWidget(self._flow_graph) hlayout.addWidget(self._statusbar) hlayout.setContentsMargins(0, 0, 0, 0) self.setLayout(hlayout)
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())
def __init__(self, parent=None): QWidget.__init__(self, parent) # Layouts layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addLayout(self._initUI()) # Initialize widgets layout.addStretch() self.setLayout(layout) # Signals for widget in self._iter_parameter_widgets(): widget.valuesChanged.connect(self.valueChanged)
def __init__(self, *args, **kwargs ): QWidget.__init__( self, *args, **kwargs ) mainLayout = QVBoxLayout( self ) mainLayout.setContentsMargins(0,0,0,0) listWidget = QListWidget() loadButton = QPushButton( "Load Constrain Targets" ) mainLayout.addWidget( listWidget ) mainLayout.addWidget( loadButton ) self.listWidget = listWidget self.loadButton = loadButton QtCore.QObject.connect( self.loadButton, QtCore.SIGNAL( 'clicked()' ), self.loadConstrainTargets )
def _init_widgets(self): tab = QTabWidget() self._init_pathgroups_tab(tab) self._init_settings_tab(tab) self._init_avoids_tab(tab) layout = QVBoxLayout() layout.addWidget(tab) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def create_frame(self, parent, style, title=""): """ Returns an adapted top-level window frame/dialog control. The *style* parameter is a set containing values from the following list: - 'frame': The result should be a normal top-level window. - 'dialog': The result should be a dialog window. - 'resizable': The window should have a resize border. - 'simple': The window should have a simple border. - 'none': The window should not have any border. - 'min_max': The window should have minimize/maximize buttons. - 'float': The window should float on top of its parent. - 'no_taskbar': The window should not appear on the system taskbar. """ layout = QVBoxLayout() if "frame" in style: flags = Qt.Window else: flags = Qt.WindowSystemMenuHint if "min_max" in style: flags |= Qt.WindowMinMaxButtonsHint if "resizable" in style: flags |= Qt.WindowMinMaxButtonsHint elif "simple" in style: flags = Qt.Popup elif "none" in style: flags = Qt.FramelessWindowHint if "float" in style: flags |= Qt.WindowStaysOnTopHint klass = MainWindow is_dialog = "dialog" in style if is_dialog: klass = Dialog control = klass(check_parent(parent), flags) control.setWindowTitle(title) # Create the main window so we can add toolbars etc: if is_dialog: control._mw = QMainWindow() layout.addWidget(control._mw) control.setLayout(layout) layout.setContentsMargins(4, 0, 4, 0) control.setMouseTracking(True) return control_adapter_for(control)
def __init__(self, fig): QDialog.__init__(self) self.canvas = FigureCanvas(fig) p = self.palette() p.setColor(self.backgroundRole(), QtCore.Qt.white) self.setPalette(p) lo = QVBoxLayout() lo.setContentsMargins(0, 0, 0, 0) self.setLayout(lo) # mynav = NavigationToolbar(self.canvas, self) mynav = MyNavToolbar(self.canvas, self) lo.addWidget(mynav) # qmy_button(lo, self.do_copy, "copy") lo.addWidget(self.canvas)
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 setupUI(self): paneLayout = QHBoxLayout() paneLayout.setContentsMargins(0, 0, 0, 0) leftPane = QFrame() leftPane.setObjectName("leftPane") leftPaneLayout = QVBoxLayout() leftPaneLayout.setContentsMargins(20, 20, 20, 10) heading = QLabel("Select Employee: ") heading.setObjectName("heading") leftPaneLayout.addWidget(heading) leftPaneLayout.addSpacing(10) form1 = QFormLayout() form1.addRow(QLabel("Name"), self.nameSearch) form1.addRow(QLabel("ID No."), self.id) leftPaneLayout.addLayout(form1) leftPaneLayout.addStretch() leftPane.setLayout(leftPaneLayout) layout = QVBoxLayout() layout.setContentsMargins(20, 20, 20, 10) editGroup = QGroupBox("Edit below") form = QFormLayout() form.setContentsMargins(10, 10, 10, 30) form.setSpacing(20) form.addRow(QLabel("Name"), self.nameEdit) form.addRow(QLabel("Designation"), self.designation) form.addRow(QLabel("Original Pay"), self.originalPay) form.addRow(QLabel("Original Pay Grade"), self.originalPayGrade) form.addRow(QLabel("Date of joining"), self.DOJ) form.addRow(QLabel("Pan No."), self.pan) editGroup.setLayout(form) layout.addWidget(editGroup) layout.addStretch() bttnLayout = QHBoxLayout() bttnLayout.addStretch() bttnLayout.addWidget(self.bttnCancel) bttnLayout.addWidget(self.bttnSave) layout.addLayout(bttnLayout) paneLayout.addWidget(leftPane) paneLayout.addLayout(layout) self.setLayout(paneLayout)
def create_lineedit(self, text, option, default=NoDefault, tip=None, alignment=Qt.Horizontal): label = QLabel(text) label.setWordWrap(True) edit = QLineEdit() layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout() layout.addWidget(label) layout.addWidget(edit) layout.setContentsMargins(0, 0, 0, 0) if tip: edit.setToolTip(tip) self.lineedits[option] = edit widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, record_id, parent=None): super(BookEditForm, self).__init__(parent) self.setupUi(self) # had to subclass this spinbox to support return grabbing self.edYear = ReturnKeySpinBox(self) self.edYearHolder.addWidget(self.edYear) # configuring id's for radio group self.radioAvailability.setId(self.rdSell,0) self.radioAvailability.setId(self.rdRent,1) self.radioAvailability.setId(self.rdInactive,2) # overlaying a clean button over the image (couldn't do it in designer) self.btnCleanImage = QPushButton() self.btnCleanImage.setIcon(QIcon(":icons/clean.png")) self.btnCleanImage.setFixedWidth(35) self.btnCleanImage.clicked.connect(self.clear_image) self.btnCleanImage.setVisible(False) clean_img_layout = QVBoxLayout(self.edImage) clean_img_layout.addWidget(self.btnCleanImage) clean_img_layout.setAlignment(Qt.AlignTop | Qt.AlignLeft) clean_img_layout.setContentsMargins(2,2,0,0) self._access = statics.access_level # for currency formatting self._locale = QLocale() self._record_id = record_id # had to hardcode these, wouldn't work otherwise: self.contentsLayout.setAlignment(self.groupBox, QtCore.Qt.AlignTop) self.contentsLayout.setAlignment(self.groupBox_2, QtCore.Qt.AlignTop) self.log = logging.getLogger('BookEditForm') self._subject_list = [] self._removed_subjects = [] self._added_subjects = [] self.setup_model() self.fill_form() self.setup_fields() self._old_data = self.extract_input(text_only=True) # flag to indicate whether there were changes to the fields self._dirty = False # user did input an image self._image_set = False # image changed during edit self._image_changed = False
def __init__(self): QWidget.__init__(self) self.title = u"窗口" # Current window id self.__window_id = None # Model self.__model = WindowModel() self.__model.usr_set_definition(def_view_window_def) # Control _control = WindowControl(def_view_window_def) # Data result display window _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Search condition self.__wid_search_cond = ViewSearch(def_view_window_def) self.__wid_search_cond.set_col_num(3) self.__wid_search_cond.create() # Buttons window _btn_definition = [ dict(id="refresh", name=u'刷新'), dict(id="search", name=u"查询"), dict(id="update", name=u"修改", type="CHECK"), dict(id="delete", name=u"删除") ] _wid_buttons = ViewButtons(_btn_definition) _wid_buttons.align_back() # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate)
def __init__(self, options, parent=None): QWizardPage.__init__(self, parent) # Variables self._options = options # Layouts layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) sublayout = self._initUI() # Initialize widgets sublayout.setContentsMargins(10, 10, 10, 10) layout.addLayout(sublayout, 1) layout.addStretch() self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) # Variables self._tabs = {} self._widgets = {} self._readonly = False # Widgets self._wdg_tab = QTabWidget() # Layouts layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._wdg_tab) self.setLayout(layout)
class UI_options( QWidget ): def __init__( self, *args, **kwargs ): QWidget.__init__( self, *args, **kwargs ) self.installEventFilter( self ) self.layout = QVBoxLayout( self ) self.layout.setContentsMargins( 0,0,0,0 ) self.checkBox = QCheckBox( "To Parent" ) self.layout.addWidget( self.checkBox ) def eventFilter( self, *args, **kwargs ): event = args[1] if event.type() == QtCore.QEvent.LayoutRequest or event.type() == QtCore.QEvent.Move : pass
def __init__(self, fig): QDialog.__init__(self) self.fig = fig self.canvas = FigureCanvas(fig) p = self.palette() p.setColor(self.backgroundRole(), QtCore.Qt.white) self.setPalette(p) lo = QVBoxLayout() lo.setContentsMargins(0, 0, 0, 0) self.setLayout(lo) # mynav = NavigationToolbar(self.canvas, self) if sys.platform == "darwin": # The navivation toolbar doesn't seem to work on linux mynav = MyNavToolbar(self.canvas, self) lo.addWidget(mynav) else: qmy_button(lo, self.do_copy, "copy") lo.addWidget(self.canvas)
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)