def __init__(self): QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("application main window") self.file_menu = QMenu('&File', self) self.file_menu.addAction('&Quit', self.fileQuit, QtCore.Qt.CTRL + QtCore.Qt.Key_Q) self.menuBar().addMenu(self.file_menu) self.help_menu = QMenu('&Help', self) self.menuBar().addSeparator() self.menuBar().addMenu(self.help_menu) self.help_menu.addAction('&About', self.about) self.filename = "Fields_global.h5" self.f=h5.File(self.filename) dset = self.f["/1d_global/potential"] print "Attention: the dataset must be 4 dimensions" #> the main layout: left part (for the hdf5 tree view) and right part (for the plot area) self.main_widget = QWidget(self) #> if not putting splitter into a layout, the widgets in splitter do not fill the main windows #> (may exceed the app windows, so that the figures are partially shown ). layout = QVBoxLayout(self.main_widget) hSplitter = QSplitter(self.main_widget) layout.addWidget(hSplitter) #> the left part: the hdf5 tree view h5tree = QWidget() treeview = QTreeView(h5tree) self.model = HDFTreeModel([]) self.model.openFile(self.filename, 'r+') treeview.setModel(self.model) treeview.doubleClicked.connect(self.redraw) hSplitter.addWidget(treeview) #> the right part: the plot area plotArea = QWidget(self.main_widget) sizePolicy = QSizePolicy(); sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding); sizePolicy.setVerticalPolicy(QSizePolicy.Expanding); plotArea.setSizePolicy(sizePolicy); hSplitter.addWidget(plotArea) plotVboxlayout = QVBoxLayout(plotArea) self.sc = MyStaticMplCanvas(self.main_widget, dset, width=5, height=4, dpi=100) self.dc = MyDynamicMplCanvas(self.main_widget, dset, width=5, height=4, dpi=100) plotVboxlayout.addWidget(self.sc) plotVboxlayout.addWidget(self.dc) self.main_widget.setFocus() self.setCentralWidget(self.main_widget) self.statusBar().showMessage("All hail matplotlib!", 2000)
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.updateSecs = 0.5 # Border self.setLineWidth(0) self.setFrameShape(QtWidgets.QFrame.NoFrame) # Size sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHeightForWidth(True) self.setSizePolicy(sizePolicy) # No scrollbars self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Scene self.scene = QGraphicsScene() self.setScene(self.scene) self.setBackgroundBrush(QColor("black")) # Text of clock self.textItem = QGraphicsTextItem() self.textItem.color = QColor(QColor("black")) self.textItem.setFont(QFont("Segoe UI", 80)) self.textItem.setDefaultTextColor(QColor("white")) self.textItem.setHtml("") self.textItem.setZValue(20) self.scene.addItem(self.textItem) # Start ticking self.start()
def __init__(self, parent, binpath): super().__init__(parent) sizePolicy = QSizePolicy() sizePolicy.setHorizontalPolicy(QSizePolicy.Maximum) sizePolicy.setVerticalPolicy(QSizePolicy.Maximum) #self.setSizePolicy(sizePolicy) self.setMouseTracking(True) self.on_selection = False self.selected = False self.c = Communicate() self.start_position = QPoint(0,0) self.last_position = QPoint(0,0) image = ( b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" b"\x00\x00\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00" b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00" b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00" b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00" b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00" b"\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF\x00\x00" b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") im = QImage(image, 8,8, QImage.Format_RGB16) im = im.scaled(64,64) self.crop = QPixmap() self.crop.convertFromImage(im)
def __init__(self,position=None,parent=None,value=0): #super(OrbButton,self).__init__(parent) super().__init__(parent) self.value = Orb.Null if value==0 else value self.parent = parent if position == None: pol = QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Fixed) pol.setHeightForWidth(True) self.setSizePolicy(pol) if self.value == Orb.Null: p = self.palette() p.setColor(self.backgroundRole(),QColor(205,127,50,254)) self.setPalette(p) self.setAutoFillBackground(True) else: self.setSizePolicy(QSizePolicy()) self.position = position self.pressed.connect(self.onClick) p = self.palette() if (position[0]+position[1]) % 2 != 0: p.setColor(self.backgroundRole(),QColor(205,127,50,254)) else: p.setColor(self.backgroundRole(),QColor(128,70,27,254)) self.setPalette(p) self.setAutoFillBackground(1)
def initUI(self): self.setObjectName("naviBar") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.vboxList = QVBoxLayout(self) self.vboxList.setContentsMargins(0, 0, 0, 0) self.vboxList.setSpacing(6) self.initBtnList(self.vboxList)
def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget (QWidget) """ super(StackedUrlBar, self).__init__(parent) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(6) sizePolicy.setVerticalStretch(0) self.setSizePolicy(sizePolicy) self.setMinimumSize(200, 22)
def __init__(self,parent = None,ImgComp = None,ImgOut = None): super(BrowserComp, self).__init__(parent) self.ImgObj = ImgComp self.ImgOut = ImgOut self.webView = QtWebKitWidgets.QWebView(self) setting = self.webView.settings() print os.path.join(currDir, "user", "Blocks") print setting.setLocalStoragePath(os.path.join(currDir,"user","Blocks")) print setting.localStoragePath() print setting.defaultTextEncoding() #sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) #sizePolicy.setHorizontalStretch(1) #sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.webView.sizePolicy().hasHeightForWidth()) self.webView.setSizePolicy(sizePolicy) self.webView.setObjectName("webView") path = os.path.abspath(os.path.dirname(__file__) ) url = "file:///{0}".format(os.path.join(path,"lib","editor","index.html").replace("\\","/")) qurl = QUrl(url) self.webView.load(qurl) # http://nullege.com/codes/search/PyQt5.QtWebKitWidgets.QWebView.loadFinished.connect self.webView.loadFinished.connect(self.on_webView_loadFinished) self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.webView) self.button = QPushButton("&Execute") self.button.clicked.connect(self.executeScript) self.button_open = QPushButton("&Open") self.button_open.clicked.connect(self.openBlocks) self.button_save = QPushButton("&Save") self.button_save.clicked.connect(self.saveBlocks) #タイマーを設定. self.timer = QTimer(parent=self) self.timer.setInterval(1*1000) self.timer.timeout.connect(self.selectingBlock) self.timer.start() self.mainLayout.addWidget(self.button) self.mainLayout.addWidget(self.button_open) self.mainLayout.addWidget(self.button_save) self.setLayout(self.mainLayout)
def _setupUi(self): self.resize(400, 300) self.verticalLayout = QVBoxLayout(self) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.filterBar = RadioBox(self) sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.filterBar.sizePolicy().hasHeightForWidth()) self.filterBar.setSizePolicy(sizePolicy) self.filterBar.setMinimumSize(QtCore.QSize(0, 20)) self.verticalLayout.addWidget(self.filterBar) self.tableView = TableView(self) self.tableView.setAcceptDrops(True) self.tableView.setEditTriggers(QAbstractItemView.DoubleClicked|QAbstractItemView.EditKeyPressed) self.tableView.setDragEnabled(True) self.tableView.setDragDropMode(QAbstractItemView.InternalMove) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setSortingEnabled(True) self.tableView.setCornerButtonEnabled(False) self.tableView.horizontalHeader().setHighlightSections(False) self.tableView.horizontalHeader().setMinimumSectionSize(18) self.tableView.verticalHeader().setVisible(False) self.tableView.verticalHeader().setDefaultSectionSize(18) self.verticalLayout.addWidget(self.tableView)
def _setupUi(self): self.resize(340, 165) self.setWindowTitle(tr("Re-assign Account")) self.verticalLayout = QVBoxLayout(self) self.label = QLabel(self) self.label.setWordWrap(True) self.label.setText(tr( "You\'re about to delete a non-empty account. Select an account to re-assign its " "transactions to." )) self.verticalLayout.addWidget(self.label) self.accountComboBoxView = QComboBox(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.accountComboBoxView.sizePolicy().hasHeightForWidth()) self.accountComboBoxView.setSizePolicy(sizePolicy) self.accountComboBoxView.setMinimumSize(QSize(200, 0)) self.verticalLayout.addWidget(self.accountComboBoxView) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout = QHBoxLayout() spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.cancelButton = QPushButton(self) self.cancelButton.setText(tr("Cancel")) self.cancelButton.setShortcut("Esc") self.horizontalLayout.addWidget(self.cancelButton) self.continueButton = QPushButton(self) self.continueButton.setDefault(True) self.continueButton.setText(tr("Continue")) self.horizontalLayout.addWidget(self.continueButton) self.verticalLayout.addLayout(self.horizontalLayout)
def group_tasks_list(self): """Define the Tasks Group arrangement.""" gb_tasks = QGroupBox(self.central_widget) gb_tasks.setTitle(self.tr('List of Conversion Tasks')) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(gb_tasks.sizePolicy().hasHeightForWidth()) gb_tasks.setSizePolicy(sizePolicy) hl = QHBoxLayout(gb_tasks) self.tb_tasks = QTableWidget(gb_tasks) self.tb_tasks.setColumnCount(4) self.tb_tasks.setRowCount(0) self.tb_tasks.setSelectionMode(QAbstractItemView.SingleSelection) self.tb_tasks.setSelectionBehavior(QAbstractItemView.SelectRows) self.tb_tasks.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) self.tb_tasks.setHorizontalHeaderLabels( [self.tr('File Name'), self.tr('Duration'), self.tr('Target Quality'), self.tr('Progress')]) self.tb_tasks.cellClicked.connect(self._enable_remove_file_action) # Create a combo box for Target quality self.tb_tasks.setItemDelegate(TargetQualityDelegate(parent=self)) hl.addWidget(self.tb_tasks) self.vl2.addWidget(gb_tasks) self.tb_tasks.doubleClicked.connect(self.update_edit_triggers)
def _setupUi(self): self.resize(259, 32) self.horizontalLayout = QHBoxLayout(self) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.prevButton = QPushButton(self) icon = QIcon() icon.addPixmap(QPixmap(":/nav_left_9"), QIcon.Normal, QIcon.Off) self.prevButton.setIcon(icon) self.horizontalLayout.addWidget(self.prevButton) self.typeButton = QPushButton("<date range>") sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.typeButton.sizePolicy().hasHeightForWidth()) self.typeButton.setSizePolicy(sizePolicy) self.typeButton.setMinimumSize(QSize(0, 0)) self.typeButton.setMaximumSize(QSize(16777215, 16777215)) self.typeButton.setIconSize(QSize(6, 6)) self.horizontalLayout.addWidget(self.typeButton) self.nextButton = QPushButton(self) icon1 = QIcon() icon1.addPixmap(QPixmap(":/nav_right_9"), QIcon.Normal, QIcon.Off) self.nextButton.setIcon(icon1) self.horizontalLayout.addWidget(self.nextButton) self.horizontalLayout.setStretch(1, 1)
def __init__(self, buf, parent=None): super(HexViewWidget, self).__init__() self.setupUi(self) self._buf = buf self._model = HexTableModel(self._buf) self._colored_regions = intervaltree.IntervalTree() self._origins = [] # ripped from pyuic5 ui/hexview.ui # at commit 6c9edffd32706097d7eba8814d306ea1d997b25a # so we can add our custom HexTableView instance self.view = HexTableView(self) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.view.sizePolicy().hasHeightForWidth()) self.view.setSizePolicy(sizePolicy) self.view.setMinimumSize(QSize(660, 0)) self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setSelectionMode(QAbstractItemView.NoSelection) self.view.setShowGrid(False) self.view.setWordWrap(False) self.view.setObjectName("view") self.view.horizontalHeader().setDefaultSectionSize(25) self.view.horizontalHeader().setMinimumSectionSize(25) self.view.verticalHeader().setDefaultSectionSize(21) self.mainLayout.insertWidget(0, self.view) # end rip # TODO: provide a HexViewWidget.setModel method, and don't build it ourselves self.view.setModel(self._model) for i in range(0x10): self.view.setColumnWidth(i, 25) self.view.setColumnWidth(0x10, 12) for i in range(0x11, 0x22): self.view.setColumnWidth(i, 11) self._hsm = HexItemSelectionModel(self._model, self.view) self.view.setSelectionModel(self._hsm) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self._handle_context_menu_requested) self._hsm.selectionRangeChanged.connect(self._handle_selection_range_changed) self.originsChanged.connect(self._handle_origins_changed) self.view.moveKeyPressed.connect(self._hsm.handle_move_key) self.view.selectKeyPressed.connect(self._hsm.handle_select_key) f = QFontDatabase.systemFont(QFontDatabase.FixedFont) self.view.setFont(f) self.statusLabel.setFont(f) self.view.setItemDelegate(HexItemDelegate(self._model, self)) self.statusLabel.setText("")
def __init__(self, parent): super(ShipStatus, self).__init__(parent) self.con = parent.con self.hbox = QHBoxLayout() self.hbox.setContentsMargins(0,0,0,0) self.setLayout(self.hbox) self.name = QLabel(self) self.hbox.addWidget(self.name) self.name.setMinimumSize(QSize(80, 30)) self.name.setMaximumSize(QSize(80, 30)) self.lv = QLabel(self) self.hbox.addWidget(self.lv) self.lv.setMinimumSize(QSize(60, 30)) self.lv.setMaximumSize(QSize(60, 30)) self.hp = ShipHp(self) self.hbox.addWidget(self.hp) self.cond = ShipCondition(self) self.cond.setMinimumSize(QSize(80, 50)) self.cond.setMaximumSize(QSize(80, 50)) self.hbox.addWidget(self.cond) self.fuelbull = FuelBulletMeter(self) self.hbox.addWidget(self.fuelbull) self.slot = ShipSlot(self) self.hbox.addWidget(self.slot) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox.addItem(spacerItem) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.setSizePolicy(sizePolicy) self.setMinimumSize(QSize(500, 40)) self.setMaximumSize(QSize(9999, 40))
def createWidget(self): if self.text: self.setText(self.text) if self.size: addAssetSizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.setMaximumSize(self.size[0], self.size[1]) self.setSizePolicy(addAssetSizePolicy) if self.icon: self.setIcon(QIcon(self.icon))
def initUI(self): self.setWindowTitle("Main Window") self.resize(400, 300) self.setAttribute(Qt.WA_TranslucentBackground, True) # construct self.history = ShowHistory(self) self.setCentralWidget(self.history) self.history.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)) ## self.sw_transparent() ## self.setWindowFlags(self.windowFlags()|Qt.CustomizeWindowHint) self.init_cmenu()
def viewDetails(self, function): """ calling function from MainWindow """ self.viewBtn = QPushButton("View") self.viewBtn.setStyleSheet(self.styleSheet) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self.viewBtn.setSizePolicy(sizePolicy) self.viewBtn.setMinimumSize(QSize(0, 150)) self.viewBtn.clicked.connect( lambda: function(self.userName, self.name, self.id)) self.btns_vault.addWidget(self.viewBtn)
def _createLayout(self): self.clientArea = QWidget() self.clientArea.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.clientArea.setMinimumSize(QSize(640, 400)) self.clientArea.setBaseSize(QSize(640, 400)) self.clientArea.setLayoutDirection(Qt.LeftToRight) self.clientArea.setObjectName("clientArea") self.gridLayout = QGridLayout(self.clientArea) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName("gridLayout")
def __init__(self): super(initial, self).__init__() self.form1 = QWidget() self.formLayout1 = QHBoxLayout(self.form1) self.label1 = QLabel() self.label1.setText("初始化界面") self.label1.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.label1.setAlignment(Qt.AlignCenter) self.label1.setFont(QFont("Roman times", 50, QFont.Bold)) self.formLayout1.addWidget(self.label1) self.setLayout(self.formLayout1)
def createLessonLetterButtons(self, parentGrid): newButtonCount = int(self.settings.value("currentLesson")) + 1 oldButtonCount = len(self.lessonButtons) if oldButtonCount > newButtonCount: for button in self.lessonButtons[newButtonCount:]: parentGrid.removeWidget(button) button.deleteLater() self.lessonButtons = self.lessonButtons[:newButtonCount] else: for idx, letter in enumerate(KOCH_LETTERS[oldButtonCount:newButtonCount]): idx = idx + oldButtonCount button = QToolButton() button.setText(letter) button.clicked.connect(functools.partial(self.playMorse, letter)) buttonPolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed, QSizePolicy.PushButton) buttonPolicy.setHorizontalStretch(0) button.setSizePolicy(buttonPolicy) button.setMinimumWidth(5) parentGrid.addWidget(button, 1 + int(idx / 12), int(idx % 12)) self.lessonButtons.append(button)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.setSizePolicy(size_policy) self.setStyleSheet(""" QPushButton { border: none; } QPushButton[alignleft=true] { text-align: left; } """)
def __init__(self): QLabel.__init__(self, wordWrap=True) self.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)) self.setStyleSheet(css.lcd_screen) self._tempoTimer = QTimer(interval=1500, singleShot=True, timeout=self.setTempo) self._statusTimer = QTimer(interval=2000, singleShot=True, timeout=self.statusMessage) self._tempo = None self._status = None self.reset() app.translateUI(self)
def addProgramButtons(self): labels = [ "Move to EE", "Move to contact", "UserSync", "Move fingers", "Apply force to fingers" ] for label in labels: newButton = QPushButton(label) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) #newButton.setSizePolicy(sizePolicy) self.buttons.append(newButton) self.layout.addWidget(newButton)
def newGame(self): self.field = Matrix(self.y, self.x, self.mine) self.count = 0 for i in range(self.y): for j in range(self.x): button = self.game_map[i][j] button.setText(" ") button.setStyleSheet("background-color: #4e4f59") button.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) button.setIcon(QIcon("")) button.setEnabled(True)
def confirmation_layout(self): sizepolicy = QSizePolicy() sizepolicy.setVerticalPolicy(QSizePolicy.Expanding) sizepolicy.setVerticalPolicy(QSizePolicy.Preferred) btn_exit = QPushButton() btn_exit.setIcon(QIcon(os.path.abspath(__file__ + '/../..' + '/img/exit.png'))) btn_exit.setSizePolicy(sizepolicy) btn_exit.pressed.connect(self.on_exit_pressed) btn_save = QPushButton() btn_save.setIcon(QIcon(os.path.abspath(__file__ + '/../..' + '/img/figshare_upload.png'))) btn_save.setSizePolicy(sizepolicy) btn_save.pressed.connect(self.on_save_pressed) vbox = QVBoxLayout() vbox.addWidget(btn_exit) vbox.addWidget(btn_save) return vbox
def on_add_button_to_list(self, button_group, layout, textedit, overide_str=None): """ Adds a button to a specified button group and layout. :param button_group: QButtonGroup button is to be added to. :param layout: QLayout button is to be added to. :param lineedit: QLineEdit containing the new button string. :return: """ if overide_str is not None: new_btn_str = overide_str else: new_btn_str = textedit.toPlainText() textedit.clear() new_btn = QPushButton(new_btn_str) new_btn.setFont(self.edit_font) new_btn.setFlat(True) new_btn.setCheckable(True) new_btn.toggle() size_policy = QSizePolicy() size_policy.setHorizontalPolicy(QSizePolicy.Expanding) size_policy.setVerticalPolicy(QSizePolicy.Preferred) new_btn.setSizePolicy(size_policy) button_group.addButton(new_btn) inset_pos = layout.count() - 2 layout.insertWidget(inset_pos, new_btn)
def selfSetUp(self): self.setWindowTitle('TableView v 0.2') self.setMinimumSize(QSize(int(680 * 1.5), int(600 * 1.5))) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) sizePolicy.setWidthForHeight(self.sizePolicy().hasWidthForHeight()) self.setSizePolicy(sizePolicy)
def createGridLayout(self): self.containerGrid = QGridLayout() noticeLayout = QGridLayout() noticeLayout.setColumnStretch(1, 4) noticeLayout.setColumnStretch(2, 4) noticeGroupBox = QGroupBox("Notice") noticeGroupBox.setLayout(noticeLayout) self.containerGrid.addWidget(noticeGroupBox, 0, 0) donate1 = QPushButton('$1') sizePolicy = QSizePolicy() sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) donate5 = QPushButton('$5') donate10 = QPushButton('$10') donateLayout = QGridLayout() donateLayout.setRowStretch(1, 1) donateLayout.addWidget(donate1, 0, 0) donateLayout.addWidget(donate5, 1, 0) donateLayout.addWidget(donate10, 2, 0) donateGroupBox = QGroupBox("Donate") donateGroupBox.setLayout(donateLayout) self.containerGrid.addWidget(donateGroupBox, 0, 1) createLayout = QGridLayout() createLayout.setColumnStretch(1, 4) createLayout.setColumnStretch(2, 4) createGroupBox = QGroupBox("Create") createGroupBox.setLayout(createLayout) self.containerGrid.addWidget(createGroupBox, 0, 2)
def text_line(self, name, default=None, width=30): """Make a text input with the given name and default value.""" text_line = QLineEdit(self) text_line.setObjectName(name) if default: text_line.setText(str(default)) text_line.setFixedWidth(width) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(text_line.sizePolicy().hasHeightForWidth()) text_line.setSizePolicy(sizePolicy) return text_line
def _set_frame_downloaded(self): """Sets the size policies of the downloaded features frame.""" self.frame_downloaded = QFrame(self) size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth( self.frame_downloaded.sizePolicy().hasHeightForWidth()) self.frame_downloaded.setSizePolicy(size_policy) self.frame_downloaded.setMinimumSize(QSize(0, 150)) self.frame_downloaded.setBaseSize(QSize(0, 100)) self.frame_downloaded.setFrameShape(QFrame.StyledPanel) self.frame_downloaded.setFrameShadow(QFrame.Raised)
def __init__(self, parent=None): super(PlotWidget1D, self).__init__() self.parent = parent # data4d has four dimensions, the first is time self.prefix = 'data' self.data4d = collect("/Fields/", "Phi_global_avg", prefix=self.prefix) self.dataName = "electric potential" sizePolicy = QSizePolicy() sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding) sizePolicy.setVerticalPolicy(QSizePolicy.Expanding) self.setSizePolicy(sizePolicy) self.plotVboxlayout = QVBoxLayout(self) self.tab_widget = QTabWidget(self) self.plotVboxlayout.addWidget(self.tab_widget) # matplotlib figure tab self.sc = MyStaticMplCanvas1D(self, self.data4d, title=self.dataName) self.sc.draw() self.tab_widget.addTab(self.sc, "Figures") # data tab self.data_widget = QTableWidget(self) self.set_data_widget(self.data4d[0, 0, :, :]) self.tab_widget.addTab(self.data_widget, "data") #> The slider self.sp_widget = QWidget(self) self.sp_layout = QHBoxLayout(self.sp_widget) self.label = QLabel("time") self.plainTextEdit = QTextEdit("0") self.plainTextEdit.setMaximumHeight(20) self.plainTextEdit.setMaximumWidth(100) self.sp = QSlider(QtCore.Qt.Horizontal) self.sp.setMinimum(0) self.sp.setMaximum(self.data4d.shape[0] - 1) self.sp.setTickPosition(QSlider.TicksBelow) self.sp.setTickInterval(1) self.sp.valueChanged.connect(self.timeChange) self.sp_layout.addWidget(self.label) self.sp_layout.addWidget(self.plainTextEdit) self.sp_layout.addWidget(self.sp) self.save_widget = QWidget(self) self.save_layout = QHBoxLayout(self.save_widget) self.button_saveFig = QPushButton("Save Figure") self.button_saveAnimation = QPushButton("Save Animation") self.save_layout.addWidget(self.button_saveFig) self.save_layout.addWidget(self.button_saveAnimation) self.button_saveAnimation.clicked.connect(self.save_animation) self.button_saveFig.clicked.connect(self.save_fig) #self.plotVboxlayout.addWidget(self.sc) self.plotVboxlayout.addWidget(self.sp_widget) self.plotVboxlayout.addWidget(self.save_widget)
def __init__(self, *args, **kwargs): super(ItemList, self).__init__(*args, **kwargs) self.setGeometry(869, 6, 144, 511) self.layout = QVBoxLayout() self.setLayout(self.layout) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.tableWidget = QTableWidget() self.tableWidgetSetup()
def __init__(self): super().__init__() self.setMinimumWidth(200) self.box_frame = QVBoxLayout() self.box_frame.setContentsMargins(0, 0, 0, 0) self.icon_bar = QWidget() self.icon_bar_spacer = QWidget() self.icon_bar.setStyleSheet( 'background-color: rgba(77, 103, 125, 0.5);\ border-radius: 10px') #self.icon_bar.setStyleSheet('background-color: \ # qlineargradient(x1:0.5 y1:0, x2:0.5 y2:1, stop:0 #646464, stop:1 #366a97);\ # border-radius: 10px') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) # widget which contains the icons self.iconBox = QVBoxLayout() self.iconBox_spacer = QVBoxLayout() self.iconBox_spacer.addStretch(1) self.iconBox.setContentsMargins(0, 0, 0, 0) self.iconBox_spacer.setContentsMargins(0, 0, 0, 0) self.icon_bar.setLayout(self.iconBox) self.icon_bar_spacer.setLayout(self.iconBox_spacer) self.box_frame.addWidget(self.icon_bar) self.box_frame.addWidget(self.icon_bar_spacer) self.setLayout(self.box_frame) self.addBox() self.tmp_config = None self.tmp_element = None
def __init__(self, url, get_current_proxy, *args, **kwargs): QWebEngineView.__init__(self, *args, **kwargs) # Register proxy authentication handler self.page().proxyAuthenticationRequired.connect( lambda url, auth, proxyHost: self._proxy_auth( get_current_proxy, url, auth, proxyHost)) # Override user agent self.page().profile().setHttpUserAgent( user_agent_with_system( user_agent=self.page().profile().httpUserAgent(), system_name=system.NAME, system_version=system.VERSION)) # Allow sound playback without user gesture self.page().settings().setAttribute( QWebEngineSettings.PlaybackRequiresUserGesture, False) # Load url self.page().setUrl(url) # Shortcut to manually reload self.reload_shortcut = QShortcut('CTRL+R', self) self.reload_shortcut.activated.connect(self.reload) # Check if pages is correctly loaded self.loadFinished.connect(self._load_finished) # Shortcut to close self.quit_shortcut = QShortcut('CTRL+ALT+DELETE', self) self.quit_shortcut.activated.connect(lambda: self.close()) # Stretch the browser policy = QSizePolicy() policy.setVerticalStretch(1) policy.setHorizontalStretch(1) policy.setVerticalPolicy(QSizePolicy.Preferred) policy.setHorizontalPolicy(QSizePolicy.Preferred) self.setSizePolicy(policy)
def __init__(self, positioner_class, *args, **kwargs): """Initialise this segment.""" super().__init__(*args, **kwargs) self.positioner_class = positioner_class sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.init_container() self.init_controls()
def __init__(self): super().__init__() visualize_button = PushButton("Visualization") visualize_button.clicked.connect(self.visualize_button_clicked) # to style it in our stylesheet visualize_button.setObjectName("bigButton") bulk_investigation_button = PushButton("Investigation / Settings") bulk_investigation_button.clicked.connect( self.bulk_investigation_button_clicked) bulk_investigation_button.setObjectName("bigButton") for button in [visualize_button, bulk_investigation_button]: font = button.font() font.setPointSize(30) button.setFont(font) expanding = QSizePolicy() expanding.setHorizontalPolicy(QSizePolicy.Expanding) expanding.setVerticalPolicy(QSizePolicy.Expanding) button.setSizePolicy(expanding) layout = QHBoxLayout() layout.addWidget(visualize_button) layout.addWidget(bulk_investigation_button) layout.setContentsMargins(15, 15, 15, 10) self.setLayout(layout)
def __init__(self, parent, args): super(CentralWidget, self).__init__(parent) self.layout = QHBoxLayout() self.setLayout(self.layout) self.annotator_config = AnnotatorConfigurationModel(args.config) self.annotation = AnnotationModel(args.video, args.output, self.annotator_config) splitter = QSplitter(Qt.Horizontal) self.canvas = ImageCanvas(self, self.annotator_config, self.annotation) splitter.addWidget(self.canvas) self.sidebar = QWidget(self) self.sidebar.setMinimumWidth(450) splitter.addWidget(self.sidebar) self.sidebar_layout = QVBoxLayout() self.sidebar.setLayout(self.sidebar_layout) self.video_control = VideoControl(self, self.annotation, self.canvas) self.sidebar_layout.addWidget(self.video_control) self.config_editor = ConfigurationEditor(self, self.annotator_config) self.sidebar_layout.addWidget(self.config_editor) self.ann_editor = AnnotationEditor(self, self.annotation, self.canvas) self.sidebar_layout.addWidget(self.ann_editor) policy = QSizePolicy() policy.setHorizontalPolicy(QSizePolicy.Maximum) policy.setVerticalPolicy(QSizePolicy.Maximum) self.canvas.setSizePolicy(policy) splitter.setStretchFactor(0, 1) splitter.setStretchFactor(1, 0) self.layout.addWidget(splitter)
def slotUpdate(self): for item in self.m_recreateQueue: par = item.parent w = 0 l = 0 oldRow = -1 if (not par): w = self.q_ptr l = self.m_mainLayout oldRow = self.m_children.indexOf(item) else: w = par.groupBox l = par.layout oldRow = par.children.indexOf(item) if (self.hasHeader(par)): oldRow += 2 if (item.widget): item.widget.setParent(w) elif (item.widgetLabel): item.widgetLabel.setParent(w) else: item.widgetLabel = QLabel(w) item.widgetLabel.setSizePolicy(QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)) item.widgetLabel.setTextFormat(Qt.PlainText) span = 1 if (item.widget): l.addWidget(item.widget, oldRow, 1, 1, 1) elif (item.widgetLabel): l.addWidget(item.widgetLabel, oldRow, 1, 1, 1) else: span = 2 item.label = QLabel(w) item.label.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) l.addWidget(item.label, oldRow, 0, 1, span) self.updateItem(item) self.m_recreateQueue.clear()
def init_form(self): buttons_layout = QGridLayout() button_size_policy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) up_icon = qta.icon('fa.arrow-up') up_button = QPushButton(up_icon, '') up_button.setSizePolicy(button_size_policy) up_button.clicked[bool].connect(self._up) down_icon = qta.icon('fa.arrow-down') down_button = QPushButton(down_icon, '') down_button.setSizePolicy(button_size_policy) down_button.clicked[bool].connect(self._down) left_icon = qta.icon('fa.arrow-left') left_button = QPushButton(left_icon, '') left_button.setSizePolicy(button_size_policy) left_button.clicked[bool].connect(self._left) right_icon = qta.icon('fa.arrow-right') right_button = QPushButton(right_icon, '') right_button.setSizePolicy(button_size_policy) right_button.clicked[bool].connect(self._right) home_icon = qta.icon('fa.home') home_button = QPushButton(home_icon, '') home_button.setSizePolicy(button_size_policy) home_button.clicked[bool].connect(self._home) buttons_layout.addWidget(up_button, 0, 1) buttons_layout.addWidget(down_button, 2, 1) buttons_layout.addWidget(left_button, 1, 0) buttons_layout.addWidget(right_button, 1, 2) buttons_layout.addWidget(home_button, 1, 1) layout = QVBoxLayout() self._step = ControlNumber(label="Step Size", default=self._step, minimum=0, maximum=float('inf'), decimals=5) layout.addLayout(buttons_layout) layout.addWidget(self._step.form) self._form = QWidget() self._form.setLayout(layout) self.label = self._label
def __init__(self, *args): QDialog.__init__(self, *args) self.setWindowTitle(_('About rp9UnpAckEr for FS-UAE')) dlglyt = QVBoxLayout() self.setLayout(dlglyt) info = QWidget() infolyt = QHBoxLayout() info.setLayout(infolyt) dlglyt.addWidget(info) pixmap = QPixmap(str(images_path.joinpath('amigaballsmall.png'))) lbl = QLabel(self) lbl.setPixmap(pixmap) infolyt.addWidget(lbl) text = QWidget() textlyt = QVBoxLayout() text.setLayout(textlyt) infolyt.addWidget(text) appstr = _('rp9UnpAckEr for FS-UAE') l1 = QLabel(appstr + ' ' + const.VERSION) l1.setStyleSheet('font: bold') l2 = QLabel(_('Copyright © Jens Kieselbach')) textlyt.addWidget(l1) textlyt.addWidget(l2) infolyt.addStretch() textedit = QPlainTextEdit(self) try: file = open(resources_path.joinpath('LICENSE'), 'r', encoding="utf-8") textedit.insertPlainText(file.read()) except Exception as e: textedit.insertPlainText(str(e)) textedit.moveCursor(QTextCursor.Start) textedit.setTextInteractionFlags(Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse) textedit.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) textedit.setStyleSheet('font: 9pt "Monospace"') dlglyt.addWidget(textedit) button_box = QDialogButtonBox(QDialogButtonBox.Ok) button_box.accepted.connect(self.accept) dlglyt.addWidget(button_box) self.resize(600, 400)
def __init__(self): super().__init__() loadUi(get_file_realpath("kdDesktopAssistant.ui"), self) icon = QIcon(get_file_realpath('data/image/logo.png')) self.setWindowIcon(icon) self.setWindowFlag(Qt.FramelessWindowHint) # self.setStyleSheet("#MainWindow{border-image:url("+get_file_realpath("data/image/S60922-232113.jpg").replace("\\","/") +");}") self.gl_apps.setAlignment(Qt.AlignTop) # 右键菜单设置 self.pop_menu = QMenu() # TODO 待实现的右键功能:QAction("导出配置"),QAction("导入配置") self.pop_menu_item = [QAction("新增启动项"),QAction("新增桌面"),QAction("设置背景图片"),QAction("修改桌面"),QAction("删除桌面"),QAction("设置为主桌面"),QAction("小程序模式"),QAction("退出")] self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested[QPoint].connect(self.handle_pop_menu) # 系统托盘 sys_tray = QSystemTrayIcon(self) self.sys_tray = sys_tray sys_tray.setIcon(icon) sys_tray.activated.connect(self.sys_tray_handler) sys_tray_menu = QMenu() sys_tray_menu.menu_items =[ QAction("退出",self,triggered=sys.exit)] sys_tray.setContextMenu(sys_tray_menu) sys_tray.show() self.session_bt_size_policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.session_btn_size = QSize(100, 25) # 初始化桌面 print(QDesktopWidget().screenGeometry().height()) print(self.gl_apps.geometry().height()) self.vetical_widget_number = math.floor((QDesktopWidget().screenGeometry().height() - 150) / get_option_int("item_size")) self.home_session = get_option_value("home_session") self.init_session() # 初始化对话框对象 self.dl_launch_item_detail = dl_launch_item_detail() self.session = session() self.wg_catelog = QFrame() self.wg_catelog.setWindowFlags(Qt.Popup) self.gl_catelog = QGridLayout() self.wg_catelog.setLayout(self.gl_catelog) # self.gl_catelog.setWindowOpacity(0.5) # self.wg_catelog.setAttribute(Qt.WA_TranslucentBackground,True ) self.wg_catelog.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool) self.wg_catelog.setAutoFillBackground(True) # self.wg_catelog.setStyleSheet("background-image:url("+get_file_realpath("data/image/bg_catelog.gif") + ");background-size:cover;}") p = QPalette() p.setBrush(QPalette.Background, QBrush(QPixmap(get_file_realpath("data/image/bg_catelog.jpg")))) self.wg_catelog.setPalette(p)
def __init__(self, command, meta, value=None, *args, **kwargs): super(Interlock, self).__init__(*args, **kwargs) self.setMinimumWidth(250) self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)) self.input = None self.groups = [] vl = VLayout() hl = HLayout(0) hl.addWidget(QLabel("<b>{}</b>".format(command))) hl.addStretch(1) hl.addWidget(CmdWikiUrl(command, "Wiki")) vl.addLayout(hl) desc = QLabel(meta['description']) desc.setWordWrap(True) vl.addWidget(desc) self.input = QComboBox() user_data = ["OFF", "ON"] for k, v in meta['parameters'].items(): self.input.addItem("{} {}".format(v['description'], "(default)" if v.get("default") else ""), user_data[int(k)]) if value and value.get("Interlock", "OFF") == "OFF": self.input.setCurrentIndex(0) else: self.input.setCurrentIndex(1) vl.addWidget(self.input) vl_groups = VLayout(0) for i in range(4): le = QLineEdit() le.setAlignment(Qt.AlignCenter) group_value = value.get("Groups", []) if group_value: group_value_list = group_value.split(" ") if i < len(group_value_list): group_value = group_value_list[i] le.setText(group_value) hl_group = HLayout(0) hl_group.addWidgets([QLabel("Group {}".format(i+1)), le]) vl_groups.addLayout(hl_group) self.groups.append(le) vl.addLayout(vl_groups) line = QFrame() line.setFrameStyle(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) vl.addWidget(line) self.setLayout(vl)
def __init__(self, command, meta, value=None, *args, **kwargs): # print(command, value) super(Command, self).__init__(*args, **kwargs) self.setMinimumWidth(250) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)) vl = VLayout() hl = HLayout(0) hl.addWidget(QLabel("<b>{}</b>".format(command))) hl.addStretch(1) hl.addWidget(CmdWikiUrl(command, "Wiki")) hl_input = HLayout(0) if meta['type'] == "select": self.input = QComboBox() for k, v in meta['parameters'].items(): self.input.addItem( "{} {}".format(v['description'], "(default)" if v.get("default") else ""), k) if meta.get('editable'): self.input.setEditable(True) if value: self.input.setCurrentIndex(value) elif meta['type'] == "value": self.input = SpinBox(minimum=int(meta['parameters']['min']), maximum=int(meta['parameters']['max'])) self.input.setMinimumWidth(75) if value: self.input.setValue(value) hl_input.addStretch(1) default = meta['parameters'].get('default') if default: hl_input.addWidget(QLabel("Default: {}".format(default))) hl_input.addWidget(self.input) vl.addLayout(hl) desc = QLabel(meta['description']) desc.setWordWrap(True) vl.addWidget(desc) vl.addLayout(hl_input) line = QFrame() line.setFrameStyle(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) vl.addWidget(line) self.setLayout(vl)
def __init__(self, parent: DataFrameViewer, df, orientation): super().__init__(parent) # Setup self.orientation = orientation self.df = df self.parent = parent self.table = parent.dataView self.setModel(HeaderModel(df, orientation)) # These are used during column resizing self.column_being_resized = None self.resize_start_position = None self.initial_column_width = None # Handled by self.eventFilter() self.setMouseTracking(True) self.viewport().setMouseTracking(True) self.viewport().installEventFilter(self) # Settings self.setSizePolicy( QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)) self.setWordWrap(False) self.setFont(QtGui.QFont("Times", weight=QtGui.QFont.Bold)) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Link selection to DataTable self.selectionModel().selectionChanged.connect( self.on_selectionChanged) self.setSpans() self.initSize() # Orientation specific settings if orientation == Qt.Horizontal: self.setHorizontalScrollBarPolicy( Qt.ScrollBarAlwaysOff ) # Scrollbar is replaced in DataFrameViewer self.horizontalHeader().hide() self.verticalHeader().setDisabled(True) self.verticalHeader().setHighlightSections( False) # Selection lags a lot without this else: self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.verticalHeader().hide() self.horizontalHeader().setDisabled(True) self.horizontalHeader().setHighlightSections( False) # Selection lags a lot without this # Set initial size self.resize(self.sizeHint())
def __init__(self, parent): QWidget.__init__(self, parent) fc_home_recommended_item.__init__(self) self.setupUi(self) self.show_torrent = True self.torrent_info = None self.channel_info = None self.download_uri = None self.dialog = None # Create the category label, shown on cells that display a torrent on the home page self.category_label = QLabel(self) self.category_label.setFixedHeight(24) self.category_label.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)) self.category_label.setStyleSheet(""" border: 2px solid white; border-radius: 12px; background-color: transparent; color: white; padding-left: 4px; padding-right: 4px; font-weight: bold; """) self.category_label.move(QPoint(6, 6)) self.category_label.show() # Create the dark overlay and download button over the thumbnail on hover self.dark_overlay = QWidget(self) self.dark_overlay.setStyleSheet( "background-color: rgba(0, 0, 0, 0.65);") self.dark_overlay.hide() self.download_button = QToolButton(self) self.download_button.setFixedSize(QSize(40, 40)) self.download_button.setStyleSheet(""" QToolButton { background-color: transparent; border: 2px solid white; border-radius: 20px; } QToolButton::hover { border: 2px solid #B5B5B5; } """) self.download_button.setIcon(QIcon(get_image_path('downloads.png'))) self.download_button.setIconSize(QSize(18, 18)) self.download_button.clicked.connect(self.on_download_button_clicked) self.download_button.hide()
def __init__(self, doc, parent=None): super(PartToolBar, self).__init__(parent) self.doc = doc # Set the appearance _sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) _sizePolicy.setHorizontalStretch(0) _sizePolicy.setVerticalStretch(0) _sizePolicy.setHeightForWidth(_sizePolicy.hasHeightForWidth()) self.setSizePolicy(_sizePolicy) self.setOrientation(Qt.Vertical) # default is horizontal # _maxH = 40 if app().prefs.show_icon_labels else 30 # self.setMaximumHeight(_maxH) # horizontal self.setMaximumWidth(36) # vertical self.setIconSize(QSize(20, 20)) self.setLayoutDirection(Qt.LeftToRight) if app().prefs.show_icon_labels: self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) # Toolbar Label self.action_toolbar_label = self.setupLabel("Add\nPart:", "action_new_honeycomb_part") # Origami ToolButton self.add_origamipart_button = self.setupToolButton( "Origami", None, "add_origamipart_button", ":/parttools/new-origami" ) # Origami Part (Honeycomb) self.action_new_honeycomb_part = self.setupAction( "Hcomb", None, "action_new_honeycomb_part", ":/parttools/new-honeycomb", self.add_origamipart_button ) self.action_new_honeycomb_part.triggered.connect(self.doc.controller().actionAddHoneycombPartSlot) # Origami Part (Square) self.action_new_square_part = self.setupAction( "Square", None, "action_new_square_part", ":/parttools/new-square", self.add_origamipart_button ) self.action_new_square_part.triggered.connect(self.doc.controller().actionAddSquarePartSlot) # Origami Part (H-PX) self.action_new_hpx_part = self.setupAction( "H-PX", None, "action_new_honeypx_part", ":/parttools/new-hpx", self.add_origamipart_button ) self.action_new_hpx_part.triggered.connect(self.doc.controller().actionAddHpxPartSlot) # Origami Part (S-px) self.action_new_spx_part = self.setupAction( "Sq-PX", None, "action_new_squarepx_part", ":/parttools/new-spx", self.add_origamipart_button ) self.action_new_spx_part.triggered.connect(self.doc.controller().actionAddSpxPartSlot)
def _setupPreferenceWidgets(self): scanTypeLabels = [ tr("Filename"), tr("Contents"), tr("Folders"), ] self._setupScanTypeBox(scanTypeLabels) self._setupFilterHardnessBox() self.widgetsVLayout.addLayout(self.filterHardnessHLayout) self.widget = QWidget(self) self.widget.setMinimumSize(QSize(0, 136)) self.verticalLayout_4 = QVBoxLayout(self.widget) self._setupAddCheckbox('wordWeightingBox', tr("Word weighting"), self.widget) self.verticalLayout_4.addWidget(self.wordWeightingBox) self._setupAddCheckbox('matchSimilarBox', tr("Match similar words"), self.widget) self.verticalLayout_4.addWidget(self.matchSimilarBox) self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"), self.widget) self.verticalLayout_4.addWidget(self.mixFileKindBox) self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"), self.widget) self.verticalLayout_4.addWidget(self.useRegexpBox) self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"), self.widget) self.verticalLayout_4.addWidget(self.removeEmptyFoldersBox) self.horizontalLayout_2 = QHBoxLayout() self._setupAddCheckbox('ignoreSmallFilesBox', tr("Ignore files smaller than"), self.widget) self.horizontalLayout_2.addWidget(self.ignoreSmallFilesBox) self.sizeThresholdEdit = QLineEdit(self.widget) sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizeThresholdEdit.sizePolicy().hasHeightForWidth()) self.sizeThresholdEdit.setSizePolicy(sizePolicy) self.sizeThresholdEdit.setMaximumSize(QSize(50, 16777215)) self.horizontalLayout_2.addWidget(self.sizeThresholdEdit) self.label_6 = QLabel(self.widget) self.label_6.setText(tr("KB")) self.horizontalLayout_2.addWidget(self.label_6) spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.verticalLayout_4.addLayout(self.horizontalLayout_2) self._setupAddCheckbox( 'ignoreHardlinkMatches', tr("Ignore duplicates hardlinking to the same file"), self.widget ) self.verticalLayout_4.addWidget(self.ignoreHardlinkMatches) self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"), self.widget) self.verticalLayout_4.addWidget(self.debugModeBox) self.widgetsVLayout.addWidget(self.widget) self._setupBottomPart()
def group_settings(self): """Settings group.""" gb_settings = QGroupBox(self.central_widget) gb_settings.setTitle(self.tr('Conversion Presets')) size_policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth( gb_settings.sizePolicy().hasHeightForWidth()) gb_settings.setSizePolicy(size_policy) hl = QHBoxLayout(gb_settings) vl = QVBoxLayout() hl1 = QHBoxLayout() label = QLabel(self.tr('Convert to:')) hl1.addWidget(label) spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) hl1.addItem(spacer_item) vl.addLayout(hl1) self.cb_profiles = QComboBox( gb_settings, statusTip=self.tr('Select the desired video format')) self.cb_profiles.setMinimumSize(QSize(200, 0)) vl.addWidget(self.cb_profiles) hl2 = QHBoxLayout() label = QLabel(self.tr('Target Quality:')) hl2.addWidget(label) spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) hl2.addItem(spacerItem1) vl.addLayout(hl2) self.cb_presets = QComboBox( gb_settings, statusTip=self.tr('Select the desired video quality')) self.cb_presets.setMinimumSize(QSize(200, 0)) self.cb_profiles.currentIndexChanged.connect(partial( self.populate_presets, self.cb_presets)) self.cb_presets.activated.connect(self.update_media_files_status) vl.addWidget(self.cb_presets) hl.addLayout(vl) self.vl1.addWidget(gb_settings)
def refresh(self): libfiles = [] for filename in os.listdir(self.libpath): if filename.endswith('jpeg') or filename.endswith('.jpg'): libfiles.append(os.path.join(self.libpath, filename)) Log.i('files in library:{}'.format(libfiles)) self.libraryWidgets = [] sp = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) sp.setHorizontalStretch(0) sp.setVerticalStretch(0) i = -1 # init i in case of libfiles is [] for i, filepath in enumerate(libfiles): col = i % self.columnSize row = i // self.columnSize widget = GridWidget(self.scrollAreaWidgetContents) sp.setHeightForWidth(widget.sizePolicy().hasHeightForWidth()) widget.setSizePolicy(sp) widget.setContent(filepath, (250, 250)) self.gridLayout.addWidget( widget, row, col, Qt.AlignHCenter | Qt.AlignVCenter ) self.libraryWidgets.append(widget) while i < 11: i += 1 col = i % self.columnSize row = i // self.columnSize widget = GridWidget(self.scrollAreaWidgetContents) sp.setHeightForWidth(widget.sizePolicy().hasHeightForWidth()) widget.setSizePolicy(sp) widget.setContent('', None) self.gridLayout.addWidget( widget, row, col, Qt.AlignHCenter | Qt.AlignVCenter ) self.libraryWidgets.append(widget)
def __init__(self, doc, parent=None): super(PathToolBar, self).__init__(parent) self.doc = doc # Set the appearance _sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) _sizePolicy.setHorizontalStretch(0) _sizePolicy.setVerticalStretch(0) _sizePolicy.setHeightForWidth(_sizePolicy.hasHeightForWidth()) self.setSizePolicy(_sizePolicy) self.setOrientation(Qt.Vertical) # default is horizontal # _maxH = 40 if app().prefs.show_icon_labels else 30 # self.setMaximumHeight(_maxH) # horizontal self.setMaximumWidth(46) # vertical self.setIconSize(QSize(20, 20)) self.setLayoutDirection(Qt.LeftToRight) if app().prefs.show_icon_labels: self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) # Tools self.action_path_select = self.setupAction("Select", "V", "action_path_select", ":/pathtools/select") self.action_path_pencil = self.setupAction("Pencil", "N", "action_path_pencil", ":/pathtools/force") self.action_path_break = self.setupAction("Nick", "K", "action_path_break", ":/pathtools/nick") self.action_path_insertion = self.setupAction("Insert", "I", "action_path_insertion", ":/pathtools/insert") self.action_path_skip = self.setupAction("Skip", "S", "action_path_skip", ":/pathtools/skip") self.action_path_paint = self.setupAction("Paint", "P", "action_path_paint", ":/pathtools/paint") self.action_path_mod = self.setupAction("Mod", "M", "action_path_mod", ":/pathtools/mod") self.action_path_add_seq = self.setupAction("Seq", "A", "action_path_add_seq", ":/pathtools/addseq") # Separator self.addSeparator() # Buttons self.action_autostaple = self.setupAction("Auto", None, "action_autostaple", ":/pathtools/autostaple") self.action_autostaple.triggered.connect(self.doc.controller().actionAutostapleSlot) self.action_renumber = self.setupAction("Rnum", None, "action_renumber", ":/parttools/renum") self.action_renumber.triggered.connect(self.doc.controller().actionRenumberSlot) self.action_svg = self.setupAction("SVG", None, "action_svg", ":/filetools/svg") self.action_svg.triggered.connect(self.doc.controller().actionSVGSlot) self.action_export = self.setupAction("Export", None, "action_export_staples", ":/filetools/export") self.action_export.triggered.connect(self.doc.controller().actionExportSequencesSlot)
def _setupUi(self): self.setWindowTitle(tr("Account Info")) self.resize(274, 121) self.setModal(True) self.verticalLayout = QVBoxLayout(self) self.formLayout = QFormLayout() self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.label = QLabel(tr("Name")) self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label) self.nameEdit = QLineEdit() self.formLayout.setWidget(0, QFormLayout.FieldRole, self.nameEdit) self.label_2 = QLabel(tr("Type")) self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label_2) self.typeComboBoxView = QComboBox() self.formLayout.setWidget(1, QFormLayout.FieldRole, self.typeComboBoxView) self.label_3 = QLabel(tr("Currency")) self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_3) self.currencyComboBoxView = QComboBox() sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.currencyComboBoxView.sizePolicy().hasHeightForWidth()) self.currencyComboBoxView.setSizePolicy(sizePolicy) self.currencyComboBoxView.setEditable(True) self.currencyComboBoxView.setInsertPolicy(QComboBox.NoInsert) self.formLayout.setWidget(2, QFormLayout.FieldRole, self.currencyComboBoxView) self.accountNumberLabel = QLabel(tr("Account #")) self.formLayout.setWidget(3, QFormLayout.LabelRole, self.accountNumberLabel) self.accountNumberEdit = QLineEdit() self.accountNumberEdit.setMaximumSize(QSize(80, 16777215)) self.formLayout.setWidget(3, QFormLayout.FieldRole, self.accountNumberEdit) self.inactiveBox = QCheckBox() self.formLayout.addRow(tr("Inactive:"), self.inactiveBox) self.notesEdit = QPlainTextEdit() self.formLayout.addRow(tr("Notes:"), self.notesEdit) self.verticalLayout.addLayout(self.formLayout) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Save) self.verticalLayout.addWidget(self.buttonBox) self.label.setBuddy(self.nameEdit) self.label_2.setBuddy(self.typeComboBoxView) self.label_3.setBuddy(self.currencyComboBoxView)
def _setupFilterHardnessBox(self): self.filterHardnessHLayout = QHBoxLayout() self.filterHardnessLabel = QLabel(self) self.filterHardnessLabel.setText(tr("Filter Hardness:")) self.filterHardnessLabel.setMinimumSize(QSize(0, 0)) self.filterHardnessHLayout.addWidget(self.filterHardnessLabel) self.filterHardnessVLayout = QVBoxLayout() self.filterHardnessVLayout.setSpacing(0) self.filterHardnessHLayoutSub1 = QHBoxLayout() self.filterHardnessHLayoutSub1.setSpacing(12) self.filterHardnessSlider = QSlider(self) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.filterHardnessSlider.sizePolicy().hasHeightForWidth()) self.filterHardnessSlider.setSizePolicy(sizePolicy) self.filterHardnessSlider.setMinimum(1) self.filterHardnessSlider.setMaximum(100) self.filterHardnessSlider.setTracking(True) self.filterHardnessSlider.setOrientation(Qt.Horizontal) self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessSlider) self.filterHardnessLabel = QLabel(self) self.filterHardnessLabel.setText("100") self.filterHardnessLabel.setMinimumSize(QSize(21, 0)) self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessLabel) self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub1) self.filterHardnessHLayoutSub2 = QHBoxLayout() self.filterHardnessHLayoutSub2.setContentsMargins(-1, 0, -1, -1) self.moreResultsLabel = QLabel(self) self.moreResultsLabel.setText(tr("More Results")) self.filterHardnessHLayoutSub2.addWidget(self.moreResultsLabel) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.filterHardnessHLayoutSub2.addItem(spacerItem) self.fewerResultsLabel = QLabel(self) self.fewerResultsLabel.setText(tr("Fewer Results")) self.filterHardnessHLayoutSub2.addWidget(self.fewerResultsLabel) self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub2) self.filterHardnessHLayout.addLayout(self.filterHardnessVLayout)
def setupUi(self, YaP): YaP.setGeometry(300, 300, 270, 270) YaP.setWindowTitle('YaP') YaP.show() self.gridLayout_3 = QGridLayout(YaP) self.gridLayout_3.setObjectName("gridLayout_3") self.graphicsView = QWidget(YaP) self.graphicsView.setObjectName("graphicsView") self.graphicsView.setGeometry(0, 0, 270, 270) self.graphicsView.setStyleSheet("QWidget { background-color: blue}") self.gridLayout_3.addWidget(self.graphicsView, 1, 0, 1, 6) self.btn_save = QPushButton(YaP) sizePolicy = QSizePolicy( QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btn_save.sizePolicy().hasHeightForWidth()) self.btn_save.setSizePolicy(sizePolicy) self.btn_save.setMaximumSize(QSize(16777215, 16777215)) self.btn_save.setObjectName("btn_save") self.gridLayout_3.addWidget(self.btn_save, 2, 3, 1, 1)
def _setupUi(self): self.setWindowTitle(tr("About {}").format(QCoreApplication.instance().applicationName())) self.resize(400, 190) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.horizontalLayout = QHBoxLayout(self) self.logoLabel = QLabel(self) self.logoLabel.setPixmap(QPixmap(':/%s_big' % self.app.LOGO_NAME)) self.horizontalLayout.addWidget(self.logoLabel) self.verticalLayout = QVBoxLayout() self.nameLabel = QLabel(self) font = QFont() font.setWeight(75) font.setBold(True) self.nameLabel.setFont(font) self.nameLabel.setText(QCoreApplication.instance().applicationName()) self.verticalLayout.addWidget(self.nameLabel) self.versionLabel = QLabel(self) self.versionLabel.setText(tr("Version {}").format(QCoreApplication.instance().applicationVersion())) self.verticalLayout.addWidget(self.versionLabel) self.label_3 = QLabel(self) self.verticalLayout.addWidget(self.label_3) self.label_3.setText(tr("Licensed under GPLv3")) self.label = QLabel(self) font = QFont() font.setWeight(75) font.setBold(True) self.label.setFont(font) self.verticalLayout.addWidget(self.label) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) self.horizontalLayout.addLayout(self.verticalLayout)
def load_settings_widgets_from_pipeline_groupbox(self, position): """ Extracts all widgets from a single algorithm and returns a QBoxLayout Args: alg: the alg instance we extract from Returns: a QBoxLayout containing all widgets for this particular alg. """ alg = self.pipeline.executed_cats[position].active_algorithm print("alg " + str(alg)) print("cat " + str(self.pipeline.executed_cats[position])) empty_flag = True groupOfSliders = QGroupBox() sp = QSizePolicy() sp.setVerticalPolicy(QSizePolicy.Preferred) # groupOfSliders.setSizePolicy(sp) groupOfSliderssLayout = QBoxLayout(QBoxLayout.TopToBottom) groupOfSliderssLayout.setContentsMargins(0, -0, -0, 0) groupOfSliderssLayout.setAlignment(Qt.AlignTop) groupOfSliderssLayout.setSpacing(0) print("Build Slider @ "+ str(position)) # create integer sliders for slider in alg.integer_sliders: empty_flag = False print("slider.value " + str(slider.value)) print("slider " + str(slider)) #print(alg.get_name() + ": add slider (int).") groupOfSliderssLayout.addWidget( SliderWidget(slider.name, slider.lower, slider.upper, slider.step_size, slider.value, slider.set_value, False)) # create float sliders for slider in alg.float_sliders: empty_flag = False #print(alg.get_name() + ": add slider (float).") groupOfSliderssLayout.addWidget( SliderWidget(slider.name, slider.lower, slider.upper, slider.step_size, slider.value, slider.set_value, True), 0, Qt.AlignTop) # create checkboxes for checkbox in alg.checkboxes: empty_flag = False #print(alg.get_name() + ": add checkbox.") groupOfSliderssLayout.addWidget(CheckBoxWidget(checkbox.name, checkbox.value, checkbox.set_value), 0, Qt.AlignTop) # create dropdowns for combobox in alg.drop_downs: empty_flag = False #print(alg.get_name() + ": add combobox.") groupOfSliderssLayout.addWidget( ComboBoxWidget(combobox.name, combobox.options, combobox.set_value, combobox.value), 0, Qt.AlignTop) if empty_flag: label = QLabel() label.setText("This algorithm has no Settings.") groupOfSliderssLayout.addWidget(label, 0, Qt.AlignHCenter) groupOfSliders.setLayout(groupOfSliderssLayout) return groupOfSliders
def _setupUi(self): # has to take place *before* base elements creation self.setWindowTitle("moneyGuru") self.resize(700, 580) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.topBar = QWidget(self.centralwidget) self.horizontalLayout_2 = QHBoxLayout(self.topBar) self.horizontalLayout_2.setContentsMargins(2, 0, 2, 0) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.dateRangeSelectorView = DateRangeSelectorView(self.topBar) self.dateRangeSelectorView.setMinimumSize(QSize(220, 0)) self.horizontalLayout_2.addWidget(self.dateRangeSelectorView) spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.searchLineEdit = SearchEdit(self.topBar) self.searchLineEdit.setMaximumSize(QSize(240, 16777215)) self.horizontalLayout_2.addWidget(self.searchLineEdit) self.verticalLayout.addWidget(self.topBar) self.tabBar = TabBarPlus(self.centralwidget) self.tabBar.setMinimumSize(QSize(0, 20)) self.verticalLayout.addWidget(self.tabBar) self.mainView = QStackedWidget(self.centralwidget) self.verticalLayout.addWidget(self.mainView) # Bottom buttons & status label self.bottomBar = QWidget(self.centralwidget) self.horizontalLayout = QHBoxLayout(self.bottomBar) self.horizontalLayout.setContentsMargins(2, 2, 2, 2) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.newItemButton = QPushButton(self.bottomBar) buttonSizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) buttonSizePolicy.setHorizontalStretch(0) buttonSizePolicy.setVerticalStretch(0) buttonSizePolicy.setHeightForWidth(self.newItemButton.sizePolicy().hasHeightForWidth()) self.newItemButton.setSizePolicy(buttonSizePolicy) self.newItemButton.setIcon(QIcon(QPixmap(':/plus_8'))) self.horizontalLayout.addWidget(self.newItemButton) self.deleteItemButton = QPushButton(self.bottomBar) self.deleteItemButton.setSizePolicy(buttonSizePolicy) self.deleteItemButton.setIcon(QIcon(QPixmap(':/minus_8'))) self.horizontalLayout.addWidget(self.deleteItemButton) self.editItemButton = QPushButton(self.bottomBar) self.editItemButton.setSizePolicy(buttonSizePolicy) self.editItemButton.setIcon(QIcon(QPixmap(':/info_gray_12'))) self.horizontalLayout.addWidget(self.editItemButton) self.horizontalLayout.addItem(horizontalSpacer(size=20)) self.graphVisibilityButton = QPushButton() self.graphVisibilityButton.setSizePolicy(buttonSizePolicy) self.graphVisibilityButton.setIcon(QIcon(QPixmap(':/graph_visibility_on_16'))) self.horizontalLayout.addWidget(self.graphVisibilityButton) self.piechartVisibilityButton = QPushButton() self.piechartVisibilityButton.setSizePolicy(buttonSizePolicy) self.piechartVisibilityButton.setIcon(QIcon(QPixmap(':/piechart_visibility_on_16'))) self.horizontalLayout.addWidget(self.piechartVisibilityButton) self.columnsVisibilityButton = QPushButton() self.columnsVisibilityButton.setSizePolicy(buttonSizePolicy) self.columnsVisibilityButton.setIcon(QIcon(QPixmap(':/columns_16'))) self.horizontalLayout.addWidget(self.columnsVisibilityButton) self.statusLabel = QLabel(tr("Status")) self.statusLabel.setAlignment(Qt.AlignCenter) self.horizontalLayout.addWidget(self.statusLabel) self.verticalLayout.addWidget(self.bottomBar) self.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(self) self.menubar.setGeometry(QRect(0, 0, 700, 20)) self.menuFile = QMenu(tr("File")) self.menuOpenRecent = QMenu(tr("Open Recent")) self.menuView = QMenu(tr("View")) self.menuDateRange = QMenu(tr("Date Range")) self.menuEdit = QMenu(tr("Edit")) self.menuHelp = QMenu(tr("Help")) self.setMenuBar(self.menubar) self.actionOpenDocument = QAction(tr("Open..."), self) self.actionOpenDocument.setShortcut("Ctrl+O") self.actionShowNetWorth = QAction(tr("Net Worth"), self) self.actionShowNetWorth.setShortcut("Ctrl+1") self.actionShowNetWorth.setIcon(QIcon(QPixmap(':/balance_sheet_48'))) self.actionShowProfitLoss = QAction(escapeamp(tr("Profit & Loss")), self) self.actionShowProfitLoss.setShortcut("Ctrl+2") self.actionShowProfitLoss.setIcon(QIcon(QPixmap(':/income_statement_48'))) self.actionShowTransactions = QAction(tr("Transactions"), self) self.actionShowTransactions.setShortcut("Ctrl+3") self.actionShowTransactions.setIcon(QIcon(QPixmap(':/transaction_table_48'))) self.actionShowSelectedAccount = QAction(tr("Show Account"), self) self.actionShowSelectedAccount.setShortcut("Ctrl+]") self.actionNewItem = QAction(tr("New Item"), self) self.actionNewItem.setShortcut("Ctrl+N") self.actionDeleteItem = QAction(tr("Remove Selected"), self) self.actionEditItem = QAction(tr("Show Info"), self) self.actionEditItem.setShortcut("Ctrl+I") self.actionToggleGraph = QAction(tr("Toggle Graph"), self) self.actionToggleGraph.setShortcut("Ctrl+Alt+G") self.actionTogglePieChart = QAction(tr("Toggle Pie Chart"), self) self.actionTogglePieChart.setShortcut("Ctrl+Alt+P") self.actionMoveUp = QAction(tr("Move Up"), self) self.actionMoveUp.setShortcut("Ctrl++") self.actionMoveDown = QAction(tr("Move Down"), self) self.actionMoveDown.setShortcut("Ctrl+-") self.actionNavigateBack = QAction(tr("Go Back"), self) self.actionNavigateBack.setShortcut("Ctrl+[") self.actionNewAccountGroup = QAction(tr("New Account Group"), self) self.actionNewAccountGroup.setShortcut("Ctrl+Shift+N") self.actionShowNextView = QAction(tr("Next View"), self) self.actionShowNextView.setShortcut("Ctrl+Shift+]") self.actionShowPreviousView = QAction(tr("Previous View"), self) self.actionShowPreviousView.setShortcut("Ctrl+Shift+[") self.actionNewDocument = QAction(tr("New Document"), self) self.actionImport = QAction(tr("Import..."), self) self.actionImport.setShortcut("Ctrl+Alt+I") self.actionExport = QAction(tr("Export..."), self) self.actionExport.setShortcut("Ctrl+Alt+E") self.actionSave = QAction(tr("Save"), self) self.actionSave.setShortcut("Ctrl+S") self.actionSaveAs = QAction(tr("Save As..."), self) self.actionSaveAs.setShortcut("Ctrl+Shift+S") self.actionAbout = QAction(tr("About moneyGuru"), self) self.actionToggleReconciliationMode = QAction(tr("Toggle Reconciliation Mode"), self) self.actionToggleReconciliationMode.setShortcut("Ctrl+Shift+R") self.actionToggleAccountExclusion = QAction(tr("Toggle Exclusion Status of Account"), self) self.actionToggleAccountExclusion.setShortcut("Ctrl+Shift+X") self.actionShowSchedules = QAction(tr("Schedules"), self) self.actionShowSchedules.setShortcut("Ctrl+4") self.actionShowSchedules.setIcon(QIcon(QPixmap(':/schedules_48'))) self.actionReconcileSelected = QAction(tr("Reconcile Selection"), self) self.actionReconcileSelected.setShortcut("Ctrl+R") self.actionMakeScheduleFromSelected = QAction(tr("Make Schedule from Selected"), self) self.actionMakeScheduleFromSelected.setShortcut("Ctrl+M") self.actionShowPreferences = QAction(tr("Preferences..."), self) self.actionPrint = QAction(tr("Print..."), self) self.actionPrint.setShortcut("Ctrl+P") self.actionQuit = QAction(tr("Quit moneyGuru"), self) self.actionQuit.setShortcut("Ctrl+Q") self.actionUndo = QAction(tr("Undo"), self) self.actionUndo.setShortcut("Ctrl+Z") self.actionRedo = QAction(tr("Redo"), self) self.actionRedo.setShortcut("Ctrl+Y") self.actionShowHelp = QAction(tr("moneyGuru Help"), self) self.actionShowHelp.setShortcut("F1") self.actionDuplicateTransaction = QAction(tr("Duplicate Transaction"), self) self.actionDuplicateTransaction.setShortcut("Ctrl+D") self.actionJumpToAccount = QAction(tr("Jump to Account..."), self) self.actionJumpToAccount.setShortcut("Ctrl+Shift+A") self.actionNewTab = QAction(tr("New Tab"), self) self.actionNewTab.setShortcut("Ctrl+T") self.actionCloseTab = QAction(tr("Close Tab"), self) self.actionCloseTab.setShortcut("Ctrl+W") self.menuFile.addAction(self.actionNewDocument) self.menuFile.addAction(self.actionNewTab) self.menuFile.addAction(self.actionOpenDocument) self.menuFile.addAction(self.menuOpenRecent.menuAction()) self.menuFile.addAction(self.actionImport) self.menuFile.addSeparator() self.menuFile.addAction(self.actionCloseTab) self.menuFile.addAction(self.actionSave) self.menuFile.addAction(self.actionSaveAs) self.menuFile.addAction(self.actionExport) self.menuFile.addAction(self.actionPrint) self.menuFile.addAction(self.actionQuit) self.menuView.addAction(self.actionShowNetWorth) self.menuView.addAction(self.actionShowProfitLoss) self.menuView.addAction(self.actionShowTransactions) self.menuView.addAction(self.actionShowSchedules) self.menuView.addAction(self.actionShowPreviousView) self.menuView.addAction(self.actionShowNextView) self.menuView.addAction(self.menuDateRange.menuAction()) self.menuView.addAction(self.actionShowPreferences) self.menuView.addAction(self.actionToggleGraph) self.menuView.addAction(self.actionTogglePieChart) self.menuEdit.addAction(self.actionNewItem) self.menuEdit.addAction(self.actionNewAccountGroup) self.menuEdit.addAction(self.actionDeleteItem) self.menuEdit.addAction(self.actionEditItem) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionMoveUp) self.menuEdit.addAction(self.actionMoveDown) self.menuEdit.addAction(self.actionDuplicateTransaction) self.menuEdit.addAction(self.actionMakeScheduleFromSelected) self.menuEdit.addAction(self.actionReconcileSelected) self.menuEdit.addAction(self.actionToggleReconciliationMode) self.menuEdit.addAction(self.actionToggleAccountExclusion) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionShowSelectedAccount) self.menuEdit.addAction(self.actionNavigateBack) self.menuEdit.addAction(self.actionJumpToAccount) self.menuEdit.addSeparator() self.menuEdit.addAction(self.actionUndo) self.menuEdit.addAction(self.actionRedo) self.menuHelp.addAction(self.actionShowHelp) self.menuHelp.addAction(self.actionAbout) mainmenus = [self.menuFile, self.menuEdit, self.menuView, self.menuHelp] for menu in mainmenus: self.menubar.addAction(menu.menuAction()) setAccelKeys(menu) setAccelKeys(self.menubar) self.tabBar.setMovable(True) self.tabBar.setTabsClosable(True) self.tabBar.setExpanding(False) seq = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Right) self._shortcutNextTab = QShortcut(seq, self) seq = QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Left) self._shortcutPrevTab = QShortcut(seq, self)
def __init__(self, parent=None, doc_ctrlr=None): super(DocumentWindow, self).__init__(parent) self.controller = doc_ctrlr doc = doc_ctrlr.document() self.setupUi(self) self.settings = QSettings() self._readSettings() # Slice setup self.slicescene = QGraphicsScene(parent=self.slice_graphics_view) self.sliceroot = SliceRootItem(rect=self.slicescene.sceneRect(),\ parent=None,\ window=self,\ document=doc) self.sliceroot.setFlag(QGraphicsItem.ItemHasNoContents) self.slicescene.addItem(self.sliceroot) self.slicescene.setItemIndexMethod(QGraphicsScene.NoIndex) assert self.sliceroot.scene() == self.slicescene self.slice_graphics_view.setScene(self.slicescene) self.slice_graphics_view.scene_root_item = self.sliceroot self.slice_graphics_view.setName("SliceView") self.slice_tool_manager = SliceToolManager(self) # Part toolbar splitter_size_policy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) splitter_size_policy.setHorizontalStretch(0) splitter_size_policy.setVerticalStretch(0) splitter_size_policy.setHeightForWidth(self.main_splitter.sizePolicy().hasHeightForWidth()) self.slice_splitter.setSizePolicy(splitter_size_policy) self.slice_splitter.setFrameShape(QFrame.NoFrame) self.slice_splitter.setFrameShadow(QFrame.Plain) self.slice_splitter.setLineWidth(0) self.slice_splitter.setOrientation(Qt.Horizontal) self.slice_splitter.setOpaqueResize(False) self.slice_splitter.setHandleWidth(0) self.part_toolbar = PartToolBar(doc, self.slice_splitter) self.slice_splitter.addWidget(self.slice_graphics_view) # reorder # Path setup self.pathscene = QGraphicsScene(parent=self.path_graphics_view) self.pathroot = PathRootItem(rect=self.pathscene.sceneRect(),\ parent=None,\ window=self,\ document=doc) self.pathroot.setFlag(QGraphicsItem.ItemHasNoContents) self.pathscene.addItem(self.pathroot) self.pathscene.setItemIndexMethod(QGraphicsScene.NoIndex) assert self.pathroot.scene() == self.pathscene self.path_graphics_view.setScene(self.pathscene) self.path_graphics_view.scene_root_item = self.pathroot self.path_graphics_view.setScaleFitFactor(0.9) self.path_graphics_view.setName("PathView") # Path toolbar self.path_splitter.setSizePolicy(splitter_size_policy) self.path_splitter.setFrameShape(QFrame.NoFrame) self.path_splitter.setFrameShadow(QFrame.Plain) self.path_splitter.setLineWidth(0) self.path_splitter.setOrientation(Qt.Horizontal) self.path_splitter.setOpaqueResize(False) self.path_splitter.setHandleWidth(0) self.path_splitter.setObjectName("path_splitter") self.path_splitter.setSizes([600,0]) # for path_splitter horizontal self.path_splitter.addWidget(self.selectionToolBar) self.path_toolbar = PathToolBar(doc, self.path_splitter) # self.path_splitter.addWidget(self.path_graphics_view) # reorder self.path_color_panel = ColorPanel() self.path_graphics_view.toolbar = self.path_color_panel # HACK for customqgraphicsview self.pathscene.addItem(self.path_color_panel) self.path_tool_manager = PathToolManager(self, self.path_toolbar) self.slice_tool_manager.path_tool_manager = self.path_tool_manager self.path_tool_manager.slice_tool_manager = self.slice_tool_manager # set the selection filter default doc.documentSelectionFilterChangedSignal.emit(["endpoint", "scaffold", "staple", "xover"]) self.path_graphics_view.setupGL() self.slice_graphics_view.setupGL() if GL: pass # self.slicescene.drawBackground = self.drawBackgroundGL # self.pathscene.drawBackground = self.drawBackgroundGL # Edit menu setup self.actionUndo = doc_ctrlr.undoStack().createUndoAction(self) self.actionRedo = doc_ctrlr.undoStack().createRedoAction(self) self.actionUndo.setText(QApplication.translate( "MainWindow", "Undo", None)) self.actionUndo.setShortcut(QApplication.translate( "MainWindow", "Ctrl+Z", None)) self.actionRedo.setText(QApplication.translate( "MainWindow", "Redo", None)) self.actionRedo.setShortcut(QApplication.translate( "MainWindow", "Ctrl+Shift+Z", None)) self.sep = QAction(self) self.sep.setSeparator(True) self.menu_edit.insertAction(self.action_modify, self.sep) self.menu_edit.insertAction(self.sep, self.actionRedo) self.menu_edit.insertAction(self.actionRedo, self.actionUndo) self.main_splitter.setSizes([250, 550]) # balance main_splitter size self.statusBar().showMessage("")
def _setupUi(self): self.setWindowTitle(tr("Schedule Info")) self.resize(469, 416) self.setModal(True) self.verticalLayout_2 = QVBoxLayout(self) self.tabWidget = QTabWidget(self) self.tab = QWidget() self.formLayout = QFormLayout(self.tab) self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.label_2 = QLabel(tr("Start Date:")) self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label_2) self.startDateEdit = DateEdit(self.tab) self.startDateEdit.setMaximumSize(QSize(120, 16777215)) self.formLayout.setWidget(0, QFormLayout.FieldRole, self.startDateEdit) self.label_7 = QLabel(tr("Repeat Type:")) self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label_7) self.repeatTypeComboBoxView = QComboBox(self.tab) self.formLayout.setWidget(1, QFormLayout.FieldRole, self.repeatTypeComboBoxView) self.label_8 = QLabel(tr("Every:")) self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_8) self.horizontalLayout_2 = QHBoxLayout() self.repeatEverySpinBox = QSpinBox(self.tab) self.repeatEverySpinBox.setMinimum(1) self.horizontalLayout_2.addWidget(self.repeatEverySpinBox) self.repeatEveryDescLabel = QLabel(self.tab) self.horizontalLayout_2.addWidget(self.repeatEveryDescLabel) self.formLayout.setLayout(2, QFormLayout.FieldRole, self.horizontalLayout_2) self.label_9 = QLabel(tr("Stop Date:")) self.formLayout.setWidget(3, QFormLayout.LabelRole, self.label_9) self.stopDateEdit = DateEdit(self.tab, is_clearable=True) self.stopDateEdit.setMaximumSize(QSize(120, 16777215)) self.formLayout.setWidget(3, QFormLayout.FieldRole, self.stopDateEdit) self.label_3 = QLabel(tr("Description:")) self.formLayout.setWidget(4, QFormLayout.LabelRole, self.label_3) self.descriptionEdit = DescriptionEdit(self.model.completable_edit, self.tab) self.formLayout.setWidget(4, QFormLayout.FieldRole, self.descriptionEdit) self.label_4 = QLabel(tr("Payee:")) self.formLayout.setWidget(5, QFormLayout.LabelRole, self.label_4) self.payeeEdit = PayeeEdit(self.model.completable_edit, self.tab) self.formLayout.setWidget(5, QFormLayout.FieldRole, self.payeeEdit) self.label_5 = QLabel(tr("Check #:")) self.formLayout.setWidget(6, QFormLayout.LabelRole, self.label_5) self.checkNoEdit = QLineEdit(self.tab) self.checkNoEdit.setMaximumSize(QSize(120, 16777215)) self.formLayout.setWidget(6, QFormLayout.FieldRole, self.checkNoEdit) self.amountLabel = QLabel(tr("Transfers:")) self.formLayout.setWidget(7, QFormLayout.LabelRole, self.amountLabel) self.splitTableView = TableView(self.tab) self.splitTableView.setMinimumSize(QSize(355, 0)) self.splitTableView.setAcceptDrops(True) self.splitTableView.setDragEnabled(True) self.splitTableView.setDragDropOverwriteMode(False) self.splitTableView.setDragDropMode(QAbstractItemView.InternalMove) self.splitTableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.splitTableView.horizontalHeader().setDefaultSectionSize(40) self.splitTableView.verticalHeader().setVisible(False) self.splitTableView.verticalHeader().setDefaultSectionSize(18) self.formLayout.setWidget(7, QFormLayout.FieldRole, self.splitTableView) self.widget = QWidget(self.tab) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth()) self.widget.setSizePolicy(sizePolicy) self.horizontalLayout_6 = QHBoxLayout(self.widget) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_6.addItem(spacerItem) self.addSplitButton = QPushButton(self.widget) icon = QIcon() icon.addPixmap(QPixmap(':/plus_8'), QIcon.Normal, QIcon.Off) self.addSplitButton.setIcon(icon) self.horizontalLayout_6.addWidget(self.addSplitButton) self.removeSplitButton = QPushButton(self.widget) icon1 = QIcon() icon1.addPixmap(QPixmap(':/minus_8'), QIcon.Normal, QIcon.Off) self.removeSplitButton.setIcon(icon1) self.horizontalLayout_6.addWidget(self.removeSplitButton) self.formLayout.setWidget(8, QFormLayout.FieldRole, self.widget) self.tabWidget.addTab(self.tab, tr("Info")) self.tab_3 = QWidget() self.horizontalLayout_5 = QHBoxLayout(self.tab_3) self.notesEdit = QPlainTextEdit(self.tab_3) self.horizontalLayout_5.addWidget(self.notesEdit) self.tabWidget.addTab(self.tab_3, tr("Notes")) self.verticalLayout_2.addWidget(self.tabWidget) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Save) self.verticalLayout_2.addWidget(self.buttonBox) self.label_2.setBuddy(self.startDateEdit) self.label_7.setBuddy(self.repeatTypeComboBoxView) self.label_3.setBuddy(self.descriptionEdit) self.label_4.setBuddy(self.payeeEdit) self.label_5.setBuddy(self.checkNoEdit) self.tabWidget.setCurrentIndex(0)
def __init__(self): super().__init__() #window self.resize(475, 465) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setMinimumSize(QtCore.QSize(475, 465)) self.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.setWindowIcon(QIcon('icon')) self.widget = QWidget(self) self.widget.setGeometry(QtCore.QRect(9, 9, 454, 442)) self.verticalLayout = QVBoxLayout(self) self.addlink_verticalLayout = QVBoxLayout() self.addlink_verticalLayout.setContentsMargins(0, 0, 0, 0) self.link_frame = QFrame(self) self.link_frame.setFrameShape(QFrame.StyledPanel) self.link_frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_2 = QHBoxLayout(self.link_frame) self.link_horizontalLayout = QHBoxLayout() #link self.link_label = QLabel(self.link_frame) self.link_horizontalLayout.addWidget(self.link_label) self.link_lineEdit = QLineEdit(self.link_frame) self.link_horizontalLayout.addWidget(self.link_lineEdit) self.horizontalLayout_2.addLayout(self.link_horizontalLayout) self.addlink_verticalLayout.addWidget(self.link_frame) #proxy self.proxy_verticalLayout = QVBoxLayout() self.proxy_checkBox = QCheckBox(self.widget) self.proxy_verticalLayout.addWidget(self.proxy_checkBox) self.proxy_frame = QFrame(self.widget) self.proxy_frame.setFrameShape(QFrame.StyledPanel) self.proxy_frame.setFrameShadow(QFrame.Raised) self.gridLayout = QGridLayout(self.proxy_frame) self.ip_lineEdit = QLineEdit(self.proxy_frame) self.ip_lineEdit.setInputMethodHints(QtCore.Qt.ImhNone) self.gridLayout.addWidget(self.ip_lineEdit, 0, 1, 1, 1) self.proxy_pass_label = QLabel(self.proxy_frame) self.gridLayout.addWidget(self.proxy_pass_label, 2, 2, 1, 1) self.proxy_pass_lineEdit = QLineEdit(self.proxy_frame) self.proxy_pass_lineEdit.setEchoMode(QLineEdit.Password) self.gridLayout.addWidget(self.proxy_pass_lineEdit, 2, 3, 1, 1) self.ip_label = QLabel(self.proxy_frame) self.gridLayout.addWidget(self.ip_label, 0, 0, 1, 1) self.proxy_user_lineEdit = QLineEdit(self.proxy_frame) self.gridLayout.addWidget(self.proxy_user_lineEdit, 0, 3, 1, 1) self.proxy_user_label = QLabel(self.proxy_frame) self.gridLayout.addWidget(self.proxy_user_label, 0, 2, 1, 1) self.port_label = QLabel(self.proxy_frame) self.gridLayout.addWidget(self.port_label, 2, 0, 1, 1) self.port_spinBox = QSpinBox(self.proxy_frame) self.port_spinBox.setMaximum(9999) self.port_spinBox.setSingleStep(1) self.gridLayout.addWidget(self.port_spinBox, 2, 1, 1, 1) self.proxy_verticalLayout.addWidget(self.proxy_frame) self.addlink_verticalLayout.addLayout(self.proxy_verticalLayout) #download UserName & Password self.download_horizontalLayout = QHBoxLayout() self.download_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.download_verticalLayout = QVBoxLayout() self.download_checkBox = QCheckBox(self.widget) self.download_verticalLayout.addWidget(self.download_checkBox) self.download_frame = QFrame(self.widget) self.download_frame.setFrameShape(QFrame.StyledPanel) self.download_frame.setFrameShadow(QFrame.Raised) self.gridLayout_2 = QGridLayout(self.download_frame) self.download_user_lineEdit = QLineEdit(self.download_frame) self.gridLayout_2.addWidget(self.download_user_lineEdit, 0, 1, 1, 1) self.download_user_label = QLabel(self.download_frame) self.gridLayout_2.addWidget(self.download_user_label, 0, 0, 1, 1) self.download_pass_label = QLabel(self.download_frame) self.gridLayout_2.addWidget(self.download_pass_label, 1, 0, 1, 1) self.download_pass_lineEdit = QLineEdit(self.download_frame) self.download_pass_lineEdit.setEchoMode(QLineEdit.Password) self.gridLayout_2.addWidget(self.download_pass_lineEdit, 1, 1, 1, 1) self.download_verticalLayout.addWidget(self.download_frame) self.download_horizontalLayout.addLayout(self.download_verticalLayout) #select folder self.folder_frame = QFrame(self.widget) self.folder_frame.setFrameShape(QFrame.StyledPanel) self.folder_frame.setFrameShadow(QFrame.Raised) self.gridLayout_3 = QGridLayout(self.folder_frame) self.download_folder_lineEdit = QLineEdit(self.folder_frame) self.gridLayout_3.addWidget(self.download_folder_lineEdit, 2, 0, 1, 1) self.folder_pushButton = QPushButton(self.folder_frame) self.gridLayout_3.addWidget(self.folder_pushButton, 3, 0, 1, 1) self.folder_pushButton.setIcon(QIcon(icons + 'folder')) self.folder_label = QLabel(self.folder_frame) self.folder_label.setAlignment(QtCore.Qt.AlignCenter) self.gridLayout_3.addWidget(self.folder_label, 1, 0, 1, 1) self.download_horizontalLayout.addWidget(self.folder_frame) self.addlink_verticalLayout.addLayout(self.download_horizontalLayout) #start time self.time_limit_horizontalLayout = QHBoxLayout() self.time_limit_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.start_verticalLayout = QVBoxLayout() self.start_checkBox = QCheckBox(self.widget) self.start_verticalLayout.addWidget(self.start_checkBox) self.start_frame = QFrame(self.widget) self.start_frame.setFrameShape(QFrame.StyledPanel) self.start_frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_5 = QHBoxLayout(self.start_frame) self.start_hour_spinBox = QSpinBox(self.start_frame) self.start_hour_spinBox.setMaximum(23) self.horizontalLayout_5.addWidget(self.start_hour_spinBox) self.start_label = QLabel(self.start_frame) self.horizontalLayout_5.addWidget(self.start_label) self.start_minute_spinBox = QSpinBox(self.start_frame) self.start_minute_spinBox.setMaximum(59) self.horizontalLayout_5.addWidget(self.start_minute_spinBox) self.start_verticalLayout.addWidget(self.start_frame) self.time_limit_horizontalLayout.addLayout(self.start_verticalLayout) #end time self.end_verticalLayout = QVBoxLayout() self.end_checkBox = QCheckBox(self.widget) self.end_verticalLayout.addWidget(self.end_checkBox) self.end_frame = QFrame(self.widget) self.end_frame.setFrameShape(QFrame.StyledPanel) self.end_frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_6 = QHBoxLayout(self.end_frame) self.end_hour_spinBox = QSpinBox(self.end_frame) self.end_hour_spinBox.setMaximum(23) self.horizontalLayout_6.addWidget(self.end_hour_spinBox) self.end_label = QLabel(self.end_frame) self.horizontalLayout_6.addWidget(self.end_label) self.end_minute_spinBox = QSpinBox(self.end_frame) self.end_minute_spinBox.setMaximum(59) self.horizontalLayout_6.addWidget(self.end_minute_spinBox) self.end_verticalLayout.addWidget(self.end_frame) self.time_limit_horizontalLayout.addLayout(self.end_verticalLayout) #limit Speed self.limit_verticalLayout = QVBoxLayout() self.limit_checkBox = QCheckBox(self.widget) self.limit_verticalLayout.addWidget(self.limit_checkBox) self.limit_frame = QFrame(self.widget) self.limit_frame.setFrameShape(QFrame.StyledPanel) self.limit_frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_4 = QHBoxLayout(self.limit_frame) self.limit_spinBox = QSpinBox(self.limit_frame) self.limit_spinBox.setMinimum(1) self.limit_spinBox.setMaximum(1023) self.horizontalLayout_4.addWidget(self.limit_spinBox) self.limit_comboBox = QComboBox(self.limit_frame) self.limit_comboBox.addItem("") self.limit_comboBox.addItem("") self.horizontalLayout_4.addWidget(self.limit_comboBox) self.limit_verticalLayout.addWidget(self.limit_frame) self.time_limit_horizontalLayout.addLayout(self.limit_verticalLayout) self.addlink_verticalLayout.addLayout(self.time_limit_horizontalLayout) #number of connections self.connections_horizontalLayout = QHBoxLayout() self.connections_horizontalLayout.setContentsMargins(-1, 10, -1, -1) self.connections_frame = QFrame(self.widget) self.connections_frame.setFrameShape(QFrame.StyledPanel) self.connections_frame.setFrameShadow(QFrame.Raised) self.horizontalLayout_3 = QHBoxLayout(self.connections_frame) self.connections_label = QLabel(self.connections_frame) self.horizontalLayout_3.addWidget(self.connections_label) self.connections_spinBox = QSpinBox(self.connections_frame) self.connections_spinBox.setMinimum(1) self.connections_spinBox.setMaximum(16) self.connections_spinBox.setProperty("value", 16) self.horizontalLayout_3.addWidget(self.connections_spinBox) self.connections_horizontalLayout.addWidget(self.connections_frame) self.buttons_horizontalLayout = QHBoxLayout() #ok cancel buttons self.cancel_pushButton = QPushButton(self.widget) self.cancel_pushButton.setIcon(QIcon(icons + 'remove')) self.ok_pushButton = QPushButton(self.widget) self.ok_pushButton.setIcon(QIcon(icons + 'ok')) self.buttons_horizontalLayout.addWidget(self.ok_pushButton) self.buttons_horizontalLayout.addWidget(self.cancel_pushButton) self.connections_horizontalLayout.addLayout(self.buttons_horizontalLayout) self.addlink_verticalLayout.addLayout(self.connections_horizontalLayout) self.verticalLayout.addLayout(self.addlink_verticalLayout) self.proxy_checkBox.raise_() self.download_checkBox.raise_() self.folder_frame.raise_() self.download_frame.raise_() self.limit_checkBox.raise_() self.connections_frame.raise_() self.limit_frame.raise_() self.cancel_pushButton.raise_() self.ok_pushButton.raise_() self.link_frame.raise_() self.proxy_frame.raise_() self.start_checkBox.raise_() self.end_checkBox.raise_() self.start_frame.raise_() self.end_frame.raise_() #labels self.setWindowTitle( "Enter Your Link") self.link_label.setText( "Download Link : ") self.proxy_checkBox.setText( "Proxy") self.proxy_pass_label.setText( "Proxy PassWord : "******"IP :") self.proxy_user_label.setText( "Proxy UserName : "******"Port:") self.download_checkBox.setText( "Download UserName and PassWord") self.download_user_label.setText( "Download UserName : "******"Download PassWord : "******"Change Download Folder") self.folder_label.setText( "Download Folder : ") self.start_checkBox.setText( "Start Time") self.start_label.setText( ":") self.end_checkBox.setText( "End Time") self.end_label.setText( ":") self.limit_checkBox.setText( "Limit Speed") self.limit_comboBox.setItemText(0, "KB/S") self.limit_comboBox.setItemText(1, "MB/S") self.connections_label.setText( "Number Of Connections :") self.cancel_pushButton.setText( "Cancel") self.ok_pushButton.setText( "OK")
def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget (QWidget) """ super(PreviewerHTML, self).__init__(parent) self.__layout = QVBoxLayout(self) self.titleLabel = QLabel(self) self.titleLabel.setWordWrap(True) self.titleLabel.setTextInteractionFlags(Qt.NoTextInteraction) self.__layout.addWidget(self.titleLabel) try: from PyQt5.QtWebEngineWidgets import QWebEngineView self.previewView = QWebEngineView(self) self.__usesWebKit = False except ImportError: from PyQt5.QtWebKitWidgets import QWebPage, QWebView self.previewView = QWebView(self) self.previewView.page().setLinkDelegationPolicy( QWebPage.DelegateAllLinks) self.__usesWebKit = True sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.previewView.sizePolicy().hasHeightForWidth()) self.previewView.setSizePolicy(sizePolicy) self.previewView.setContextMenuPolicy(Qt.NoContextMenu) self.previewView.setUrl(QUrl("about:blank")) self.__layout.addWidget(self.previewView) self.jsCheckBox = QCheckBox(self.tr("Enable JavaScript"), self) self.jsCheckBox.setToolTip(self.tr( "Select to enable JavaScript for HTML previews")) self.__layout.addWidget(self.jsCheckBox) self.ssiCheckBox = QCheckBox(self.tr("Enable Server Side Includes"), self) self.ssiCheckBox.setToolTip(self.tr( "Select to enable support for Server Side Includes")) self.__layout.addWidget(self.ssiCheckBox) self.jsCheckBox.clicked[bool].connect(self.on_jsCheckBox_clicked) self.ssiCheckBox.clicked[bool].connect(self.on_ssiCheckBox_clicked) self.previewView.titleChanged.connect(self.on_previewView_titleChanged) if self.__usesWebKit: self.previewView.linkClicked.connect( self.on_previewView_linkClicked) self.jsCheckBox.setChecked( Preferences.getUI("ShowFilePreviewJS")) self.ssiCheckBox.setChecked( Preferences.getUI("ShowFilePreviewSSI")) self.__scrollBarPositions = {} self.__vScrollBarAtEnd = {} self.__hScrollBarAtEnd = {} self.__processingThread = PreviewProcessingThread() self.__processingThread.htmlReady.connect(self.__setHtml) self.__previewedPath = None self.__previewedEditor = None
def _setupUi(self): self.setWindowTitle(tr("Custom Date Range")) self.resize(292, 86) self.setModal(True) self.verticalLayout = QVBoxLayout(self) self.label = QLabel(tr("Select start and end dates from your custom range:")) self.verticalLayout.addWidget(self.label) self.horizontalLayout = QHBoxLayout() self.label_2 = QLabel(tr("Start:")) self.horizontalLayout.addWidget(self.label_2) self.startDateEdit = DateEdit(self) self.horizontalLayout.addWidget(self.startDateEdit) self.label_3 = QLabel(tr("End:")) self.horizontalLayout.addWidget(self.label_3) self.endDateEdit = DateEdit(self) self.horizontalLayout.addWidget(self.endDateEdit) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QHBoxLayout() self.label_4 = QLabel(tr("Save this range under slot:")) self.horizontalLayout_2.addWidget(self.label_4) self.slotIndexComboBox = QComboBox(self) sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.slotIndexComboBox.sizePolicy().hasHeightForWidth()) self.slotIndexComboBox.setSizePolicy(sizePolicy) for s in [tr("None"), tr("#1"), tr("#2"), tr("#3")]: self.slotIndexComboBox.addItem(s) self.horizontalLayout_2.addWidget(self.slotIndexComboBox) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.verticalLayout.addLayout(self.horizontalLayout_2) self.horizontalLayout_3 = QHBoxLayout() self.label_5 = QLabel(tr("Under the name:")) self.horizontalLayout_3.addWidget(self.label_5) self.slotNameEdit = QLineEdit(self) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.slotNameEdit.sizePolicy().hasHeightForWidth()) self.slotNameEdit.setSizePolicy(sizePolicy) self.horizontalLayout_3.addWidget(self.slotNameEdit) self.verticalLayout.addLayout(self.horizontalLayout_3) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox)