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
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(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 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, parent=None): super().__init__(parent) self.setWindowTitle("五子棋") self.setWindowIcon(QIcon('source/icon.ico')) self.setFixedSize(760, 650) p = QPalette(self.palette()) b = QBrush(QImage('source/游戏界面.png')) p.setBrush(QPalette.Background, b) self.setPalette(p) self.startBtn = Mybutton('source/开始按钮_normal.png', 'source/开始按钮_hover.png', 'source/开始按钮_press.png', parent=self) self.startBtn.move(630, 200) self.regretBtn = Mybutton('source/悔棋按钮_normal.png', 'source/悔棋按钮_hover.png', 'source/悔棋按钮_press.png', parent=self) self.regretBtn.move(630, 250) self.loseBtn = Mybutton('source/认输按钮_normal.png', 'source/认输按钮_hover.png', 'source/认输按钮_press.png', parent=self) self.loseBtn.move(630, 300) self.backBtn = Mybutton('source/返回按钮_normal.png', 'source/返回按钮_hover.png', 'source/返回按钮_press.png', parent=self) self.backBtn.move(630, 50) louzi_sound = PySide2.QtMultimedia.QSound.play('source/luozisheng.wav')
def __init__(self): super(ClientWindow, self).__init__() self.resize(823,511) self.setWindowTitle('用户客户端') self.friendList = QListWidget() self.friendList.doubleClicked.connect(self.changeFriendText) self.friendList.clicked.connect(self.changeFriendText) self.portLine = QLineEdit() self.portLine.setText('12345') self.connectBtn = QPushButton('连接') self.connectBtn.clicked.connect(self.setupFun) self.messageText = QTextEdit() self.messageLine = QLineEdit() self.sendBtn = QPushButton('发送') self.sendBtn.clicked.connect(self.sendFun) self.text = '' self.userText = {} self.initUI() self.palette = QPalette() self.palette.setBrush(QPalette.Background, QBrush(QPixmap('./image/background.jpg'))) self.setPalette(self.palette) self.client = Client() self.client.trigger.connect(self.updateTextFun) self.ininData()
def __init__(self): super(MainWindow, self).__init__() self.resize(562, 381) self.setWindowTitle('服务器') self.addClientBtn = QPushButton('添加客户端') self.addClientBtn.clicked.connect(self.addClientFunc) self.clearTextBtn = QPushButton('清除文本') self.setupBtn = QPushButton('启动服务器') self.setupBtn.clicked.connect(self.setupFunc) self.portLabel = QLabel('端口:') self.chatText = QTextEdit() self.portLine = QLineEdit() self.portLine.setText('8888') self.setupBtn1 = QPushButton('关闭服务器') self.setupBtn1.clicked.connect(lambda: self.updateText('服务器已关闭')) self.server = SocketServer() self.server.trigger.connect(self.updateText) self.palette = QPalette() self.palette.setBrush(QPalette.Background, QBrush(QPixmap('./image/background.jpg'))) self.setPalette(self.palette) self.text = '' self.windowList = [] self.ipLine = QLineEdit('127.0.0.1') self.ipLabel = QLabel('IP:') self.initUI() self.initData()
def axis_tool(self): w = 300 h = 600 # 判断 if self.tool_dialog == None: # 创建坐标工具窗 self.tool_dialog = QDialog(self.ui) self.tool_dialog.setWindowTitle('坐标工具') self.tool_dialog.resize(w, h) # 截图 photo_path = self.screen_cap() if photo_path != None: if self.screen_cap_file != None: os.remove(self.screen_cap_file) self.screen_cap_file = photo_path pix = QPixmap(photo_path) w = pix.width() h = pix.height() # 设置面板大小 self.tool_dialog.setFixedSize(w / 4, h / 4) # 调色板 palette = QPalette() # 缩小图片 pix = pix.scaled(w / 4, h / 4) palette.setBrush(self.tool_dialog.backgroundRole(), QBrush(pix)) self.tool_dialog.setAutoFillBackground(True) self.tool_dialog.setPalette(palette) self.tool_dialog.setMouseTracking(True) # 绑定鼠标移动事件 self.tool_dialog.mouseMoveEvent = self.mouse_move # 显示窗口 self.tool_dialog.show() # 十字光标 self.tool_dialog.setCursor(Qt.CrossCursor)
def __init__(self, widget): QMainWindow.__init__(self) self.setWindowTitle("Login to Backend Discord GUI") grad = QPalette() gradient = QConicalGradient(QPointF(400, -10), 200) gradient.setColorAt(0.0, QColor(30, 30, 30)) gradient.setColorAt(0.5, QColor(50, 50, 50)) gradient.setColorAt(0.95, QColor(50, 13, 150)) gradient.setColorAt(1.0, QColor(106, 13, 173)) gradient.setSpread(QGradient.RepeatSpread) grad.setBrush(QPalette.Window, QBrush(gradient)) self.setPalette(grad) # Status Bar self.statusbar = self.statusBar() self.statusbar.showMessage("Looking for data...") self.searchData() frameGm = self.frameGeometry() screen = QApplication.desktop().screenNumber( QApplication.desktop().cursor().pos()) centerPoint = QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) self.setCentralWidget(widget)
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 __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 __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 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 __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 __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 __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.grid_layout = QGridLayout() self.shortcuts = {} # shortcut := {'status': '', 'widget': widget} self.pal = QPalette() self.feature = FeatureStyle() self.start()
def __init__(self): super().__init__() if QApplication.instance(): self.palette = QApplication.instance().palette() else: self.palette = QPalette() self.color = None
def _pastePic(self, image): self.img = image self.qt_image = ImageQt.ImageQt(image) self.pic = QPixmap.fromImage(self.qt_image) self.resize(self.pic.width(), self.pic.height()) self.pic = self.pic.scaled(self.size(), Qt.IgnoreAspectRatio) self.palette = QPalette() self.palette.setBrush(QPalette.Background, self.pic) self.setPalette(self.palette)
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 __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 update_lock_checkbox(self): if self.lock_checkbox.isChecked(): self.set_bpm_palette = QPalette() self.set_bpm_palette.setColor(QPalette.Text, Qt.black) self.set_bpm_widget.setPalette(self.set_bpm_palette) self.set_bpm_widget.setReadOnly(False) else: self.set_bpm_palette = QPalette() self.set_bpm_palette.setColor(QPalette.Text, Qt.gray) self.set_bpm_widget.setPalette(self.set_bpm_palette) self.set_bpm_widget.setReadOnly(True)
def __init__(self, *args, **kwargs): super(UpdatePage, self).__init__(*args, *kwargs) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle('分析决策系统自动更新程序') self.request_stack = list() self.update_error = False self.current_count = 0 self.update_count = 0 self._pressed = False self._mouse_pos = None self.sys_bit = "32" if sys.maxsize < 2**32 else "64" self._server = "" self.network_manager = QNetworkAccessManager(self) icon_path = os.path.join(BASE_DIR, "icons/app.png") pix_path = os.path.join(BASE_DIR, "images/update_bg.png") self.setWindowIcon(QIcon(icon_path)) self.setPixmap(QPixmap(pix_path)) self.red = QPalette() self.red.setColor(QPalette.WindowText, Qt.red) self.blue = QPalette() self.blue.setColor(QPalette.WindowText, Qt.blue) font = QFont() font.setPointSize(16) font.setBold(True) font.setWeight(75) self.setFixedSize(500, 200) self.setScaledContents(True) self.setFont(font) self.show_text = QLabel("系统正在下载新版本文件...", self) self.show_text.setFont(font) self.show_text.setFixedSize(self.width(), self.height()) self.show_text.setAlignment(Qt.AlignCenter) self.show_text.setPalette(self.blue) self.update_process_bar = QProgressBar(self) self.update_process_bar.setGeometry(1, 160, 498, 12) self.update_process_bar.setObjectName('processBar') self.setStyleSheet(""" #processBar{ text-align:center; font-size: 12px; font-weight:100; border: 1px solid #77d333; border-radius: 5px; background-color:none; } #processBar::chunk { background-color: #77d363; border-radius: 3px; margin:2px } """) self._updating()
def initGlobalStyle(cls, *args): """ Initialize style that will be used across the application """ palette = QPalette() palette.setColor(QPalette.WindowText, QColor(150, 150, 255)) palette.setBrush(QPalette.Window, QBrush(Qt.darkMagenta, Qt.Dense7Pattern)) palette.setColor(QPalette.Base, Qt.darkGreen) palette.setColor(QPalette.AlternateBase, Qt.darkMagenta) QApplication.instance().setPalette(palette)
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 setUp_Login_UI(self): self.palette = QPalette() self.pixmap = QPixmap("sec_shield.png") self.brush = QBrush() self.frame_layout = QVBoxLayout() self.setFixedSize(300, 300) self.setFrameStyle(QFrame.Box) self.setLineWidth(4) self.setLayout(self.frame_layout) self.palette.setBrush(QPalette.Background, self.brush) self.setPalette(self.palette)
def __init__( self, parent=None, ): super(ScreenShotMainWidget, self).__init__(parent) self.setWindowFlags(Qt.FramelessWindowHint) self.palette = QPalette() self.desk = QApplication.desktop() self.screen = self.desk.screenGeometry() self.show_widget = ScreenShotShowWidget(self) self.draw_signal.connect(self.show_widget.adjustGeometry) self.screenshot()
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