我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用PyQt5.QtCore.QSize()。
def __init__(self, link_url: str, dl_path: str, parent=None): super(Downloader, self).__init__(parent) self.parent = parent self.dltool_cmd = find_executable(self.download_cmd) self.download_link = link_url self.download_path = dl_path if self.dltool_cmd.strip(): self.dltool_args = self.dltool_args.format(dl_path=self.download_path, dl_link=self.download_link) self.console = QTextEdit(self.parent) self.console.setWindowTitle('%s Downloader' % qApp.applicationName()) self.proc = QProcess(self.parent) layout = QVBoxLayout() layout.addWidget(self.console) self.setLayout(layout) self.setFixedSize(QSize(400, 300)) else: QMessageBox.critical(self.parent, 'DOWNLOADER ERROR', '<p>The <b>aria2c</b> executable binary could not ' + 'be found in your installation folders. The binary comes packaged with this ' + 'application so it is likely that it was accidentally deleted via human ' + 'intervntion or incorrect file permissions are preventing access to it.</p>' + '<p>You may either download and install <b>aria2</b> manually yourself, ensuring ' + 'its installation location is globally accessible via PATH environmnt variables or ' + 'simply reinstall this application again. If the issue is not resolved then try ' + 'to download the application again incase the orignal you installed already was ' + 'corrupted/broken.', buttons=QMessageBox.Close)
def __init__(self, ebeveyn=None): super(Son, self).__init__(ebeveyn) self.e = ebeveyn self.kapanacak_mi =False kutu = QGridLayout() self.setLayout(kutu) milis_logo = QLabel() milis_logo.setAlignment(Qt.AlignCenter) milis_logo.setPixmap(QPixmap("./resimler/milis-logo.svg")) kutu.addWidget(milis_logo,0,0,1,2) self.veda_label = QLabel() self.veda_label.setAlignment(Qt.AlignCenter) self.veda_label.setWordWrap(True) kutu.addWidget(self.veda_label,1,0,1,2) self.denemeye_devam = QRadioButton() self.denemeye_devam.setIcon(QIcon("./resimler/cik.svg")) self.denemeye_devam.setIconSize(QSize(50,50)) self.denemeye_devam.toggled.connect(self.degisti) kutu.addWidget(self.denemeye_devam,2,0,1,1) self.kapat = QRadioButton() self.kapat.setIcon(QIcon("./resimler/yeniden-baslat.svg")) self.kapat.setIconSize(QSize(50,50)) self.kapat.toggled.connect(self.degisti) kutu.addWidget(self.kapat,2,1,1,1) self.denemeye_devam.setChecked(True)
def __init__(self, parent=None): super(GraphView, self).__init__(parent) self.setObjectName('graphView') self.__graphViewWidget = parent self.setRenderHint(QtGui.QPainter.Antialiasing) self.setRenderHint(QtGui.QPainter.TextAntialiasing) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # Explicitly set the scene rect. This ensures all view parameters will be explicitly controlled # in the event handlers of this class. size = QtCore.QSize(600, 400) self.resize(size) self.setSceneRect(-size.width() * 0.5, -size.height() * 0.5, size.width(), size.height()) self.setAcceptDrops(True) self.reset()
def clickUI(self, click_types, clickstack): layout = QVBoxLayout() widget = QWidget() hbox = QHBoxLayout() for name in click_types: cbtn = QPushButton(name) cbtn.setMinimumSize(QtCore.QSize(100, 50)) cbtn.setStyleSheet(self.btnstyle) cbtn.clicked.connect(partial(self.all_keys_list, name, cbtn, 'click')) layout.addWidget(cbtn) widget.setLayout(layout) hbox.addStretch(1) hbox.addWidget(widget) hbox.addStretch(1) clickstack.setLayout(hbox)
def setupUi(self, About): About.setObjectName("About") About.resize(401, 117) About.setMinimumSize(QtCore.QSize(401, 117)) About.setMaximumSize(QtCore.QSize(401, 117)) self.buttonBox = QtWidgets.QDialogButtonBox(About) self.buttonBox.setGeometry(QtCore.QRect(10, 80, 381, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.label = QtWidgets.QLabel(About) self.label.setGeometry(QtCore.QRect(0, 20, 401, 21)) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(About) self.label_2.setGeometry(QtCore.QRect(0, 40, 401, 20)) self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.retranslateUi(About) self.buttonBox.clicked['QAbstractButton*'].connect(About.close) QtCore.QMetaObject.connectSlotsByName(About)
def __init__( self, app, debug_fn, parent=None ): self.app = app self.log = self.app.log self.debugLog = app.debug_options.debugLogMainWindow super().__init__( parent ) self.icon_size = QtCore.QSize( 32, 32 ) # list of all the WbActionState for the menus and toolbars self.__action_state_manager = WbActionStateManager( self.debugLog ) self.__focus_is_in = self.focus_is_in_names[0] # Often the rest of init has to be done after the widgets are rendered # for example to set focus on a widget self.__timer_init = QtCore.QTimer() self.__timer_init.timeout.connect( self.__completeInit ) self.__timer_init.setSingleShot( True ) self.__timer_init.start( 0 )
def main_window(app, translator, cntlr=None): """Run the main exectuable.""" from PyQt5.QtCore import QSize from PyQt5.QtGui import QIcon from scctool.controller import MainController from scctool.view.main import MainWindow try: """Run the main program.""" icon = QIcon() icon.addFile(getAbsPath('src/scct.ico'), QSize(32, 32)) icon.addFile(getAbsPath('src/scct.png'), QSize(256, 256)) app.setWindowIcon(icon) if cntlr is None: cntlr = MainController() MainWindow(cntlr, app, translator) logger.info("Starting...") return cntlr except Exception as e: logger.exception("message") raise
def setupUi(self, Help): Help.setObjectName("Help") Help.resize(300, 400) Help.setMinimumSize(QtCore.QSize(300, 400)) Help.setMaximumSize(QtCore.QSize(300, 400)) self.plainTextEdit = QtWidgets.QPlainTextEdit(Help) self.plainTextEdit.setGeometry(QtCore.QRect(0, 0, 301, 341)) self.plainTextEdit.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) self.plainTextEdit.setObjectName("plainTextEdit") self.pushButton = QtWidgets.QPushButton(Help) self.pushButton.setGeometry(QtCore.QRect(100, 360, 99, 27)) self.pushButton.setObjectName("pushButton") self.retranslateUi(Help) self.pushButton.clicked.connect(Help.close) QtCore.QMetaObject.connectSlotsByName(Help)
def setupUi(self, Login): Login.setObjectName("Login") Login.resize(300, 400) Login.setMinimumSize(QtCore.QSize(300, 400)) Login.setMaximumSize(QtCore.QSize(300, 400)) self.pushButton = QtWidgets.QPushButton(Login) self.pushButton.setGeometry(QtCore.QRect(100, 320, 99, 27)) self.pushButton.setObjectName("pushButton") self.label_2 = QtWidgets.QLabel(Login) self.label_2.setGeometry(QtCore.QRect(28, 190, 68, 17)) self.label_2.setObjectName("label_2") self.lineEdit_2 = QtWidgets.QLineEdit(Login) self.lineEdit_2.setGeometry(QtCore.QRect(120, 190, 151, 27)) self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password) self.lineEdit_2.setObjectName("lineEdit_2") self.label = QtWidgets.QLabel(Login) self.label.setGeometry(QtCore.QRect(28, 120, 68, 17)) self.label.setObjectName("label") self.lineEdit = QtWidgets.QLineEdit(Login) self.lineEdit.setGeometry(QtCore.QRect(120, 120, 151, 27)) self.lineEdit.setObjectName("lineEdit") self.retranslateUi(Login) QtCore.QMetaObject.connectSlotsByName(Login)
def setupUi(self, DlgAbout): DlgAbout.setObjectName("DlgAbout") DlgAbout.resize(382, 372) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(DlgAbout.sizePolicy().hasHeightForWidth()) DlgAbout.setSizePolicy(sizePolicy) self.gridLayout = QtWidgets.QGridLayout(DlgAbout) self.gridLayout.setObjectName("gridLayout") self.btnClose = QtWidgets.QPushButton(DlgAbout) self.btnClose.setMinimumSize(QtCore.QSize(80, 0)) self.btnClose.setObjectName("btnClose") self.gridLayout.addWidget(self.btnClose, 1, 0, 1, 1, QtCore.Qt.AlignRight) self.txtAbout = QtWidgets.QTextBrowser(DlgAbout) self.txtAbout.setMinimumSize(QtCore.QSize(350, 240)) self.txtAbout.setOpenExternalLinks(True) self.txtAbout.setObjectName("txtAbout") self.gridLayout.addWidget(self.txtAbout, 0, 0, 1, 1) self.retranslateUi(DlgAbout) self.btnClose.clicked.connect(DlgAbout.reject) QtCore.QMetaObject.connectSlotsByName(DlgAbout)
def __init__(self): """ Initialize main window. """ QMainWindow.__init__(self) self.setupUi(self) self.resize(QSize(settings.get('citewidth'), settings.get('citeheight'))) self.move(QPoint(settings.get('citex'), settings.get('citey'))) self.tabWidget.tabBar().setCurrentIndex(0) self.searchTab.setFocus() self.setWindowTitle('Cite') self.show() self.raise_() self.linkSettings() self.searchQuery.installEventFilter(self) self.text = self.bibtext = self.lastquery = "" self.batchBibtext = self.batchText = "" self.neverOpened = True self.helpText.setSource(QUrl('doc/help.html'))
def __init__(self): QToolBar.__init__(self) self.setToolButtonStyle( Qt.ToolButtonTextUnderIcon) self.setIconSize(QSize(42, 42)) self.materials = QAction(QIcon_load("organic_material"), _("Materials\ndatabase"), self) self.materials.triggered.connect(self.callback_view_materials) self.addAction(self.materials) self.spectra_file = QAction(QIcon_load("spectra_file"), _("Optical\ndatabase"), self) self.spectra_file.triggered.connect(self.callback_view_optical) self.addAction(self.spectra_file) if enable_betafeatures()==True: self.tb_import_pvlighthouse = QAction(QIcon_load("sync"), _("Update materials\nfrom PVLighthouse"), self) self.tb_import_pvlighthouse.triggered.connect(self.callback_pvlighthouse) self.addAction(self.tb_import_pvlighthouse) self.tb_import_refractiveindex = QAction(QIcon_load("sync"), _("Update materials\nfrom refractiveindex.info"), self) self.tb_import_refractiveindex.triggered.connect(self.callback_refractiveindex) self.addAction(self.tb_import_refractiveindex)
def file(self): toolbar = QToolBar() toolbar.setToolButtonStyle( Qt.ToolButtonTextUnderIcon) toolbar.setIconSize(QSize(42, 42)) self.home_new = QAction(QIcon_load("document-new"), _("New simulation").replace(" ","\n"), self) #self.home_new.setText(_("New\nsimulation")) toolbar.addAction(self.home_new) self.home_open = QAction(QIcon_load("document-open"), _("Open\nsimulation"), self) toolbar.addAction(self.home_open) self.home_export = QAction(QIcon_load("document-export"), _("Export\ndata"), self) toolbar.addAction(self.home_export) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(spacer) self.home_help = QAction(QIcon_load("internet-web-browser"), _("Help"), self) toolbar.addAction(self.home_help) return toolbar
def init_timer(self): self.interval_timer = 10 self.timer = QTimer() self.timer.timeout.connect(self.update_time_elapsed) self.hours_elapsed = 0 self.mins_elapsed = 0 self.segs_elapsed = 0 self.msegs_elapsed = 0 self.lbl_time_elapsed = QLabel() self.update_timer_elapsed() self.lbl_time_elapsed.setFixedSize(QSize(100, 30)) self.lbl_time_elapsed.setStyleSheet(""" color: white; background-color: #080f1c; """) self.layout_timer.addWidget(self.lbl_time_elapsed) self.layout_timer.addStretch(-1)
def set_up_button(self, style, str_icon_on, str_icon_off, auto_repeat, size, receiver, key, str_key): self.__size = size self.__style = style self.__icon_on = str_icon_on self.__icon_off = str_icon_off self.__auto_repeat = auto_repeat self.__receiver = receiver self.__key = key self.__str_key = str_key if str_key not in ['KB', 'A?', '?', '?', 'backspace']: self.setText(str_key) self.setFixedSize(size[0], size[1]) self.setStyleSheet(style) self.setIconSize(QSize(size[0], size[1])) self.setIcon(QIcon(self.__path + str_icon_off + ".png")) self.setAutoRepeat(auto_repeat) # pix_map = QPixmap(self.__path + str_icon_off + ".png") # self.setMask(pix_map.mask()) self.pressed.connect(self.key_pressed) self.released.connect(self.key_released)
def sizeHint(self): parent = self.parent() width = parent.width() if parent is not None else self.width() if self._glyphs: columnCount = int(width / self._cellWidth) if columnCount == 0: columnCount = 1 if columnCount > len(self._glyphs): columnCount = len(self._glyphs) rowCount = len(self._glyphs) // columnCount if columnCount * rowCount < len(self._glyphs): rowCount += 1 newWidth = self._cellWidth * columnCount newHeight = self._cellHeight * rowCount else: columnCount = 0 rowCount = 0 newWidth = newHeight = 0 self._columnCount = columnCount self._rowCount = rowCount return QSize(newWidth, newHeight)
def _setup_ui(self): geometry = ConfigFile.GEOMETRY x = Configuration().parser.getint(geometry, 'x', fallback=480) y = Configuration().parser.getint(geometry, 'y', fallback=320) width = Configuration().parser.getint(geometry, 'width', fallback=880) height = Configuration().parser.getint(geometry, 'height', fallback=474) self.setMinimumSize(QtCore.QSize(480, 320)) self.setGeometry(x, y, 480, 320) self.setWindowIcon(QtGui.QIcon(config.ICON)) self.set_title() self.resize(width, height) self.setLayoutDirection(QtCore.Qt.LeftToRight) self.setDockNestingEnabled(False) self.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks | QtWidgets.QMainWindow.AnimatedDocks | QtWidgets.QMainWindow.ForceTabbedDocks)
def __init__(self, colormap_dialog): # set window title, object name and window size colormap_dialog.setWindowTitle("Choose Colormap") colormap_dialog.setObjectName("ColormapDialog") colormap_dialog.setFixedWidth(455) colormap_dialog.setFixedHeight(100) # button box self.button_box = QDialogButtonBox(colormap_dialog) self.button_box.setEnabled(True) self.button_box.setGeometry(QRect(10, 60, 435, 30)) self.button_box.setOrientation(Qt.Horizontal) self.button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.button_box.setObjectName("button_box") # colormap selector self.colormap_combobox = QComboBox(colormap_dialog) self.colormap_combobox.setGeometry(QRect(10, 10, 435, 30)) self.colormap_combobox.setIconSize(QSize(435, 20)) # connect accept and reject self.button_box.accepted.connect(colormap_dialog.accept) self.button_box.rejected.connect(colormap_dialog.reject)
def setupUi(self, window): window.setObjectName("window") window.resize(380, 477) window.setModal(True) self.verticalLayout = QtWidgets.QVBoxLayout(window) self.verticalLayout.setObjectName("verticalLayout") self.txt_list = QtWidgets.QTextEdit(window) self.txt_list.setMinimumSize(QtCore.QSize(183, 0)) self.txt_list.setAcceptRichText(False) self.txt_list.setObjectName("txt_list") self.verticalLayout.addWidget(self.txt_list) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, -1, -1, 10) self.horizontalLayout.setObjectName("horizontalLayout") self.btn_cancel = QtWidgets.QPushButton(window) self.btn_cancel.setAutoDefault(False) self.btn_cancel.setObjectName("btn_cancel") self.horizontalLayout.addWidget(self.btn_cancel) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.btn_ok = QtWidgets.QPushButton(window) self.btn_ok.setAutoDefault(True) self.btn_ok.setObjectName("btn_ok") self.horizontalLayout.addWidget(self.btn_ok) self.verticalLayout.addLayout(self.horizontalLayout) self.retranslateUi(window) QtCore.QMetaObject.connectSlotsByName(window)
def calculateSize(self, sizeType): totalSize = QSize() for wrapper in self.list: position = wrapper.position itemSize = QSize() if sizeType == self.MinimumSize: itemSize = wrapper.item.minimumSize() else: # sizeType == self.SizeHint itemSize = wrapper.item.sizeHint() if position in (self.North, self.South, self.Center): totalSize.setHeight(totalSize.height() + itemSize.height()) if position in (self.West, self.East, self.Center): totalSize.setWidth(totalSize.width() + itemSize.width()) return totalSize
def openFile(self, path=None): if not path: path, _ = QFileDialog.getOpenFileName(self, "Open SVG File", self.currentPath, "SVG files (*.svg *.svgz *.svg.gz)") if path: svg_file = QFile(path) if not svg_file.exists(): QMessageBox.critical(self, "Open SVG File", "Could not open file '%s'." % path) self.outlineAction.setEnabled(False) self.backgroundAction.setEnabled(False) return self.view.openFile(svg_file) if not path.startswith(':/'): self.currentPath = path self.setWindowTitle("%s - SVGViewer" % self.currentPath) self.outlineAction.setEnabled(True) self.backgroundAction.setEnabled(True) self.resize(self.view.sizeHint() + QSize(80, 80 + self.menuBar().height()))
def changeSize(self, checked=True): if not checked: return if self.otherRadioButton.isChecked(): extent = self.otherSpinBox.value() else: if self.smallRadioButton.isChecked(): metric = QStyle.PM_SmallIconSize elif self.largeRadioButton.isChecked(): metric = QStyle.PM_LargeIconSize elif self.toolBarRadioButton.isChecked(): metric = QStyle.PM_ToolBarIconSize elif self.listViewRadioButton.isChecked(): metric = QStyle.PM_ListViewIconSize elif self.iconViewRadioButton.isChecked(): metric = QStyle.PM_IconViewIconSize else: metric = QStyle.PM_TabBarIconSize extent = QApplication.style().pixelMetric(metric) self.previewArea.setSize(QSize(extent, extent)) self.otherSpinBox.setEnabled(self.otherRadioButton.isChecked())
def layout(self): """ Layout the row for this experiment. """ self._main_layout = QW.QGridLayout(self) # Construct the header for the experiment self._main_layout.addWidget(QW.QLabel(self._expt_label),0,0) # -------------- Buttons -------------------- # Button to show experiment options self._show_options_button = QW.QPushButton("", self) self._show_options_button.clicked.connect(self._options_callback) self._show_options_button.setIcon(QG.QIcon(os.path.join(self._image_base,"icons","more-info.png"))) self._show_options_button.setIconSize(QC.QSize(21,21)) self._show_options_button.setFixedWidth(30) self._main_layout.addWidget(self._show_options_button,0,1) # Button to remove experiment self._remove_button = QW.QPushButton("", self) self._remove_button.clicked.connect(self._remove_callback) self._remove_button.setIcon(QG.QIcon(os.path.join(self._image_base,"icons","delete-icon.png"))) self._remove_button.setIconSize(QC.QSize(21,21)) self._remove_button.setFixedWidth(30) self._main_layout.addWidget(self._remove_button,0,2) self.setFrameShape(QW.QFrame.StyledPanel) if self._experiment is None: self._show_options_button.setDisabled(True) self._remove_button.setDisabled(True)
def update_registers(self, registers): """ Takes a dict of registers - 'name' : (value, width). Mostly just a wrapper around update_single_registers""" self._table.setRowCount(len(registers)) for register in registers: self.update_single_register(register, registers[register][0], registers[register][1]) self.resize(QSize(self._layout.sizeHint().width(), self._table.viewportSizeHint().height() + self._picker.sizeHint().height() + self._table.sizeHint().height()))
def sizeHint(self): return QSize(800, 400)
def sizeHint(self): return QSize(400, 100)
def sizeHint(self): """ Could be implemented like this to return the width and heights of the table. """ if self.rowCount() > 0: height = self.rowHeight(0) * (self.rowCount() + 1) + self.autoScrollMargin() # print("Size Hint:", height) return QtCore.QSize(self.width(), height) else: return QtCore.QSize(self.width(), 50)
def minimumSizeHint(self): return QSize(50, 50)
def sizeHint(self): return QSize(400, 400)
def init(self, parent): layout = QHBoxLayout(parent) layout.setContentsMargins(0, 0, 0, 0) self.m_treeWidget = QtPropertyEditorView(parent) self.m_treeWidget.setEditorPrivate(self) self.m_treeWidget.setIconSize(QSize(18, 18)) layout.addWidget(self.m_treeWidget) parent.setFocusProxy(self.m_treeWidget) self.m_treeWidget.setColumnCount(2) labels = QList() labels.append(QCoreApplication.translate("QtTreePropertyBrowser", "Property")) labels.append(QCoreApplication.translate("QtTreePropertyBrowser", "Value")) self.m_treeWidget.setHeaderLabels(labels) self.m_treeWidget.setAlternatingRowColors(True) self.m_treeWidget.setEditTriggers(QAbstractItemView.EditKeyPressed) self.m_delegate = QtPropertyEditorDelegate(parent) self.m_delegate.setEditorPrivate(self) self.m_treeWidget.setItemDelegate(self.m_delegate) self.m_treeWidget.header().setSectionsMovable(False) self.m_treeWidget.header().setSectionResizeMode(QHeaderView.Stretch) self.m_expandIcon = drawIndicatorIcon(self.q_ptr.palette(), self.q_ptr.style()) self.m_treeWidget.collapsed.connect(self.slotCollapsed) self.m_treeWidget.expanded.connect(self.slotExpanded) self.m_treeWidget.currentItemChanged.connect(self.slotCurrentTreeItemChanged)
def sizeHint(self, option, index): return super(QtPropertyEditorDelegate, self).sizeHint(option, index) + QSize(3, 4)
def createButton(self, parent=None): button = QToolButton(parent) button.setCheckable(True) button.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)) button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) button.setArrowType(Qt.DownArrow) button.setIconSize(QSize(3, 16)) ### #QIcon icon #icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowDown), QIcon.Normal, QIcon.Off) #icon.addPixmap(self.style().standardPixmap(QStyle.SP_ArrowUp), QIcon.Normal, QIcon.On) #button.setIcon(icon) ### return button
def keyUI(self, syms, keystack): layout = QGridLayout() scroll = QScrollArea() scroll.setWidgetResizable(True) widget = QWidget() vbox = QVBoxLayout() widget.setLayout(layout) btn_list = [] positions = [(i,j) for i in range(int(len(syms)/4)+1) for j in range(4)] for position, name in zip(positions, syms): kbtn = QPushButton(name) kbtn.setMinimumSize(QtCore.QSize(50, 50)) kbtn.setStyleSheet(self.btnstyle) layout.addWidget(kbtn, *position) kbtn.clicked.connect(partial(self.all_keys_list, name, kbtn, 'key')) scroll.setWidget(widget) qs = QScroller.scroller(scroll.viewport()) props = qs.scrollerProperties() props.setScrollMetric(QScrollerProperties.DecelerationFactor, 0.35) props.setScrollMetric(QScrollerProperties.DragStartDistance, .001) qs.setScrollerProperties(props) qs.grabGesture(scroll.viewport(), QScroller.TouchGesture) vbox.addWidget(scroll) keystack.setLayout(vbox)
def __init__(self, settings: QSettings): super(FavoritesTab, self).__init__() self.settings = settings faves_formLayout = QFormLayout(labelAlignment=Qt.AlignRight) self.faves_lineEdit = QLineEdit(self) self.faves_lineEdit.returnPressed.connect(self.add_item) self.faves_lineEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) faves_addItemButton = QPushButton(parent=self, flat=False, cursor=Qt.PointingHandCursor, text='Add', icon=QIcon(':assets/images/plus.png'), toolTip='Add item', clicked=self.add_item) faves_addItemButton.setIconSize(QSize(12, 12)) faves_deleteItemButton = QPushButton(parent=self, flat=False, cursor=Qt.PointingHandCursor, text='Delete', icon=QIcon(':assets/images/minus.png'), toolTip='Delete selected item', clicked=self.delete_items) faves_deleteItemButton.setIconSize(QSize(12, 12)) faves_buttonLayout = QHBoxLayout() faves_buttonLayout.addWidget(faves_addItemButton) faves_buttonLayout.addWidget(faves_deleteItemButton) faves_formLayout.addRow('Item Label:', self.faves_lineEdit) faves_formLayout.addRow(faves_buttonLayout) faves_formLayout.addRow(self.get_notes()) self.faves_listWidget = QListWidget(self) self.faves_listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.faves_listWidget.setSortingEnabled(True) self.add_items(self.settings.value('favorites', '')) tab_layout = QHBoxLayout() tab_layout.addLayout(faves_formLayout) tab_layout.addWidget(self.faves_listWidget) self.setLayout(tab_layout)
def createTabIconSet(self): self.tabIconSet = QWidget() self.tabIconSet.setObjectName("tabIconSet") self.verticalLayout_3 = QVBoxLayout(self.tabIconSet) self.verticalLayout_3.setObjectName("verticalLayout_3") self.listWidgetIconSet = QListWidget(self.tabIconSet) self.listWidgetIconSet.setResizeMode(QListView.Adjust) self.listWidgetIconSet.setObjectName("listWidgetIconSet") self.listWidgetIconSet.setViewMode(QListView.IconMode) self.listWidgetIconSet.setIconSize(QSize(370, 64)) item = QListWidgetItem(self.listWidgetIconSet) item.setIcon(QIcon(":/data/images/midna-set.png")) item.setText("Midna") item = QListWidgetItem(self.listWidgetIconSet) item.setIcon(QIcon(":/data/images/midna-dark-set.png")) item.setText("MidnaDark") item = QListWidgetItem(self.listWidgetIconSet) item.setIcon(QIcon(":/data/images/breeze-set.png")) item.setText("Breeze") item = QListWidgetItem(self.listWidgetIconSet) item.setIcon(QIcon(":/data/images/oxygen-set.png")) item.setText("Oxygen") self.verticalLayout_3.addWidget(self.listWidgetIconSet) self.addTab(self.tabIconSet, self.tr("Icon Set"))
def sizeHint(self): height = super().sizeHint().height() min_width = self.minimumSizeHint().width() text_width = self.fontMetrics().width(self.text()) width = text_width + min_width if not self.isVisible() and self.isClearButtonEnabled(): width += 26 return QtCore.QSize(width, height)
def alreadyReservedMessageBox(self, text): msgBox = QtWidgets.QMessageBox() msgBox.setIcon(QtWidgets.QMessageBox.Information) msgBox.setBaseSize(QtCore.QSize(600, 300)) msgBox.setText("Bereits reservierte Spiele gefunden!") msgBox.setInformativeText(text) msgBox.exec()
def installUpdates(self): if platform == "win32": url = self.data['url-windows'] os = 'Windows' else: url = self.data['url-mac'] os = 'macOS' text = """ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li {{ white-space: pre-wrap; }} </style></head><body style=" font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;"> Die neuste Version für {platform} kannst du unter folgendem Link herunterladen: <br /> <a href='{url}'>{url}</a><br /><br /> Lade das Update herunter, schließe FuME, installiere die Datei und öffne FuME erneut.<br /><br /> Mit einem klick auf OK erlaubst du FuME, den obigen Link in deinem Browser zu öffnen.<br /><br /> </body></html> """.format(platform=os, url=url) msgBox = QtWidgets.QMessageBox(self) msgBox.setIcon(QtWidgets.QMessageBox.Information) msgBox.setWindowTitle("Software-Update") msgBox.setText("Software-Update") msgBox.setInformativeText(text) msgBox.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok) msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok) msgBox.setBaseSize(QtCore.QSize(550, 275)) ret = msgBox.exec() if ret == QtWidgets.QMessageBox.Ok: webbrowser.open(url) self.close()
def drawUI(self): self.play = QPushButton(self) self.play.setIconSize(QSize(40, 40)) self.play.setIcon(QIcon(QPixmap("play.png").scaled(40, 40, Qt.KeepAspectRatio, Qt.SmoothTransformation))) self.play.setStyleSheet("background-color: rgba(0, 0, 0, 0);") self.play.clicked.connect(lambda:self.playpause(self.play)) self.resize(50, 50)
def drawUI(self): self.play = QPushButton(self) self.play.setIconSize(QSize(40, 20)) self.play.setIcon(QIcon(QPixmap("fastforward.png").scaled(40, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))) self.play.setStyleSheet("background-color: rgba(0, 0, 0, 0);") self.play.clicked.connect(lambda:self.forward()) self.resize(80, 40)
def drawUI(self): self.play = QPushButton(self) self.play.setIconSize(QSize(40, 20)) self.play.setIcon(QIcon(QPixmap("rewind.png").scaled(40, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))) self.play.setStyleSheet("background-color: rgba(0, 0, 0, 0);") self.play.clicked.connect(lambda:self.rewind()) self.resize(80, 40)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(830, 333) Form.setMinimumSize(QtCore.QSize(700, 300)) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setSpacing(20) self.verticalLayout.setObjectName("verticalLayout") self.listView = QtWidgets.QListView(Form) self.listView.setObjectName("listView") self.verticalLayout.addWidget(self.listView) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setSpacing(30) self.horizontalLayout.setObjectName("horizontalLayout") self.pushButton = QtWidgets.QPushButton(Form) self.pushButton.setMinimumSize(QtCore.QSize(0, 50)) self.pushButton.setObjectName("pushButton") self.horizontalLayout.addWidget(self.pushButton) self.pushButton_2 = QtWidgets.QPushButton(Form) self.pushButton_2.setMinimumSize(QtCore.QSize(0, 50)) self.pushButton_2.setMaximumSize(QtCore.QSize(230, 16777215)) self.pushButton_2.setObjectName("pushButton_2") self.horizontalLayout.addWidget(self.pushButton_2) self.verticalLayout.addLayout(self.horizontalLayout) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.retranslateUi(Form) self.listView.clicked['QModelIndex'].connect(Form.key_selected) self.pushButton.clicked.connect(Form.enter) self.pushButton_2.clicked.connect(Form.not_use_key) QtCore.QMetaObject.connectSlotsByName(Form)
def __init__(self, parent=None): super(VideoToolBar, self).__init__(parent) self.parent = parent self.setObjectName('appcontrols') self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.setFloatable(False) self.setMovable(False) self.setIconSize(QSize(50, 53)) if sys.platform == 'darwin': self.setStyle(QStyleFactory.create('Fusion'))
def get_size(mode: str = 'NORMAL') -> QSize: modes = { 'LOW': QSize(450, 300), 'NORMAL': QSize(515, 520), 'HIGH': QSize(1080, 920) } return modes[mode]
def initThumbs(self) -> None: framesize = self.parent.videoService.framesize() thumbsize = QSize(VideoService.ThumbSize.TIMELINE.value.height() * (framesize.width() / framesize.height()), VideoService.ThumbSize.TIMELINE.value.height()) positions, frametimes = [], [] thumbs = int(math.ceil((self.rect().width() - (self.offset * 2)) / thumbsize.width())) for pos in range(thumbs): val = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), (thumbsize.width() * pos) - self.offset, self.rect().width() - (self.offset * 2)) positions.append(val) positions[0] = 1000 [frametimes.append(self.parent.delta2QTime(msec).toString(self.parent.timeformat)) for msec in positions] class ThumbWorker(QObject): completed = pyqtSignal(list) def __init__(self, media: str, times: list, size: QSize): super(ThumbWorker, self).__init__() self.media = media self.times = times self.size = size @pyqtSlot() def generate(self): frames = list() [frames.append(VideoService.captureFrame(self.media, frame, self.size)) for frame in self.times] self.completed.emit(frames) self.thumbsThread = QThread(self) self.thumbsWorker = ThumbWorker(self.parent.currentMedia, frametimes, thumbsize) self.thumbsWorker.moveToThread(self.thumbsThread) self.thumbsThread.started.connect(self.parent.sliderWidget.setLoader) self.thumbsThread.started.connect(self.thumbsWorker.generate) self.thumbsThread.finished.connect(self.thumbsThread.deleteLater, Qt.DirectConnection) self.thumbsWorker.completed.connect(self.buildTimeline) self.thumbsWorker.completed.connect(self.thumbsWorker.deleteLater, Qt.DirectConnection) self.thumbsWorker.completed.connect(self.thumbsThread.quit, Qt.DirectConnection) self.thumbsThread.start()