def apply_style(style_name): if style_name == 'LiSP': qApp.setStyleSheet(QLiSPTheme) # Change link color palette = qApp.palette() palette.setColor(QPalette.Link, QColor(65, 155, 230)) palette.setColor(QPalette.LinkVisited, QColor(43, 103, 153)) qApp.setPalette(palette) else: qApp.setStyleSheet('') qApp.setStyle(QStyleFactory.create(style_name))
def apply_style(name): """Load a style given its name.""" style = LiSPStyles.get(name.title()) if isinstance(style, Style): if style.has_py: module = __package__ + '.' + os.path.basename( style.path) + '.style' __load_py_style(module) if style.has_qss: __load_qss_style(os.path.join(style.path, 'style.qss')) else: qApp.setStyleSheet('') qApp.setStyle(QStyleFactory.create(name))
def setMainWindowProperty(self) -> None: width = self.settings.getint("Global", "WindowWidth", 1600) heigth = self.settings.getint("Global", "WindowHeigth", 800) self.resize(width, heigth) self.updateTitle() # center the window frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) # apply the style style = self.settings.get("Theme", "QtStyle", "Cleanlooks") qApp.setStyle(style) return
def apply_style(name): """Load a style given its name.""" style = LiSPStyles.get(name.title()) if isinstance(style, Style): if style.has_py: __load_py_style(os.path.join(style.path, 'style.py')) if style.has_qss: __load_qss_style(os.path.join(style.path, 'style.qss')) # Change link color palette = qApp.palette() palette.setColor(QPalette.Link, QColor(65, 155, 230)) palette.setColor(QPalette.LinkVisited, QColor(43, 103, 153)) qApp.setPalette(palette) else: qApp.setStyleSheet('') qApp.setStyle(QStyleFactory.create(name))
def __init__(self, pathObjects, parent=None): """Initialize the main tree controls Arguments: pathObjects -- a list of file objects to open parent -- the parent QObject if given """ super().__init__(parent) self.localControls = [] self.activeControl = None self.trayIcon = None self.isTrayMinimized = False self.configDialog = None self.sortDialog = None self.numberingDialog = None self.findTextDialog = None self.findConditionDialog = None self.findReplaceDialog = None self.filterTextDialog = None self.filterConditionDialog = None self.basicHelpView = None self.passwords = {} globalref.mainControl = self self.allActions = {} try: # check for existing TreeLine session socket = QLocalSocket() socket.connectToServer('treeline3-session', QIODevice.WriteOnly) # if found, send files to open and exit TreeLine if socket.waitForConnected(1000): socket.write( bytes(repr([str(path) for path in pathObjects]), 'utf-8')) if socket.waitForBytesWritten(1000): socket.close() sys.exit(0) # start local server to listen for attempt to start new session self.serverSocket = QLocalServer() self.serverSocket.listen('treeline3-session') self.serverSocket.newConnection.connect(self.getSocket) except AttributeError: print(_('Warning: Could not create local socket')) mainVersion = '.'.join(__version__.split('.')[:2]) globalref.genOptions = options.Options('general', 'TreeLine', mainVersion, 'bellz') optiondefaults.setGenOptionDefaults(globalref.genOptions) globalref.miscOptions = options.Options('misc') optiondefaults.setMiscOptionDefaults(globalref.miscOptions) globalref.histOptions = options.Options('history') optiondefaults.setHistOptionDefaults(globalref.histOptions) globalref.toolbarOptions = options.Options('toolbar') optiondefaults.setToolbarOptionDefaults(globalref.toolbarOptions) globalref.keyboardOptions = options.Options('keyboard') optiondefaults.setKeyboardOptionDefaults(globalref.keyboardOptions) try: globalref.genOptions.readFile() globalref.miscOptions.readFile() globalref.histOptions.readFile() globalref.toolbarOptions.readFile() globalref.keyboardOptions.readFile() except IOError: errorDir = options.Options.basePath if not errorDir: errorDir = _('missing directory') QMessageBox.warning( None, 'TreeLine', _('Error - could not write config file to {}').format( errorDir)) options.Options.basePath = None iconPathList = self.findResourcePaths('icons', iconPath) globalref.toolIcons = icondict.IconDict( [path / 'toolbar' for path in iconPathList], ['', '32x32', '16x16']) globalref.toolIcons.loadAllIcons() windowIcon = globalref.toolIcons.getIcon('treelogo') if windowIcon: QApplication.setWindowIcon(windowIcon) globalref.treeIcons = icondict.IconDict(iconPathList, ['', 'tree']) icon = globalref.treeIcons.getIcon('default') qApp.setStyle(QStyleFactory.create('Fusion')) setThemeColors() self.recentFiles = recentfiles.RecentFileList() if globalref.genOptions['AutoFileOpen'] and not pathObjects: recentPath = self.recentFiles.firstPath() if recentPath: pathObjects = [recentPath] self.setupActions() self.systemFont = QApplication.font() self.updateAppFont() if globalref.genOptions['MinToSysTray']: self.createTrayIcon() qApp.focusChanged.connect(self.updateActionsAvail) if pathObjects: for pathObj in pathObjects: self.openFile(pathObj, True) else: self.createLocalControl()
def setStyle(self, style): # Save style to Qt Settings sttgs = QSettings(qApp.organizationName(), qApp.applicationName()) sttgs.setValue("applicationStyle", style) qApp.setStyle(style)
def setStyle(self, style): # Save style to Qt Settings sttgs = QSettings(qApp.organizationName(), qApp.applicationName()) sttgs.setValue("applicationStyle", style) qApp.setStyle(style)
def __init_ui(self) -> None: qApp.setStyle('Fusion') self.setWindowIcon(QIcon(resource_path("logo.ico"))) self.setWindowTitle('Lista de Contatos') self.model = QSqlTableModel() self.setMinimumSize(800, 400) root_layout: QVBoxLayout = QVBoxLayout() # search hbox_search: QHBoxLayout = QHBoxLayout() search_lbl: QLabel = QLabel('Buscar') self.__dict_keyword = {'nome': 'name', 'anydesk': 'anydesk'} keyword_cmb: QComboBox = QComboBox() keyword_cmb.addItems(self.__dict_keyword.keys()) keyword_cmb.currentTextChanged.connect(self.__set_selected_keyword) search_txt: QLineEdit = QLineEdit() search_txt.setValidator(UpperCaseValidator(self)) search_txt.textChanged.connect(self.__update_searching) search_txt.returnPressed.connect(self.__search) search_btn: QPushButton = QPushButton('Buscar') search_btn.clicked.connect(self.__search) hbox_search.addWidget(search_lbl) hbox_search.addWidget(keyword_cmb) hbox_search.addWidget(search_txt) hbox_search.addWidget(search_btn) root_layout.addLayout(hbox_search) # ./search hbox_container: QHBoxLayout = QHBoxLayout() self.tbl_contacts = QTableView() button_delegate = ButtonDelegate() button_delegate.clicked[int, int].connect(self.__on_click_button_delegate) self.tbl_contacts.setEditTriggers(QTableView.NoEditTriggers) # Type Selection self.tbl_contacts.setAlternatingRowColors(True) self.tbl_contacts.setSelectionMode(QTableView.SingleSelection) self.tbl_contacts.setSelectionBehavior(QTableView.SelectRows) self.tbl_contacts.setModel(self.model) self.tbl_contacts.setItemDelegateForColumn(1, button_delegate) # Enable sorting self.tbl_contacts.setSortingEnabled(True) # Adjust Header horizontal_header: QHeaderView = self.tbl_contacts.horizontalHeader() horizontal_header.setSectionResizeMode(QHeaderView.ResizeToContents) horizontal_header.setStretchLastSection(True) size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) size.setHorizontalStretch(1) self.tbl_contacts.setSizePolicy(size) # events self.tbl_contacts.clicked.connect(self.__set_selected_row) hbox_container.addWidget(self.tbl_contacts) vbox: QVBoxLayout = QVBoxLayout() self.new_btn: QPushButton = QPushButton('Novo') self.new_btn.clicked.connect(self.__new) self.edit_btn: QPushButton = QPushButton('Editar') self.edit_btn.clicked.connect(self.__edit) self.destroy_btn: QPushButton = QPushButton('Excluir') self.destroy_btn.clicked.connect(self.__destroy) vbox.addWidget(self.new_btn) vbox.addWidget(self.edit_btn) vbox.addWidget(self.destroy_btn) vbox.addStretch(1) hbox_container.addLayout(vbox) root_layout.addLayout(hbox_container) self.setLayout(root_layout) self.show()
def handleStyleChanged(self, style): qApp.setStyle(style)
def __init__(self): super().__init__() self.setupUi(self) qApp.setStyle(QStyleFactory.create("Fusion")) # Считывание данных из БД, таблицы 'teams' con = sqlite3.connect('FootballManager.db') cur = con.cursor() result = cur.execute("""SELECT * FROM teams""").fetchall() con.close() # Заполнение класса Team, извлеченными данными self.arrayOfTeams = [] for x in result: self.arrayOfTeams.append(Team(x[0], x[1], x[2])) # Создание списка сезонов(состоит из игр -> команд -> игроков), каждый прошедший сезон сохраняется в отдельном файле, как архив self.globalNumberSeason = 0 self.ligas = [Liga(self.arrayOfTeams[:16], self.globalNumberSeason)] self.model = QStandardItemModel() self.listView.setModel(self.model) self.listView.clicked.connect(self.onListView) self.listView.setEditTriggers(QAbstractItemView.NoEditTriggers) # Создание модели для таблицы команд self.modelForTableTeams = ModelForTableTeams(self.ligas[-1]) self.filterModelForTableTeams = QSortFilterProxyModel() self.filterModelForTableTeams.setSourceModel(self.modelForTableTeams) self.tableViewForTeams.setModel(self.filterModelForTableTeams) self.tableViewForTeams.setSortingEnabled(False) #self.tableViewForTeams.sortByColumn(0, Qt.AscendingOrder) self.tableViewForTeams.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.tableViewForTeams.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.tableViewForTeams.verticalHeader().setSectionResizeMode(QHeaderView.Stretch) self.tableViewForTeams.setFont(QFont("times", 12)) self.tableViewForTeams.clicked.connect(self.openGame) # Создание модели для таблицы лучших бомбардиров self.modelForTablePlayers = ModelForTablePlayers(self.ligas[-1].allPlayers, func=lambda x: (x.goals, x.name)) self.filterModelForTablePlayers = QSortFilterProxyModel() self.filterModelForTablePlayers.setSourceModel(self.modelForTablePlayers) self.tableViewForPlayers.setModel(self.filterModelForTablePlayers) self.tableViewForPlayers.setSortingEnabled(False) #self.tableViewForPlayers.sortByColumn(0, Qt.AscendingOrder) self.tableViewForPlayers.setFont(QFont("times", 16)) self.tableViewForPlayers.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.tableViewForPlayers.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.tableViewForPlayers.verticalHeader().setSectionResizeMode(QHeaderView.Stretch) # Создание модели для таблицы лучших распасовщиков self.modelForTablePlayersPass = ModelForTablePlayersPass(self.ligas[-1].allPlayers, func=lambda x: (x.correctPass / (x.allPass * 100), x.name) if x.skillPass != 1 and x.allPass != 0 else (0, x.name)) self.filterModelForTablePlayersPass = QSortFilterProxyModel() self.filterModelForTablePlayersPass.setSourceModel(self.modelForTablePlayersPass) self.tableViewForPlayersPass.setModel(self.filterModelForTablePlayersPass) self.tableViewForPlayersPass.setSortingEnabled(False) #self.tableViewForPlayers.sortByColumn(0, Qt.AscendingOrder) self.tableViewForPlayersPass.setFont(QFont("times", 16)) self.tableViewForPlayersPass.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.tableViewForPlayersPass.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.tableViewForPlayersPass.verticalHeader().setSectionResizeMode(QHeaderView.Stretch) # Обновление таблиц self.onlineTables() self.pushButton.clicked.connect(self.playOneTour)
def __init__(self): super().__init__() uic.loadUi("windows.ui", self) #self.arg = arg self.radioU.setChecked(True) self.widgetDownload.setEnabled(False) self.setWindowIcon(QIcon('img/pplogo.png')) self.setWindowTitle('TrivialPiper - Client') #Definiendo el tema o paleta de la ventana para el cliente qApp.setStyle("kvantum-dark") #qApp.setStyle("Fusion") dark_palette = QPalette() dark_palette.setColor(QPalette.Window, QColor(53, 53, 53)) dark_palette.setColor(QPalette.WindowText, Qt.white) dark_palette.setColor(QPalette.Base, QColor(25, 25, 25)) dark_palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) dark_palette.setColor(QPalette.ToolTipBase, Qt.white) dark_palette.setColor(QPalette.ToolTipText, Qt.white) dark_palette.setColor(QPalette.Text, Qt.white) dark_palette.setColor(QPalette.Button, QColor(53, 53, 53)) dark_palette.setColor(QPalette.ButtonText, Qt.white) dark_palette.setColor(QPalette.BrightText, Qt.red) dark_palette.setColor(QPalette.Link, QColor(42, 130, 218)) dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) dark_palette.setColor(QPalette.HighlightedText, Qt.black) qApp.setPalette(dark_palette) qApp.setStyleSheet( "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }" ) #Definiendo el input port self.portValidate = QIntValidator(0, 1023, self) self.inputPort.setValidator(self.portValidate) self.inputPort.setEnabled(False) #Definiendo el input block self.blockValidate = QIntValidator( 8, 1468, self) #En practica definimos 1468 o 65464 como en el rfc 2348 self.inputBlocksize.setValidator(self.blockValidate) self.inputBlocksize.setEnabled(False) #Definiendo el input Window self.winValidate = QIntValidator(1, 65535, self) self.inputWindow.setValidator(self.winValidate) self.inputWindow.setEnabled(False) #Definiendo RadioButtons y CheckBox self.radioD.clicked.connect(self.activarDownload) self.radioU.clicked.connect(self.activarUpload) self.checkBoxPuerto.stateChanged.connect(self.activarPort) self.checkBoxBlocksize.stateChanged.connect(self.activarBlock) self.checkBoxWindowsize.stateChanged.connect(self.activarWind) #Definicion de los botones Upload y Download self.finalizarU.clicked.connect(self.finalizar_Up) self.finalizarD.clicked.connect(self.finalizar_Dw) self.model = QFileSystemModel() self.model.setRootPath('/home') self.arbolDir.setModel(self.model) self.arbolDir.clicked.connect(self.dummy) self.menusUI()
def setMainWindowProperty(self): self.resize(*WINDOW_SIZE) self.updateTitle() self.centerMainWindow() qApp.setStyle("Cleanlooks") return
def setMainWindowProperty(self): self.resize(*WINDOW_SIZE) self.updateTitle() self.centerMainWindow() qApp.setStyle("Cleanlooks") return