用pyqt5 给按钮设置图标和css样式的方法

yipeiwu_com5年前Python基础

如下所示:

设置图标

self.pushButton.setIcon(QIcon("sure.png"))

设置css样式

self.pushButton.setStyleSheet("QPushButton{color:black}"
                    "QPushButton:hover{color:red}"
                    "QPushButton{background-color:lightgreen}"
                    "QPushButton{border:2px}"
                    "QPushButton{border-radius:10px}"
                    "QPushButton{padding:2px 4px}")

以上这篇用pyqt5 给按钮设置图标和css样式的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python shell根据ip获取主机名代码示例

这篇文章里我们主要分享了python中shell 根据 ip 获取 hostname 或根据 hostname 获取 ip的代码,具体介绍如下。 笔者有时候需要根据hostname获取i...

python程序 创建多线程过程详解

一、python线程的模块 1.1 thread和threading模块 thread模块提供了基本的线程和锁的支持 threading提供了更高级别、功能更强的线程管理的功能。...

Python 2.x如何设置命令执行的超时时间实例

前言 在Python2.x中的几个用来执行命令行的库或函数在执行命令是均不能设置一个命令执行的超时时间,用来在命令执行时间超时时终端这个命令的执行,这个功能在3.x(?)中解决了,但是在...

Python计算时间间隔(精确到微妙)的代码实例

Python计算时间间隔(精确到微妙)的代码实例

使用python中的datetime import datetime oldtime=datetime.datetime.now() print oldtime; x=1 while...

python实现将文件夹下面的不是以py文件结尾的文件都过滤掉的方法

如下所示: dir_in = os.path.join(os.path.dirname(__file__), r"oldApp")     dir_in = un...