def doLayout(self, rect, testOnly=False): """ """ x = rect.x() y = rect.y() lineHeight = 0 for item in self.itemList: wid = item.widget() spaceX = self.spacing() + wid.style().layoutSpacing( QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Horizontal) spaceY = self.spacing() + wid.style().layoutSpacing( QtGui.QSizePolicy.PushButton, QtGui.QSizePolicy.PushButton, QtCore.Qt.Vertical) nextX = x + item.sizeHint().width() + spaceX if nextX - spaceX > rect.right() and lineHeight > 0: x = rect.x() y = y + lineHeight + spaceY nextX = x + item.sizeHint().width() + spaceX lineHeight = 0 if not testOnly: item.setGeometry( QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint())) x = nextX lineHeight = max(lineHeight, item.sizeHint().height()) return y + lineHeight - rect.y()
def readSettings(self): """ Reading Settings """ self.settings.beginGroup('ui_main') self.setGeometry( self.settings.value('geometry', QtCore.QRect(500, 400, 500, 350))) self.edit_window.set_settings_from_dict( self.settings.value('edit_widndow_settings_dict', None)) self.settings.endGroup()
def graphicsSceneResizeEvent(self, event): # TODO Smooth downscaling pixmap rect = QtCore.QRect(0, 0, 512, 512) if self.pix_list: # pix = self.pix_list[self.current_pix] # self.pm1.add_pixmap(pix.scaledToHeight(self.previewGraphicsView.height(), QtCore.Qt.SmoothTransformation)) rect = self.pix_list[self.current_pix].rect() self.previewGraphicsView.setSceneRect(rect) self.previewGraphicsView.fitInView(rect, QtCore.Qt.KeepAspectRatio) # print self.previewGraphicsView.height() # print self.pm1.pixmap_item event.accept()
def resizeEvent(self, event): wrapper = self.findChild(QtGui.QWidget) flow = wrapper.findChild(FlowLayout) if wrapper and flow: width = self.viewport().width() height = flow.heightForWidth(width) size = QtCore.QSize(width, height) point = self.viewport().rect().topLeft() flow.setGeometry(QtCore.QRect(point, size)) self.viewport().update() super(ResizeScrollArea, self).resizeEvent(event)
def setupUi(self, notes): notes.setObjectName("notes") notes.resize(311, 238) self.gridLayout_2 = QtGui.QGridLayout(notes) self.gridLayout_2.setContentsMargins(9, 9, 9, 9) self.gridLayout_2.setObjectName("gridLayout_2") self.splitter = QtGui.QSplitter(notes) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") self.conversationScrollArea = QtGui.QScrollArea(self.splitter) self.conversationScrollArea.setWidgetResizable(True) self.conversationScrollArea.setObjectName("conversationScrollArea") self.scrollAreaWidgetContents = QtGui.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 291, 69)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.conversationScrollArea.setWidget(self.scrollAreaWidgetContents) self.gridLayoutWidget = QtGui.QWidget(self.splitter) self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout = QtGui.QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setSpacing(0) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.replyPushButton = QtGui.QPushButton(self.gridLayoutWidget) self.replyPushButton.setMinimumSize(QtCore.QSize(80, 0)) self.replyPushButton.setMaximumSize(QtCore.QSize(80, 16777215)) self.replyPushButton.setObjectName("replyPushButton") self.gridLayout.addWidget(self.replyPushButton, 3, 3, 1, 1) self.replyTextEdit = QtGui.QTextEdit(self.gridLayoutWidget) self.replyTextEdit.setStyleSheet("") self.replyTextEdit.setObjectName("replyTextEdit") self.gridLayout.addWidget(self.replyTextEdit, 1, 0, 1, 4) self.useFilterCheckBox = QtGui.QCheckBox(self.gridLayoutWidget) self.useFilterCheckBox.setObjectName("useFilterCheckBox") self.gridLayout.addWidget(self.useFilterCheckBox, 3, 0, 1, 1) self.filterUsersPushButton = QtGui.QPushButton(self.gridLayoutWidget) self.filterUsersPushButton.setMinimumSize(QtCore.QSize(80, 0)) self.filterUsersPushButton.setObjectName("filterUsersPushButton") self.gridLayout.addWidget(self.filterUsersPushButton, 3, 1, 1, 1) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 3, 2, 1, 1) self.editorLayout = QtGui.QVBoxLayout() self.editorLayout.setSpacing(0) self.editorLayout.setContentsMargins(0, 0, 0, 0) self.editorLayout.setObjectName("editorLayout") self.gridLayout.addLayout(self.editorLayout, 0, 0, 1, 4) self.gridLayout_2.addWidget(self.splitter, 2, 0, 1, 3) self.retranslateUi(notes) QtCore.QMetaObject.connectSlotsByName(notes)
def setupUi(self, configuration_dialog): configuration_dialog.setObjectName("configuration_dialog") configuration_dialog.setWindowModality(QtCore.Qt.ApplicationModal) configuration_dialog.resize(503, 319) configuration_dialog.setSizeGripEnabled(True) configuration_dialog.setModal(True) self.gridLayout_6 = QtGui.QGridLayout(configuration_dialog) self.gridLayout_6.setObjectName("gridLayout_6") self.configToolBox = QtGui.QToolBox(configuration_dialog) palette = Qt4Gui.QPalette() self.configToolBox.setPalette(palette) self.configToolBox.setStyleSheet("QToolBox > *,\n" "QToolBox > QScrollArea > #qt_scrollarea_viewport > QWidget {\n" " background-color: rgba(128, 128, 128, 48);\n" "}\n" "\n" "QToolBox::tab {\n" " border-style: outset;\n" " border-width: 1px;\n" " border-color: rgba(75, 75, 75, 75);\n" " border-radius: 1px;\n" " padding: 3px;\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 25), stop: 1 rgba(175, 175, 175, 0));\n" "}\n" "\n" "QToolBox::tab:hover {\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 50), stop: 1 rgba(175, 175, 175, 0));\n" " border: 1px solid rgba(128, 128, 128, 75);\n" "}\n" "QToolBox::tab:selected {\n" " font: italic;\n" " border-style: outset;\n" " border-width: 1px;\n" " border-color: rgba(75, 75, 75, 75);\n" " border-radius: 1px;\n" "}") self.configToolBox.setObjectName("configToolBox") self.serverPage = QtGui.QWidget() self.serverPage.setGeometry(QtCore.QRect(0, 0, 485, 90)) self.serverPage.setObjectName("serverPage") self.serverPageLayout = QtGui.QVBoxLayout(self.serverPage) self.serverPageLayout.setContentsMargins(6, 6, 6, 6) self.serverPageLayout.setObjectName("serverPageLayout") self.configToolBox.addItem(self.serverPage, "") self.projectPage = QtGui.QWidget() self.projectPage.setGeometry(QtCore.QRect(0, 0, 100, 30)) self.projectPage.setObjectName("projectPage") self.projectPageLayout = QtGui.QVBoxLayout(self.projectPage) self.projectPageLayout.setContentsMargins(6, 6, 6, 6) self.projectPageLayout.setObjectName("projectPageLayout") self.configToolBox.addItem(self.projectPage, "") self.checkinOutOptionsPage = QtGui.QWidget() self.checkinOutOptionsPage.setGeometry(QtCore.QRect(0, 0, 100, 30)) self.checkinOutOptionsPage.setObjectName("checkinOutOptionsPage") self.checkinPageLayout = QtGui.QVBoxLayout(self.checkinOutOptionsPage) self.checkinPageLayout.setContentsMargins(6, 6, 6, 6) self.checkinPageLayout.setObjectName("checkinPageLayout") self.configToolBox.addItem(self.checkinOutOptionsPage, "") self.checkinOutAppPage = QtGui.QWidget() self.checkinOutAppPage.setGeometry(QtCore.QRect(0, 0, 100, 30)) self.checkinOutAppPage.setObjectName("checkinOutAppPage") self.checkinOutPageLayout = QtGui.QVBoxLayout(self.checkinOutAppPage) self.checkinOutPageLayout.setContentsMargins(6, 6, 6, 6) self.checkinOutPageLayout.setObjectName("checkinOutPageLayout") self.configToolBox.addItem(self.checkinOutAppPage, "") self.globalCofigPage = QtGui.QWidget() self.globalCofigPage.setGeometry(QtCore.QRect(0, 0, 100, 30)) self.globalCofigPage.setObjectName("globalCofigPage") self.globalCofigPageLayout = QtGui.QVBoxLayout(self.globalCofigPage) self.globalCofigPageLayout.setContentsMargins(6, 6, 6, 6) self.globalCofigPageLayout.setObjectName("globalCofigPageLayout") self.configToolBox.addItem(self.globalCofigPage, "") self.currentEnvironmentPage = QtGui.QWidget() self.currentEnvironmentPage.setGeometry(QtCore.QRect(0, 0, 100, 30)) self.currentEnvironmentPage.setObjectName("currentEnvironmentPage") self.currentEnvironmentPageLayout = QtGui.QVBoxLayout(self.currentEnvironmentPage) self.currentEnvironmentPageLayout.setContentsMargins(6, 6, 6, 6) self.currentEnvironmentPageLayout.setObjectName("currentEnvironmentPageLayout") self.configToolBox.addItem(self.currentEnvironmentPage, "") self.gridLayout_6.addWidget(self.configToolBox, 0, 0, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(configuration_dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Apply|QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Reset|QtGui.QDialogButtonBox.RestoreDefaults|QtGui.QDialogButtonBox.SaveAll) self.buttonBox.setObjectName("buttonBox") self.gridLayout_6.addWidget(self.buttonBox, 1, 0, 1, 1) self.retranslateUi(configuration_dialog) self.configToolBox.setCurrentIndex(0) self.configToolBox.layout().setSpacing(6) QtCore.QMetaObject.connectSlotsByName(configuration_dialog)
def heightForWidth(self, width): height = self.doLayout(QtCore.QRect(0, 0, width, 0), True) return height
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setWindowModality(QtCore.Qt.ApplicationModal) MainWindow.setMinimumSize(QtCore.QSize(427, 276)) MainWindow.setStyleSheet( "QTreeView {\n" " show-decoration-selected: 1;\n" "}\n" "QTreeView::item {\n" " border-style: outset;\n" " border-width: 1px;\n" " border-color: rgba(75, 75, 75, 75);\n" " border-radius: 1px;\n" " padding: 0px;\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 25), stop: 1 rgba(175, 175, 175, 0));\n" "}\n" "\n" "QTreeView::item:hover {\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 50), stop: 1 rgba(175, 175, 175, 0));\n" " border: 1px solid rgba(128, 128, 128, 75);\n" "}\n" "QTreeView::item:selected {\n" " border: 1px solid transparent;\n" "}\n" "QTreeView::item:selected:active{\n" " background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(82, 133, 166, 255), stop:1 rgba(0, 0, 0, 0));\n" " border: 1px solid transparent;\n" "}\n" "QTreeView::item:selected:!active {\n" " background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(82, 133, 166, 255), stop:1 rgba(0, 0, 0, 0));\n" " border: 1px solid transparent;\n" "}\n" "QTreeView::item:selected{\n" " selection-background-color: transparent;\n" " border: 1px solid transparent;\n" "}\n" "QDockWidget::title{\n" " padding: 0px;\n" "}\n" "QDockWidget::close-button, QDockWidget::float-button {\n" " padding: 0px;\n" "}\n" "\n" "QTabWidget::pane {\n" " border: 0px;\n" "}\n" "QTabBar::tab {\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 16), stop: 1 rgba(175, 175, 175, 0));\n" " border: 0px solid transparent;\n" " border-top-left-radius: 2px;\n" " border-top-right-radius: 2px;\n" " padding: 4px;\n" "}\n" "QTabBar::tab:selected, QTabBar::tab:hover {\n" " background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255, 255, 255, 64), stop: 1 rgba(255, 255, 255, 8));\n" "}\n" "QTabBar::tab:selected {\n" " border-color: transparent;\n" "}\n" "QTabBar::tab:!selected {\n" " margin-top: 2px;\n" "}") MainWindow.setLocale( QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates)) MainWindow.setWindowFilePath("") MainWindow.setDockNestingEnabled(True) MainWindow.setDockOptions(QtGui.QMainWindow.AllowNestedDocks | QtGui.QMainWindow.AllowTabbedDocks | QtGui.QMainWindow.AnimatedDocks) self.mainwidget = QtGui.QWidget(MainWindow) self.mainwidget.setObjectName("mainwidget") MainWindow.setCentralWidget(self.mainwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 427, 25)) self.menubar.setObjectName("menubar") self.menuConfig = QtGui.QMenu(self.menubar) self.menuConfig.setObjectName("menuConfig") self.menuProject = QtGui.QMenu(self.menubar) self.menuProject.setTearOffEnabled(True) self.menuProject.setObjectName("menuProject") MainWindow.setMenuBar(self.menubar) self.actionConfiguration = QtGui.QAction(MainWindow) self.actionConfiguration.setObjectName("actionConfiguration") self.actionUpdate = QtGui.QAction(MainWindow) self.actionUpdate.setObjectName("actionUpdate") self.actionExit = QtGui.QAction(MainWindow) self.actionExit.setObjectName("actionExit") self.actionApply_to_all_Tabs = QtGui.QAction(MainWindow) self.actionApply_to_all_Tabs.setObjectName("actionApply_to_all_Tabs") self.actionServerside_Script = QtGui.QAction(MainWindow) self.actionServerside_Script.setObjectName("actionServerside_Script") self.actionDock_undock = QtGui.QAction(MainWindow) self.actionDock_undock.setObjectName("actionDock_undock") self.menuConfig.addAction(self.actionConfiguration) self.menuConfig.addAction(self.actionApply_to_all_Tabs) self.menuConfig.addAction(self.actionDock_undock) self.menuConfig.addSeparator() self.menuConfig.addAction(self.actionServerside_Script) self.menuConfig.addSeparator() self.menuConfig.addAction(self.actionUpdate) self.menuConfig.addSeparator() self.menuConfig.addSeparator() self.menuConfig.addAction(self.actionExit) self.menubar.addAction(self.menuConfig.menuAction()) self.menubar.addAction(self.menuProject.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)