def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) for i, key in enumerate(QStyleFactory.keys()): styleDict.update({key: i}) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Style") styleComboBox.setCurrentIndex( styleDict[self.changeStyle("WindowsVista")])
def main(): app = QApplication(sys.argv) if "Oxygen" in QStyleFactory.keys(): app.setStyle( QStyleFactory.create("Oxygen") ) # try to set the Oxygen style elif "Fusion" in QStyleFactory.keys(): # if not the try Fusion app.setStyle( QStyleFactory.create("Fusion") ) Globals.icons["finish flag"].addPixmap( QPixmap("Ressources/icons/finish_flag.png"), QIcon.Disabled, QIcon.On) Globals.MainWindow = MainWindow() Globals.Screen = app.primaryScreen() taille = Globals.Screen.size() height = taille.height() width = taille.width() if False: Globals.MainWindow.setMaximumSize( taille ) Globals.MainWindow.resize( height, width ) Globals.MainWindow.Tab_Container.setMaximumSize(QSize( height , width - 40)) Globals.MainWindow.Tab_Container.setGeometry( QRect(0, 0, height, width - 40)) Globals.MainWindow.main() # Init Decoder interface for dec in pref.decoderList: print ( dec ) if pref.decoderList[ dec ]['active']: decoder_task( pref.decoderList[dec], dec ) for task in Globals.decoder: receive( task ) app.exec_()
def __init__(self, parent=None, default_style='Fusion'): super(EventController, self).__init__(parent) # main window attribute self.setGeometry(300, 100, 800, 800) self.setWindowTitle('Event controller') QApplication.setStyle(QStyleFactory.create(default_style)) # needed information self.course_list = [] self.event_list = [] # call google api self.google_cal = GoogleApi('calendar', 'v3') self.attendee = [] # create groups to control widgets position self.create_course_group() # set style style_layout = QHBoxLayout() style_label = QLabel('Style:') # QLabel.setBuddy style_combo = QComboBox() style_combo.addItems(QStyleFactory.keys()) style_combo.activated[str].connect(self.change_style) # set style combo box index style_index = QStyleFactory.keys() style_index = style_index.index(default_style) style_combo.setCurrentIndex(style_index) style_layout.addWidget(style_label) style_layout.addWidget(style_combo) style_layout.addStretch(1) # set submit button submit_layout = QHBoxLayout() submit_btn = QPushButton('Submit') submit_btn.clicked.connect(self.submit_event) clean_btn = QPushButton('Clean') clean_btn.clicked.connect(self.clean_all) submit_layout.addStretch(1) submit_layout.addWidget(submit_btn) submit_layout.addWidget(clean_btn) # set main layout main_layout = QGridLayout() main_layout.addLayout(style_layout, 0, 0, 1, 2) main_layout.addWidget(self.course_group, 1, 0) main_layout.addLayout(submit_layout, 2, 0, 1, 2) self.setLayout(main_layout)
def init_style_config(self): widget = QWidget() layout = QFormLayout() widget.setLayout(layout) style_list = QComboBox() complete = QCompleter(QStyleFactory.keys()) complete.setFilterMode(Qt.MatchContains) complete.setCompletionMode(QCompleter.PopupCompletion) style_list.setCompleter(complete) style_list.setEditable(True) style_list.addItems(QStyleFactory.keys()) layout.addRow('选择样式: ', style_list) return widget
def _create_style_change_layout(self): self.originalPalette = QApplication.palette() style_combo_box = QComboBox() style_items = QStyleFactory.keys() style_items.reverse() style_combo_box.addItems(style_items) style_label = QLabel("&Style:") style_label.setBuddy(style_combo_box) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") # self.useStylePaletteCheckBox.setChecked(True) # 样式事件绑定 style_combo_box.activated[str].connect(self._change_style) self.useStylePaletteCheckBox.toggled.connect(self._change_palette) # 头部 self.topLayout = QHBoxLayout() self.topLayout.addWidget(style_label) self.topLayout.addWidget(style_combo_box) # - addStretch设置中间的空白 self.topLayout.addStretch(1) self.topLayout.addWidget(self.useStylePaletteCheckBox) # 初始化样式 self._change_style(style_items[0])
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createButtons() self.createButtons2() self.createPlotCanvas() self.createSpreadsheet() mainLayout = QGridLayout() mainLayout.addWidget(self.buttonGroup, 0, 0) mainLayout.addWidget(self.buttonGroup2, 0, 1) mainLayout.addWidget(self.leftGroup, 1, 1) mainLayout.addWidget(self.rightGroup, 1, 0) self.setLayout(mainLayout) self.setWindowTitle("jikuGUI")
def __init__(self, parent=None): super().__init__(parent=parent) self.setWindowTitle("设置窗口的样式") self.resize(200, 100) self.label_style = QLabel("设置 Style:") self.combobox_style = QComboBox() # 从QStyleFactory中增加多个显示样式 self.combobox_style.addItems(QStyleFactory.keys()) # 选择当前窗口风格 index = self.combobox_style.findText(QApplication.style().objectName(), Qt.MatchFixedString) # 设置当前窗口风格 self.combobox_style.setCurrentIndex(index) # 通过combobox控件选择窗口风格 self.combobox_style.activated[str].connect(self.handle_style_change) h_layout = QHBoxLayout() h_layout.addWidget(self.label_style) h_layout.addWidget(self.combobox_style) self.setLayout(h_layout)
def __init__(self, parent=None): super(AppWindow, self).__init__(parent) #水平佈局 Hloyout = QHBoxLayout() #實例化標籤與列表控件 self.styleLabel = QLabel('Set Style') self.styleComboBox = QComboBox() self.progress = QProgressBar(self) self.progress.setGeometry(50, 110, 400, 20) #從QStyleFactory中增加多個顯示樣式到列表控件 self.styleComboBox.addItems(QStyleFactory.keys()) #選擇當前窗口的風格 index = self.styleComboBox.findText(QApplication.style().objectName(), Qt.MatchFixedString) # # 設置無邊框窗口樣式 # self.setWindowFlags(Qt.FramelessWindowHint) # #子窗口,窗口無按鈕 ,但有標題,可注釋掉觀察效果 # self.setWindowFlags(Qt.SubWindow) #設置當前窗口的風格 self.styleComboBox.setCurrentIndex(index) #通過combobox控件選擇窗口風格 self.styleComboBox.activated[str].connect(self.handlestyleChanged) # 添加控件到佈局,設置窗口佈局 Hloyout.addWidget(self.styleLabel) Hloyout.addWidget(self.styleComboBox) Hloyout.addWidget(self.progress) self.setLayout(Hloyout)
def home(self): btn = QPushButton("Quit", self) btn.clicked.connect(self.close_application) btn.resize(btn.minimumSizeHint()) btn.move(100, 100) checkBox = QCheckBox('Enlarge Window', self) checkBox.stateChanged.connect(self.enlarge_window) checkBox.move(100, 60) checkBox.adjustSize() self.progress = QProgressBar(self) self.progress.setGeometry(200, 80, 250, 20) self.download_btn = QPushButton("Download", self) self.download_btn.move(200, 120) self.download_btn.clicked.connect(self.download) self.styleChoice = QLabel("Styles:", self) self.styleChoice.move(50, 150) comboBox = QComboBox(self) comboBox.addItems(QStyleFactory.keys()) # comboBox.addItem("motif") # comboBox.addItem("Windows") # comboBox.addItem("cde") # comboBox.addItem("Plastique") # comboBox.addItem("Cleanlooks") # comboBox.addItem("windowsvista") comboBox.move(50, 250) comboBox.activated[str].connect(self.style_choice) self.show()
def __init__(self, theme, hilite_color, parent=None): super(SettingsDialog, self).__init__(parent) self.hilite_color = hilite_color self.theme = theme self.setWindowTitle("EbookCreator - Settings") box = QHBoxLayout() self.ok = QPushButton("Ok") self.ok.setEnabled(False) self.cancel = QPushButton("Cancel") box.addStretch() box.addWidget(self.ok) box.addWidget(self.cancel) layout = QGridLayout() self.color = ColorEditor("Hilite color") self.color.setColor(QColor(self.hilite_color)) self.styles = QComboBox() self.styles.addItem("DarkFusion") self.styles.addItems(QStyleFactory.keys()) self.styles.setCurrentText(theme) layout.addWidget(QLabel(" Theme"), 0, 0) layout.addWidget(self.styles, 0, 3, 1, 4) layout.addWidget(self.color, 1, 0, 1, 7) layout.addLayout(box, 2, 0, 1, 7) self.setLayout(layout) self.color.colorChanged.connect(self.colorChanged) self.styles.currentTextChanged.connect(self.themeChanged) self.ok.clicked.connect(self.okClicked) self.cancel.clicked.connect(self.close)
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.localization = de self.srcFileString = "" self.targetFileString = "" self.truePath = None self.firstRun = True styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) self.createStartSection() self.createFileSelection() self.createDateSelection() self.createCheckboxArea() self.createInfoOutputSection() mainLayout = QGridLayout() mainLayout.addWidget(self.fileSelectionGroup, 1, 0) mainLayout.addWidget(self.dateSelectionGroupBox, 2, 0) mainLayout.addWidget(self.checkboxGroup, 3, 0) mainLayout.addWidget(self.startSection, 4, 0) mainLayout.addWidget(self.infoOutputSection, 5, 0) self.setLayout(mainLayout) self.setWindowTitle(self.localization.window_title)
def setStyle(self, styleName, styleSheetFile): """ Public method to set the style of the interface. @param styleName name of the style to set (string) @param styleSheetFile name of a style sheet file to read to overwrite defaults of the given style (string) """ # step 1: set the style style = None if styleName != "System" and styleName in QStyleFactory.keys(): style = QStyleFactory.create(styleName) if style is None: style = QStyleFactory.create(self.defaultStyleName) if style is not None: QApplication.setStyle(style) # step 2: set a style sheet if styleSheetFile: try: f = open(styleSheetFile, "r", encoding="utf-8") styleSheet = f.read() f.close() except (IOError, OSError) as msg: E5MessageBox.warning( self, self.tr("Loading Style Sheet"), self.tr("""<p>The Qt Style Sheet file <b>{0}</b> could""" """ not be read.<br>Reason: {1}</p>""").format( styleSheetFile, str(msg))) return else: styleSheet = "" e5App().setStyleSheet(styleSheet)
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() mainLayout = QGridLayout() mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Bridge2Africa") self.changeStyle('Windows')
def __init__(self, parent=None): super(MenuController, self).__init__(parent) self.c = 0 self.backgroundColor = QColor(38, 44, 105) self.cellColor = QColor(209, 220, 237) self.woundColor = QColor(252, 236, 0) self.woundPen = QPen(self.woundColor) self.woundPen.setWidth(3) self.foregroundBrush = QBrush() self.woundGraphics = None self.sceneState = SceneState() self.originalPalette = QApplication.palette() settingsComboBox = QComboBox() settingsComboBox.addItems(QStyleFactory.keys()) mainLabel = QLabel("Simulation Controls") mainLabel.setBuddy(settingsComboBox) self.createWoundControlBox() self.createSimulationControlBox() self.createGraphicsDisplay() mainLayout = QGridLayout() mainLayout.addWidget(self.graphicsDisplayBox, 0, 0, 2, 10) mainLayout.addWidget(self.woundControlBox, 0, 11) mainLayout.addWidget(self.simulationControlBox, 1, 11) self.setLayout(mainLayout) self.setWindowTitle("WoundSimulation") self.simRunning = False
def __init__(self, CTMain=None, exchange='', base_code='', curr_code='', chart_lookback='', chart_interval='', order_book_depth=5): super().__init__() self._CTMain = CTMain self._exchange = exchange self._base_curr = base_code self._curr_curr = curr_code self._chart_lookback = chart_lookback self._chart_interval = chart_interval self._order_book_depth = order_book_depth if 'Fusion' in QStyleFactory.keys(): self.change_style('Fusion') self._layout = QGridLayout() self.setLayout(self._layout) self.draw_view() self.show()
def createActions(self): self.addImagesAct = QAction( "&Add Images...", self, shortcut="Ctrl+A", triggered=self.addImage ) self.removeAllImagesAct = QAction( "&Remove All Images", self, shortcut="Ctrl+R", triggered=self.removeAllImages, ) self.exitAct = QAction("&Quit", self, shortcut="Ctrl+Q", triggered=self.close) self.styleActionGroup = QActionGroup(self) for styleName in QStyleFactory.keys(): action = QAction( self.styleActionGroup, text="%s Style" % styleName, checkable=True, triggered=self.changeStyle, ) action.setData(styleName) self.guessModeStateAct = QAction( "&Guess Image Mode/State", self, checkable=True, checked=True ) self.aboutAct = QAction("&About", self, triggered=self.about) self.aboutQtAct = QAction( "About &Qt", self, triggered=QApplication.instance().aboutQt )
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.localization = de self.srcFileString = "" styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) self.createFileSelection() self.createDateSelection() self.createCheckboxArea() mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.fileSelectionGroup, 1, 0) mainLayout.addWidget(self.dateSelectionGroupBox, 1, 1) mainLayout.addWidget(self.checkboxGroup, 2, 0) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle(self.localization.window_title)
def home(self): btn = QPushButton('quit', self) btn.clicked.connect(self.close_application) # btn.resize(btn.sizeHint()) # auto size for btn btn.resize(btn.minimumSizeHint()) btn.move(0, 100) extractAction = QAction(QIcon('icon-smoker.jpg'), 'Flee the scene', self) extractAction.triggered.connect(self.close_application) self.toolBar = self.addToolBar('Extraction') self.toolBar.addAction(extractAction) bsAction = QAction(QIcon('icon-me.jpg'), 'bullshit time', self) bsAction.triggered.connect(self.bullshit) self.toolBar.addAction(bsAction) fontChoice = QAction('font', self) fontChoice.triggered.connect(self.font_choice) self.toolBar.addAction(fontChoice) color = QColor(0, 0, 0) fontColor = QAction('Font bg Color', self) fontColor.triggered.connect(self.color_picker) self.toolBar.addAction(fontColor) cal = QCalendarWidget(self) cal.move(500, 200) cal.resize(200, 200) checkBox = QCheckBox('window size', self) checkBox.move(300, 25) # checkBox.toggle() checkBox.stateChanged.connect(self.enlargeWindow) self.progress = QProgressBar(self) self.progress.setGeometry(200, 80, 250, 20) self.btn = QPushButton('download', self) self.btn.move(200, 120) self.btn.clicked.connect(self.download) # print(self.style().objectName()) self.styleChoice = QLabel('Windows', self) comboBox = QComboBox(self) # comboBox.addItem('motif') # comboBox.addItem('Windows') # comboBox.addItem('cde') # comboBox.addItem('Plastique') # comboBox.addItem('Cleanlooks') # comboBox.addItem('windowsvista') comboBox.addItems(QStyleFactory.keys()) comboBox.move(25, 250) self.styleChoice.move(50, 150) comboBox.activated[str].connect(self.style_choice) self.show()
def __init__(self): super().__init__() self.ui=Ui_Form() self.ui.setupUi(self) self.ui.comboBox.addItems(QStyleFactory.keys()) #QApplication.setStyle(QStyleFactory.create('Windows')) self.show()
def get_style_combo_box(self): combo_box = QComboBox() combo_box.addItems(QStyleFactory.keys()) combo_box.activated[str].connect(self.change_style) all_items = [combo_box.itemText(i) for i in range(combo_box.count())] idx = all_items.index('Fusion') combo_box.setCurrentIndex(idx) return combo_box
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&University") styleLabel.setBuddy(styleComboBox) lineEditGPA = QLineEdit('GPA') styleLabel2 = QLabel("&GPA") styleLabel2.setBuddy(lineEditGPA) self.useStylePaletteCheckBox = QCheckBox("&Top University") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Others") #self.createTopLeftGroupBox() #self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() #self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) #disableWidgetsCheckBox.toggled.connect(self.topLeftGroupBox.setDisabled) #disableWidgetsCheckBox.toggled.connect(self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) #mainLayout.addWidget(self.topLeftGroupBox, 1, 0) #mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomRightGroupBox, 1, 0) mainLayout.addWidget(self.bottomLeftTabWidget, 1, 1) #mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Sydney University - Schoolarship point system") self.changeStyle('G8')
def setAppStyle(app): if "Fusion" in [st for st in QStyleFactory.keys()]: app.setStyle(QStyleFactory.create("Fusion")) elif sys.platform == "win32": app.setStyle(QStyleFactory.create("WindowsVista")) elif sys.platform == "linux": app.setStyle(QStyleFactory.create("gtk")) elif sys.platform == "darwin": app.setStyle(QStyleFactory.create("macintosh"))
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.textbox_joke = QTextBrowser(self) self.textbox_day = QLineEdit(self) self.textbox_month = QLineEdit(self) self.textbox_year = QLineEdit(self) self.textbox_day_stats = QLineEdit(self) self.textbox_month_stats = QLineEdit(self) self.textbox_year_stats = QLineEdit(self) self.textbox_found_measurments = QTextBrowser(self) self.textbox_measurment = QLineEdit(self) self.textbox_average = QLineEdit(self) self.textbox_standard_deviation = QLineEdit(self) self.AddMeasurmentGroupBox = QGroupBox("Dodaj nowy pomiar") self.SearchingGroupBox = QGroupBox("Przeszukiwanie bazy") self.JokesGroupBox = QGroupBox("Kącik rozrywkowy") self.StatisticsGroupBox = QGroupBox("Statystyka") self.originalPalette = QApplication.palette() style_combo_box = QComboBox() style_combo_box.addItems(QStyleFactory.keys()) style_label = QLabel("&Style:") style_label.setBuddy(style_combo_box) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disable_widgets_check_box = QCheckBox("&Disable widgets") self.createAddMeasurmentGroupBox() self.createSearchingGroupBox() self.createJokesGroupBox() self.createStatisticsGroupBox() self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disable_widgets_check_box.toggled.connect( self.AddMeasurmentGroupBox.setDisabled) top_layout = QHBoxLayout() top_layout.addWidget(style_label) top_layout.addWidget(style_combo_box) top_layout.addStretch(3) top_layout.addWidget(self.useStylePaletteCheckBox) top_layout.addWidget(disable_widgets_check_box) main_layout = QGridLayout() main_layout.addWidget(self.AddMeasurmentGroupBox, 0, 0) main_layout.addWidget(self.SearchingGroupBox, 1, 0) main_layout.addWidget(self.StatisticsGroupBox, 2, 0) main_layout.addWidget(self.JokesGroupBox, 3, 0) self.setLayout(main_layout) self.setWindowTitle("Dziennik") self.changeStyle('Fusion')
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.answer = "" self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox("&Use SP") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopRightGroupBox() self.createBottomRightGroupBox() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topRightGroupBox, 1, 0, 1, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 0, 1, 0) mainLayout.setRowStretch(1, 0) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("EagleVoice") self.changeStyle('Windows') with open('result.json', 'r') as fp: self.ques_dict = json.load(fp) self.ques_lst = [] self.answer = [] # self.master_lst = [] style = '''
def __init__(self, parent=None): super(Example, self).__init__(parent) QApplication.setStyle(QStyleFactory.create('Fusion')) # -------------- QCOMBOBOX ---------------------- cbx = QComboBox() # agregar lista de nombres de estilos disponibles cbx.addItems(QStyleFactory.keys()) # responder al evento cambio de texto cbx.currentTextChanged.connect(self.textChanged) # seleccionar el ultimo elemento cbx.setItemText(4, 'Fusion') # -------------- QLISTWIDGET --------------------- items = [ 'Ubuntu', 'Linux', 'Mac OS', 'Windows', 'Fedora', 'Chrome OS', 'Android', 'Windows Phone' ] self.lv = QListWidget() self.lv.addItems(items) self.lv.itemSelectionChanged.connect(self.itemChanged) # -------------- QTABLEWIDGET -------------------- self.table = QTableWidget(10, 3) # establecer nombre de cabecera de las columnas self.table.setHorizontalHeaderLabels( ['Nombre', 'Edad', 'Nacionalidad']) # evento producido cuando cambia el elemento seleccionado self.table.itemSelectionChanged.connect(self.tableItemChanged) # alternar color de fila self.table.setAlternatingRowColors(True) # seleccionar solo filas self.table.setSelectionBehavior(QTableWidget.SelectRows) # usar seleccion simple, una fila a la vez self.table.setSelectionMode(QTableWidget.SingleSelection) table_data = [("Alice", 15, "Panama"), ("Dana", 25, "Chile"), ("Fernada", 18, "Ecuador")] # agregar cada uno de los elementos al QTableWidget for i, (name, age, city) in enumerate(table_data): self.table.setItem(i, 0, QTableWidgetItem(name)) self.table.setItem(i, 1, QTableWidgetItem(str(age))) self.table.setItem(i, 2, QTableWidgetItem(city)) vbx = QVBoxLayout() vbx.addWidget(QPushButton('Tutoriales PyQT-5')) vbx.setAlignment(Qt.AlignTop) vbx.addWidget(cbx) vbx.addWidget(self.lv) vbx.addWidget(self.table) self.setWindowTitle("Items View") self.resize(362, 320) self.setLayout(vbx)
def initUI(self): self.setWindowIcon(QIcon('srail.jpg')) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget(self.output) self.createBottomRightGroupBox() # self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(0) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) # mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("RAIL CONDITION MONITORING SYSTEM") self.changeStyle('Fusion') self.setWindowFlags(Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint)
def __init_ui(self): self.view_button.setDisabled(True) self.__style.addItems(QStyleFactory.keys()) self.__style.currentIndexChanged.connect( lambda index: QApplication.setStyle(QStyleFactory.create(QStyleFactory.keys()[index]))) self.ShowFileEntry.setPlaceholderText('Ui文件目录') self.ShowFileEntry.textChanged.connect(lambda: self.view_button.setEnabled( False) if not self.ShowFileEntry.text() else self.view_button.setEnabled(True)) self.loadFileButton.setText('...') self.loadFileButton.clicked.connect(self.__load) self.view_button.clicked.connect(self.__view) self.setLayout(self.__layout) self.ShowFileEntry.setWhatsThis('文件') self.loadFileButton.setWhatsThis('选择文件') self.view_button.setWhatsThis('显示Ui文件') self.__layout.addWidget(self.ShowFileEntry, 0, 0) self.__layout.addWidget(self.loadFileButton, 0, 1) self.__layout.addWidget(self.__style, 1, 0) self.__layout.addWidget(self.view_button, 1, 1)
def __init__(self, parent=None): super(Example, self).__init__(parent) QApplication.setStyle(QStyleFactory.create('Fusion')) # -------------- QCOMBOBOX ---------------------- cbx = QComboBox() # agregar lista de nombres de estilos disponibles cbx.addItems(QStyleFactory.keys()) # responder al evento cambio de texto cbx.currentTextChanged.connect(self.textChanged) # seleccionar el ultimo elemento cbx.setItemText(4, 'Fusion') # -------------- QLISTWIDGET --------------------- items = ['Ubuntu', 'Linux', 'Mac OS', 'Windows', 'Fedora', 'Chrome OS', 'Android', 'Windows Phone'] self.lv = QListWidget() self.lv.addItems(items) self.lv.itemSelectionChanged.connect(self.itemChanged) # -------------- QTABLEWIDGET -------------------- self.table = QTableWidget(10, 3) # establecer nombre de cabecera de las columnas self.table.setHorizontalHeaderLabels(['Nombre', 'Edad', 'Nacionalidad']) # evento producido cuando cambia el elemento seleccionado self.table.itemSelectionChanged.connect(self.tableItemChanged) # alternar color de fila self.table.setAlternatingRowColors(True) # seleccionar solo filas self.table.setSelectionBehavior(QTableWidget.SelectRows) # usar seleccion simple, una fila a la vez self.table.setSelectionMode(QTableWidget.SingleSelection) table_data = [ ("Alice", 15, "Panama"), ("Dana", 25, "Chile"), ("Fernada", 18, "Ecuador") ] # agregar cada uno de los elementos al QTableWidget for i, (name, age, city) in enumerate(table_data): self.table.setItem(i, 0, QTableWidgetItem(name)) self.table.setItem(i, 1, QTableWidgetItem(str(age))) self.table.setItem(i, 2, QTableWidgetItem(city)) vbx = QVBoxLayout() vbx.addWidget(QPushButton('Tutoriales PyQT-5')) vbx.setAlignment(Qt.AlignTop) vbx.addWidget(cbx) vbx.addWidget(self.lv) vbx.addWidget(self.table) self.setWindowTitle("Items View") self.resize(362, 320) self.setLayout(vbx)
def initUI(self): self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox( "&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect( self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect( self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Styles") self.changeStyle('Windows')
def slot_setStyle(self): app.setStyleSheet('') tmp = self.sender().objectName()[6:] print(tmp) if tmp in QStyleFactory.keys(): app.setStyle(tmp) write_line(configure_file, 3, tmp) elif tmp == 'Dark': app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) write_line(configure_file, 3, tmp)
def home(self): '''Create what is placed at home. Here is also the toolbar placed. Toolbar can also be created at __init__ Here is also a checkbox defined; and a progress bar''' # BUTTONS btn0 = QPushButton('quit', self) # Button to quit btn0.clicked.connect(QCoreApplication.instance().quit) # Define action btn0.resize(50, 50) # Resize manually btn0.move(100, 200) # Move from origin 0,0 btn1 = QPushButton('close', self) # Button to close (redundant) btn1.clicked.connect( self.close_app) #action on click, calls method close_app btn1.resize(btn1.sizeHint()) # set to acceptable size automatic btn1.move(0, 100) # END BUTTONS extractA = QAction(QIcon('logo.png'), 'Salir de la app', self) extractA.triggered.connect(self.close_app) self.toolBar = self.addToolBar('Add toolbar Salir') self.toolBar.addAction(extractA) checkBox = QCheckBox('Check a box', self) # checkBox.toggle() # if you want to be checked in in the begin checkBox.move(0, 50) # Move the checkbox to a different corrdinate checkBox.stateChanged.connect(self.checking) self.progress = QProgressBar(self) self.progress.setGeometry(200, 80, 250, 20) self.btn2 = QPushButton('Descargar', self) self.btn2.setToolTip('This is a <b>QPushButton</b> widget') self.btn2.move(200, 120) self.btn2.clicked.connect(self.download) texto = 'a string passed to header' self.header_example = QLabel(texto, self) #Qlabel has a max char? self.header_example.move(25, 320) print(self.style().objectName()) print(QStyleFactory.keys()) self.styleChoice = QLabel('Default', self) comboBox = QComboBox(self) comboBox.addItem('Windows') comboBox.addItem('WindowsXP') comboBox.addItem('WindowsVista') comboBox.addItem('Fusion') comboBox.move(25, 280) self.styleChoice.move(25, 150) comboBox.activated[str].connect(self.style_choice) self.show() # Shows window
def createQApplication(app_name = 'Back In Time'): global qapp try: return qapp except NameError: pass qapp = QApplication(sys.argv + ['-title', app_name]) if os.geteuid() == 0 and \ qapp.style().objectName().lower() == 'windows' and \ 'GTK+' in QStyleFactory.keys(): qapp.setStyle('GTK+') return qapp
def __populateStyleCombo(self): """ Private method to populate the style combo box. """ curStyle = Preferences.getUI("Style") styles = sorted(list(QStyleFactory.keys())) self.styleComboBox.addItem(self.tr('System'), "System") for style in styles: self.styleComboBox.addItem(style, style) currentIndex = self.styleComboBox.findData(curStyle) if currentIndex == -1: currentIndex = 0 self.styleComboBox.setCurrentIndex(currentIndex)
def __init__(self, parent=None): super(WidgetGallery, self).__init__(parent) self.originalPalette = QApplication.palette() styleComboBox = QComboBox() styleComboBox.addItems(QStyleFactory.keys()) styleLabel = QLabel("&Style:") styleLabel.setBuddy(styleComboBox) self.useStylePaletteCheckBox = QCheckBox("&Use style's standard palette") self.useStylePaletteCheckBox.setChecked(True) disableWidgetsCheckBox = QCheckBox("&Disable widgets") self.createTopLeftGroupBox() self.createTopRightGroupBox() self.createBottomLeftTabWidget() self.createBottomRightGroupBox() self.createProgressBar() styleComboBox.activated[str].connect(self.changeStyle) self.useStylePaletteCheckBox.toggled.connect(self.changePalette) disableWidgetsCheckBox.toggled.connect(self.topLeftGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect(self.topRightGroupBox.setDisabled) disableWidgetsCheckBox.toggled.connect(self.bottomLeftTabWidget.setDisabled) disableWidgetsCheckBox.toggled.connect(self.bottomRightGroupBox.setDisabled) topLayout = QHBoxLayout() topLayout.addWidget(styleLabel) topLayout.addWidget(styleComboBox) topLayout.addStretch(1) topLayout.addWidget(self.useStylePaletteCheckBox) topLayout.addWidget(disableWidgetsCheckBox) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.topLeftGroupBox, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 1) mainLayout.setRowStretch(2, 1) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 1) self.setLayout(mainLayout) self.setWindowTitle("Styles") self.changeStyle('Windows')
def createQApplication(app_name = 'Back In Time'): global qapp try: return qapp except NameError: pass if StrictVersion(QT_VERSION_STR) >= StrictVersion('5.6') and \ hasattr(Qt, 'AA_EnableHighDpiScaling'): QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) qapp = QApplication(sys.argv + ['-title', app_name]) if os.geteuid() == 0 and \ qapp.style().objectName().lower() == 'windows' and \ 'GTK+' in QStyleFactory.keys(): qapp.setStyle('GTK+') return qapp
def __init__(self, parent=None): super(EmbeddedDialog, self).__init__(parent) self.ui = Ui_embeddedDialog() self.ui.setupUi(self) self.ui.layoutDirection.setCurrentIndex(self.layoutDirection() != Qt.LeftToRight) for styleName in QStyleFactory.keys(): self.ui.style.addItem(styleName) if self.style().objectName().lower() == styleName.lower(): self.ui.style.setCurrentIndex(self.ui.style.count() -1) self.ui.layoutDirection.activated.connect(self.layoutDirectionChanged) self.ui.spacing.valueChanged.connect(self.spacingChanged) self.ui.fontComboBox.currentFontChanged.connect(self.fontChanged) self.ui.style.activated[str].connect(self.styleChanged)
def __init__(self, parent=None): super(StyleSheetEditor, self).__init__(parent) self.ui = Ui_StyleSheetEditor() self.ui.setupUi(self) regExp = QRegExp(r'.(.*)\+?Style') defaultStyle = QApplication.style().metaObject().className() if regExp.exactMatch(defaultStyle): defaultStyle = regExp.cap(1) self.ui.styleCombo.addItems(QStyleFactory.keys()) self.ui.styleCombo.setCurrentIndex( self.ui.styleCombo.findText(defaultStyle, Qt.MatchContains)) self.ui.styleSheetCombo.setCurrentIndex( self.ui.styleSheetCombo.findText('Coffee')) self.loadStyleSheet('Coffee')
def loadSettings(self): s = QSettings() lang = s.value("language", "", str) try: index = self._langs.index(lang) except ValueError: index = 1 self.lang.setCurrentIndex(index) style = s.value("guistyle", "", str).lower() styles = [name.lower() for name in QStyleFactory.keys()] try: index = styles.index(style) + 1 except ValueError: index = 0 self.styleCombo.setCurrentIndex(index) self.systemIcons.setChecked(s.value("system_icons", True, bool)) self.tabsClosable.setChecked(s.value("tabs_closable", True, bool)) self.splashScreen.setChecked(s.value("splash_screen", True, bool)) self.allowRemote.setChecked(remote.enabled())
def __init__(self, page): super(General, self).__init__(page) grid = QGridLayout() self.setLayout(grid) self.langLabel = QLabel() self.lang = QComboBox(currentIndexChanged=self.changed) grid.addWidget(self.langLabel, 0, 0) grid.addWidget(self.lang, 0, 1) self.styleLabel = QLabel() self.styleCombo = QComboBox(currentIndexChanged=self.changed) grid.addWidget(self.styleLabel, 1, 0) grid.addWidget(self.styleCombo, 1, 1) self.systemIcons = QCheckBox(toggled=self.changed) grid.addWidget(self.systemIcons, 2, 0, 1, 3) self.tabsClosable = QCheckBox(toggled=self.changed) grid.addWidget(self.tabsClosable, 3, 0, 1, 3) self.splashScreen = QCheckBox(toggled=self.changed) grid.addWidget(self.splashScreen, 4, 0, 1, 3) self.allowRemote = QCheckBox(toggled=self.changed) grid.addWidget(self.allowRemote, 5, 0, 1, 3) grid.setColumnStretch(2, 1) # fill in the language combo self._langs = ["C", ""] self.lang.addItems(('', '')) langnames = [(language_names.languageName(lang, lang), lang) for lang in po.available()] langnames.sort() for name, lang in langnames: self._langs.append(lang) self.lang.addItem(name) # fill in style combo self.styleCombo.addItem('') self.styleCombo.addItems(QStyleFactory.keys()) app.translateUI(self)
def __init__(self): super().__init__() self.setWindowTitle('Styles') self.original_palette = QApplication.palette() styles = QLabel('Styles :') self.style_list = QComboBox() self.style_list.addItems(QStyleFactory.keys()) self.style_list.setCurrentIndex(3) self.style_list.activated[str].connect(self.change_style) self.standard_palette = QCheckBox("Standard palette") self.standard_palette.setChecked(False) self.standard_palette.toggled.connect(self.change_palette) self.change_style('Fusion') grid = QGridLayout() grid.addWidget(styles, 0, 0, 1, 1) grid.addWidget(self.style_list, 0, 1, 1, 1) grid.addWidget(self.standard_palette, 1, 0, 1, 2) self.setLayout(grid)
def setStyle(self, styleName, styleSheetFile): """ Public method to set the style of the interface. @param styleName name of the style to set (string) @param styleSheetFile name of a style sheet file to read to overwrite defaults of the given style (string) """ # step 1: set the style style = None if styleName != "System" and styleName in QStyleFactory.keys(): style = QStyleFactory.create(styleName) if style is None: style = QStyleFactory.create(self.defaultStyleName) if style is not None: QApplication.setStyle(style) # step 2: set a style sheet if styleSheetFile: try: f = open(styleSheetFile, "r", encoding="utf-8") styleSheet = f.read() f.close() except (IOError, OSError) as msg: E5MessageBox.warning( self, self.tr("Loading Style Sheet"), self.tr( """<p>The Qt Style Sheet file <b>{0}</b> could""" """ not be read.<br>Reason: {1}</p>""") .format(styleSheetFile, str(msg))) return else: styleSheet = "" e5App().setStyleSheet(styleSheet)
def createActions(self): self.addImagesAct = QAction("&Add Images...", self, shortcut="Ctrl+A", triggered=self.addImage) self.removeAllImagesAct = QAction("&Remove All Images", self, shortcut="Ctrl+R", triggered=self.removeAllImages) self.exitAct = QAction("&Quit", self, shortcut="Ctrl+Q", triggered=self.close) self.styleActionGroup = QActionGroup(self) for styleName in QStyleFactory.keys(): action = QAction(self.styleActionGroup, text="%s Style" % styleName, checkable=True, triggered=self.changeStyle) action.setData(styleName) self.guessModeStateAct = QAction("&Guess Image Mode/State", self, checkable=True, checked=True) self.aboutAct = QAction("&About", self, triggered=self.about) self.aboutQtAct = QAction("About &Qt", self, triggered=QApplication.instance().aboutQt)
def get_styles(): return QStyleFactory.keys() + ['LiSP']
def __init__(self, parent, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.grandparent = parent.persepolis_main self.persepolis_setting.beginGroup('settings') # initialization self.tries_spinBox.setValue( int(self.persepolis_setting.value('max-tries'))) self.wait_spinBox.setValue( int(self.persepolis_setting.value('retry-wait'))) self.time_out_spinBox.setValue( int(self.persepolis_setting.value('timeout'))) self.connections_spinBox.setValue( int(self.persepolis_setting.value('connections'))) self.rpc_port_spinbox.setValue( int(self.persepolis_setting.value('rpc-port'))) # wait_queue wait_queue_list = self.persepolis_setting.value('wait-queue') q_time = QTime(int(wait_queue_list[0]), int(wait_queue_list[1])) self.wait_queue_time.setTime(q_time) # save_as_tab self.download_folder_lineEdit.setText( str(self.persepolis_setting.value('download_path'))) self.temp_download_lineEdit.setText( str(self.persepolis_setting.value('download_path_temp'))) # subfolder if str(self.persepolis_setting.value('subfolder')) == 'yes': self.subfolder_checkBox.setChecked(True) else: self.subfolder_checkBox.setChecked(False) # notifications_tab self.volume_label.setText( 'Volume : ' + str(self.persepolis_setting.value('sound-volume'))) self.volume_dial.setValue( int(self.persepolis_setting.value('sound-volume'))) # set style # if style_comboBox is changed, self.styleComboBoxChanged is called. self.style_comboBox.currentIndexChanged.connect(self.styleComboBoxChanged) # finding available styles(It's depends on operating system and desktop environments). available_styles = QStyleFactory.keys() for style in available_styles: self.style_comboBox.addItem(style) # System >> for system default style # when user select System for style section, the default system style is using. self.style_comboBox.addItem('System') current_style_index = self.style_comboBox.findText( str(self.persepolis_setting.value('style'))) if current_style_index != -1: self.style_comboBox.setCurrentIndex(current_style_index) # set color_scheme color_scheme = ['System', 'Persepolis Dark Red', 'Persepolis Dark Blue', 'Persepolis ArcDark Red', 'Persepolis ArcDark Blue', 'Persepolis Light Red', 'Persepolis Light Blue'] self.color_comboBox.addItems(color_scheme) current_color_index = self.color_comboBox.findText( str(self.persepolis_setting.value('color-scheme'))) self.color_comboBox.setCurrentIndex(current_color_index) # set icons icons = ['Archdroid-Red', 'Archdroid-Blue', 'Breeze', 'Breeze-Dark'] self.icon_comboBox.addItems(icons) current_icons_index = self.icon_comboBox.findText( str(self.persepolis_setting.value('icons'))) self.icon_comboBox.setCurrentIndex(current_icons_index) self.current_icon = str(self.icon_comboBox.currentText()) # set notification notifications = ['Native notification', 'QT notification'] self.notification_comboBox.addItems(notifications) current_notification_index = self.notification_comboBox.findText( str(self.persepolis_setting.value('notification'))) self.notification_comboBox.setCurrentIndex(current_notification_index) # set font font_setting = QFont() font_setting.setFamily(str(self.persepolis_setting.value('font'))) self.fontComboBox.setCurrentFont(font_setting) self.font_size_spinBox.setValue( int(self.persepolis_setting.value('font-size'))) # sound frame self.sound_frame.setEnabled(False) self.enable_notifications_checkBox.toggled.connect(self.soundFrame) if str(self.persepolis_setting.value('sound')) == 'yes': self.enable_notifications_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # connect folder buttons self.download_folder_lineEdit.setEnabled(False) self.download_folder_pushButton.clicked.connect( self.downloadFolderPushButtonClicked) self.temp_download_lineEdit.setEnabled(False) self.temp_download_pushButton.clicked.connect( self.tempDownloadPushButtonClicked) # dial self.volume_dial.setNotchesVisible(True) self.volume_dial.valueChanged.connect(self.dialChanged) # tray icon if str(self.persepolis_setting.value('tray-icon')) == 'yes': self.enable_system_tray_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # show_menubar if str(self.persepolis_setting.value('show-menubar')) == 'yes': self.show_menubar_checkbox.setChecked(True) else: self.show_menubar_checkbox.setChecked(False) if platform.system() == 'Darwin': self.show_menubar_checkbox.setChecked(True) self.show_menubar_checkbox.hide() # show_sidepanel if str(self.persepolis_setting.value('show-sidepanel')) == 'yes': self.show_sidepanel_checkbox.setChecked(True) else: self.show_sidepanel_checkbox.setChecked(False) # show ProgressWindow if str(self.persepolis_setting.value('show-progress')) == 'yes': self.show_progress_window_checkbox.setChecked(True) else: self.show_progress_window_checkbox.setChecked(False) # after download dialog if str(self.persepolis_setting.value('after-dialog')) == 'yes': self.after_download_checkBox.setChecked(True) else: self.after_download_checkBox.setChecked(False) # run persepolis at startup checkBox if str(self.persepolis_setting.value('startup')) == 'yes': self.startup_checkbox.setChecked(True) else: self.startup_checkbox.setChecked(False) # font_checkBox if str(self.persepolis_setting.value('custom-font')) == 'yes': self.font_checkBox.setChecked(True) else: self.font_checkBox.setChecked(False) self.fontCheckBoxState(self.font_checkBox) # keep_awake_checkBox if str(self.persepolis_setting.value('awake')) == 'yes': self.keep_awake_checkBox.setChecked(True) else: self.keep_awake_checkBox.setChecked(False) # columns_tab if str(self.persepolis_setting.value('column0')) == 'yes': self.column0_checkBox.setChecked(True) else: self.column0_checkBox.setChecked(False) if str(self.persepolis_setting.value('column1')) == 'yes': self.column1_checkBox.setChecked(True) else: self.column1_checkBox.setChecked(False) if str(self.persepolis_setting.value('column2')) == 'yes': self.column2_checkBox.setChecked(True) else: self.column2_checkBox.setChecked(False) if str(self.persepolis_setting.value('column3')) == 'yes': self.column3_checkBox.setChecked(True) else: self.column3_checkBox.setChecked(False) if str(self.persepolis_setting.value('column4')) == 'yes': self.column4_checkBox.setChecked(True) else: self.column4_checkBox.setChecked(False) if str(self.persepolis_setting.value('column5')) == 'yes': self.column5_checkBox.setChecked(True) else: self.column5_checkBox.setChecked(False) if str(self.persepolis_setting.value('column6')) == 'yes': self.column6_checkBox.setChecked(True) else: self.column6_checkBox.setChecked(False) if str(self.persepolis_setting.value('column7')) == 'yes': self.column7_checkBox.setChecked(True) else: self.column7_checkBox.setChecked(False) if str(self.persepolis_setting.value('column10')) == 'yes': self.column10_checkBox.setChecked(True) else: self.column10_checkBox.setChecked(False) if str(self.persepolis_setting.value('column11')) == 'yes': self.column11_checkBox.setChecked(True) else: self.column11_checkBox.setChecked(False) if str(self.persepolis_setting.value('column12')) == 'yes': self.column12_checkBox.setChecked(True) else: self.column12_checkBox.setChecked(False) # ok cancel default button self.cancel_pushButton.clicked.connect(self.close) self.defaults_pushButton.clicked.connect( self.defaultsPushButtonPressed) self.ok_pushButton.clicked.connect(self.okPushButtonPressed) # font_checkBox connect self.font_checkBox.stateChanged.connect(self.fontCheckBoxState) # saving initial value of self.persepolis_setting in self.first_key_value_dict # at the end! in the okPushButtonPressed method, first_key_value_dict will compared with second_key_value_dict. # if any thing changed , then a message box notify user about "some changes take effect after restarting persepolis". self.first_key_value_dict = {} for member in self.persepolis_setting.allKeys(): self.first_key_value_dict[member] = str(self.persepolis_setting.value(member)) self.persepolis_setting.endGroup() # setting window size and position size = self.persepolis_setting.value( 'PreferencesWindow/size', QSize(578, 565)) position = self.persepolis_setting.value( 'PreferencesWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def test_general(MWSampleProject): MW = MWSampleProject # Loading from mainWindow MW.actSettings.triggered.emit() assert MW.sw.isVisible() MW.sw.close() MW.actLabels.triggered.emit() assert MW.sw.isVisible() MW.sw.close() MW.actStatus.triggered.emit() assert MW.sw.isVisible() MW.sw.hide() MW.sw.setTab("General") SW = MW.sw # Imports from PyQt5.QtWidgets import qApp, QStyleFactory from PyQt5.QtCore import QSettings, Qt qS = QSettings(qApp.organizationName(), qApp.applicationName()) from manuskript import settings as S # Style assert SW.cmbStyle.count() == len(list(QStyleFactory.keys())) if qS.value("applicationStyle"): assert SW.cmbStyle.currentText() == qS.value("applicationStyle") ## Seg fault when trying to set the style in tests: # for s in styles: # SW.cmbStyle.setCurrentText(s) # assert S.value("applicationStyle") == s # Translations if qS.value("applicationTranslation"): assert (SW.cmbTranslation.currentData() == qS.value("applicationTranslation")) for name in SW.translations: SW.cmbTranslation.setCurrentText(name) if qS.value("applicationTranslation"): assert qS.value("applicationTranslation") == SW.translations[name] def switchCheckBoxAndAssert(chk, settings): """ Asserts that the check state is that of settings, change checkstate and asserts settings has been changed. Settings is a function that returns the value. """ state = settings() assert chk.isChecked() == state chk.setChecked(not state) assert chk.isChecked() is not state # Loading and Saving SW.txtAutoSave.setText("0") SW.txtAutoSaveNoChanges.setText("0") switchCheckBoxAndAssert(SW.chkAutoLoad, lambda: qS.value("autoLoad", type=bool)) switchCheckBoxAndAssert(SW.chkAutoSave, lambda: S.autoSave) switchCheckBoxAndAssert(SW.chkAutoSaveNoChanges, lambda: S.autoSaveNoChanges) switchCheckBoxAndAssert(SW.chkSaveOnQuit, lambda: S.saveOnQuit) switchCheckBoxAndAssert(SW.chkSaveToZip, lambda: S.saveToZip) # Revisions switchCheckBoxAndAssert(SW.chkRevisionsKeep, lambda: S.revisions["keep"]) switchCheckBoxAndAssert(SW.chkRevisionRemove, lambda: S.revisions["smartremove"]) # Views # Simple way here, we just call the functions. SW.cmbTreeIcon.currentIndexChanged.emit(0) SW.cmbOutlineIcon.currentIndexChanged.emit(0) SW.cmbCorkIcon.currentIndexChanged.emit(0) SW.chkOutlineTitle.setChecked(Qt.Checked) #outlineColumnsChanged SW.chkOutlineTitle.setChecked(Qt.Unchecked) SW.chkOutlineTitle.setChecked(Qt.Checked) # Can't test because of the dialog # assert SW.setCorkColor() is None SW.sldTreeIconSize.setValue(SW.sldTreeIconSize.value() + 1) SW.rdoCorkNewStyle.toggled.emit(True) SW.cmbCorkImage.currentIndexChanged.emit(0) SW.cmbCorkImage.currentIndexChanged.emit(1) # Test editor: same problem as above # choseEditorFontColor # choseEditorMisspelledColor # choseEditorBackgroundColor # Test editor switchCheckBoxAndAssert(SW.chkEditorBackgroundTransparent, lambda: S.textEditor["backgroundTransparent"]) assert SW.restoreEditorColors() is None switchCheckBoxAndAssert(SW.chkEditorNoBlinking, lambda: S.textEditor["cursorNotBlinking"]) # Twice on purpose: set and restore switchCheckBoxAndAssert(SW.chkEditorNoBlinking, lambda: S.textEditor["cursorNotBlinking"]) # Manually call updateAllWidgets, because other wise timer of 250ms SW.updateAllWidgets() # Labels assert SW.updateLabelColor(MW.mdlLabels.item(1).index()) is None rc = MW.mdlLabels.rowCount() SW.addLabel() SW.lstLabels.setCurrentIndex( MW.mdlLabels.item(MW.mdlLabels.rowCount() - 1).index()) SW.removeLabel() assert MW.mdlLabels.rowCount() == rc # setLabelColor # Same problem as above # Status rc = MW.mdlStatus.rowCount() SW.addStatus() SW.lstStatus.setCurrentIndex( MW.mdlStatus.item(MW.mdlStatus.rowCount() - 1).index()) SW.removeStatus() assert MW.mdlStatus.rowCount() == rc # Fullscreen # self.lstThemes.currentItemChanged.connect(self.themeSelected) item = SW.lstThemes.item(0) SW.lstThemes.currentItemChanged.emit(item, None) assert S.fullScreenTheme in item.data(Qt.UserRole) SW.lstThemes.currentItemChanged.emit(None, None) count = SW.lstThemes.count() SW.newTheme() assert SW.lstThemes.count() == count + 1 SW.newTheme() # theme with same name item = SW.lstThemes.item(SW.lstThemes.count() - 1) SW.lstThemes.setCurrentItem(item) SW.removeTheme() item = SW.lstThemes.item(count) SW.lstThemes.setCurrentItem(item) SW.editTheme() switchCheckBoxAndAssert(SW.chkThemeIndent, lambda: SW._themeData["Spacings/IndentFirstLine"]) SW.updateThemeFont(None) SW.updateThemeBackground(0) SW.updateThemeBackground(1) SW.spnThemeLineSpacing.setValue(123) for i in range(4): SW.updateLineSpacing(i) SW.updateUIFromTheme() # No time to wait on timer assert SW._editingTheme is not None SW.resize(SW.geometry().size()) # resizeEvent #TODO: other edit test (see SW.loadTheme SW.saveTheme() item = SW.lstThemes.item(count) SW.lstThemes.setCurrentItem(item) SW.editTheme() SW.cancelEdit() item = SW.lstThemes.item(count) SW.lstThemes.setCurrentItem(item) SW.removeTheme() assert SW.lstThemes.count() == count
def __init__(self, parent, persepolis_setting): super().__init__(persepolis_setting) self.persepolis_setting = persepolis_setting self.parent = parent self.grandparent = parent.persepolis_main self.persepolis_setting.beginGroup('settings') # initialization self.tries_spinBox.setValue( int(self.persepolis_setting.value('max-tries'))) self.wait_spinBox.setValue( int(self.persepolis_setting.value('retry-wait'))) self.time_out_spinBox.setValue( int(self.persepolis_setting.value('timeout'))) self.connections_spinBox.setValue( int(self.persepolis_setting.value('connections'))) self.rpc_port_spinbox.setValue( int(self.persepolis_setting.value('rpc-port'))) # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # wait_queue wait_queue_list = self.persepolis_setting.value('wait-queue') q_time = QTime(int(wait_queue_list[0]), int(wait_queue_list[1])) self.wait_queue_time.setTime(q_time) # change aria2 path self.aria2_path_pushButton.clicked.connect(self.changeAria2Path) self.aria2_path_checkBox.toggled.connect(self.ariaCheckBoxToggled) aria2_path = self.persepolis_setting.value('settings/aria2_path') self.aria2_path_lineEdit.setEnabled(False) if aria2_path != None: self.aria2_path_checkBox.setChecked(True) self.aria2_path_lineEdit.setText(str(aria2_path)) self.ariaCheckBoxToggled('aria2') if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD': for widget in self.aria2_path_checkBox, self.aria2_path_lineEdit, self.aria2_path_pushButton: widget.hide() # save_as_tab self.download_folder_lineEdit.setText( str(self.persepolis_setting.value('download_path'))) self.temp_download_lineEdit.setText( str(self.persepolis_setting.value('download_path_temp'))) # subfolder if str(self.persepolis_setting.value('subfolder')) == 'yes': self.subfolder_checkBox.setChecked(True) else: self.subfolder_checkBox.setChecked(False) # notifications_tab self.volume_label.setText( 'Volume : ' + str(self.persepolis_setting.value('sound-volume'))) self.volume_dial.setValue( int(self.persepolis_setting.value('sound-volume'))) # set style # if style_comboBox is changed, self.styleComboBoxChanged is called. self.style_comboBox.currentIndexChanged.connect(self.styleComboBoxChanged) # find available styles(It's depends on operating system and desktop environments). available_styles = QStyleFactory.keys() for style in available_styles: # 'GTK' or 'gtk' styles may cause to crashing! Eliminate them! if 'gtk' not in str(style) and 'GTK' not in str(style): self.style_comboBox.addItem(style) # System >> for system default style # when user select System for style section, the default system style is using. self.style_comboBox.addItem('System') current_style_index = self.style_comboBox.findText( str(self.persepolis_setting.value('style'))) if current_style_index != -1: self.style_comboBox.setCurrentIndex(current_style_index) # available language available_language = ['en_US', 'fa_IR', 'zh_CN', 'fr_FR'] for lang in available_language: self.lang_comboBox.addItem(str(QLocale(lang).nativeLanguageName()), lang) current_locale = self.lang_comboBox.findData( str(self.persepolis_setting.value('locale'))) self.lang_comboBox.setCurrentIndex(current_locale) self.lang_comboBox.currentIndexChanged.connect(self.styleComboBoxChanged) self.styleComboBoxChanged() current_color_index = self.color_comboBox.findText( str(self.persepolis_setting.value('color-scheme'))) self.color_comboBox.setCurrentIndex(current_color_index) self.current_icon = self.persepolis_setting.value('icons') # icon size size = ['128', '64', '48', '32', '24', '16'] self.icons_size_comboBox.addItems(size) current_icons_size_index = self.icons_size_comboBox.findText( str(self.persepolis_setting.value('toolbar_icon_size'))) self.icons_size_comboBox.setCurrentIndex(current_icons_size_index) # call iconSizeComboBoxCanged if index is changed self.icons_size_comboBox.currentIndexChanged.connect(self.iconSizeComboBoxCanged) self.iconSizeComboBoxCanged(1) # set notification notifications = ['Native notification', 'QT notification'] self.notification_comboBox.addItems(notifications) current_notification_index = self.notification_comboBox.findText( str(self.persepolis_setting.value('notification'))) self.notification_comboBox.setCurrentIndex(current_notification_index) # set font font_setting = QFont() font_setting.setFamily(str(self.persepolis_setting.value('font'))) self.fontComboBox.setCurrentFont(font_setting) self.font_size_spinBox.setValue( int(self.persepolis_setting.value('font-size'))) # sound frame self.sound_frame.setEnabled(False) self.enable_notifications_checkBox.toggled.connect(self.soundFrame) if str(self.persepolis_setting.value('sound')) == 'yes': self.enable_notifications_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # connect folder buttons self.download_folder_lineEdit.setEnabled(False) self.download_folder_pushButton.clicked.connect( self.downloadFolderPushButtonClicked) self.temp_download_lineEdit.setEnabled(False) self.temp_download_pushButton.clicked.connect( self.tempDownloadPushButtonClicked) # dial self.volume_dial.setNotchesVisible(True) self.volume_dial.valueChanged.connect(self.dialChanged) # tray icon if str(self.persepolis_setting.value('tray-icon')) == 'yes': self.enable_system_tray_checkBox.setChecked(True) else: self.enable_notifications_checkBox.setChecked(False) # show_menubar if str(self.persepolis_setting.value('show-menubar')) == 'yes': self.show_menubar_checkbox.setChecked(True) else: self.show_menubar_checkbox.setChecked(False) if platform.system() == 'Darwin': self.show_menubar_checkbox.setChecked(True) self.show_menubar_checkbox.hide() # show_sidepanel if str(self.persepolis_setting.value('show-sidepanel')) == 'yes': self.show_sidepanel_checkbox.setChecked(True) else: self.show_sidepanel_checkbox.setChecked(False) # show ProgressWindow if str(self.persepolis_setting.value('show-progress')) == 'yes': self.show_progress_window_checkbox.setChecked(True) else: self.show_progress_window_checkbox.setChecked(False) # after download dialog if str(self.persepolis_setting.value('after-dialog')) == 'yes': self.after_download_checkBox.setChecked(True) else: self.after_download_checkBox.setChecked(False) # run persepolis at startup checkBox if str(self.persepolis_setting.value('startup')) == 'yes': self.startup_checkbox.setChecked(True) else: self.startup_checkbox.setChecked(False) # font_checkBox if str(self.persepolis_setting.value('custom-font')) == 'yes': self.font_checkBox.setChecked(True) else: self.font_checkBox.setChecked(False) self.fontCheckBoxState(self.font_checkBox) # keep_awake_checkBox if str(self.persepolis_setting.value('awake')) == 'yes': self.keep_awake_checkBox.setChecked(True) else: self.keep_awake_checkBox.setChecked(False) # columns_tab if str(self.persepolis_setting.value('column0')) == 'yes': self.column0_checkBox.setChecked(True) else: self.column0_checkBox.setChecked(False) if str(self.persepolis_setting.value('column1')) == 'yes': self.column1_checkBox.setChecked(True) else: self.column1_checkBox.setChecked(False) if str(self.persepolis_setting.value('column2')) == 'yes': self.column2_checkBox.setChecked(True) else: self.column2_checkBox.setChecked(False) if str(self.persepolis_setting.value('column3')) == 'yes': self.column3_checkBox.setChecked(True) else: self.column3_checkBox.setChecked(False) if str(self.persepolis_setting.value('column4')) == 'yes': self.column4_checkBox.setChecked(True) else: self.column4_checkBox.setChecked(False) if str(self.persepolis_setting.value('column5')) == 'yes': self.column5_checkBox.setChecked(True) else: self.column5_checkBox.setChecked(False) if str(self.persepolis_setting.value('column6')) == 'yes': self.column6_checkBox.setChecked(True) else: self.column6_checkBox.setChecked(False) if str(self.persepolis_setting.value('column7')) == 'yes': self.column7_checkBox.setChecked(True) else: self.column7_checkBox.setChecked(False) if str(self.persepolis_setting.value('column10')) == 'yes': self.column10_checkBox.setChecked(True) else: self.column10_checkBox.setChecked(False) if str(self.persepolis_setting.value('column11')) == 'yes': self.column11_checkBox.setChecked(True) else: self.column11_checkBox.setChecked(False) if str(self.persepolis_setting.value('column12')) == 'yes': self.column12_checkBox.setChecked(True) else: self.column12_checkBox.setChecked(False) # video_finder self.enable_video_finder_checkbox.stateChanged.connect(self.videoFinderFram) self.enable_video_finder_checkbox.setChecked(persepolis_setting.value('video_finder/enable', 'yes') == 'yes') self.hide_no_audio_checkbox.setChecked(persepolis_setting.value('video_finder/hide_no_audio') == 'yes') self.hide_no_video_checkbox.setChecked(persepolis_setting.value('video_finder/hide_no_video') == 'yes') try: # Integer casting may raise exception. self.max_links_spinBox.setValue(int(persepolis_setting.value('video_finder/max_links', 3))) except: pass self.videoFinderFram() # ok cancel default button self.cancel_pushButton.clicked.connect(self.close) self.defaults_pushButton.clicked.connect( self.defaultsPushButtonPressed) self.ok_pushButton.clicked.connect(self.okPushButtonPressed) # font_checkBox connect self.font_checkBox.stateChanged.connect(self.fontCheckBoxState) # saving initial value of self.persepolis_setting in self.first_key_value_dict # at the end! in the okPushButtonPressed method, first_key_value_dict will compared with second_key_value_dict. # if any thing changed , then a message box notify user about "some changes take effect after restarting persepolis". self.first_key_value_dict = {} for member in self.persepolis_setting.allKeys(): self.first_key_value_dict[member] = str(self.persepolis_setting.value(member)) self.persepolis_setting.endGroup() # setting window size and position size = self.persepolis_setting.value( 'PreferencesWindow/size', QSize(578, 565)) position = self.persepolis_setting.value( 'PreferencesWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def __init__(self, mainWindow): QWidget.__init__(self) self.setupUi(self) self.mw = mainWindow # UI for l in [self.lblTitleGeneral, self.lblTitleGeneral_2, self.lblTitleViews, self.lblTitleLabels, self.lblTitleStatus, self.lblTitleFullscreen, ]: l.setStyleSheet(S.titleLabelSS()) icons = [QIcon.fromTheme("configure"), QIcon.fromTheme("history-view"), QIcon.fromTheme("gnome-settings"), themeIcon("label"), themeIcon("status"), QIcon.fromTheme("preferences-desktop-theme") ] for i in range(self.lstMenu.count()): item = self.lstMenu.item(i) item.setSizeHint(QSize(item.sizeHint().width(), 42)) item.setTextAlignment(Qt.AlignCenter) if icons[i]: item.setIcon(icons[i]) self.lstMenu.setMaximumWidth(140) self.lstMenu.setMinimumWidth(140) # General self.cmbStyle.addItems(list(QStyleFactory.keys())) self.cmbStyle.setCurrentIndex( [i.lower() for i in list(QStyleFactory.keys())] .index(qApp.style().objectName())) self.cmbStyle.currentIndexChanged[str].connect(self.setStyle) self.cmbTranslation.clear() tr = OrderedDict() tr["English"] = "" tr["Arabic (Saudi Arabia)"] = "manuskript_ar_SA.qm" tr["Deutsch"] = "manuskript_de.qm" tr["Español"] = "manuskript_es.qm" tr["Français"] = "manuskript_fr.qm" tr["Hungarian"] = "manuskript_hu.qm" tr["Indonesian"] = "manuskript_id.qm" tr["Italian"] = "manuskript_it.qm" tr["Norwegian Bokmål"] = "manuskript_nb_NO.qm" tr["Dutch"] = "manuskript_nl.qm" tr["Polish"] = "manuskript_pl.qm" tr["Portuguese (Brazil)"] = "manuskript_pt_BR.qm" tr["Portuguese (Portugal)"] = "manuskript_pt_PT.qm" tr["Russian"] = "manuskript_ru.qm" tr["Svenska"] = "manuskript_sv.qm" tr["Ukranian"] = "manuskript_uk.qm" tr["Chinese (Simplified)"] = "manuskript_zh_CN.qm" self.translations = tr for name in tr: self.cmbTranslation.addItem(name, tr[name]) sttgs = QSettings(qApp.organizationName(), qApp.applicationName()) if (sttgs.contains("applicationTranslation") and sttgs.value("applicationTranslation") in tr.values()): # Sets the correct translation self.cmbTranslation.setCurrentText( [i for i in tr if tr[i] == sttgs.value("applicationTranslation")][0]) self.cmbTranslation.currentIndexChanged.connect(self.setTranslation) f = qApp.font() self.spnGeneralFontSize.setValue(f.pointSize()) self.spnGeneralFontSize.valueChanged.connect(self.setAppFontSize) self.txtAutoSave.setValidator(QIntValidator(0, 999, self)) self.txtAutoSaveNoChanges.setValidator(QIntValidator(0, 999, self)) self.chkAutoSave.setChecked(settings.autoSave) self.chkAutoSaveNoChanges.setChecked(settings.autoSaveNoChanges) self.txtAutoSave.setText(str(settings.autoSaveDelay)) self.txtAutoSaveNoChanges.setText(str(settings.autoSaveNoChangesDelay)) self.chkSaveOnQuit.setChecked(settings.saveOnQuit) self.chkSaveToZip.setChecked(settings.saveToZip) self.chkAutoSave.stateChanged.connect(self.saveSettingsChanged) self.chkAutoSaveNoChanges.stateChanged.connect(self.saveSettingsChanged) self.chkSaveOnQuit.stateChanged.connect(self.saveSettingsChanged) self.chkSaveToZip.stateChanged.connect(self.saveSettingsChanged) self.txtAutoSave.textEdited.connect(self.saveSettingsChanged) self.txtAutoSaveNoChanges.textEdited.connect(self.saveSettingsChanged) autoLoad, last = self.mw.welcome.getAutoLoadValues() self.chkAutoLoad.setChecked(autoLoad) self.chkAutoLoad.stateChanged.connect(self.saveSettingsChanged) # Revisions opt = settings.revisions self.chkRevisionsKeep.setChecked(opt["keep"]) self.chkRevisionsKeep.stateChanged.connect(self.revisionsSettingsChanged) self.chkRevisionRemove.setChecked(opt["smartremove"]) self.chkRevisionRemove.toggled.connect(self.revisionsSettingsChanged) self.spnRevisions10Mn.setValue(60 / opt["rules"][10 * 60]) self.spnRevisions10Mn.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsHour.setValue(60 * 10 / opt["rules"][60 * 60]) self.spnRevisionsHour.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsDay.setValue(60 * 60 / opt["rules"][60 * 60 * 24]) self.spnRevisionsDay.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsMonth.setValue(60 * 60 * 24 / opt["rules"][60 * 60 * 24 * 30]) self.spnRevisionsMonth.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsEternity.setValue(60 * 60 * 24 * 7 / opt["rules"][None]) self.spnRevisionsEternity.valueChanged.connect(self.revisionsSettingsChanged) # Views self.tabViews.setCurrentIndex(0) lst = ["Nothing", "POV", "Label", "Progress", "Compile"] for cmb in self.viewSettingsDatas(): item, part = self.viewSettingsDatas()[cmb] cmb.setCurrentIndex(lst.index(settings.viewSettings[item][part])) cmb.currentIndexChanged.connect(self.viewSettingsChanged) for chk in self.outlineColumnsData(): col = self.outlineColumnsData()[chk] chk.setChecked(col in settings.outlineViewColumns) chk.stateChanged.connect(self.outlineColumnsChanged) self.chkOutlinePOV.setVisible(settings.viewMode != "simple") # Hides checkbox if non-fiction view mode for item, what, value in [ (self.rdoTreeItemCount, "InfoFolder", "Count"), (self.rdoTreeWC, "InfoFolder", "WC"), (self.rdoTreeProgress, "InfoFolder", "Progress"), (self.rdoTreeSummary, "InfoFolder", "Summary"), (self.rdoTreeNothing, "InfoFolder", "Nothing"), (self.rdoTreeTextWC, "InfoText", "WC"), (self.rdoTreeTextProgress, "InfoText", "Progress"), (self.rdoTreeTextSummary, "InfoText", "Summary"), (self.rdoTreeTextNothing, "InfoText", "Nothing"), ]: item.setChecked(settings.viewSettings["Tree"][what] == value) item.toggled.connect(self.treeViewSettignsChanged) self.sldTreeIconSize.valueChanged.connect(self.treeViewSettignsChanged) self.sldTreeIconSize.valueChanged.connect( lambda v: self.lblTreeIconSize.setText("{}x{}".format(v, v))) self.sldTreeIconSize.setValue(settings.viewSettings["Tree"]["iconSize"]) self.rdoCorkOldStyle.setChecked(settings.corkStyle == "old") self.rdoCorkNewStyle.setChecked(settings.corkStyle == "new") self.rdoCorkNewStyle.toggled.connect(self.setCorkStyle) self.rdoCorkOldStyle.toggled.connect(self.setCorkStyle) self.populatesCmbBackgrounds(self.cmbCorkImage) self.setCorkImageDefault() self.updateCorkColor() self.cmbCorkImage.currentIndexChanged.connect(self.setCorkBackground) self.btnCorkColor.clicked.connect(self.setCorkColor) # Text editor opt = settings.textEditor # Font self.setButtonColor(self.btnEditorFontColor, opt["fontColor"]) self.btnEditorFontColor.clicked.connect(self.choseEditorFontColor) self.setButtonColor(self.btnEditorMisspelledColor, opt["misspelled"]) self.btnEditorMisspelledColor.clicked.connect(self.choseEditorMisspelledColor) self.setButtonColor(self.btnEditorBackgroundColor, opt["background"]) self.btnEditorBackgroundColor.clicked.connect(self.choseEditorBackgroundColor) self.chkEditorBackgroundTransparent.setChecked(opt["backgroundTransparent"]) self.chkEditorBackgroundTransparent.stateChanged.connect(self.updateEditorSettings) self.btnEditorColorDefault.clicked.connect(self.restoreEditorColors) f = QFont() f.fromString(opt["font"]) self.cmbEditorFontFamily.setCurrentFont(f) self.cmbEditorFontFamily.currentFontChanged.connect(self.updateEditorSettings) self.spnEditorFontSize.setValue(f.pointSize()) self.spnEditorFontSize.valueChanged.connect(self.updateEditorSettings) # Cursor self.chkEditorCursorWidth.setChecked(opt["cursorWidth"] != 1) self.chkEditorCursorWidth.stateChanged.connect(self.updateEditorSettings) self.spnEditorCursorWidth.setValue(opt["cursorWidth"] if opt["cursorWidth"] != 1 else 9) self.spnEditorCursorWidth.valueChanged.connect(self.updateEditorSettings) self.spnEditorCursorWidth.setEnabled(opt["cursorWidth"] != 1) self.chkEditorNoBlinking.setChecked(opt["cursorNotBlinking"]) self.chkEditorNoBlinking.stateChanged.connect(self.setApplicationCursorBlinking) self.chkEditorTypeWriterMode.setChecked(opt["alwaysCenter"]) self.chkEditorTypeWriterMode.stateChanged.connect(self.updateEditorSettings) self.cmbEditorFocusMode.setCurrentIndex( 0 if not opt["focusMode"] else 1 if opt["focusMode"] == "sentence" else 2 if opt["focusMode"] == "line" else 3) self.cmbEditorFocusMode.currentIndexChanged.connect(self.updateEditorSettings) # Text areas self.chkEditorMaxWidth.setChecked(opt["maxWidth"] != 0) self.chkEditorMaxWidth.stateChanged.connect(self.updateEditorSettings) self.spnEditorMaxWidth.setEnabled(opt["maxWidth"] != 0) self.spnEditorMaxWidth.setValue(500 if opt["maxWidth"] == 0 else opt["maxWidth"]) self.spnEditorMaxWidth.valueChanged.connect(self.updateEditorSettings) self.spnEditorMarginsLR.setValue(opt["marginsLR"]) self.spnEditorMarginsLR.valueChanged.connect(self.updateEditorSettings) self.spnEditorMarginsTB.setValue(opt["marginsTB"]) self.spnEditorMarginsTB.valueChanged.connect(self.updateEditorSettings) # Paragraphs self.cmbEditorAlignment.setCurrentIndex(opt["textAlignment"]) self.cmbEditorAlignment.currentIndexChanged.connect(self.updateEditorSettings) self.cmbEditorLineSpacing.setCurrentIndex( 0 if opt["lineSpacing"] == 100 else 1 if opt["lineSpacing"] == 150 else 2 if opt["lineSpacing"] == 200 else 3) self.cmbEditorLineSpacing.currentIndexChanged.connect(self.updateEditorSettings) self.spnEditorLineSpacing.setValue(opt["lineSpacing"]) self.spnEditorLineSpacing.valueChanged.connect(self.updateEditorSettings) self.spnEditorLineSpacing.setEnabled(opt["lineSpacing"] not in [100, 150, 200]) self.spnEditorLineSpacing.valueChanged.connect(self.updateEditorSettings) self.spnEditorTabWidth.setValue(opt["tabWidth"]) self.spnEditorTabWidth.valueChanged.connect(self.updateEditorSettings) self.chkEditorIndent.setChecked(opt["indent"]) self.chkEditorIndent.stateChanged.connect(self.updateEditorSettings) self.spnEditorParaAbove.setValue(opt["spacingAbove"]) self.spnEditorParaAbove.valueChanged.connect(self.updateEditorSettings) self.spnEditorParaBelow.setValue(opt["spacingBelow"]) self.spnEditorParaBelow.valueChanged.connect(self.updateEditorSettings) self.timerUpdateWidgets = QTimer() self.timerUpdateWidgets.setSingleShot(True) self.timerUpdateWidgets.setInterval(250) self.timerUpdateWidgets.timeout.connect(self.updateAllWidgets) # Labels self.lstLabels.setModel(self.mw.mdlLabels) self.lstLabels.setRowHidden(0, True) self.lstLabels.clicked.connect(self.updateLabelColor) self.btnLabelAdd.clicked.connect(self.addLabel) self.btnLabelRemove.clicked.connect(self.removeLabel) self.btnLabelColor.clicked.connect(self.setLabelColor) # Statuses self.lstStatus.setModel(self.mw.mdlStatus) self.lstStatus.setRowHidden(0, True) self.btnStatusAdd.clicked.connect(self.addStatus) self.btnStatusRemove.clicked.connect(self.removeStatus) # Fullscreen self._editingTheme = None self.btnThemeEditOK.setIcon(qApp.style().standardIcon(QStyle.SP_DialogApplyButton)) self.btnThemeEditOK.clicked.connect(self.saveTheme) self.btnThemeEditCancel.setIcon(qApp.style().standardIcon(QStyle.SP_DialogCancelButton)) self.btnThemeEditCancel.clicked.connect(self.cancelEdit) self.cmbThemeEdit.currentIndexChanged.connect(self.themeEditStack.setCurrentIndex) self.cmbThemeEdit.setCurrentIndex(0) self.cmbThemeEdit.currentIndexChanged.emit(0) self.themeStack.setCurrentIndex(0) self.lstThemes.currentItemChanged.connect(self.themeSelected) self.populatesThemesList() self.btnThemeAdd.clicked.connect(self.newTheme) self.btnThemeEdit.clicked.connect(self.editTheme) self.btnThemeRemove.clicked.connect(self.removeTheme) self.timerUpdateFSPreview = QTimer() self.timerUpdateFSPreview.setSingleShot(True) self.timerUpdateFSPreview.setInterval(250) self.timerUpdateFSPreview.timeout.connect(self.updatePreview)
def __init__(self, mainWindow): QWidget.__init__(self) self.setupUi(self) self.mw = mainWindow # UI for i in range(self.lstMenu.count()): item = self.lstMenu.item(i) item.setSizeHint(QSize(item.sizeHint().width(), 42)) item.setTextAlignment(Qt.AlignCenter) self.lstMenu.setMaximumWidth(150) # General self.cmbStyle.addItems(list(QStyleFactory.keys())) self.cmbStyle.setCurrentIndex([i.lower() for i in list(QStyleFactory.keys())].index(qApp.style().objectName())) self.cmbStyle.currentIndexChanged[str].connect(self.setStyle) self.txtAutoSave.setValidator(QIntValidator(0, 999, self)) self.txtAutoSaveNoChanges.setValidator(QIntValidator(0, 999, self)) self.chkAutoSave.setChecked(settings.autoSave) self.chkAutoSaveNoChanges.setChecked(settings.autoSaveNoChanges) self.txtAutoSave.setText(str(settings.autoSaveDelay)) self.txtAutoSaveNoChanges.setText(str(settings.autoSaveNoChangesDelay)) self.chkSaveOnQuit.setChecked(settings.saveOnQuit) self.chkAutoSave.stateChanged.connect(self.saveSettingsChanged) self.chkAutoSaveNoChanges.stateChanged.connect(self.saveSettingsChanged) self.chkSaveOnQuit.stateChanged.connect(self.saveSettingsChanged) self.txtAutoSave.textEdited.connect(self.saveSettingsChanged) self.txtAutoSaveNoChanges.textEdited.connect(self.saveSettingsChanged) autoLoad, last = self.mw.welcome.getAutoLoadValues() self.chkAutoLoad.setChecked(autoLoad) self.chkAutoLoad.stateChanged.connect(self.saveSettingsChanged) dtt = [ ("t2t", self.tr("Txt2Tags"), "text-x-script"), ("html", self.tr("Rich Text (html)"), "text-html"), ("txt", self.tr("Plain Text"), "text-x-generic"), ] self.cmbDefaultTextType.clear() for t in dtt: self.cmbDefaultTextType.addItem(QIcon.fromTheme(t[2]), t[1], t[0]) i = self.cmbDefaultTextType.findData(settings.defaultTextType) if i != -1: self.cmbDefaultTextType.setCurrentIndex(i) self.cmbDefaultTextType.currentIndexChanged.connect(self.saveSettingsChanged) # Revisions opt = settings.revisions self.chkRevisionsKeep.setChecked(opt["keep"]) self.chkRevisionsKeep.stateChanged.connect(self.revisionsSettingsChanged) self.chkRevisionRemove.setChecked(opt["smartremove"]) self.chkRevisionRemove.toggled.connect(self.revisionsSettingsChanged) self.spnRevisions10Mn.setValue(60 / opt["rules"][10 * 60]) self.spnRevisions10Mn.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsHour.setValue(60 * 10 / opt["rules"][60 * 60]) self.spnRevisionsHour.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsDay.setValue(60 * 60 / opt["rules"][60 * 60 * 24]) self.spnRevisionsDay.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsMonth.setValue(60 * 60 * 24 / opt["rules"][60 * 60 * 24 * 30]) self.spnRevisionsMonth.valueChanged.connect(self.revisionsSettingsChanged) self.spnRevisionsEternity.setValue(60 * 60 * 24 * 7 / opt["rules"][None]) self.spnRevisionsEternity.valueChanged.connect(self.revisionsSettingsChanged) # Views self.tabViews.setCurrentIndex(0) lst = ["Nothing", "POV", "Label", "Progress", "Compile"] for cmb in self.viewSettingsDatas(): item, part = self.viewSettingsDatas()[cmb] cmb.setCurrentIndex(lst.index(settings.viewSettings[item][part])) cmb.currentIndexChanged.connect(self.viewSettingsChanged) for chk in self.outlineColumnsData(): col = self.outlineColumnsData()[chk] chk.setChecked(col in settings.outlineViewColumns) chk.stateChanged.connect(self.outlineColumnsChanged) for item, what, value in [ (self.rdoTreeItemCount, "InfoFolder", "Count"), (self.rdoTreeWC, "InfoFolder", "WC"), (self.rdoTreeProgress, "InfoFolder", "Progress"), (self.rdoTreeSummary, "InfoFolder", "Summary"), (self.rdoTreeNothing, "InfoFolder", "Nothing"), (self.rdoTreeTextWC, "InfoText", "WC"), (self.rdoTreeTextProgress, "InfoText", "Progress"), (self.rdoTreeTextSummary, "InfoText", "Summary"), (self.rdoTreeTextNothing, "InfoText", "Nothing"), ]: item.setChecked(settings.viewSettings["Tree"][what] == value) item.toggled.connect(self.treeViewSettignsChanged) self.populatesCmbBackgrounds(self.cmbCorkImage) self.setCorkImageDefault() self.updateCorkColor() self.cmbCorkImage.currentIndexChanged.connect(self.setCorkBackground) self.btnCorkColor.clicked.connect(self.setCorkColor) # Text editor opt = settings.textEditor self.setButtonColor(self.btnEditorFontColor, opt["fontColor"]) self.btnEditorFontColor.clicked.connect(self.choseEditorFontColor) self.setButtonColor(self.btnEditorMisspelledColor, opt["misspelled"]) self.btnEditorMisspelledColor.clicked.connect(self.choseEditorMisspelledColor) self.setButtonColor(self.btnEditorBackgroundColor, opt["background"]) self.btnEditorBackgroundColor.clicked.connect(self.choseEditorBackgroundColor) f = QFont() f.fromString(opt["font"]) self.cmbEditorFontFamily.setCurrentFont(f) self.cmbEditorFontFamily.currentFontChanged.connect(self.updateEditorSettings) self.spnEditorFontSize.setValue(f.pointSize()) self.spnEditorFontSize.valueChanged.connect(self.updateEditorSettings) self.cmbEditorLineSpacing.setCurrentIndex( 0 if opt["lineSpacing"] == 100 else 1 if opt["lineSpacing"] == 150 else 2 if opt["lineSpacing"] == 200 else 3) self.cmbEditorLineSpacing.currentIndexChanged.connect(self.updateEditorSettings) self.spnEditorLineSpacing.setValue(opt["lineSpacing"]) self.spnEditorLineSpacing.valueChanged.connect(self.updateEditorSettings) self.spnEditorLineSpacing.setEnabled(opt["lineSpacing"] not in [100, 150, 200]) self.spnEditorLineSpacing.valueChanged.connect(self.updateEditorSettings) self.spnEditorTabWidth.setValue(opt["tabWidth"]) self.spnEditorTabWidth.valueChanged.connect(self.updateEditorSettings) self.chkEditorIndent.setChecked(opt["indent"]) self.chkEditorIndent.stateChanged.connect(self.updateEditorSettings) self.spnEditorParaAbove.setValue(opt["spacingAbove"]) self.spnEditorParaAbove.valueChanged.connect(self.updateEditorSettings) self.spnEditorParaBelow.setValue(opt["spacingBelow"]) self.spnEditorParaAbove.valueChanged.connect(self.updateEditorSettings) # Labels self.lstLabels.setModel(self.mw.mdlLabels) self.lstLabels.setRowHidden(0, True) self.lstLabels.clicked.connect(self.updateLabelColor) self.btnLabelAdd.clicked.connect(self.addLabel) self.btnLabelRemove.clicked.connect(self.removeLabel) self.btnLabelColor.clicked.connect(self.setLabelColor) # Statuses self.lstStatus.setModel(self.mw.mdlStatus) self.lstStatus.setRowHidden(0, True) self.btnStatusAdd.clicked.connect(self.addStatus) self.btnStatusRemove.clicked.connect(self.removeStatus) # Fullscreen self._editingTheme = None self.btnThemeEditOK.setIcon(qApp.style().standardIcon(QStyle.SP_DialogApplyButton)) self.btnThemeEditOK.clicked.connect(self.saveTheme) self.btnThemeEditCancel.setIcon(qApp.style().standardIcon(QStyle.SP_DialogCancelButton)) self.btnThemeEditCancel.clicked.connect(self.cancelEdit) self.cmbThemeEdit.currentIndexChanged.connect(self.themeEditStack.setCurrentIndex) self.cmbThemeEdit.setCurrentIndex(0) self.cmbThemeEdit.currentIndexChanged.emit(0) self.themeStack.setCurrentIndex(0) self.lstThemes.currentItemChanged.connect(self.themeSelected) self.populatesThemesList() self.btnThemeAdd.clicked.connect(self.newTheme) self.btnThemeEdit.clicked.connect(self.editTheme) self.btnThemeRemove.clicked.connect(self.removeTheme)
def main(argv): a = TiledApplication(argv) a.setOrganizationDomain("mapeditor.org") a.setApplicationName("Tiled") a.setApplicationVersion("0.14.2") if sys.platform == 'darwin': a.setAttribute(Qt.AA_DontShowIconsInMenus) # Enable support for highres images (added in Qt 5.1, but off by default) a.setAttribute(Qt.AA_UseHighDpiPixmaps) if sys.platform != 'win32': baseName = QApplication.style().objectName() if (baseName == "windows"): # Avoid Windows 95 style at all cost if (QStyleFactory.keys().contains("Fusion")): baseName = "fusion" # Qt5 else: # Qt4 # e.g. if we are running on a KDE4 desktop desktopEnvironment = qgetenv("DESKTOP_SESSION") if (desktopEnvironment == "kde"): baseName = "plastique" else: baseName = "cleanlooks" a.setStyle(QStyleFactory.create(baseName)) languageManager = LanguageManager.instance() languageManager.installTranslators() commandLine = CommandLineHandler() if (not commandLine.parse(QCoreApplication.arguments())): return 0 if (commandLine.quit): return 0 if (commandLine.disableOpenGL): preferences.Preferences.instance().setUseOpenGL(False) PluginManager.instance().loadPlugins() if (commandLine.exportMap): # Get the path to the source file and target file if (commandLine.filesToOpen().length() < 2): qWarning(QCoreApplication.translate("Command line", "Export syntax is --export-map [format] ")) return 1 index = 0 if commandLine.filesToOpen().length() > 2: filter = commandLine.filesToOpen().at(index) index += 1 else: filter = None sourceFile = commandLine.filesToOpen().at(index) index += 1 targetFile = commandLine.filesToOpen().at(index) index += 1 chosenFormat = None formats = PluginManager.objects() if filter: # Find the map format supporting the given filter for format in formats: if not format.hasCapabilities(MapFormat.Write): continue if format.nameFilter().lower()==filter.lower(): chosenFormat = format break if not chosenFormat: qWarning(QCoreApplication.translate("Command line", "Format not recognized (see --export-formats)")) return 1 else: # Find the map format based on target file extension suffix = QFileInfo(targetFile).completeSuffix() for format in formats: if not format.hasCapabilities(MapFormat.Write): continue if suffix.lower() in format.nameFilter().lower(): if chosenFormat: qWarning(QCoreApplication.translate("Command line", "Non-unique file extension. Can't determine correct export format.")) return 1 chosenFormat = format if not chosenFormat: qWarning(QCoreApplication.translate("Command line", "No exporter found for target file.")) return 1 # Load the source file reader = MapReader() map = reader.readMap(sourceFile) if (not map): qWarning(QCoreApplication.translate("Command line", "Failed to load source map.")) return 1 # Write out the file success = chosenFormat.write(map.data(), targetFile) if (not success): qWarning(QCoreApplication.translate("Command line", "Failed to export map to target file.")) return 1 return 0 w = MainWindow() w.show() a.fileOpenRequest.connect(w.openFile) if (not commandLine.filesToOpen().isEmpty()): for fileName in commandLine.filesToOpen(): w.openFile(fileName) elif preferences.Preferences.instance().openLastFilesOnStartup(): w.openLastFiles() return a.exec()
def keys(): return [name.lower() for name in QStyleFactory.keys()]
def returnDefaultSettings(): os_type, desktop_env = osAndDesktopEnvironment() # persepolis temporary download folder if os_type != 'Windows': download_path_temp = str(home_address) + '/.persepolis' else: download_path_temp = os.path.join( str(home_address), 'AppData', 'Local', 'persepolis') # user download folder path download_path = os.path.join(str(home_address), 'Downloads', 'Persepolis') # find available styles(It's depends on operating system and desktop environments). available_styles = QStyleFactory.keys() style = 'Fusion' color_scheme = 'Persepolis Light Blue' icons = 'Breeze' if os_type == 'Linux' or os_type == 'FreeBSD' or 'os_type' == 'OpenBSD': if desktop_env == 'KDE': if 'Breeze' in available_styles: style = 'Breeze' color_scheme = 'System' else: style = 'Fusion' color_scheme = 'Persepolis Light Blue' else: # finout user prefers dark theme or light theme :) # read this links for more information: # https://wiki.archlinux.org/index.php/GTK%2B#Basic_theme_configuration # https://wiki.archlinux.org/index.php/GTK%2B#Dark_theme_variant # find user gtk3 config file path. gtk3_confing_file_path = os.path.join(home_address, '.config', 'gtk-3.0', 'settings.ini') if not(os.path.isfile(gtk3_confing_file_path)): if os.path.isfile('/etc/gtk-3.0/settings.ini'): gtk3_confing_file_path = '/etc/gtk-3.0/settings.ini' else: gtk3_confing_file_path = None # read this for more information: dark_theme = False if gtk3_confing_file_path: with open(gtk3_confing_file_path) as f: for line in f: if "gtk-application-prefer-dark-theme" in line: if 'true' in line: dark_theme = True else: dark_theme = False if dark_theme: icons = 'Breeze-Dark' if 'Adwaita-Dark' in available_styles: style = 'Adwaita-Dark' color_scheme = 'System' else: style = 'Fusion' color_scheme = 'Persepolis Dark Blue' else: icons = 'Breeze' if 'Adwaita' in available_styles: style = 'Adwaita' color_scheme = 'System' else: style = 'Fusion' color_scheme = 'Persepolis Light Blue' elif os_type == 'Darwin': style = 'Macintosh' color_scheme = 'System' icons = 'Breeze' elif os_type == 'Windows': style = 'Fusion' color_scheme = 'Persepolis Old Light Blue' icons = 'Breeze' else: style = 'Fusion' color_scheme = 'Persepolis Light Blue' icons = 'Breeze' # Persepolis default setting default_setting_dict = {'locale': 'en_US', 'toolbar_icon_size': 32, 'wait-queue': [0, 0], 'awake': 'no', 'custom-font': 'no', 'column0': 'yes', 'column1': 'yes', 'column2': 'yes', 'column3': 'yes', 'column4': 'yes', 'column5': 'yes', 'column6': 'yes', 'column7': 'yes', 'column10': 'yes', 'column11': 'yes', 'column12': 'yes', 'subfolder': 'yes', 'startup': 'no', 'show-progress': 'yes', 'show-menubar': 'no', 'show-sidepanel': 'yes', 'rpc-port': 6801, 'notification': 'Native notification', 'after-dialog': 'yes', 'tray-icon': 'yes', 'max-tries': 5, 'retry-wait': 0, 'timeout': 60, 'connections': 16, 'download_path_temp': download_path_temp, 'download_path': download_path, 'sound': 'yes', 'sound-volume': 100, 'style': style, 'color-scheme': color_scheme, 'icons': icons, 'font': 'Ubuntu', 'font-size': 9, 'aria2_path': '', 'video_finder/enable': 'yes', 'video_finder/hide_no_audio': 'yes', 'video_finder/hide_no_video': 'yes', 'video_finder/max_links': '3'} return default_setting_dict