def __init__(self): # Call superclass constructor super().__init__() # Title image title_image = QLabel() pixmap = QPixmap(TITLE_IMAGE_PATH) title_image.setPixmap(pixmap) title_image.setAlignment(Qt.AlignLeft | Qt.AlignBottom) # Author title_author = QLabel(AUTHOR, self) # Version title_version = QLabel(VERSION, self) # Set up layout vbox = QVBoxLayout() vbox.addWidget(title_image) vbox.addWidget(title_author) vbox.addWidget(title_version) hbox = QHBoxLayout() hbox.insertStretch(0) hbox.addLayout(vbox) self.setLayout(hbox)
def __init__(self, parent, title): QWidget.__init__(self, parent) self.setWindowFlags(Qt.FramelessWindowHint) self.setAutoFillBackground(True) self.setBackgroundRole(QPalette.Highlight) minmax = QToolButton(self) minmax.setIcon( QIcon(join(config.ASSETS_DIR, "minimize_window_white.png"))) minmax.setMinimumHeight(10) minmax.setWindowOpacity(0.5) minmax.clicked.connect(self.minimax) minmax.setAttribute(Qt.WA_MacShowFocusRect, 0) close = QToolButton(self) close.setIcon(QIcon(join(config.ASSETS_DIR, "close_window_white.png"))) close.setMinimumHeight(10) close.setWindowOpacity(0.5) close.clicked.connect(self.close) close.setAttribute(Qt.WA_MacShowFocusRect, 0) self.label = QLabel(self) self.label.setText(title) hbox = QHBoxLayout(self) hbox.addWidget(self.label) hbox.addWidget(minmax) hbox.addWidget(close) hbox.insertStretch(1, 500) hbox.setSpacing(0) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def _setup_ui(self): # self self.setMaximumHeight(17) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) layout.addWidget(get_spell_icon(self.spell.spell_icon), 0) layout.setSpacing(0) # progress bar self.progress = QProgressBar() self.progress.setTextVisible(False) if self.spell.type: self.progress.setObjectName('SpellWidgetProgressBarGood') else: self.progress.setObjectName('SpellWidgetProgressBarBad') # labels progress_layout = QHBoxLayout(self.progress) progress_layout.setContentsMargins(5, 0, 5, 0) self._name_label = QLabel(string.capwords(self.spell.name), self.progress) self._name_label.setObjectName('SpellWidgetNameLabel') progress_layout.addWidget(self._name_label) progress_layout.insertStretch(2, 1) self._time_label = QLabel('', self.progress) self._time_label.setObjectName('SpellWidgetTimeLabel') progress_layout.addWidget(self._time_label) layout.addWidget(self.progress, 1)
def __init__(self, name="base", timestamp=None, duration=6, icon=1, style=None, sound=None, direction=NDirection.DOWN, persistent=False, noreplace=False): super().__init__() self.name = name self.timestamp = timestamp if timestamp else datetime.datetime.now() self._duration = duration self._icon = icon self._style = style self._active = True self._sound = sound self._alert = False self._direction = direction self.persistent = persistent self.noreplace = noreplace self.progress = QProgressBar() # ui self.setMaximumHeight(18) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) layout.addWidget(get_spell_icon(self._icon), 0) # progress bar self.progress = QProgressBar() self.progress.setTextVisible(False) self.progress.setAutoFillBackground(True) # labels progress_layout = QHBoxLayout(self.progress) progress_layout.setContentsMargins(5, 0, 5, 0) self._name_label = QLabel(string.capwords(self.name), self.progress) progress_layout.addWidget(self._name_label) progress_layout.insertStretch(2, 1) self._time_label = QLabel('', self.progress) progress_layout.addWidget(self._time_label) layout.addWidget(self.progress, 1) # init self._calculate(self.timestamp) self.setStyleSheet(self._style) self._update()
def __init__(self): super().__init__() self.setWindowTitle('nParse Settings') layout = QVBoxLayout() top_layout = QHBoxLayout() self._list_widget = QListWidget() self._list_widget.setObjectName('SettingsList') self._list_widget.setSelectionMode(QListWidget.SingleSelection) self._list_widget.currentItemChanged.connect(self._switch_stack) self._widget_stack = QStackedWidget() self._widget_stack.setObjectName('SettingsStack') top_layout.addWidget(self._list_widget, 0) top_layout.addWidget(self._widget_stack, 1) settings = self._create_settings() if settings: for setting_name, stacked_widget in settings: self._list_widget.addItem(QListWidgetItem(setting_name)) self._widget_stack.addWidget(stacked_widget) self._list_widget.setCurrentRow(0) self._list_widget.setMaximumWidth( self._list_widget.minimumSizeHint().width()) self._list_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) buttons = QWidget() buttons.setObjectName('SettingsButtons') buttons_layout = QHBoxLayout() buttons_layout.setContentsMargins(0, 0, 0, 0) save_button = QPushButton('Save') save_button.setAutoDefault(False) save_button.clicked.connect(self._save) buttons_layout.addWidget(save_button) cancel_button = QPushButton('Cancel') cancel_button.setAutoDefault(False) cancel_button.clicked.connect(self._cancelled) buttons_layout.addWidget(cancel_button) buttons_layout.insertStretch(0) buttons.setLayout(buttons_layout) layout.addLayout(top_layout, 1) layout.addWidget(buttons, 0) self.setLayout(layout) self._set_values()
def create_meteorological_data_box(self) -> None: self.gbox_metdata = QGroupBox('Meteorological Data') vbox_metdata = QVBoxLayout() self.gbox_metdata.setLayout(vbox_metdata) gbox_avail_metdata = QGroupBox('Available Datasets') vbox_metdata.addWidget(gbox_avail_metdata) vbox_avail_metdata = QVBoxLayout() gbox_avail_metdata.setLayout(vbox_avail_metdata) self.tree_met_data = QTreeWidget() self.tree_met_data.setMinimumHeight(200) vbox_avail_metdata.addWidget(self.tree_met_data) self.tree_met_data.setHeaderItem( QTreeWidgetItem(['Product / Time Range'])) self.tree_met_data.setSelectionMode( QAbstractItemView.ContiguousSelection) self.tree_met_data.setContextMenuPolicy(Qt.CustomContextMenu) self.tree_met_data.customContextMenuRequested.connect( self.on_tree_met_data_open_context_menu) gbox_datasets_spec = QGroupBox('Selection') vbox_metdata.addWidget(gbox_datasets_spec) vbox_datasets_spec = QVBoxLayout() gbox_datasets_spec.setLayout(vbox_datasets_spec) selection_button = QPushButton('Use Dataset Selection from List') selection_button.clicked.connect( self.on_met_data_selection_button_clicked) vbox_datasets_spec.addWidget(selection_button) custom_button = QPushButton('Use Custom Dataset') custom_button.clicked.connect(self.on_met_data_custom_button_clicked) vbox_datasets_spec.addWidget(custom_button) hbox_current_config = QHBoxLayout() vbox_datasets_spec.addLayout(hbox_current_config) hbox_current_config.addWidget(QLabel('Current Configuration: ')) self.met_data_current_config_label = QLabel() hbox_current_config.addWidget(self.met_data_current_config_label) self.set_met_data_current_config_label() hbox_current_config.insertStretch(-1)
def __init__(self, parent=None): super().__init__(parent) self.mainwindow = parent self.newwindow = QToolButton(self) icon = QIcon() icon.addPixmap(QPixmap("icons/windowadd.png"), QIcon.Normal, QIcon.Off) self.newwindow.setIcon(icon) self.newwindow.setStyleSheet("background-color: rgba(255,255,255,0)") #self.newwindow.setIcon(QIcon("/windowadd.png")) #self.newwindow.setIconSize(QSize(40,0)) self.minimize = QToolButton(self) icon = QIcon() icon.addPixmap(QPixmap("icons/windowminimize.png"), QIcon.Normal, QIcon.Off) self.minimize.setIcon(icon) self.minimize.setStyleSheet("background-color: rgba(255,255,255,0)") #self.minimize.setIcon(QIcon("/windowminimize.png")) self.maximize = QToolButton(self) icon = QIcon() icon.addPixmap(QPixmap("icons/windowmin.png"), QIcon.Normal, QIcon.Off) self.maximize.setIcon(icon) self.maximize.setStyleSheet("background-color: rgba(255,255,255,0)") #self.maximize.setIcon(QIcon("/windowmin.png")) close = QToolButton(self) icon = QIcon() icon.addPixmap(QPixmap("icons/windowclose.png"), QIcon.Normal, QIcon.Off) close.setIcon(icon) close.setStyleSheet("background-color: rgba(255,255,255,0)") #close.setIcon(QIcon("/windowclose.png")) hbox = QHBoxLayout(self) hbox.setContentsMargins(-1, -1, -1, 0) hbox.addWidget(self.newwindow) hbox.addWidget(self.minimize) hbox.addWidget(self.maximize) hbox.addWidget(close) hbox.insertStretch(1, 500) self.setFixedHeight(20) self.newwindow.clicked.connect(self.newWindow) self.minimize.clicked.connect(self.showSmall) self.maximize.clicked.connect(self.showMaxRestore) close.clicked.connect(self.close) self.maxNormal = False
class TableView(QDialog): def __init__(self, mainWindow, *args): QDialog.__init__(self, *args) self.setWindowFlags(QtCore.Qt.WindowFlags() | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint) self.mainWindow = mainWindow self.mainLayout = QVBoxLayout(self) self.tableLayout = QVBoxLayout(self) self.buttonLayout = QHBoxLayout(self) self.table = QTableWidget(parent=self) self.table.addAction(CopySelectedCellsAction(self.table)) self.table.addAction(PasteSelectedCellsAction(self.table)) self.shortcut_close = QShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_T, self) self.shortcut_close.activated.connect(self.close) self.canvas = self.mainWindow._centralWidget.canvas self.data = self.canvas.prepare_export_counts() self.nrows = len(self.data) self.ncols = len(self.data[0]) self.table.setRowCount(self.nrows) self.table.setColumnCount(self.ncols) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.applyButton = QPushButton("Apply", self) self.applyButton.setSizePolicy(sizePolicy) self.closeButton = QPushButton("Close", self) self.closeButton.setSizePolicy(sizePolicy) self.exportButton = QPushButton("Export", self) self.exportButton.setSizePolicy(sizePolicy) self.tableLayout.addWidget(self.table) self.buttonLayout.addWidget(self.exportButton, QtCore.Qt.AlignRight) self.buttonLayout.addWidget(self.closeButton, QtCore.Qt.AlignRight) self.buttonLayout.addWidget(self.applyButton, QtCore.Qt.AlignRight) self.buttonLayout.insertStretch(0, 1) self.mainLayout.addLayout(self.tableLayout) self.mainLayout.addLayout(self.buttonLayout) self.setLayout(self.mainLayout) self.setData() self.closeButton.clicked.connect(self.close) self.applyButton.clicked.connect(self.applyChanges) self.exportButton.clicked.connect(self.export) # format table self.table.resizeColumnsToContents() self.table.resizeRowsToContents() self.table.horizontalHeader().setStretchLastSection(False) self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Interactive) h = self.table.verticalHeader().length() w = self.table.horizontalHeader().length() screenSize = QApplication.primaryScreen().physicalSize() self.resize(min(int(w*1.3), screenSize.width()), min(int(h*1.3), screenSize.height())) self.setWindowTitle("BOM Preview") self.ctrl = False def setData(self): flags = QtCore.Qt.ItemFlags() flags != QtCore.Qt.ItemIsEditable for ir in range(1, self.nrows): for ic in range(self.ncols): newitem = QTableWidgetItem(str(self.data[ir][ic]).strip(), QtCore.Qt.ItemIsSelectable) if ic in [0, 1, 2, 4, 5]:# newitem.setFlags(flags) self.table.setItem(ir - 1, ic, newitem) self.table.setHorizontalHeaderLabels(self.data[0]) def applyChanges(self): header = self.data[0] data = [] for ir in range(self.nrows): row = {} for ic in range(self.ncols): item = self.table.item(ir, ic) if item: text = item.text() else: text = "" row[header[ic]] = text data.append(row) self.canvas.apply_attribute_data(data) def export(self): self.applyChanges() self.mainWindow._centralWidget.point_widget.export_counts()
def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) pasteBox = QHBoxLayout() self.textLine = QLineEdit() self.textLine.setToolTip('Current Director/selected File') self.pasteButton = QToolButton() self.pasteButton.setEnabled(False) self.pasteButton.setText('Paste') self.pasteButton.setToolTip( 'Copy file from copy path to current directory/file') self.pasteButton.clicked.connect(self.paste) self.pasteButton.hide() pasteBox.addWidget(self.textLine) pasteBox.addWidget(self.pasteButton) self.copyBox = QFrame() hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.copyLine = QLineEdit() self.copyLine.setToolTip('File path to copy from, when pasting') self.copyButton = QToolButton() self.copyButton.setText('Copy') self.copyButton.setToolTip('Record current file as copy path') self.copyButton.clicked.connect(self.recordCopyPath) hbox.addWidget(self.copyButton) hbox.addWidget(self.copyLine) self.copyBox.setLayout(hbox) self.copyBox.hide() self.model = QFileSystemModel() self.model.setRootPath(QDir.currentPath()) self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files) self.model.setNameFilterDisables(False) self.model.rootPathChanged.connect(self.folderChanged) self.list = QListView() self.list.setModel(self.model) self.list.resize(640, 480) self.list.clicked[QModelIndex].connect(self.listClicked) self.list.activated.connect(self._getPathActivated) self.list.setAlternatingRowColors(True) self.list.hide() self.table = QTableView() self.table.setModel(self.model) self.table.resize(640, 480) self.table.clicked[QModelIndex].connect(self.listClicked) self.table.activated.connect(self._getPathActivated) self.table.setAlternatingRowColors(True) header = self.table.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.Stretch) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(3, QHeaderView.ResizeToContents) header.swapSections(1, 3) header.setSortIndicator(1, Qt.AscendingOrder) self.table.setSortingEnabled(True) self.table.setColumnHidden(2, True) # type self.table.verticalHeader().setVisible(False) # row count header self.cb = QComboBox() self.cb.currentIndexChanged.connect(self.filterChanged) self.fillCombobox(INFO.PROGRAM_FILTERS_EXTENSIONS) self.cb.setMinimumHeight(30) self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2 = QToolButton() self.button2.setText('User') self.button2.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2.setMinimumSize(60, 30) self.button2.setToolTip( 'Jump to User directory.\nLong press for Options.') self.button2.clicked.connect(self.onJumpClicked) self.button3 = QToolButton() self.button3.setText('Add Jump') self.button3.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button3.setMinimumSize(60, 30) self.button3.setToolTip('Add current directory to jump button list') self.button3.clicked.connect(self.onActionClicked) self.settingMenu = QMenu(self) self.button2.setMenu(self.settingMenu) hbox = QHBoxLayout() hbox.addWidget(self.button2) hbox.addWidget(self.button3) hbox.insertStretch(2, stretch=0) hbox.addWidget(self.cb) windowLayout = QVBoxLayout() windowLayout.addLayout(pasteBox) windowLayout.addWidget(self.copyBox) windowLayout.addWidget(self.list) windowLayout.addWidget(self.table) windowLayout.addLayout(hbox) self.setLayout(windowLayout) self.show()
class HostInformationWidget(QWidget): def __init__(self, informationTab, parent=None): QWidget.__init__(self, parent) self.informationTab = informationTab self.setupLayout() self.updateFields() # set default values def setupLayout(self): self.HostStatusLabel = QLabel() self.HostStateLabel = QLabel() self.HostStateText = QLabel() self.HostStateLayout = QHBoxLayout() self.HostStateLayout.addSpacing(20) self.HostStateLayout.addWidget(self.HostStateLabel) self.HostStateLayout.addWidget(self.HostStateText) self.HostStateLayout.addStretch() self.OpenPortsLabel = QLabel() self.OpenPortsText = QLabel() self.OpenPortsLayout = QHBoxLayout() self.OpenPortsLayout.addSpacing(20) self.OpenPortsLayout.addWidget(self.OpenPortsLabel) self.OpenPortsLayout.addWidget(self.OpenPortsText) self.OpenPortsLayout.addStretch() self.ClosedPortsLabel = QLabel() self.ClosedPortsText = QLabel() self.ClosedPortsLayout = QHBoxLayout() self.ClosedPortsLayout.addSpacing(20) self.ClosedPortsLayout.addWidget(self.ClosedPortsLabel) self.ClosedPortsLayout.addWidget(self.ClosedPortsText) self.ClosedPortsLayout.addStretch() self.FilteredPortsLabel = QLabel() self.FilteredPortsText = QLabel() self.FilteredPortsLayout = QHBoxLayout() self.FilteredPortsLayout.addSpacing(20) self.FilteredPortsLayout.addWidget(self.FilteredPortsLabel) self.FilteredPortsLayout.addWidget(self.FilteredPortsText) self.FilteredPortsLayout.addStretch() ################### self.AddressLabel = QLabel() self.IP4Label = QLabel() self.IP4Text = QLabel() self.IP4Layout = QHBoxLayout() self.IP4Layout.addSpacing(20) self.IP4Layout.addWidget(self.IP4Label) self.IP4Layout.addWidget(self.IP4Text) self.IP4Layout.addStretch() self.IP6Label = QLabel() self.IP6Text = QLabel() self.IP6Layout = QHBoxLayout() self.IP6Layout.addSpacing(20) self.IP6Layout.addWidget(self.IP6Label) self.IP6Layout.addWidget(self.IP6Text) self.IP6Layout.addStretch() self.MacLabel = QLabel() self.MacText = QLabel() self.MacLayout = QHBoxLayout() self.MacLayout.addSpacing(20) self.MacLayout.addWidget(self.MacLabel) self.MacLayout.addWidget(self.MacText) self.MacLayout.addStretch() self.dummyLabel = QLabel() self.dummyText = QLabel() self.dummyLayout = QHBoxLayout() self.dummyLayout.addSpacing(20) self.dummyLayout.addWidget(self.dummyLabel) self.dummyLayout.addWidget(self.dummyText) self.dummyLayout.addStretch() ######### self.OSLabel = QLabel() self.OSNameLabel = QLabel() self.OSNameText = QLabel() self.OSNameLayout = QHBoxLayout() self.OSNameLayout.addSpacing(20) self.OSNameLayout.addWidget(self.OSNameLabel) self.OSNameLayout.addWidget(self.OSNameText) self.OSNameLayout.addStretch() self.OSAccuracyLabel = QLabel() self.OSAccuracyText = QLabel() self.OSAccuracyLayout = QHBoxLayout() self.OSAccuracyLayout.addSpacing(20) self.OSAccuracyLayout.addWidget(self.OSAccuracyLabel) self.OSAccuracyLayout.addWidget(self.OSAccuracyText) self.OSAccuracyLayout.addStretch() font = QFont() # in each different section font.setBold(True) self.HostStatusLabel.setText('Host Status') self.HostStatusLabel.setFont(font) self.HostStateLabel.setText("State:") self.OpenPortsLabel.setText('Open Ports:') self.ClosedPortsLabel.setText('Closed Ports:') self.FilteredPortsLabel.setText('Filtered Ports:') self.AddressLabel.setText('Addresses') self.AddressLabel.setFont(font) self.IP4Label.setText('IPv4:') self.IP6Label.setText('IPv6:') self.MacLabel.setText('MAC:') self.OSLabel.setText('Operating System') self.OSLabel.setFont(font) self.OSNameLabel.setText('Name:') self.OSAccuracyLabel.setText('Accuracy:') ######### self.vlayout_1 = QVBoxLayout() self.vlayout_2 = QVBoxLayout() self.vlayout_3 = QVBoxLayout() self.hlayout_1 = QHBoxLayout() self.vlayout_1.addWidget(self.HostStatusLabel) self.vlayout_1.addLayout(self.HostStateLayout) self.vlayout_1.addLayout(self.OpenPortsLayout) self.vlayout_1.addLayout(self.ClosedPortsLayout) self.vlayout_1.addLayout(self.FilteredPortsLayout) self.vlayout_2.addWidget(self.AddressLabel) self.vlayout_2.addLayout(self.IP4Layout) self.vlayout_2.addLayout(self.IP6Layout) self.vlayout_2.addLayout(self.MacLayout) self.vlayout_2.addLayout(self.dummyLayout) self.hlayout_1.addLayout(self.vlayout_1) self.hlayout_1.addSpacing(20) self.hlayout_1.addLayout(self.vlayout_2) self.vlayout_3.addWidget(self.OSLabel) self.vlayout_3.addLayout(self.OSNameLayout) self.vlayout_3.addLayout(self.OSAccuracyLayout) self.vlayout_3.addStretch() self.vlayout_4 = QVBoxLayout() self.vlayout_4.addLayout(self.hlayout_1) self.vlayout_4.addSpacing(10) self.vlayout_4.addLayout(self.vlayout_3) self.hlayout_4 = QHBoxLayout(self.informationTab) self.hlayout_4.addLayout(self.vlayout_4) self.hlayout_4.insertStretch(-1, 1) self.hlayout_4.addStretch() def updateFields(self, status='', openPorts='', closedPorts='', filteredPorts='', ipv4='', ipv6='', macaddr='', osMatch='', osAccuracy=''): self.HostStateText.setText(str(status)) self.OpenPortsText.setText(str(openPorts)) self.ClosedPortsText.setText(str(closedPorts)) self.FilteredPortsText.setText(str(filteredPorts)) self.IP4Text.setText(str(ipv4)) self.IP6Text.setText(str(ipv6)) self.MacText.setText(str(macaddr)) self.OSNameText.setText(str(osMatch)) self.OSAccuracyText.setText(str(osAccuracy))
def initUi(self): outerFrame = QtWidgets.QFrame() outerFrame.setFrameShape(QFrame.Panel) outerFrame.setFrameShadow(QFrame.Raised) outerFrameLayout = QHBoxLayout() outerFrame.setLayout(outerFrameLayout) outerFrameLayout.setSpacing(10) outerFrameLayout.setContentsMargins(20, 20, 20, 20) # Left top right then bottom frameDouble = QtWidgets.QFrame() doubleFrameSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) doubleFrameSizePolicy.setHorizontalStretch(1) frameDouble.setSizePolicy(doubleFrameSizePolicy) frameDoubleVLayout = QVBoxLayout() frameDouble.setLayout(frameDoubleVLayout) innerFrame = QtWidgets.QFrame(self, objectName="innerFrameLogin") innerFrame.setFrameShape(QFrame.Panel) innerFrame.setFrameShadow(QFrame.Raised) innerFrame.setStyleSheet("""QFrame{ background: rgba(90,90,90,100); border-width: 1px; border-style: outset; border-color: rgba(130,130,130,100); border-radius: 35px;}""") innerFrameLayout = QVBoxLayout() innerFrameLayout.setSpacing(30) innerFrameLayout.setContentsMargins(20, 20, 20, 20) innerFrame.setLayout(innerFrameLayout) formBlock = QtWidgets.QWidget() formBlockSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) formBlock.setSizePolicy(formBlockSizePolicy) formBlockLayout = QGridLayout() formBlock.setLayout(formBlockLayout) loginLabel = QtWidgets.QLabel("Forgot it Huh?", objectName="loginLabel") loginLabel.setAlignment(Qt.AlignCenter) loginLabel.setStyleSheet("""font-size: 100px;""") loginLabelSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) loginLabel.setSizePolicy(loginLabelSizePolicy) #Makes logo label and places logo image inside it logoLabel = QtWidgets.QLabel() logoLabel.setStyleSheet("""background: rgba(90,90,90,0); border-color: rgba(140,140,140,0);""") logoLabelSizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed) #Horizontal,vertical logoLabel.setSizePolicy(logoLabelSizePolicy) pixmap = QPixmap("Logo.ico") logoLabel.setPixmap(pixmap) logoLabel.setAlignment(Qt.AlignCenter) widgetExplanation = QtWidgets.QWidget( ) #below border-radius 35px works but onnly for username widgetExplanation.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 30px; """) widgetExplanationSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetExplanation.setSizePolicy(widgetExplanationSizePolicy) explanationLayout = QHBoxLayout() widgetExplanation.setLayout(explanationLayout) explanationLabel = QtWidgets.QLabel( "Type in your credentials below to reset your password. You will recieve an email \n confirmation if the procedure is successfull." ) explanationLabel.setStyleSheet("""color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") explanationLayout.addWidget(explanationLabel) widgetUsername = QtWidgets.QWidget( ) #below border-radius 35px works but onnly for username widgetUsername.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 30px; """) widgetUsernameSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetUsername.setSizePolicy(widgetUsernameSizePolicy) usernameLayout = QHBoxLayout() widgetUsername.setLayout(usernameLayout) widgetEmail = QtWidgets.QWidget() widgetEmail.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 30px; """) widgetEmailSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetEmail.setSizePolicy(widgetEmailSizePolicy) emailLayout = QHBoxLayout() widgetEmail.setLayout(emailLayout) widgetPassword = QtWidgets.QWidget() widgetPassword.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 30px; """) widgetPasswordSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetPassword.setSizePolicy(widgetPasswordSizePolicy) passwordLayout = QHBoxLayout() widgetPassword.setLayout(passwordLayout) widgetConfirmPassword = QtWidgets.QWidget() widgetConfirmPassword.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 30px; """) widgetConfirmPasswordSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetConfirmPassword.setSizePolicy(widgetConfirmPasswordSizePolicy) confirmPasswordLayout = QHBoxLayout() widgetConfirmPassword.setLayout(confirmPasswordLayout) self.usernameLineEditLogin = QtWidgets.QLineEdit() self.usernameLineEditLogin.setStyleSheet( """color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") self.usernameLineEditLogin.setPlaceholderText("Username") self.emailLineEditLogin = QtWidgets.QLineEdit() self.emailLineEditLogin.setStyleSheet("""color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") self.emailLineEditLogin.setPlaceholderText("Email Address") self.passwordLineEditLogin = QtWidgets.QLineEdit() self.passwordLineEditLogin.setPlaceholderText("Password") self.passwordLineEditLogin.setEchoMode(2) self.passwordLineEditLogin.setStyleSheet( """color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") self.confirmPasswordLineEditLogin = QtWidgets.QLineEdit() self.confirmPasswordLineEditLogin.setPlaceholderText( "Confirm Password") self.confirmPasswordLineEditLogin.setEchoMode(2) self.confirmPasswordLineEditLogin.setStyleSheet( """color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") usernameLogoLabel = QtWidgets.QLabel() usernameLogoLabel.setStyleSheet("""background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") usernameLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical usernameLogoLabel.setSizePolicy(usernameLogoLabelSizePolicy) pixmap = QPixmap("48px.png") usernameLogoLabel.setPixmap(pixmap) usernameLogoLabel.setAlignment(Qt.AlignCenter) emailLogoLabel = QtWidgets.QLabel() emailLogoLabel.setStyleSheet("""background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") emailLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical emailLogoLabel.setSizePolicy(emailLogoLabelSizePolicy) pixmap = QPixmap("email2_48px.png") emailLogoLabel.setPixmap(pixmap) emailLogoLabel.setAlignment(Qt.AlignCenter) passwordLogoLabel = QtWidgets.QLabel() passwordLogoLabel.setStyleSheet("""background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") passwordLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical passwordLogoLabel.setSizePolicy(passwordLogoLabelSizePolicy) pixmap = QPixmap("lock2_48px.png") passwordLogoLabel.setPixmap(pixmap) passwordLogoLabel.setAlignment(Qt.AlignCenter) confirmPasswordLogoLabel = QtWidgets.QLabel() confirmPasswordLogoLabel.setStyleSheet( """background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") confirmPasswordLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical confirmPasswordLogoLabel.setSizePolicy( confirmPasswordLogoLabelSizePolicy) pixmap = QPixmap("lock2_48px.png") confirmPasswordLogoLabel.setPixmap(pixmap) confirmPasswordLogoLabel.setAlignment(Qt.AlignCenter) usernameLayout.addWidget(usernameLogoLabel) usernameLayout.addWidget(self.usernameLineEditLogin) emailLayout.addWidget(emailLogoLabel) emailLayout.addWidget(self.emailLineEditLogin) passwordLayout.addWidget(passwordLogoLabel) passwordLayout.addWidget(self.passwordLineEditLogin) confirmPasswordLayout.addWidget(confirmPasswordLogoLabel) confirmPasswordLayout.addWidget(self.confirmPasswordLineEditLogin) showPasswordCheck = QtWidgets.QCheckBox("Show Password") showPasswordCheck.setStyleSheet("""QCheckBox::indicator { border: 3px solid #5A5A5A; background: none; } """) resetButton = QtWidgets.QPushButton("Reset Password") resetButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical resetButton.setSizePolicy(resetButtonSizePolicy) resetButton.setStyleSheet(""" QPushButton{font-size: 15px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 16px; min-height:30px; max-height:35px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) resetButton.clicked.connect(self.resetButtonClicked) returnButton = QtWidgets.QPushButton("Return to Mainpage") returnButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical returnButton.setSizePolicy(returnButtonSizePolicy) returnButton.setStyleSheet(""" QPushButton{font-size: 15px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 16px; min-height:30px; max-height:35px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) returnButton.clicked.connect(self.returnButtonClicked) formBlockLayout.addWidget(widgetExplanation, 0, 0, 1, 2) formBlockLayout.addWidget(widgetUsername, 1, 0, 1, 2) formBlockLayout.addWidget(widgetEmail, 2, 0, 1, 2) formBlockLayout.addWidget(widgetPassword, 3, 0, 1, 2) formBlockLayout.addWidget(widgetConfirmPassword, 4, 0, 1, 2) formBlockLayout.addWidget(showPasswordCheck, 5, 0, 1, 2, Qt.AlignRight) formBlockLayout.addWidget(resetButton, 6, 0, 1, 1) formBlockLayout.addWidget(returnButton, 6, 1, 1, 1) innerFrameLayout.addWidget(logoLabel, Qt.AlignCenter) innerFrameLayout.addWidget(formBlock) frameDoubleVLayout.addWidget(loginLabel, Qt.AlignCenter) frameDoubleVLayout.addWidget(innerFrame, Qt.AlignCenter) outerFrameLayout.insertStretch(0, 1) outerFrameLayout.addWidget(frameDouble) outerFrameLayout.addStretch(1) mainGrid = QGridLayout() mainGrid.setSpacing(10) mainGrid.addWidget(outerFrame) outerWidgetBox = QtWidgets.QWidget() outerWidgetBox.setLayout(mainGrid) self.setCentralWidget(outerWidgetBox) self.setWindowTitle("Forgot Password") self.showMaximized()
class BrowserWidget(QWidget): def __init__(self, parent): super(BrowserWidget, self).__init__(parent) self.browser = WebView(self) self.__layout() self.__bookmark = None self.filename = '' def __layout(self): self.browser.loadFinished.connect(self.__onLoadFinished) self.__vbox = QVBoxLayout() self.__ctrls_layout = QHBoxLayout() self.__edit_url = QLineEdit() self.__ctrls_layout.addWidget(self.__edit_url) # self.__btn_go = QPushButton('Go') # self.__btn_go.clicked.connect(self.__on_btn_go) # self.__ctrls_layout.addWidget(self.__btn_go) # https://www.learnpyqt.com/examples/mooseache/ # https://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum self.__btn_back = QPushButton() self.__btn_back.setIcon(self.style().standardIcon(QStyle.SP_ArrowLeft)) self.__btn_back.setFlat(True) self.__btn_back.setToolTip('Back') self.__btn_back.clicked.connect(self.browser.back) self.__ctrls_layout.addWidget(self.__btn_back) self.__btn_forward = QPushButton() self.__btn_forward.setIcon(self.style().standardIcon( QStyle.SP_ArrowForward)) self.__btn_forward.setFlat(True) self.__btn_forward.setToolTip('Forward') self.__btn_forward.clicked.connect(self.browser.forward) self.__ctrls_layout.addWidget(self.__btn_forward) self.__btn_reload = QPushButton() self.__btn_reload.setIcon(self.style().standardIcon( QStyle.SP_BrowserReload)) self.__btn_reload.setFlat(True) self.__btn_reload.setToolTip('Reload') self.__btn_reload.clicked.connect(self.browser.reload) self.__ctrls_layout.addWidget(self.__btn_reload) self.__btn_stop = QPushButton() self.__btn_stop.setIcon(self.style().standardIcon( QStyle.SP_BrowserStop)) self.__btn_stop.setFlat(True) self.__btn_stop.setToolTip('Stop') self.__btn_stop.clicked.connect(self.browser.stop) self.__ctrls_layout.addWidget(self.__btn_stop) self.browser.urlChanged.connect(self.update_urlbar) self.__label_zoom = QLabel() self.__label_zoom.setText('Zoom') self.__label_zoom.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.__ctrls_layout.addWidget(self.__label_zoom, alignment=Qt.AlignRight) self.__spin_zoom = QDoubleSpinBox() self.__spin_zoom.setRange(0.125, 15) self.__spin_zoom.setValue(1.0) self.__spin_zoom.setSingleStep(0.125) self.__spin_zoom.valueChanged.connect(self.__spin_zoom_valueChanged) self.__spin_zoom.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) # https://stackoverflow.com/questions/53573382/pyqt5-set-widget-size-to-minimum-and-fix self.__ctrls_layout.addWidget(self.__spin_zoom, alignment=Qt.AlignRight) self.__vbox.addLayout(self.__ctrls_layout) self.__vbox.addWidget(self.browser) self.setLayout(self.__vbox) self.__ctrl_plus_shortcut = QShortcut(QKeySequence("Ctrl++"), self) self.__ctrl_plus_shortcut.activated.connect(self.__on_ctrl_plus) self.__ctrl_minus_shortcut = QShortcut(QKeySequence("Ctrl+-"), self) self.__ctrl_minus_shortcut.activated.connect(self.__on_ctrl_minus) def keyPressEvent(self, event): if event.key() == Qt.Key_Return: self.__on_btn_go() def update_urlbar(self, q): """ if q.scheme() == 'https': # Secure padlock icon self.httpsicon.setPixmap( QPixmap( os.path.join('icons','lock-ssl.png') ) ) else: # Insecure padlock icon self.httpsicon.setPixmap( QPixmap( os.path.join('icons','lock-nossl.png') ) ) """ self.__edit_url.setText(q.toString()) self.__edit_url.setCursorPosition(0) def __onLoadFinished(self, ok): if self.__bookmark is not None: self.__spin_zoom.setValue(self.__bookmark.zoomFactor) text = self.__bookmark.text if len(text) > 0: self.browser.findText(text) self.__bookmark = None def __spin_zoom_valueChanged(self, value): self.browser.setZoomFactor(value) def __on_ctrl_plus(self): self.__spin_zoom.setValue(self.__spin_zoom.value() + self.__spin_zoom.singleStep()) def __on_ctrl_minus(self): self.__spin_zoom.setValue(self.__spin_zoom.value() - self.__spin_zoom.singleStep()) def load_page(self, url): qurl = QUrl(url) self.__edit_url.setText(qurl.toString()) self.browser.stop() self.browser.load(qurl) def __on_btn_go(self, *args): if len(self.__edit_url.text()) > 0: self.filename = self.__edit_url.text() self.load_page(QUrl.fromUserInput(self.filename)) def open_local_text(self, textFile): if len(textFile) > 0: self.filename = textFile self.load_page(QUrl.fromUserInput(textFile)) def toggle_internet_controls(self, show=True): if show: self.__edit_url.show() self.__btn_go.show() else: self.__edit_url.hide() self.__btn_go.hide() # https://doc.qt.io/qtforpython/PySide2/QtWidgets/QBoxLayout.html#PySide2.QtWidgets.PySide2.QtWidgets.QBoxLayout.insertStretch self.__ctrls_layout.insertStretch(0, stretch=0) return self
def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) pasteBox = QHBoxLayout() self.textLine = QLineEdit() self.textLine.setToolTip('Current Director/selected File') self.pasteButton = QToolButton() self.pasteButton.setEnabled(False) self.pasteButton.setText('Paste') self.pasteButton.setToolTip( 'Copy file from copy path to current directory/file') self.pasteButton.clicked.connect(self.paste) self.pasteButton.hide() pasteBox.addWidget(self.textLine) pasteBox.addWidget(self.pasteButton) self.copyBox = QFrame() hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.copyLine = QLineEdit() self.copyLine.setToolTip('File path to copy from, when pasting') self.copyButton = QToolButton() self.copyButton.setText('Copy') self.copyButton.setToolTip('Record current file as copy path') self.copyButton.clicked.connect(self.recordCopyPath) hbox.addWidget(self.copyButton) hbox.addWidget(self.copyLine) self.copyBox.setLayout(hbox) self.copyBox.hide() self.model = QFileSystemModel() self.model.setRootPath(QDir.currentPath()) self.model.setFilter(QDir.AllDirs | QDir.NoDot | QDir.Files) self.model.setNameFilterDisables(False) self.model.rootPathChanged.connect(self.folderChanged) self.list = QListView() self.list.setModel(self.model) self.updateDirectoryView(self.media_path) self.list.resize(640, 480) self.list.clicked[QModelIndex].connect(self.listClicked) self.list.activated.connect(self._getPathActivated) self.list.setAlternatingRowColors(True) self.cb = QComboBox() self.cb.currentIndexChanged.connect(self.filterChanged) self.fillCombobox(INFO.PROGRAM_FILTERS_EXTENSIONS) self.cb.setMinimumHeight(30) self.cb.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2 = QToolButton() self.button2.setText('Media') self.button2.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button2.setMinimumSize(60, 30) self.button2.setToolTip('Jump to Media directory') self.button2.clicked.connect(self.onJumpClicked) SettingMenu = QMenu(self) self.settingMenu = SettingMenu for i in ('Media', 'User'): axisButton = QAction(QIcon.fromTheme('user-home'), i, self) # weird lambda i=i to work around 'function closure' axisButton.triggered.connect( lambda state, i=i: self.jumpTriggered(i)) SettingMenu.addAction(axisButton) self.button2.setMenu(SettingMenu) self.button3 = QToolButton() self.button3.setText('Add Jump') self.button3.setSizePolicy( QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) self.button3.setMinimumSize(60, 30) self.button3.setToolTip('Add current directory to jump button list') self.button3.clicked.connect(self.onActionClicked) hbox = QHBoxLayout() hbox.addWidget(self.button2) hbox.addWidget(self.button3) hbox.insertStretch(2, stretch=0) hbox.addWidget(self.cb) windowLayout = QVBoxLayout() windowLayout.addLayout(pasteBox) windowLayout.addWidget(self.copyBox) windowLayout.addWidget(self.list) windowLayout.addLayout(hbox) self.setLayout(windowLayout) self.show()
def initUi(self): outerFrame = QtWidgets.QFrame() outerFrame.setFrameShape(QFrame.Panel) outerFrame.setFrameShadow(QFrame.Raised) outerFrameLayout = QHBoxLayout() outerFrame.setLayout(outerFrameLayout) outerFrameLayout.setSpacing(10) outerFrameLayout.setContentsMargins(20, 20, 20, 20) # Left top right then bottom frameDouble = QtWidgets.QFrame() doubleFrameSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) doubleFrameSizePolicy.setHorizontalStretch(1) frameDouble.setSizePolicy(doubleFrameSizePolicy) frameDoubleVLayout = QVBoxLayout() frameDouble.setLayout(frameDoubleVLayout) innerFrame = QtWidgets.QFrame(self, objectName="innerFrameLogin") innerFrame.setFrameShape(QFrame.Panel) innerFrame.setFrameShadow(QFrame.Raised) innerFrame.setStyleSheet("""QFrame{ background: rgba(90,90,90,100); border-width: 1px; border-style: outset; border-color: rgba(130,130,130,100); border-radius: 35px;}""") #innerFrameSizePolicy=QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum) #innerFrameSizePolicy.setHorizontalStretch(1) #innerFrame.setSizePolicy(innerFrameSizePolicy) innerFrameLayout = QVBoxLayout() innerFrameLayout.setSpacing(30) innerFrameLayout.setContentsMargins(20, 20, 20, 20) innerFrame.setLayout(innerFrameLayout) formBlock = QtWidgets.QWidget() formBlockSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) formBlock.setSizePolicy(formBlockSizePolicy) formBlockLayout = QGridLayout() formBlock.setLayout(formBlockLayout) loginLabel = QtWidgets.QLabel("STC2", objectName="loginLabel") loginLabel.setAlignment(Qt.AlignCenter) loginLabel.setStyleSheet("""font-size: 100px;""") loginLabelSizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) loginLabel.setSizePolicy(loginLabelSizePolicy) #Makes logo label and places logo image inside it logoLabel = QtWidgets.QLabel() logoLabel.setStyleSheet("""background: rgba(90,90,90,0); border-color: rgba(140,140,140,0);""") logoLabelSizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Maximum) #Horizontal,vertical logoLabel.setSizePolicy(logoLabelSizePolicy) pixmap = QPixmap("Logo.ico") logoLabel.setPixmap(pixmap) logoLabel.setAlignment(Qt.AlignCenter) widgetUsername = QtWidgets.QWidget() widgetUsername.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 35px; """) widgetUsernameSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetUsername.setSizePolicy(widgetUsernameSizePolicy) usernameLayout = QHBoxLayout() widgetUsername.setLayout(usernameLayout) widgetPassword = QtWidgets.QWidget() widgetPassword.setStyleSheet(""" background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(96,99,108,200), stop:1 rgba(133,131,142,200)); border-width: 1px; border-style: outset; border-color: rgba(140,140,140,100); border-radius: 35px; """) widgetPasswordSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical widgetPassword.setSizePolicy(widgetPasswordSizePolicy) passwordLayout = QHBoxLayout() widgetPassword.setLayout(passwordLayout) self.usernameLineEditLogin = QtWidgets.QLineEdit() #usernameLineEditSizePolicy=QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding)#Horizontal,vertical #self.usernameLineEditLogin.setSizePolicy(logoLabelSizePolicy) self.usernameLineEditLogin.setStyleSheet( """color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") self.usernameLineEditLogin.setPlaceholderText("Username") self.passwordLineEditLogin = QtWidgets.QLineEdit() self.passwordLineEditLogin.setPlaceholderText("Password") self.passwordLineEditLogin.setStyleSheet( """color: rgba(255,255,255,255); background:rgba(69, 83, 105,0); border-color: rgba(14,14,14,0); border-radius: 20px; font-size: 15px;""") self.passwordLineEditLogin.setEchoMode(2) usernameLogoLabel = QtWidgets.QLabel() usernameLogoLabel.setStyleSheet("""background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") usernameLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical usernameLogoLabel.setSizePolicy(usernameLogoLabelSizePolicy) pixmap = QPixmap("48px.png") usernameLogoLabel.setPixmap(pixmap) usernameLogoLabel.setAlignment(Qt.AlignCenter) passwordLogoLabel = QtWidgets.QLabel() passwordLogoLabel.setStyleSheet("""background:rgba(156, 165, 179,255); border-color: rgba(14,14,14,0); border-radius: 23px;""") passwordLogoLabelSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical passwordLogoLabel.setSizePolicy(passwordLogoLabelSizePolicy) pixmap = QPixmap("lock2_48px.png") passwordLogoLabel.setPixmap(pixmap) passwordLogoLabel.setAlignment(Qt.AlignCenter) usernameLayout.addWidget(usernameLogoLabel) usernameLayout.addWidget(self.usernameLineEditLogin) passwordLayout.addWidget(passwordLogoLabel) passwordLayout.addWidget(self.passwordLineEditLogin) showPasswordCheck = QtWidgets.QCheckBox("Show Password") showPasswordCheck.setStyleSheet("""QCheckBox::indicator { border: 3px solid #5A5A5A; background: none; } """) loginButton = QtWidgets.QPushButton("Login") loginButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Minimum) #Horizontal,vertical loginButton.setSizePolicy(loginButtonSizePolicy) loginButton.setStyleSheet(""" QPushButton{font-size: 25px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 30px; min-height:65px; max-height:68px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) loginButton.clicked.connect(self.loginButtonFunction) forgotButton = QtWidgets.QPushButton("Forgot Password?") forgotButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical forgotButton.setSizePolicy(forgotButtonSizePolicy) forgotButton.setStyleSheet(""" QPushButton{font-size: 15px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 16px; min-height:30px; max-height:35px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) forgotButton.clicked.connect(self.forgotPasswordClicked) registerButton = QtWidgets.QPushButton("Register") registerButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical registerButton.setSizePolicy(registerButtonSizePolicy) registerButton.setStyleSheet(""" QPushButton{font-size: 15px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 16px; min-height:30px; max-height:35px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) registerButton.clicked.connect(self.goRegisterButtonFunction) quitButton = QtWidgets.QPushButton("Quit Program") quitButtonSizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Maximum) #Horizontal,vertical quitButton.setSizePolicy(quitButtonSizePolicy) quitButton.setStyleSheet(""" QPushButton{font-size: 15px; color: rgba(60,70,89,225); background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(188, 192, 204,200), stop:1 rgba(205,208,220,225)); border-width: 1px; border-style: outset; border-color: rgba(240,240,240,200); border-radius: 16px; min-height:30px; max-height:35px;} QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(205,208,220,225), stop:1 rgba(188, 192, 204,200)); } QPushButton:pressed { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 rgba(185,188,200,225), stop:1 rgba(168, 172, 184,200)); border-style: inset; } """) quitButton.clicked.connect(self.quitButtonFunction) formBlockLayout.addWidget(widgetUsername, 0, 0, 1, 2) formBlockLayout.addWidget(widgetPassword, 1, 0, 1, 2) formBlockLayout.addWidget(showPasswordCheck, 2, 0, 1, 2, Qt.AlignRight) formBlockLayout.addWidget(loginButton, 3, 0, 1, 2) formBlockLayout.addWidget(forgotButton, 4, 0, 1, 1) formBlockLayout.addWidget(registerButton, 4, 1, 1, 1) formBlockLayout.addWidget(quitButton, 5, 0, 1, 2) innerFrameLayout.addWidget(logoLabel, Qt.AlignCenter) innerFrameLayout.addWidget(formBlock) frameDoubleVLayout.addWidget(loginLabel, Qt.AlignCenter) frameDoubleVLayout.addWidget(innerFrame, Qt.AlignCenter) outerFrameLayout.insertStretch(0, 1) outerFrameLayout.addWidget(frameDouble) outerFrameLayout.addStretch(1) mainGrid = QGridLayout() mainGrid.setSpacing(10) mainGrid.addWidget(outerFrame) outerWidgetBox = QtWidgets.QWidget() outerWidgetBox.setLayout(mainGrid) self.setCentralWidget(outerWidgetBox) #self.setGeometry(0,0,1500,900) self.setWindowTitle("Login") self.showMaximized()
def __init__(self): # Call supercalss constructor super().__init__() # Initialize backend self.decision_maker = DecisionMaker(DEFAULT_DB_PATH) # These parameter values get adjusted by the front panel controls self.day = 0 self.year = 0 self.time = 0 self.weather = 0 self.alone = 0 self.retrograde = 0 self.hunger_level = 0 self.thirst_level = 0 self.energy_level = 0 self.introvert_level = 0 self.stress_level = 0 # Status bar #self.statusBar().showMessage('Ready') # Menu bar #menu_bar = self.menuBar() #file_menu = menu_bar.addMenu('&File') # Set up layout vbox = QVBoxLayout() title = DecisionMakerTitle() controls = DecisionMakerControls(self) output = DecisionMakerOutput(self) vbox.addWidget(title) vbox.addWidget(controls) vbox.addWidget(output) vbox.insertStretch(1) vbox.insertStretch(3) vbox.setSpacing(10) vbox.addSpacing(10) hbox = QHBoxLayout() hbox.addLayout(vbox) hbox.insertStretch(0) central = QWidget(self) self.setCentralWidget(central) central.setLayout(hbox) # Color palette self.setAutoFillBackground(True) palette = self.palette() palette.setColor(self.backgroundRole(), Qt.black) self.setPalette(palette) # Window properties #self.setGeometry(300, 600, 300, 220) #window_geom = self.frameGeometry() #center_pos = QDesktopWidget().availableGeometry().center() #window_geom.moveCenter(center_pos) #self.move(window_geom.topLeft()) self.setWindowTitle('DecisionMaker') self.setWindowIcon(QIcon(ICON_PATH)) # Show window self.show()
def build_interface(self): # Hide starting widget self._w_start.hide() # Reserve a place to display input and output images pix = QPixmap(2 * self.image_size, 2 * self.image_size) pix.fill(QColor(0, 0, 0)) # Left sidebar l_left = QVBoxLayout() self._l_start.deleteLater() self._l_main.addLayout(l_left) b_iimgl = [ QPushButton('Load first image', self), QPushButton('Load second image', self) ] b_iimgrz = [ QPushButton('Sample random first z', self), QPushButton('Sample random second z', self) ] b_iimgri = [ QPushButton('Sample random first image', self), QPushButton('Sample random second image', self) ] imgl_slots = [partial(self.load_image, 0), partial(self.load_image, 1)] imgrz_slots = [ partial(self.sample_random_z, 0), partial(self.sample_random_z, 1) ] imgri_slots = [ partial(self.sample_random_image, 0), partial(self.sample_random_image, 1) ] for i in range(2): self._l_iimg[i].setPixmap(pix) self._l_oimg[i].setPixmap(pix) l_left.addWidget(b_iimgl[i]) l_left.addWidget(b_iimgrz[i]) l_left.addWidget(b_iimgri[i]) l = QHBoxLayout() l.addWidget(self._l_iimg[i]) l.addWidget(self._l_oimg[i]) b_iimgl[i].clicked.connect(imgl_slots[i]) b_iimgrz[i].clicked.connect(imgrz_slots[i]) b_iimgri[i].clicked.connect(imgri_slots[i]) l_left.addLayout(l) # Middle layout l_mid = QVBoxLayout() self._l_main.addLayout(l_mid) l = QHBoxLayout() l_mid.addLayout(l) b_run_d = QPushButton('Run decoder') b_run_d.clicked.connect(self.run_decoder) l.addWidget(b_run_d) b_run_a = QPushButton('Run animation') b_run_a.clicked.connect(self.run_animation) l.addWidget(b_run_a) l_mid.insertStretch(-1) # Build z sliders l = QHBoxLayout() l_mid.addLayout(l) for i in range(self.z_dim): if not i % 25: lv = QVBoxLayout() l.addLayout(lv) l.insertStretch(-1) h_l = QHBoxLayout() lv.addLayout(h_l) l_z1 = QLabel('Z: %d, -3' % i) l_z2 = QLabel('Z: %d, 3' % i) s_z = QSlider(Qt.Horizontal) s_z.setMinimum(-3000) s_z.setMaximum(3000) s_z.valueChanged.connect(self.get_sliders) self.z_sliders.append(s_z) h_l.addWidget(l_z1) h_l.addWidget(s_z) h_l.addWidget(l_z2) # Build y checkboxes if self.y_dim is not None: for i in range(self.y_dim): if not i % 20: lv = QVBoxLayout() l.addLayout(lv) l.insertStretch(-1) c_y = QCheckBox() c_y.setText('y %d' % i) c_y.stateChanged.connect(self.get_y) lv.addWidget(c_y) self.y_checks.append(c_y) l.insertStretch(-1) # Right sidebar l_right = QVBoxLayout() self._l_main.addLayout(l_right) self._l_anim.setPixmap(pix) l_right.addWidget(QLabel('Animation', self)) l_right.addWidget(self._l_anim) l_right.insertStretch(-1)
class DisplayButtonsBar(QFrame): def __init__(self, parent, *args, **kwargs): super().__init__() self._wh = parent.frameGeometry().height() self._btn_size = {"h": int(self._wh * 0.05), "w": int(self._wh * 0.15)} self._lbl_size = {"h": int(self._wh * 0.08), "w": int(self._wh * 0.15)} self._display_buttons_bar_layout = QHBoxLayout() self._dp_bar_widgets = [] self._rec_type_layout = QHBoxLayout() self._rec_type_widget = QFrame() self._rec_type_buttons = { "income": QPushButton(), "expense": QPushButton() } self._dp_bar_widgets.append(self._rec_type_widget) self._show_layout = QVBoxLayout() self._show_widget = QFrame() self._show_button = QPushButton() self._dp_bar_widgets.append(self._show_widget) self._range_type_layout = QVBoxLayout() self._range_type_widget = QFrame() self._range_type_buttons = { "last": QRadioButton(), "from": QRadioButton() } self._dp_bar_widgets.append(self._range_type_widget) self._last_layout = QHBoxLayout() self._last_widget = QFrame() self._days_combo = QComboBox() self._days_label = QLabel() self._from_layout = QHBoxLayout() self._from_widget = QFrame() self._from_combo_boxes = { "day": QComboBox(), "month": QComboBox(), "year": QComboBox() } self._to_label = QLabel() self._to_combo_boxes = { "day": QComboBox(), "month": QComboBox(), "year": QComboBox() } self._last_from_combo_layout = QVBoxLayout() self._last_from_combo_widget = QFrame() self._dp_bar_widgets.append(self._last_from_combo_widget) self._init_display_buttons() self.init_display_buttons_bar() def _init_display_buttons(self): for key, button in self._rec_type_buttons.items( ): # Income and Expense buttons button.setFixedHeight(self._btn_size["h"]) button.setFixedWidth(self._btn_size["w"]) button.setText(key[0].upper() + key[1:]) self._show_button.setText("Show") self._show_button.setFixedHeight(self._btn_size["h"]) self._show_button.setFixedWidth(self._btn_size["w"]) for key, button in self._range_type_buttons.items( ): # Last and From radio buttons button.setFixedHeight(self._lbl_size["h"]) button.setFixedWidth(self._lbl_size["w"]) button.setText(key[0].upper() + key[1:]) self._days_combo.setFixedHeight(self._btn_size["h"]) self._days_combo.setFixedWidth(self._btn_size["w"]) self._days_combo.addItems([f"{x}" for x in [30, 60, 90]]) self._days_label.setText("Days") self._days_label.setFixedHeight(self._lbl_size["h"]) days = [f"{x}" for x in range(1, 31)] months = [ "Jan", "Feb", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] years = [f"{x}" for x in range(1980, 2050)] for cmb in self._from_combo_boxes.values(): cmb.setFixedHeight(self._btn_size["h"]) self._from_combo_boxes["day"].addItem("DD") self._from_combo_boxes["day"].addItems(days) self._from_combo_boxes["month"].addItem("MM") self._from_combo_boxes["month"].addItems(months) self._from_combo_boxes["year"].addItem("YYYY") self._from_combo_boxes["year"].addItems(years) self._to_label.setText("To") self._to_combo_boxes["day"].addItem("DD") self._to_combo_boxes["day"].addItems(days) self._to_combo_boxes["month"].addItem("MM") self._to_combo_boxes["month"].addItems(months) self._to_combo_boxes["year"].addItem("YYYY") self._to_combo_boxes["year"].addItems(years) def init_display_buttons_bar(self): self.setFrameStyle(QFrame.Box) self.setLineWidth(2) self.setMaximumHeight(self._wh * 0.25) self._rec_type_layout.addWidget(self._rec_type_buttons["income"]) self._rec_type_layout.addWidget(self._rec_type_buttons["expense"]) self._rec_type_layout.setAlignment(Qt.AlignTop) self._rec_type_layout.setContentsMargins(0, 0, 0, 0) self._rec_type_widget.setLayout(self._rec_type_layout) self._show_layout.setAlignment(Qt.AlignTop) self._show_layout.setContentsMargins(0, self._wh * 0.035, 0, 0) self._show_layout.addWidget(self._show_button) self._show_widget.setLayout(self._show_layout) self._range_type_layout.addWidget(self._range_type_buttons["last"]) self._range_type_layout.addStretch(1) self._range_type_layout.addWidget(self._range_type_buttons["from"]) self._range_type_widget.setLayout(self._range_type_layout) self._last_layout.setContentsMargins(0, 0, 0, 0) self._last_layout.addWidget(self._days_combo) self._last_layout.addWidget(self._days_label) self._last_widget.setLayout(self._last_layout) self._last_widget.setFrameStyle(QFrame.Box) self._last_widget.setLineWidth(2) for key in sorted(self._from_combo_boxes.keys()): self._from_layout.addWidget(self._from_combo_boxes[key]) self._from_layout.addWidget( self._to_label) # Adds "To" label between sets of combo boxes self._from_layout.setContentsMargins(0, 0, 0, 0) for key in sorted(self._to_combo_boxes.keys()): self._from_layout.addWidget(self._to_combo_boxes[key]) self._from_widget.setLayout(self._from_layout) self._last_from_combo_layout.setContentsMargins(0, 0, 0, 0) self._last_from_combo_layout.addWidget(self._last_widget) self._last_from_combo_layout.addWidget(self._from_widget) self._last_from_combo_widget.setLayout(self._last_from_combo_layout) self._last_from_combo_widget.setFrameStyle(QFrame.Box) self._last_from_combo_widget.setLineWidth(2) self._display_buttons_bar_layout.setAlignment(Qt.AlignCenter) self._display_buttons_bar_layout.setContentsMargins(0, 0, 0, 0) self._display_buttons_bar_layout.setSpacing(0) for widget in self._dp_bar_widgets: self._display_buttons_bar_layout.addWidget(widget) self._display_buttons_bar_layout.insertStretch(1, 1) self.setLayout(self._display_buttons_bar_layout)