def __init__(self, parent, codigo_inicial=None): super(InterpreteLanas, self).__init__() self.ventana = parent self.refreshMarker = False self.multiline = False self.command = '' self.history = [] self.historyIndex = -1 self.interpreterLocals = {'raw_input': self.raw_input, 'input': self.input, 'sys': sys, 'help': help, 'ayuda': self.help} palette = QPalette() palette.setColor(QPalette.Text, QColor(0, 0, 0)) self.setPalette(palette) if codigo_inicial: self.insertar_codigo_falso(codigo_inicial) self.marker() self.setUndoRedoEnabled(False) self.setContextMenuPolicy(Qt.NoContextMenu) self.timer_cursor = QTimer() self.timer_cursor.start(1000) self.timer_cursor.timeout.connect(self.marker_si_es_necesario)
def updateFilledCircle(self, s): size = s * self.zoom pixmap = QPixmap(self.width(), self.height()) pixmap.fill(Qt.transparent) #painter filled ellipse p = QPalette() painter = QPainter() painter.begin(pixmap) painter.setRenderHint(QPainter.Antialiasing) brush = QBrush(p.link().color()) painter.setBrush(brush) painter.setOpacity(0.4) painter.drawEllipse( QRect(self.width() / 2 - size / 2, self.height() / 2 - size / 2, size, size)) painter.end() #painter ellipse 2 painter2 = QPainter() painter2.begin(pixmap) painter2.setRenderHint(QPainter.Antialiasing) pen2 = QPen(Qt.green) pen2.setWidth(1) painter2.setPen(pen2) painter2.drawEllipse( QRect(self.width() / 2 - size / 2, self.height() / 2 - size / 2, size, size)) painter2.end() self.ellipseLabel.setPixmap(QPixmap(pixmap)) self.lastSize = s
def __init__(self, direction): self.dns_lookup_id = 0 QDialog.__init__(self) self.setupUi(self) if (direction == 'OUT'): text = 'is trying to connect to' if (direction == 'IN'): text = 'is being connected to from' self.setWindowTitle("Leopard Flower firewall") self.label_text.setText(text) self.pushButton_allow.clicked.connect(self.allowClicked) self.pushButton_deny.clicked.connect(self.denyClicked) self.pushButton_hide.setVisible(False) self.tableWidget_details.setVisible(False) self.rejected.connect(self.escapePressed) self.finished.connect(self.dialogFinished) fullpath_text = QTableWidgetItem("Full path") self.tableWidget_details.setItem(0,0,fullpath_text) pid_text = QTableWidgetItem("Process ID") self.tableWidget_details.setItem(1,0,pid_text) remoteip_text = QTableWidgetItem("Remote IP") self.tableWidget_details.setItem(2,0,remoteip_text) remotedomain_text = QTableWidgetItem("Remote domain") self.tableWidget_details.setItem(3,0,remotedomain_text) remoteport_text = QTableWidgetItem("Remote port") self.tableWidget_details.setItem(4,0,remoteport_text) localport_text = QTableWidgetItem("Local port") self.tableWidget_details.setItem(5,0,localport_text) #make the incoming dialog stand out. It is not common to receive incoming connections if (direction == 'IN'): pal = QPalette() col = QColor(255, 0, 0, 127) pal.setColor(QPalette.Window, col) self.setPalette(pal)
def __init__(self, parent=None): super(AbstractTraitDots, self).__init__(parent) self.__minimum = 0 self.__maximum = 5 self.__readOnly = False self.__value = 0 # Es gibt anfangs keine verbotenen Werte, also nur eine leere Liste erstellen self.__forbiddenValues = [] # Standardwerte setzen self.setMinimum( 0) self.setMaximum( 5) # setValue() muß nach dem Füllen der MyAllowedValues-Liste aufgurefen werden, damit die List Einträge besitzt, bevort sie abgefragt wird. self.setValue(0) # Widget darf nur proportional in seiner Größe verändert werden? # Minimalgröße festlegen self.__minimumSizeY = 8 minimumSizeX = self.__minimumSizeY * self.__maximum self.setMinimumSize( minimumSizeX, self.__minimumSizeY) self.setSizePolicy( QSizePolicy.Minimum, QSizePolicy.Fixed ) # Setze Farben abhängig von der verwendeten Palette. __palette = QPalette() self._colorEmpty = __palette.text().color() self._colorFull = __palette.highlight().color() self._colorFrame = __palette.highlight().color() self.maximumChanged.connect(self.resetMinimumSize)
def __init__(self, parent=None): super(AbstractTraitDots, self).__init__(parent) self.__minimum = 0 self.__maximum = 5 self.__readOnly = False self.__value = 0 # Es gibt anfangs keine verbotenen Werte, also nur eine leere Liste erstellen self.__forbiddenValues = [] # Standardwerte setzen self.setMinimum(0) self.setMaximum(5) # setValue() muß nach dem Füllen der MyAllowedValues-Liste aufgurefen werden, damit die List Einträge besitzt, bevort sie abgefragt wird. self.setValue(0) # Widget darf nur proportional in seiner Größe verändert werden? # Minimalgröße festlegen self.__minimumSizeY = 8 minimumSizeX = self.__minimumSizeY * self.__maximum self.setMinimumSize(minimumSizeX, self.__minimumSizeY) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) # Setze Farben abhängig von der verwendeten Palette. __palette = QPalette() self._colorEmpty = __palette.text().color() self._colorFull = __palette.highlight().color() self._colorFrame = __palette.highlight().color() self.maximumChanged.connect(self.resetMinimumSize)
def __init__(self, parent = None): QDialog.__init__(self, parent = parent) self.setWindowModality(False) self._open_instances.append(self) self.ui = UiDialog() self.ui.setupUi(self) self.parent = parent self.ui.folder_error.setVisible(False) palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) self.ui.folder_error.setPalette(palette) o_loaded_ascii = ReducedAsciiLoader(parent = parent, ascii_file_name = '', is_live_reduction = True) if parent.o_stitching_ascii_widget is None: o_stitching_ascii_widget = StitchingAsciiWidget(parent = self.parent, loaded_ascii = o_loaded_ascii) parent.o_stitching_ascii_widget = o_stitching_ascii_widget # retrieve gui parameters _export_stitching_ascii_settings = ExportStitchingAsciiSettings() self.dq0 = str(_export_stitching_ascii_settings.fourth_column_dq0) self.dq_over_q = str(_export_stitching_ascii_settings.fourth_column_dq_over_q) self.is_with_4th_column_flag = bool(_export_stitching_ascii_settings.fourth_column_flag) self.use_lowest_error_value_flag = bool(_export_stitching_ascii_settings.use_lowest_error_value_flag) self.ui.dq0Value.setText(self.dq0) self.ui.dQoverQvalue.setText(self.dq_over_q) self.ui.output4thColumnFlag.setChecked(self.is_with_4th_column_flag) self.ui.usingLessErrorValueFlag.setChecked(self.use_lowest_error_value_flag) self.ui.usingMeanValueFalg.setChecked(not self.use_lowest_error_value_flag)
def __init__(self, parent=None): super(RenamingOptionsPage, self).__init__(parent) self.ui = Ui_RenamingOptionsPage() self.ui.setupUi(self) self.ui.ascii_filenames.clicked.connect(self.update_examples) self.ui.windows_compatibility.clicked.connect(self.update_examples) self.ui.rename_files.clicked.connect(self.update_examples) self.ui.move_files.clicked.connect(self.update_examples) self.ui.move_files_to.editingFinished.connect(self.update_examples) self.ui.move_files.toggled.connect( partial(enabledSlot, self.toggle_file_moving)) self.ui.rename_files.toggled.connect( partial(enabledSlot, self.toggle_file_renaming)) self.ui.file_naming_format.textChanged.connect(self.check_formats) self.ui.file_naming_format_default.clicked.connect( self.set_file_naming_format_default) self.highlighter = TaggerScriptSyntaxHighlighter( self.ui.file_naming_format.document()) self.ui.move_files_to_browse.clicked.connect(self.move_files_to_browse) textEdit = self.ui.file_naming_format self.textEditPaletteNormal = textEdit.palette() self.textEditPaletteReadOnly = QPalette(self.textEditPaletteNormal) disabled_color = self.textEditPaletteNormal.color( QPalette.Inactive, QPalette.Window) self.textEditPaletteReadOnly.setColor(QPalette.Disabled, QPalette.Base, disabled_color)
def set_style_sheet(cls): """设置样式""" # cls.query_button.setStyleSheet(WindowCons.button_style()) cls.save_button.setStyleSheet(WindowCons.button_style()) # cls.compute_button.setStyleSheet(WindowCons.button_style()) cls.add_record.setStyleSheet(WindowCons.background_image()) cls.title.setStyleSheet(WindowCons.LIGHT_BLUE_STYLE) cls.sale_num_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.share_name_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.sale_price_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.buy_date_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.win_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.buy_num_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.can_sale_num_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.have_num_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.share_code_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.buy_price_title.setStyleSheet(WindowCons.WHITE_STYLE) cls.have_avg_price.setStyleSheet(WindowCons.WHITE_STYLE) cls.sale_date_title.setStyleSheet(WindowCons.WHITE_STYLE) # cls.text_edit.setAttribute(Qt.WA_TranslucentBackground, True) # cls.text_edit.repaint() cls.text_edit.setStyleSheet(WindowCons.TRANSPARENT) palette1 = QPalette() palette1.setBrush( cls.add_record.backgroundRole(), QBrush(QPixmap(':backgroud.png').scaled(cls.add_record.size()))) cls.add_record.setPalette(palette1) cls.add_record.setStyleSheet(WindowCons.background_image())
def test_gui_cv(): sleep(1) import threading import sys import os import logging from setting import config from setting.configs.tool import update_config_by_name, SAFE_ARGVS from .testcases import knife_into_cv project_name = "cvoffline" config_info = update_config_by_name(project_name) config.SIMULATOR_IMG_SERVER_COFIG = [ "127.0.0.1", 9883, "randomImg", "IMG/G652/0912R/" ] log_level = getattr(logging, config.LOG_LEVEL, logging.ERROR) log_dir = getattr(config, "LOG_DIR", False) if log_dir == "print": logging.basicConfig(format="%(asctime)s-%(name)s-%(levelname)s-%(message)s", level=log_level) else: logging.basicConfig(filename="setting\\testlog.log", filemode="a", format="%(asctime)s-%(name)s-%(levelname)s-%(message)s", level=log_level) logger = logging.getLogger(__name__) logger.error(config_info) from PyQt4.QtGui import QPalette, QColor, QApplication from GUI.view.view import get_view from GUI.controller import get_controller from util.loadfile import loadStyleSheet try: label = config.VIEW_LABEL # label为AutomaticCV logger.error(" main info: {} {} \n{}".format(label, project_name, sys.argv[0])) app = QApplication(sys.argv) app.setStyleSheet(loadStyleSheet('main')) pt = QPalette() pt.setColor(QPalette.Background, QColor(4, 159, 241)) app.setPalette(pt) controller = get_controller(label) view = get_view(label) # print view.__dict__, type(view) c = controller(view()) threading.Thread(target=knife_into_cv, args=(c, app)).start() # unittest thread insert c.show() # sys.stdout = sys.__stdout__ sys.exit(app.exec_()) except SystemExit: # print "system exit\n",sys._getframe(1).f_code sleep(3) except Exception as e: raise e
def updateFilledCircle(self, s): size = s * self.zoom pixmap = QPixmap(self.width(), self.height()) pixmap.fill(Qt.transparent) #painter filled ellipse p = QPalette() painter = QPainter() painter.begin(pixmap) painter.setRenderHint(QPainter.Antialiasing) brush = QBrush(p.link().color()) painter.setBrush(brush) painter.setOpacity(0.4) painter.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size)) painter.end() #painter ellipse 2 painter2 = QPainter() painter2.begin(pixmap) painter2.setRenderHint(QPainter.Antialiasing) pen2 = QPen(Qt.green) pen2.setWidth(1) painter2.setPen(pen2) painter2.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size)) painter2.end() self.ellipseLabel.setPixmap(QPixmap(pixmap)) self.lastSize = s
def View1(self): #Nueva vista 1 palette = QPalette() palette.setBrush( QPalette.Background, QBrush(QPixmap(self.MAIN_VIEW).scaled(self.size_x, self.size_y))) self.ui.setPalette(palette) #Reinicio de las opciones self.unlock() red_btn = QPixmap(self.RED) self.ui.red_ranger.setPixmap(red_btn) blue_btn = QPixmap(self.BLUE) self.ui.blue_ranger.setPixmap(blue_btn) black_btn = QPixmap(self.BLACK) self.ui.black_ranger.setPixmap(black_btn) pink_btn = QPixmap(self.PINK) self.ui.pink_ranger.setPixmap(pink_btn) yellow_btn = QPixmap(self.YELLOW) self.ui.yellow_ranger.setPixmap(yellow_btn) self.firstTime = False self.promptTex = "" self.flag_Key = 3 self.IsChecked = [['Red', False], ['Pink', False], ['Blue', False], ['Black', False], ['Yellow', False]] self.ui.acepto_btn.setChecked(False) self.ui.setCurrentWidget(self.ui.View1)
def __init__(self, parent: QWidget=None): ContainerWidget.__init__(self, parent) pal = QPalette(self.palette()) self.setMinimumSize(250, 250) pal.setColor(QPalette.Background, QColor(55, 50, 47)) self.setAutoFillBackground(True) self.setPalette(pal)
def on_normalizationComboBoxChanged(self): selection = str(self.normalizationComboBox.currentText()) if selection == "No Normalization": self.normalizationMethod = 0 elif selection == "Change range from": self.normalizationMethod = 1 elif selection == "Auto Normalization": self.normalizationMethod = 2 #Currently not implemented p = QPalette() if self.normalizationMethod == 0: p.setColor(QPalette.Base,Qt.gray) p.setColor(QPalette.Text,Qt.gray) self.inputValueRange.setPalette(p) self.inputValueRange.setEnabled(False) self.outputValueRange.setPalette(p) self.outputValueRange.setEnabled(False) else: self.setLayerValueRangeInfo() p.setColor(QPalette.Base,Qt.white) p.setColor(QPalette.Text,Qt.black) self.inputValueRange.setPalette(p) self.inputValueRange.setEnabled(True) self.outputValueRange.setPalette(p) self.outputValueRange.setEnabled(True) self.validateInputValueRange()
def __init__(self, parent: QWidget = None): ContainerWidget.__init__(self, parent) pal = QPalette(self.palette()) self.setMinimumSize(250, 250) pal.setColor(QPalette.Background, QColor(55, 50, 47)) self.setAutoFillBackground(True) self.setPalette(pal)
def initUI(self): # title title = QLabel(self) title.setText("User Instruction") title.setAlignment(Qt.AlignCenter) # user instruction groupBox = QGroupBox() text = QLabel(self) text.setText("Create image montages and histograms from the interface:\nChoose option No. 1 to 5 on main interface.\nClick Enter to select the paths for input and output locations.\nEnjoy using the interface!") self.setStyleSheet("QLabel { color: #8B4513; font-size: 16px;font-family: cursive, sans-serif;}") title.setStyleSheet("QLabel { color: #8B4513; font-weight: 600;}") # set layout sbox = QVBoxLayout(self) sbox.addWidget(text) groupBox.setLayout(sbox) vBoxLayout = QVBoxLayout() vBoxLayout.addSpacing(15) vBoxLayout.addWidget(title) vBoxLayout.addWidget(groupBox) vBoxLayout.addSpacing(15) self.setLayout(vBoxLayout) # set background as transparent palette = QPalette() palette.setBrush(QPalette.Background,QBrush(QPixmap())) self.setPalette(palette)
def View3(self): #Nueva vista 3 palette = QPalette() palette.setBrush( QPalette.Background, QBrush(QPixmap(self.VIEW_3).scaled(self.size_x, self.size_y))) self.ui.setPalette(palette) #Acción Envía Vista 3 self.ui.setCurrentWidget(self.ui.View3) if self.flag_Key == 3: #Vista 3 self.ui.title_v3.move(int(self.size_x / 2 - self.t3x / 2), int(self.size_y / 9)) self.ui.photo_ranger.move(int(self.size_x / 2 - self.fx / 2), int(self.size_y / 6)) self.ui.name_v3.move(int(self.size_x / 2 - self.name_x / 2), int(self.size_y / 2 + 2 * self.name_y)) self.ui.continue_btn_V3.move(int(self.size_x / 2 - self.c3x / 2), int(self.y_init_btn)) #Vista 6 self.ui.the_gif_validate.move(self.size_x + 1, self.size_y + 1) self.ui.title_V6.move(self.size_x + 1, self.size_y + 1) self.ui.acepto.move(self.size_x + 1, self.size_y + 1) self.ui.acepto_btn.move(self.size_x + 1, self.size_y + 1) self.ui.cancelar.move(self.size_x + 1, self.size_y + 1) for i in range(len(self.IsChecked)): if self.IsChecked[i][1] == True: face_ranger = QPixmap(self.URL_FACES[i]) self.ui.photo_ranger.setPixmap(face_ranger) break elif self.flag_Key == 5: #Vista 6 #---------------------- #Aqui se pone el gif :) self.ui.the_gif_validate.setMovie(self.movie) self.movie.start() #---------------------- self.ui.the_gif_validate.move( int(self.size_x / 2 - self.gif2_x / 2), int(self.altura_gif2)) self.ui.title_V6.move(int(self.size_x / 2 - self.mail_x / 2), int(self.altura_mail)) self.ui.acepto.move(int(self.size_x / 2 - self.acepto_x / 2), int(self.altura_acepto)) self.ui.acepto_btn.move(int(0.26 * self.size_x), int(self.altura_acepto + 5)) self.ui.continue_btn_V3.move(int(self.size_x / 2), int(self.y_init_btn)) self.ui.cancelar.move(int(self.size_x / 25), int(self.y_init_btn)) #Vista 3 self.ui.title_v3.move(self.size_x + 1, self.size_y + 1) self.ui.photo_ranger.move(self.size_x + 1, self.size_y + 1) self.ui.name_v3.move(self.size_x + 1, self.size_y + 1)
def initSubWidget(self): self.linesPath = None self.widthtwo = 0 self.widthseven = 0 self.heightone = 0 self.heightfive = 0 self.copyLabel = QLabel(self) self.copyLabel.setFixedWidth(400) self.copyLabel.setAlignment(Qt.AlignCenter) self.nameLabel = QLabel(self) self.nameLabel.setFixedWidth(400) self.nameLabel.setAlignment(Qt.AlignCenter) self.copyLabel.setFont(QFont("simhei",9)) self.nameLabel.setFont(QFont("simhei",15)) self.netLabel = QLabel(self) self.netLabel.setFixedWidth(800) self.netLabel.setFixedHeight(20) #self.netLabel.setAlignment(Qt.AlignLeft) self.netLabel.setAlignment(Qt.AlignCenter) self.netLabel.setText(self.tr("Can not connect to server, please check network and server address!")) self.netLabel.setFont(QFont("simhei",12,QFont.Bold)) pe = QPalette() pe.setColor(QPalette.WindowText,Qt.red) self.netLabel.setPalette(pe) self.netLabel.hide() #self.updateTimer = QTimer(self) #self.connect(self.updateTimer, SIGNAL("timeout"),self.updateWidgetInfo) #self.updateTimer.start(10) #主窗口 self.mainwindow = MainWindow(self) #关于对话框 self.aboutWidget = AboutWidget(self) self.aboutWidget.hide() #self.showDlg = SettingWidget(self.mainwindow) #日志窗口 #self.recordWidget = RecordWidget(self) #self.recordWidget.mythread.stop() #self.recordWidget.hide() #self.toolWidget = ToolWidget() #self.toolWidget.hide() #创建action #self.action_showRecord_A = QAction(self) #self.action_closeRecord_B = QAction(self) #self.action_showRecord_A.setShortcut(QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_B)) #self.action_closeRecord_B.setShortcut(QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_C)) #self.addAction(self.action_showRecord_A) #self.addAction(self.action_closeRecord_B) self.udpClient = UdpClient() self.connect(self.udpClient, SIGNAL("start"),self.startB) self.connect(self.udpClient, SIGNAL("stop"),self.stopB)
def createWidgets(self): """ QtWidgets creation """ self.mainTab = QTabWidget() mainLayout = QVBoxLayout() self.toRead = QLabel( "%s" % "Release notes are specific to each version of the server, SUT adapters, libraries and toolbox. More details on each HISTORY files." ) mainLayout.addWidget(self.toRead) mainLayout.addWidget(self.mainTab) palette = QPalette() brush = QBrush(QColor(240, 240, 240)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Active, QPalette.Base, brush) # treewidget for server rn self.rn = QTreeWidget(self) self.rn.setHeaderHidden(True) self.rn.setFrameShape(QFrame.NoFrame) self.rn.setSelectionMode(QAbstractItemView.NoSelection) self.rn.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.rn.setRootIsDecorated(False) self.rn.setPalette(palette) # treewidget for adapter rn self.rnAdp = QTreeWidget(self) self.rnAdp.setHeaderHidden(True) self.rnAdp.setFrameShape(QFrame.NoFrame) self.rnAdp.setSelectionMode(QAbstractItemView.NoSelection) self.rnAdp.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.rnAdp.setRootIsDecorated(False) self.rnAdp.setPalette(palette) # treewidget for library rn self.rnLibAdp = QTreeWidget(self) self.rnLibAdp.setHeaderHidden(True) self.rnLibAdp.setFrameShape(QFrame.NoFrame) self.rnLibAdp.setSelectionMode(QAbstractItemView.NoSelection) self.rnLibAdp.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.rnLibAdp.setRootIsDecorated(False) self.rnLibAdp.setPalette(palette) # treewidget for agent rn self.rnToolbox = QTreeWidget(self) self.rnToolbox.setHeaderHidden(True) self.rnToolbox.setFrameShape(QFrame.NoFrame) self.rnToolbox.setSelectionMode(QAbstractItemView.NoSelection) self.rnToolbox.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) self.rnToolbox.setRootIsDecorated(False) self.rnToolbox.setPalette(palette) self.mainTab.addTab( self.rn, Settings.instance().readValue( key = 'Common/acronym-server' ) ) self.mainTab.addTab( self.rnAdp, "Sut Adapters" ) self.mainTab.addTab( self.rnLibAdp, "Sut Librairies" ) self.mainTab.addTab( self.rnToolbox, "Toolbox" ) self.setLayout(mainLayout)
def __init__(self, c, *args, **kwargs): QwtDialNeedle.__init__(self, *args, **kwargs) palette = QPalette() for i in range(QPalette.NColorGroups): # ( int i = 0; i < QPalette.NColorGroups; i++ ) palette.setColor(i, palette.Text, c) palette.setColor(QPalette.Base, QColor(0,0,0)) self.setPalette(palette)
def __init__(self, container_widget=None, target_method=None): QWidget.__init__(self, container_widget) self.container_widget = container_widget self.target_method = target_method palette = QPalette(self.palette()) palette.setColor(palette.Background, Qt.transparent) self.setPalette(palette)
def set_palette(self, background, foreground): """ Set text editor palette colors: background color and caret (text cursor) color """ palette = QPalette() palette.setColor(QPalette.Base, background) palette.setColor(QPalette.Text, foreground) self.setPalette(palette)
def initColorStyle(self): self.colorStyle = Styles[self.styleIndex] pal = QPalette(self.tabWidget_2.palette()) #print pal.color(QPalette.Base).name() #print pal.color(QPalette.Window).name() pal.setColor(QPalette.Base,self.colorStyle.paper) pal.setColor(QPalette.Text,self.colorStyle.color) self.tabWidget_2.setPalette(pal) self.tabWidget_3.setPalette(pal)
def View2(self): #Cambio de fondo vista 2 palette = QPalette() palette.setBrush( QPalette.Background, QBrush(QPixmap(self.VIEW_2).scaled(self.size_x, self.size_y))) self.ui.setPalette(palette) self.ui.setCurrentWidget(self.ui.View2)
def addLog(self, log): self.log.append(log) self.logbtn.show() palette = QPalette() brush = QBrush(QColor(240, 100, 100)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Normal, QPalette.Background, brush) self.label.setPalette(palette) self.label.setAutoFillBackground(True)
def change_palette(self, color): '''Sets the global tooltip background to the given color and initializes reset''' p = QPalette(self.default_palette) p.setColor(QPalette.All, QPalette.ToolTipBase, color) QToolTip.setPalette(p) self.timer = QTimer() self.timer.timeout.connect(self.try_reset_palette) self.timer.start(300) #short enough not to flicker a wrongly colored tooltip
def initUI(self): self.setWindowTitle('Scroll PDF and reveal another one') p = QPalette() p.setColor(QPalette.Background, QtCore.Qt.black); self.setPalette(p) self.showMaximized() self.show()
def __init__(self, text, parent=None): FLabel.__init__(self, text, parent) font = QFont() self.setFont(font) red = QColor(Qt.red) palette = QPalette() palette.setColor(QPalette.WindowText, red) self.setPalette(palette) self.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
def __init__(self, rightVal, topVal, line_packet, mainWinObj, cmdIndex, infoArray): QWidget.__init__(self) self.ui = Ui_consoleWidget() self.ui.setupUi(self) self.setGeometry(QRect(rightVal + 1, topVal, varlisting.CMDCONSOLE_WIDTH, varlisting.CMDCONSOLE_HEIGHT)) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground) self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_default.png')) self.ui.btn_setcmd = ExtendedQLabel(self) self.ui.btn_setcmd.setPixmap(QPixmap(getcwd() + '/lib/images/btn_setcmd.png')) self.ui.btn_setcmd.setGeometry(QRect(272, 345, 38, 18)) self.ui.btn_setcmd.setObjectName('btn_setcmd') QObject.connect(self.ui.btn_setcmd, SIGNAL('mouseEnter()'), self.changeCursor) QObject.connect(self.ui.btn_setcmd, SIGNAL('mouseLeave()'), self.changeCursorBack) QObject.connect(self.ui.btn_setcmd, SIGNAL('clicked()'), self.cmdSet) grblPalette = QPalette() #grblPalette.setColor(QPalette.Text, QColor(0, 255, 0)) grblPalette.setColor(QPalette.Base, QColor(0, 0, 0)) self.ui.textEdit.setPalette(grblPalette) QObject.connect(self.ui.textEdit, SIGNAL('textChanged()'), self.autoScroll) self.ui.textEdit.insertHtml(varlisting.cmdScreenInitial) self.line_packet = line_packet QObject.connect(self.ui.stackedWidget, SIGNAL('currentChanged(int)'), self.updateConsole) self.mainWinObj = mainWinObj if not cmdIndex == 'Null': self.ui.stackedWidget.setCurrentIndex(cmdIndex) if cmdIndex == 1: self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_getstatus.png')) if cmdIndex == 2: self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_setrate.png')) if cmdIndex == 3: self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_disconnect.png')) if cmdIndex == 4: self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_dlall.png')) if cmdIndex == 5: self.ui.bg_cmdconsole.setPixmap(QPixmap(getcwd() + '/lib/images/bg_cmdconsole_dlspecific')) try: f = open(getcwd() + '/lib/cfg/ui_cmdconsole.cfg', 'r') tempIn = f.read() self.ui.textEdit.clear() self.ui.textEdit.insertHtml(str(tempIn)) f.close() except IOError: pass # Re-update values received (if necessary) self.ui.val_totaldl.setText('%i' %infoArray[0]) self.ui.val_numpkts.setText('%s' %infoArray[1]) self.ui.val_availdled.setText('? / %s' %infoArray[1]) self.ui.val_statustime.setText(infoArray[2])
def __init__(self, parent=None, **kwargs): super(AddonManagerWidget, self).__init__(parent, **kwargs) #: list of Available | Installed self.__items = [] self.setLayout(QVBoxLayout()) self.__header = QLabel( wordWrap=True, textFormat=Qt.RichText ) self.__search = QLineEdit( placeholderText=self.tr("Filter") ) self.layout().addWidget(self.__search) self.__view = view = QTreeView( rootIsDecorated=False, editTriggers=QTreeView.NoEditTriggers, selectionMode=QTreeView.SingleSelection, alternatingRowColors=True ) self.__view.setItemDelegateForColumn(0, TristateCheckItemDelegate()) self.layout().addWidget(view) self.__model = model = QStandardItemModel() model.setHorizontalHeaderLabels(["", "Name", "Version", "Action"]) model.dataChanged.connect(self.__data_changed) proxy = QSortFilterProxyModel( filterKeyColumn=1, filterCaseSensitivity=Qt.CaseInsensitive ) proxy.setSourceModel(model) self.__search.textChanged.connect(proxy.setFilterFixedString) view.setModel(proxy) view.selectionModel().selectionChanged.connect( self.__update_details ) header = self.__view.header() header.setResizeMode(0, QHeaderView.Fixed) header.setResizeMode(2, QHeaderView.ResizeToContents) self.__details = QTextBrowser( frameShape=QTextBrowser.NoFrame, readOnly=True, lineWrapMode=QTextBrowser.WidgetWidth, openExternalLinks=True, ) self.__details.setWordWrapMode(QTextOption.WordWrap) palette = QPalette(self.palette()) palette.setColor(QPalette.Base, Qt.transparent) self.__details.setPalette(palette) self.layout().addWidget(self.__details)
def View6(self): #Pasamos a vista 6 palette = QPalette() palette.setBrush( QPalette.Background, QBrush(QPixmap(self.VIEW_6).scaled(self.size_x, self.size_y))) self.ui.setPalette(palette) self.ui.setCurrentWidget(self.ui.View6) self.sendMail(self.GIF)
def gyroL(self,val,status): palette = QPalette() if status: palette.setColor(self.highlght, self.greeny) self.obj.pB_Gleft.setPalette(palette) self.obj.pB_Gleft.setValue(val) self.armb.GyrL(True) else: palette.setColor(self.highlght, self.bluey) self.obj.pB_Gleft.setPalette(palette)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumSize(3 * Info.dpi, 3 * Info.dpi) self.setWindowTitle('OpenIris: Workspace') pal = QPalette(self.palette()) pal.setColor(self.backgroundRole(), QColor(105, 100, 97)) self.setPalette(pal) self.setAutoFillBackground(True) self.__c_widget = OIWSWidget(1, 1, self) self.__c_widget.setGeometry(0, 0, self.width(), self.height())
def setHighlighted(self,highlight): """ Highlight the property by changing the background color of the textfield. """ p=QPalette() if highlight: p.setColor(QPalette.Active, QPalette.ColorRole(9),Qt.red) else: p.setColor(QPalette.Active, QPalette.ColorRole(9),Qt.white) self._lineEdit.setPalette(p) self._textEdit.viewport().setPalette(p)
def gyroR(self,val,status): palette = QPalette() if status: palette.setColor(self.highlght, self.greeny) self.obj.pB_Gright.setPalette(palette) self.obj.pB_Gright.setValue(abs(val)) self.armb.GyrR(True) else: palette.setColor(self.highlght, self.bluey) self.obj.pB_Gright.setPalette(palette)
def initUI(self): # local variable that records which radio button is clicked self.choice = 1 # welcome message welcomeMsg = QLabel(self) welcomeMsg.setText("Welcome to the PyQt Interface!") welcomeMsg.setAlignment(Qt.AlignCenter) menu = QLabel(self) menu.setText("Menu") # create buttons & connect them with function btnClicked btn1 = QRadioButton(self) btn1.setText("1. Create montages recursively from given directory and sub-directories") btn1.setChecked(True) btn1.toggled.connect(lambda:self.btnClicked(1)) btn2 = QRadioButton(self) btn2.setText("2. Create montages from provided CSV files (split by categories or bins)") btn2.toggled.connect(lambda:self.btnClicked(2)) btn3 = QRadioButton(self) btn3.setText("3. Create vertical montage from provided CSV file") btn3.toggled.connect(lambda:self.btnClicked(3)) btn4 = QRadioButton(self) btn4.setText("4. Create image histogram from provided CSV file") btn4.toggled.connect(lambda:self.btnClicked(4)) btn5 = QRadioButton(self) btn5.setText("5. Create scatter plot from provided CSV file") btn5.toggled.connect(lambda:self.btnClicked(5)) quit = QPushButton(self) quit.setText("Quit") enter = QPushButton(self) enter.setText("Enter") instr = QPushButton(self) instr.setText("Instruction") self.setStyleSheet('QLabel {font-family: cursive, sans-serif; font-weight: 500; font-size: 16px; color: #A0522D;} QRadioButton {font-family: cursive, sans-serif; font-weight: 300; font-size: 16px; color: #8B4513;} QPushButton {font-family: cursive, sans-serif; font-weight: 500; font-size: 16px; color: #CD853F; }') welcomeMsg.setStyleSheet('QLabel {font-weight: 900;font-size: 20px;}') # set layout mbox = QGridLayout(self) mbox.addWidget(welcomeMsg, 1, 1) mbox.addWidget(menu,2,1) mbox.addWidget(btn1,3,1) mbox.addWidget(btn2,4,1) mbox.addWidget(btn3,5,1) mbox.addWidget(btn4,6,1) mbox.addWidget(btn5,7,1) mbox.addWidget(quit,8,0) mbox.addWidget(enter,8,2) mbox.addWidget(instr,8,1) self.setLayout(mbox) # connect the click event with a function enter.clicked.connect(self.nextPage) quit.clicked.connect(self.close) instr.clicked.connect(self.instruction) # set background as transparent palette = QPalette() palette.setBrush(QPalette.Background,QBrush(QPixmap())) self.setPalette(palette)
def __init__(self, parent): QToolBar.__init__(self, parent) pal = QPalette(self.palette()) pal.setColor(self.backgroundRole(), QColor(105, 100, 97)) self.setPalette(pal) self.setAutoFillBackground(True) self.__objects = [] self.init() self.__type = None self.__mode = ViewMode self.__menu = None
def __init__(self,parent = None): super(TabBar,self).__init__(parent) self.hoveredTab = 0 self.setMouseTracking(True) self.hasUnderLine = True self.textLabel = QLabel(self) self.setFont(QFont("Times New Roman", 15)) palette = QPalette() palette.setColor(QPalette.WindowText, QColor(255,255,255)) self.setPalette(palette)
def change_palette(self, color): """Sets the global tooltip background to the given color and initializes reset""" self.old_palette = QToolTip.palette() p = QPalette(self.old_palette) p.setColor(QPalette.All, QPalette.ToolTipBase, color) QToolTip.setPalette(p) self.timer = QTimer() self.timer.timeout.connect(self.try_reset_palette) self.timer.start( 300) #short enough not to flicker a wrongly colored tooltip
def __init__(self, parent=None, **kwargs): super(AddonManagerWidget, self).__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.__header = QLabel( wordWrap=True, textFormat=Qt.RichText ) self.__search = QLineEdit( placeholderText=self.tr("Filter") ) self.layout().addWidget(self.__search) self.__view = view = QTreeView( rootIsDecorated=False, editTriggers=QTreeView.NoEditTriggers, selectionMode=QTreeView.SingleSelection, alternatingRowColors=True ) self.__view.setItemDelegateForColumn(0, TristateCheckItemDelegate()) self.layout().addWidget(view) self.__model = model = QStandardItemModel() model.setHorizontalHeaderLabels(["", "Name", "Version", "Action"]) model.dataChanged.connect(self.__data_changed) proxy = QSortFilterProxyModel( filterKeyColumn=1, filterCaseSensitivity=Qt.CaseInsensitive ) proxy.setSourceModel(model) self.__search.textChanged.connect(proxy.setFilterFixedString) view.setModel(proxy) view.selectionModel().selectionChanged.connect( self.__update_details ) header = self.__view.header() header.setResizeMode(0, QHeaderView.Fixed) header.setResizeMode(2, QHeaderView.ResizeToContents) self.__details = QTextBrowser( frameShape=QTextBrowser.NoFrame, readOnly=True, lineWrapMode=QTextBrowser.WidgetWidth, openExternalLinks=True, ) self.__details.setWordWrapMode(QTextOption.WordWrap) palette = QPalette(self.palette()) palette.setColor(QPalette.Base, Qt.transparent) self.__details.setPalette(palette) self.layout().addWidget(self.__details)
def __init__(self): super(MyDlg, self).__init__() uic.loadUi("./mydlg.ui", self) # 加载ui文件 ***** self.setGeometry(50, 50, 800, 600) self.setAutoFillBackground(True) # 设置窗口背景 pixmap = QPixmap(":/images/onepiece.jpg").scaled(self.size()) # 适应窗口大小 palette = QPalette() palette.setBrush(QPalette.Window, QBrush(pixmap)) self.setPalette(palette)
def __init__(self): super(MyDlg, self).__init__() uic.loadUi("./mydlg.ui", self) # 加载ui文件 ***** self.setGeometry(50,50,800,600) self.setAutoFillBackground(True) # 设置窗口背景 pixmap = QPixmap(":/images/onepiece.jpg").scaled(self.size()) # 适应窗口大小 palette = QPalette() palette.setBrush(QPalette.Window,QBrush(pixmap)) self.setPalette(palette)
def editFinished(self): """Commented Code below checks whether there is real changed else it skips further processing But sometimes, users may find some dependent data is not updated, so user will edit and enter same value and expect that dependent data updates. This won't happen if we skip further processing.""" # "Check whether data is changed" # if self.applyFormat (self.data.getDisplayMag()) != self.lineEdit.text() and \ # str (self.data.getDisplayMag()) != self.lineEdit.text(): """Condition True means data is different. It needs to be validated as well""" inputStr = str(self.lineEdit.text()) """self.data._minValue and self.data._maxValue are default float. But, you can assign a scalar to it if you want to validate it against its value. In that case, you need to compare it with scalar.magSI""" if isinstance(self.data._minValue, float): min = self.data._minValue else: min = self.data._minValue.magSI if isinstance(self.data._maxValue, float): max = self.data._maxValue else: max = self.data._maxValue.magSI msg = "" if inputStr == '':#.isEmpty(): isDouble = False else: if self.data._format == "int": isDouble, msg = validate_int(inputStr, min, max, self.data._specialValues) else: isDouble, msg = validate_double(inputStr, min, max, self.data._specialValues) if isDouble == True: # self._validStr = inputStr oldValue = self.data.magSI self.data.magChanged(self.lineEdit.text()) newValue = self.data.magSI #self._updateNotifiers(oldValue, newValue) self._updateNotifiersSignal.emit(str(oldValue), str(newValue)) palette = QPalette() palette.setColor(QPalette.Text, QColor('black')); self.lineEdit.setPalette(palette) if isDouble == False: palette = QPalette() palette.setColor(QPalette.Text, QColor('red')); self.lineEdit.setPalette(palette) self.lineEdit.blockSignals(True) string = "" if self.data._info != "": string = "\n\nAdditional Info: \n" + self.data._info ret = QtGui.QMessageBox.information(WorkbenchHelper.window, "Information", msg + string, QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) self.lineEdit.blockSignals(False) self.lineEdit.setText(self.applyFormat(self.data.getDisplayMag())) palette.setColor(QPalette.Text, QColor('black')); self.lineEdit.setPalette(palette) """Below setFocus call will compel users to work on same lineedit.
def setBackgroundandSize(self, qwidget, imgpath, role, fixedHeight=None, fixedWidth=None): if isinstance(qwidget, QWidget) and isinstance(imgpath, str): palette = QPalette() palette.setBrush(role, QBrush(QPixmap(imgpath))) qwidget.setAutoFillBackground(True) qwidget.setPalette(palette) if fixedHeight is not None and fixedWidth is not None: qwidget.setFixedHeight(fixedHeight) qwidget.setFixedWidth(fixedWidth)
def __init__(self, rect): self.doc = None super(PdfViewer, self).__init__(None) self.setWindowTitle('PDF Viewer') self.isBlanked = False p = QPalette() p.setColor(QPalette.Background, QtCore.Qt.black); self.setPalette(p) self.setGeometry(rect) self.hide()
def updateGradient(self): self.pal = QPalette() self.buttonColor = self.pal.color( QPalette.Button ) self.midLightColor = self.pal.color( QPalette.Midlight ) #self.gradient = QLinearGradient( rect().topLeft(), rect().topRight() ) FIXME self.gradient = QLinearGradient( ) self.gradient.setColorAt( 0.0, self.midLightColor ) self.gradient.setColorAt( 0.7, self.buttonColor ) self.gradient.setColorAt( 1.0, self.buttonColor ) self.pal.setBrush( QPalette.Window, self.gradient ) self.setPalette( self.pal )
def __init__(self, show_automatic_box=True): super().__init__(show_automatic_box) self.setFixedWidth(420) self.setFixedHeight(350) gen_box = gui.widgetBox(self.controlArea, "Energy Cirp", addSpace=True, orientation="vertical") button_box = oasysgui.widgetBox(gen_box, "", addSpace=False, orientation="horizontal") button = gui.button(button_box, self, "Generate Energy Spectrum", callback=self.generate_energy_spectrum) font = QFont(button.font()) font.setBold(True) button.setFont(font) palette = QPalette(button.palette()) # make a copy of the palette palette.setColor(QPalette.ButtonText, QColor('Dark Blue')) button.setPalette(palette) # assign new palette button.setFixedHeight(45) gui.separator(gen_box, height=10) result_box = oasysgui.widgetBox(gen_box, "Energy Cirp Setting", addSpace=True, orientation="vertical") gui.comboBox(result_box, self, "units", label="Units", labelWidth=260, items=["Energy", "Wavelength"], sendSelectedValue=False, orientation="horizontal") gui.comboBox(result_box, self, "kind_of_calculation", label="Kind of calculation", labelWidth=110, items=["Energy/Wavelength = C + k*Y", "User File (Energy/Wavelength vs. Y)"], sendSelectedValue=False, orientation="horizontal", callback=self.set_KindOfCalculation) self.kind_box_1 = oasysgui.widgetBox(result_box, "", addSpace=True, orientation="vertical", height=50) oasysgui.lineEdit(self.kind_box_1, self, "factor", "Proportionality factor (k) [to eV/Å]", labelWidth=240, valueType=float, orientation="horizontal") oasysgui.lineEdit(self.kind_box_1, self, "central_value", "Central Energy/Wavelength Value [eV/Å]", labelWidth=240, valueType=float, orientation="horizontal") self.kind_box_2 = oasysgui.widgetBox(result_box, "", addSpace=True, orientation="horizontal", height=50) self.le_user_file = oasysgui.lineEdit(self.kind_box_2, self, "user_file", "File Name", labelWidth=60, valueType=str, orientation="horizontal") gui.button(self.kind_box_2, self, "...", callback=self.selectUserFile) self.set_KindOfCalculation()
def __init__(self, baseColor=QColor(50, 50, 50), highlightColor=QColor(247, 147, 30), spread=2.5): """Constructor By default a nukeish color scheme (dark slate + orange highlight) is created This can be overriden by either supplying colors or by loading a different scheme from disc via the load settings """ self.palette = QPalette() self.baseColor = baseColor self.highlightColor = highlightColor self.spread = spread self.generateScheme() QApplication.setStyle("Plastique")
def display(sc, title="SVG scene"): """Display a scene in a Qdialog :Parameters: - `sc` (`SVGScene`) - `title` (str) - window title """ qapp = QApplication.instance() if qapp is None: qapp = QApplication([]) dial = QDialog() dial.setWindowTitle(title) dial.setPalette(QPalette(QColor(255, 255, 255))) lay = QVBoxLayout(dial) w = QSvgWidget(dial) data = QByteArray(str(to_xml(sc))) w.load(data) r = w.renderer() w.setMinimumSize(r.defaultSize()) lay.addWidget(w) dial.show() qapp.exec_()
def vfkFileLineEdit_textChanged(self, arg1): """ :type arg1: str :return: """ info = QFileInfo(arg1) if info.isFile(): self.loadVfkButton.setEnabled(True) self.vfkFileLineEdit.setPalette(self.__mDefaultPalette) else: self.loadVfkButton.setEnabled(False) pal = QPalette(self.vfkFileLineEdit.palette()) pal.setColor(QPalette.text(), Qt.red) self.vfkFileLineEdit.setPalette(pal)
def palette( self ): """ Converts the current color data to a QPalette. :return <QPalette> """ palette = QPalette() for colorGroup, qColorGroup in self.GroupMapping.items(): for colorRole, qColorRole in self.RoleMapping.items(): color = self.color(colorRole, colorGroup) palette.setColor( qColorGroup, qColorRole, color ) return palette
def __init__(self, parent=None): Qwt.QwtPlot.__init__(self, parent ) self.grid=None self.setTitle( "Watching TV during a weekend" ) canvas = Qwt.QwtPlotCanvas() canvas.setPalette( QPalette(Qt.gray) ) canvas.setBorderRadius( 10 ) self.setCanvas( canvas ) self.plotLayout().setAlignCanvasToScales( True ) self.setAxisTitle( Qwt.QwtPlot.yLeft, "Number of People" ) self.setAxisTitle( Qwt.QwtPlot.xBottom, "Number of Hours" ) self.legend = Qwt.QwtLegend() self.legend.setDefaultItemMode( Qwt.QwtLegendData.Checkable ) self.insertLegend( self.legend, Qwt.QwtPlot.RightLegend ) self.populate() self.legend.checked['QVariant','bool','int'].connect(self.showItem ) self.replot() # creating the legend items """self.items = Qwt.QwtPlotDict.itemList( Qwt.QwtPlotItem.Rtti_PlotHistogram ) for i in range(len(self.items)): if ( i == 0 ): #const QVariant itemInfo = itemToInfo( self.items[i] ) #QwtLegendLabel * legendLabel = legend.legendWidget( itemInfo ) if ( legendLabel ): legendLabel.setChecked( True ) self.items[i].setVisible( True ) else: self.items[i].setVisible( False )""" self.setAutoReplot( True )
def paintEvent(self, event): self.painter = QPainter() self.painter.begin(self) if self.zoom >= 3: self.painter.setPen(QPalette().foreground().color()) # draw horizontal lines for i in range(self.image.width() + 1): self.painter.drawLine(self.zoom * i, 0, self.zoom * i, self.zoom * self.image.height()) # draw vertical lines for j in range(self.image.height() + 1): self.painter.drawLine(0, self.zoom * j, self.zoom * self.image.width(), self.zoom * j) for i in range(self.image.width()): for j in range(self.image.height()): rect = self.pixelRect(i, j) if not event.region().intersected(rect).isEmpty(): color = QColor.fromRgba(self.image.pixel(QPoint(i, j))) if color.red() < 255: self.painter.fillRect(rect, self.QT_WHITE) self.painter.fillRect(rect, color) self.painter.end()
def __init__(self, parent=None, start_dir=""): super(OpenMenu, self).__init__(parent) self.ui = Ui_OpenMenu() self.ui.setupUi(self) #self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.current_dir = None self.updateUI() self.populate_list() self.normal_palette = self.ui.txtSearch.palette() self.red_palette = QPalette(self.normal_palette) self.red_palette.setColor(QPalette.Normal, QPalette.Base, QColor(200, 98, 96)) self.findDirectory(start_dir)