def createLeftSide(self): self.leftSideGB = QGroupBox() home_directory = "./app/" palette = QPalette() palette.setColor(QPalette.Window, QColor(30, 30, 30)) model = QDirModel() view = QTreeView() view.setStyleSheet("QTreeView { border: 0px; }") view.setModel(model) view.setRootIndex(model.index(home_directory)) view.setColumnHidden(1, True) view.setColumnHidden(2, True) view.setColumnHidden(3, True) view.show() view.setPalette(palette) runButton = QPushButton("►") stopButton = QPushButton("❚❚") bottomBar = QHBoxLayout() bottomBar.addWidget(runButton) bottomBar.addWidget(stopButton) layout = QVBoxLayout() layout.addWidget(view) layout.addLayout(bottomBar) layout.setStretch(0, 2) self.leftSideGB.setLayout(layout)
def __init__(self, text, color, func): super(ClickableLabel, self).__init__(text) style = QPalette(self.palette()) style.setColor(QPalette.WindowText, color) self.setPalette(style) self.setFont(binaryninjaui.getMonospaceFont(self)) self.func = func
class LineEdit(QLineEdit): def __init__(self, parent=None): QLineEdit.__init__(self, parent) self.clearOnFocus = False self.originalPalette = self.palette() self.newPalette = QPalette(self.palette()) # copy constructor self.newPalette.setColor(QPalette.Normal, QPalette.Base, QColor(200, 255, 125)) def setColorOnFocus(self, color): self.newPalette.setColor(QPalette.Normal, QPalette.Base, color) def setClearOnFocus(self, clear): self.clearOnFocus = clear def focusInEvent(self, e): # event 상속 self.setPalette(self.newPalette) if self.clearOnFocus: self.clear() QLineEdit.focusInEvent(self, e) def focusOutEvent(self, e): # event 상속 self.setPalette(self.originalPalette) QLineEdit.focusOutEvent(self, e)
def __init__(self, imgFrame): QtWidgets.QWidget.__init__(self, imgFrame) Ui_ReadImg.__init__(self) self.setupUi(self) self.resize(100, 400) self._imgFrame = weakref.ref(imgFrame) self.modelBox.setToolTip(""" cunet通用,效果好,速度慢。 photo写真,速度块。 anime_style_art_rgb动漫,速度块。 """) # self.setWindowFlags( # Qt.Window | Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint) # self.setStyleSheet("background-color:white;") self.setAttribute(Qt.WA_StyledBackground, True) palette = QPalette(self.palette()) palette.setColor(QPalette.Background, Qt.white) self.setAutoFillBackground(True) self.setPalette(palette) self.radioButton.installEventFilter(self) self.radioButton_2.installEventFilter(self) self.downloadMaxSize = 0 self.downloadSize = 0 self.progressBar.setMinimum(0) self.slider = QtCustomSlider(self) self.horizontalLayout_7.addWidget(self.slider)
def set_background_color(widget, color: str): """ set widget color to color: str""" pal = QPalette() # set black background pal.setColor(QPalette.Background, QColor(color)) widget.setAutoFillBackground(True) widget.setPalette(pal)
def __init__(self): super().__init__() self.ui = Ui_ConfigCreator() self.ui.setupUi(self) Styling.set_style(self) self.setWindowTitle("Enter your Token") cookie_explanation = "" with open(os.path.join(os.path.realpath(__file__), "../../files/cookie_explanation.txt"), 'r', encoding='utf8') as f: for line in f.read().splitlines(): cookie_explanation += line + "\n" self.ui.label_sids.setText("SIDS Token: ") self.ui.label_explanation.setText(cookie_explanation) self.ui.btn_ok.setText("CONFIRM") self.ui.btn_ok.pressed.connect(self.ok_pressed) # dark mode options dark_mode_enabled = Config.load_config_key(Config.ConfigKeys.DARK_MODE.value) if dark_mode_enabled is None: dark_mode_enabled = True if dark_mode_enabled: # style items palette = QPalette() palette.setColor(QPalette.Text, Qt.white) self.ui.text_sids.setPalette(palette)
def initUI(self): self.resize(window_width,window_height) self.setWindowTitle("Healthcare Smart Mirror") self.show() pal=QPalette() pal.setColor(QPalette.Background,Qt.black) pal.setColor(QPalette.Foreground,Qt.white) self.setPalette(pal) hbox1 = QHBoxLayout() clock = Clock(QWidget()) weather = Weather(QWidget()) clock.setFixedHeight(200) weather.setFixedHeight(200) hbox1.addWidget(weather) hbox1.addStretch() hbox1.addWidget(clock) hbox2 = QHBoxLayout() fit=FitBitData(QWidget()) fit.setFixedHeight(280) todo= ToDo(QWidget()) todo.setFixedWidth(200) tododoc=ToDoDoctor(QWidget()) todomed=ToDoMedicines(QWidget()) cal = Calendar(QWidget()) hbox2.addWidget(fit) hbox2.addStretch(2) hbox2.addWidget(todo) hbox2.addWidget(tododoc) hbox2.addWidget(todomed) hbox2.addWidget(cal) hbox4 = QHBoxLayout() speechrecog = SpeechLabel(QWidget()) hbox4.addWidget(speechrecog) hbox4.addStretch(2) hbox5 = QHBoxLayout() messageBox = Message(QWidget()) hbox5.addWidget(messageBox) hbox6 = QHBoxLayout() health = HealthTips(QWidget()) health.setFixedHeight(150) hbox6.addWidget(health) vbox = QVBoxLayout() vbox.addLayout(hbox1) vbox.addLayout(hbox2) vbox.addStretch(2) vbox.addLayout(hbox4) vbox.addStretch(2) vbox.addLayout(hbox5) vbox.addLayout(hbox6) self.setLayout(vbox)
def on_btn_select_brush_color(self): self.brush_color = QColorDialog.getColor() self.label_img.update_brush_color(self.brush_color) pe = QPalette() pe.setColor(QPalette.Window, self.brush_color) self.label_brush_color.setPalette(pe) self.label_brush_color.setAutoFillBackground(True)
def validate_line_edit(widget): palette = QPalette() palette.setColor(QPalette.Text, QtCore.Qt.black if widget.text() else "#D8000C") palette.setColor(QPalette.Background, QtCore.Qt.white if widget.text() else QtCore.Qt.red) widget.setPalette(palette) return len(widget.text().strip()) > 0
def __init__(self, mainframe): QWidget.__init__(self) self.mainframe = mainframe print("Application started") self.setAutoFillBackground(True) palette = QPalette() palette.setColor(QPalette.Background, Qt.black) self.setPalette(palette) self.initUI()
def draw(self, color: QColor): """ Draws this cell with the specified color. The class variables will be passed in, but any color can be used """ self.clear() self.setGraphicsEffect(None) pal = QPalette() pal.setColor(QPalette.Background, color) self.setPalette(pal)
def __init_style(self): """ Sets the background of this canvas widget """ color = AssetManager.getInstance().config( 'colors', 'room_bg') if self.__is_config else "white" pal = QPalette() pal.setColor(QPalette.Background, QColor(color)) self.setPalette(pal)
def setColor(self, newColor): self._color = newColor palette = QPalette(self.palette()) palette.setColor(QPalette.Button, self.color) palette.setColor(QPalette.Background, self.color) self.setAutoFillBackground(True) self.setPalette(palette)
def setStatusBar(self, text, isError=False): if isError: palette = QPalette() palette.setColor(QPalette.WindowText, QColor(175, 0, 0)) self.statusbar.setPalette(palette) else: palette = QPalette() palette.setColor(QPalette.WindowText, Qt.white) self.statusbar.setPalette(palette) self.statusbar.showMessage(text)
def AddLog(self, Text, Sens="Entrant"): tmpLabel = QLabel(Text) pal = QPalette() if Sens == "Entrant": #Entrant : Device -> Computer pal.setColor(QPalette.Background, Qt.green) elif Sens == "Sortant": #Sortant : Computer -> Device pal.setColor(QPalette.Background, Qt.red) tmpLabel.setAutoFillBackground(True) tmpLabel.setPalette(pal) self.VBoxLayout.addWidget(tmpLabel)
class TradeAction(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.db = None self.p_type = 0 self.layout = QHBoxLayout() self.label = QLabel() self.label.setText("") self.layout.addWidget(self.label) self.setLayout(self.layout) self.palette = QPalette() def init_db(self, db): self.db = db def getType(self): return self.p_type def setType(self, trade_type): # if (self.p_type == type): # return self.p_type = trade_type if self.p_type: self.label.setText(g_tr('TradeAction', "CORP.ACTION")) self.palette.setColor(self.label.foregroundRole(), CustomColor.DarkBlue) self.label.setPalette(self.palette) else: self.label.setText(g_tr('TradeAction', "TRADE")) self.palette.setColor(self.label.foregroundRole(), CustomColor.DarkGreen) self.label.setPalette(self.palette) # else: # self.label.setText("SELL") # self.palette.setColor(self.label.foregroundRole(), CustomColor.DarkRed) # self.label.setPalette(self.palette) # else: # self.label.setText("UNKNOWN") self.changed.emit() @Signal def changed(self): pass corp_action_type = Property(int, getType, setType, notify=changed, user=True) def isCustom(self): return True
def __init__(self, parent=None): QWidget.__init__(self, parent) self._visualizer = PlumbingVisualizer(parent=self) pal = QPalette() pal.setColor(QPalette.Background, 'white') self.setAutoFillBackground(True) self.setPalette(pal) self.paint = self._visualizer.paint
def __init__(self): super(Pronunciator, self).__init__() self.setMaximumHeight(21) self.setMinimumWidth(200) self.setWindowTitle('Pronunciator') self.setWindowIcon(QIcon('arti.PNG')) palette = QPalette() palette.setColor(palette.Window, QColor('#000000')) palette.setColor(palette.WindowText, QColor('#FFFFFF')) self.setPalette(palette) centralWidget = QWidget() self.setCentralWidget(centralWidget) layout = QFormLayout(centralWidget) textLayout = QHBoxLayout() self.text = QLineEdit() self.text.setClearButtonEnabled(True) textLayout.addWidget(self.text) self.sayButton = QPushButton('Say') textLayout.addWidget(self.sayButton) self.text.returnPressed.connect(self.sayButton.animateClick) self.sayButton.clicked.connect(self.say) layout.addRow('Text:', textLayout) self.voiceCombo = QComboBox() layout.addRow('Voice:', self.voiceCombo) self.volumeSlider = QSlider(Qt.Horizontal) self.volumeSlider.setMinimum(0) self.volumeSlider.setMaximum(100) self.volumeSlider.setValue(100) layout.addRow('Volume:', self.volumeSlider) self.engine = None engineNames = QTextToSpeech.availableEngines() if len(engineNames) > 0: engineName = engineNames[0] self.engine = QTextToSpeech(engineName) self.engine.stateChanged.connect(self.stateChanged) self.voices = [] for voice in self.engine.availableVoices(): self.voices.append(voice) self.voiceCombo.addItem(voice.name()) else: self.setWindowTitle('No voices available') self.sayButton.setEnabled(False)
def new_GUI_link(self): # initialize second window second_window = Window_csv() # recolor p = QPalette() p.setColor(QPalette.Background, QColor("white")) second_window.setPalette(p) #show and exec (on click) second_window.show() second_window.exec_()
def checkButton(self, checked, button, spinBox): """ If button is checked, turn green and enable spin box with minimum 1. else turn back to normal and disable spin box. """ if checked: palette = QPalette() palette.setColor(QPalette.Button, Qt.darkGreen) palette.setColor(QPalette.ButtonText, Qt.white) button.setPalette(palette) spinBox.setPalette(palette) spinBox.setReadOnly(False) spinBox.setMinimum(1) button.setText('✓ Enabled') else: palette = QPalette() if self.mainWindow.theme is 0: palette.setColor(QPalette.Button, QColor(180, 180, 180)) palette.setColor(QPalette.ButtonText, Qt.black) else: palette.setColor(QPalette.Button, QColor(53, 53, 53)) button.setPalette(palette) spinBox.setPalette(palette) spinBox.setReadOnly(True) spinBox.setMinimum(0) button.setText('Enable')
def unloadTimeCheck(self, checked, machine, timeBox, button): """ If the button next to the time is clicked (checked), this handles what to do with the data and gui. If it is unchecked, the data is deleted and the timeObject is enabled. """ if checked: machine.unloadTime = timeBox.time().toString() timeBox.setReadOnly(True) palette = QPalette() palette.setColor(QPalette.Button, Qt.darkGreen) palette.setColor(QPalette.ButtonText, Qt.white) button.setPalette(palette) timeBox.setPalette(palette) else: machine.unloadTime = None timeBox.setReadOnly(False) palette = QPalette() if self.theme is 0: palette.setColor(QPalette.Button, QColor(180, 180, 180)) palette.setColor(QPalette.ButtonText, Qt.black) else: palette.setColor(QPalette.Button, QColor(53, 53, 53)) button.setPalette(palette) timeBox.setPalette(palette) self.updateResults(machine)
def __init__(self): super(Weather, self).__init__() self.resize(530, 414) self.setMinimumSize(QSize(530, 414)) self.setMaximumSize(QSize(530, 414)) self.setGeometry(800, 130, 530, 414) self.setFont(QFont('Roboto', 12)) self.setWindowIcon(QIcon('arti.PNG')) self.setWindowTitle('Weather') palette = QPalette() palette.setColor(palette.Window, QColor('#000000')) palette.setColor(palette.WindowText, QColor('#FFFFFF')) palette.setColor(palette.Button, QColor("#00FF00")) palette.setColor(palette.ButtonText, QColor("#000000")) self.setPalette(palette) self.menubar = QMenuBar(self) self.menubar.setGeometry(0, 0, 682, 21) self.menubar.setFont(QFont('Roboto', 10)) self.date_menu = QMenu(self.menubar) self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y'))) self.setMenuBar(self.menubar) self.menubar.addAction(self.date_menu.menuAction()) self.city = QLineEdit(self) self.city.setObjectName(u"city") self.city.setGeometry(QRect(10, 30, 511, 41)) self.city.setMinimumSize(QSize(511, 41)) self.city.setMaximumSize(QSize(511, 41)) self.city.setPlaceholderText( 'Enter the city name of which you want to view the weather.') self.city.setToolTip( 'Enter the city name of which you want to view the weather.') self.celsius = QLabel(self) self.celsius.setGeometry(QRect(10, 90, 491, 31)) self.fahrenheit = QLabel(self) self.fahrenheit.setGeometry(QRect(10, 140, 491, 31)) self.kelvin = QLabel(self) self.kelvin.setGeometry(QRect(10, 190, 491, 31)) self.pressure = QLabel(self) self.pressure.setGeometry(QRect(10, 240, 491, 31)) self.humidity = QLabel(self) self.humidity.setGeometry(QRect(10, 290, 491, 31)) self.description = QLabel(self) self.description.setGeometry(QRect(10, 340, 491, 31)) speak('Welcome to the Weather.') self.city.returnPressed.connect(lambda: self.weather()) self.city.returnPressed.connect(lambda: self.clear_text())
def __init__(self, parent=None): self.parent = parent QPlainTextEdit.__init__(self, parent) self.m_localEchoEnabled = False self.document().setMaximumBlockCount(100) p = QPalette() p.setColor(QPalette.Base, Qt.black) p.setColor(QPalette.Text, Qt.green) self.setPalette(p)
def camera_data_available(self, available: int): pal = QPalette() pal.setColor(QPalette.Button, QColor(240, 240, 240)) if available == 0: self.ui.cam_btn.setEnabled(False) elif available == 1: self.ui.cam_btn.setEnabled(True) elif available == 2: pal.setColor(QPalette.Button, QColor(240, 150, 150)) self.ui.cam_btn.setEnabled(True) self.ui.cam_btn.setAutoFillBackground(True) self.ui.cam_btn.setPalette(pal) self.ui.cam_btn.update()
def __init__(self): super(GameHub, self).__init__() self.setGeometry(90, 50, 524, 186) self.setMinimumSize(524, 186) self.setMaximumSize(524, 186) self.setWindowIcon(QIcon('arti.PNG')) self.setWindowTitle('GameHub') palette = QPalette() palette.setColor(palette.Window, QColor('#000000')) palette.setColor(palette.WindowText, QColor('#FFFFFF')) palette.setColor(palette.Button, QColor("#00FF00")) palette.setColor(palette.ButtonText, QColor("#000000")) self.setPalette(palette) self.menubar = QMenuBar(self) self.menubar.setGeometry(0, 0, 682, 21) self.menubar.setFont(QFont('Roboto', 10)) self.date_menu = QMenu(self.menubar) self.date_menu.setTitle(str(datetime.now().strftime('%d-%m-%Y'))) self.setMenuBar(self.menubar) self.menubar.addAction(self.date_menu.menuAction()) self.label = QLabel(self) self.label.setGeometry(QRect(10, 30, 501, 51)) self.label.setText( "Hello, I am your host, Artigence. Welcome to GameHub. Please click on below buttons to " "choose a game of your choice.") self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignHCenter) self.label.setFont(QFont('Roboto', 12)) self.pong = QPushButton(self) self.pong.setGeometry(QRect(20, 130, 95, 33)) self.pong.setCursor(QCursor(Qt.PointingHandCursor)) self.pong.setText('Pong') self.tictactoe = QPushButton(self) self.tictactoe.setGeometry(150, 130, 95, 33) self.tictactoe.setCursor(QCursor(Qt.PointingHandCursor)) self.tictactoe.setText('Tic-Tac-Toe') self.connect_four = QPushButton(self) self.connect_four.setGeometry(290, 130, 95, 33) self.connect_four.setCursor(QCursor(Qt.PointingHandCursor)) self.connect_four.setText('Connect-4') self.snake = QPushButton(self) self.snake.setGeometry(420, 130, 95, 33) self.snake.setCursor(QCursor(Qt.PointingHandCursor)) self.snake.setText('Snake') self.pong.clicked.connect(lambda: pong()) self.tictactoe.clicked.connect(lambda: tictactoe()) self.connect_four.clicked.connect(lambda: connect_four()) self.snake.clicked.connect(lambda: snake())
def setColorToRow(self, rowIndex, color): """ Sets color for a single row. """ palette = QPalette() palette.setColor(QPalette.Button, color.darker(f=110)) for j in range(self.columnCount()): try: wg = self.cellWidget(rowIndex, j) if wg: wg.setPalette(palette) else: self.item(rowIndex, j).setBackground(color) except: pass
def __init__(self, parent): QtWidgets.QSlider.__init__(self) self.label = QLabel(self) self._qtTool = weakref.ref(parent) self.label.setFixedSize(QSize(20, 20)) self.label.setAutoFillBackground(True) self.label.setAutoFillBackground(True) palette = QPalette() palette.setColor(QPalette.Background, Qt.white) self.label.setPalette(palette) self.label.setAlignment(Qt.AlignCenter) self.label.setVisible(False) self.label.move(0, 3) self.setMaximum(100) self.setOrientation(Qt.Horizontal) self.setPageStep(0)
def __init__(self): super(Calculator, self).__init__() self.setWindowTitle("Calculator") self.setWindowIcon(QIcon('arti.PNG')) self.setFont(QFont('Roboto', 12)) palette = QPalette() palette.setColor(palette.Window, QColor('#000000')) palette.setColor(palette.WindowText, QColor('#FFFFFF')) self.setPalette(palette) self.setGeometry(300, 300, 300, 300) self.generalLayout = QVBoxLayout() self._centralWidget = QWidget(self) self.setCentralWidget(self._centralWidget) self._centralWidget.setLayout(self.generalLayout) self._createDisplay() self._createButtons()
def __init__(self): super().__init__() self.selected = 0 self.setStyleSheet(Style.QLIST_VIEW.value) self.setLayoutDirection(Qt.RightToLeft) self.setAlternatingRowColors(True) color = QColor(Color.GREY.value) palette = QPalette() palette.setColor(QPalette.Highlight, color) self.setPalette(palette) self.model = ItemModel(0, 1, self) self.setModel(self.model) self.setItemDelegate(ItemDelegate()) self.model.rowsAboutToBeRemoved.connect(self.__items_deleted)
def set_widget_colour(self, colour=None): """ Changes the colour of the widget. colour: Accepts either Qt.GlobalColour (Qt.red) or QPalette input anything else will do nothing. """ if colour: if isinstance(colour, Qt.GlobalColor): bg = QPalette() bg.setColor(QPalette.Window, colour) elif isinstance(colour, QPalette): bg = colour else: return self.setPalette(bg) self.setAutoFillBackground(True)