![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PyQt5
记录PyQt5的常用控件
zmjames2000
这个作者很懒,什么都没留下…
展开
-
Pipenv的基本使用
Pipenv的基本使用本章将介绍pipenv的一些基本功能的使用Pipfile & Pipfile.lock下面是一个Pipfile和其产生的Pipfile.lock文件的简单示例。Pipfile[[source]]url = "https://pypi.python.org/simple"verify_ssl = truename = "pypi"[pac...转载 2019-12-05 08:43:47 · 1009 阅读 · 0 评论 -
1. 主要内容
QT designerPyQt5 基本窗口控件:QMainWindow,Qwidget,Qlabel,QLineEdit,等PyQt5高级组件:QTableView, QListView,容器,多线程等PyQt5布局管理:QBoxLayout, QGridLayout,QFormlayout, 嵌套布局等PyQt5信号与槽:事件处理,数据传递等PyQt5图形与特效:定制窗口风格...原创 2019-09-07 20:12:10 · 110 阅读 · 0 评论 -
2.使用QTdesigner工具
将.ui文件转化 .py文件方法1. python -m PyQt5.uic.pyuic demo.ui -o demo.py方法2 pyuic5 demo.ui -o demo.pypyuic5 /anaconda3/pkgs/pyqt-5.9.2/bin/pyuic5pyuic5.bat@D:/Anaconda3\python.exe -m PyQt5.uic.pyu...原创 2019-09-07 20:16:35 · 250 阅读 · 0 评论 -
3.主窗口类型QMainWindow,QWidget,QDialog
主窗口类型:QMainWindow: 可以包含菜单栏,工具栏,状态栏和标题栏,是最常见的窗口形式QWidget: 不确定窗口的用途的时候, 就用这个。QDialog: 是对话窗口的基类。是没有工具栏,状态栏,菜单栏的。简单案例:from PyQt5.QtWidgets import QApplication,QWidget,QMainWindow,QPushButto...原创 2019-09-07 20:22:51 · 269 阅读 · 0 评论 -
4.控件提示信息QToolTip
简单案例from PyQt5.QtWidgets import QMainWindow,QApplication,QToolTip,QPushButton,QHBoxLayout,QWidgetfrom PyQt5.QtGui import QIcon,QFontimport sysclass TooltipForm(QMainWindow): def __init__(se...原创 2019-09-07 20:25:53 · 376 阅读 · 0 评论 -
debug函数
像linux一样 使用 __func__,__line__,def debug(message):import sysimport inspectcallerframerecord = inspect.stack()[1]# 0代表当前行 , 1当前调用frame = callerframerecord[0]info = insp...原创 2019-09-09 20:41:05 · 769 阅读 · 0 评论 -
5.QLable控件
QLabel控件setAlignment() 设置文件的对齐方式setIndent()设置文本缩进text()获取文本内容setBuddy() 设置伙伴关系setText()设置文本内容selectedText() 返回选择的字符setWordWrap() 设置是否允许换行常用的信号(事件);1.当鼠标滑过QLabel控件时触发: linkHovered2....原创 2019-09-09 21:01:43 · 287 阅读 · 0 评论 -
6.QLineEdit 控件与回显模式EchoMode
Normal NoEcho 不回显, linux中输入密码,不显示 Password 模式 sha md5 PasswordEchoOnEdit 先显示A,过1s就显示※#placeholdertext 文本编辑框显示灰色的内容,默认是灰色的 def initUI(self): print('initUI ...') # self.s...原创 2019-09-09 21:04:11 · 731 阅读 · 0 评论 -
6.QLineEdit 控件 校验器
如限制只能输入整数,浮点数,或满足一定条件的字符串def initUI(self): # self.setGeometry(300,300, 500,500) self.move(500,500) self.setWindowTitle('QLineEditValidator') intLineEdit = QLineEdit...原创 2019-09-09 21:05:58 · 467 阅读 · 0 评论 -
6.QLineEdit 控件 input Mask
input maskdef initUI(self): # self.setGeometry(300,300, 500,500) self.move(500,500) self.setWindowTitle('QLineEditValidator') #192.168.21.45 ipLineEdit = QL...原创 2019-09-09 21:09:03 · 1726 阅读 · 0 评论 -
7.QTextEdit 控件
def initUI(self): self.setWindowTitle('QLineEditDemo') self.setGeometry(500,500,300,200) self.textEdit = QTextEdit() #用self是为了函数能直接调用 self.buttonText = QPushButton...原创 2019-09-09 21:10:14 · 190 阅读 · 0 评论 -
8.QPushButton 控件
QPushButton 父类 QAbstractButtonQAbstracktButtonQPushButtonQToolButtonQRadioButtonQCheckBox def initUI(self): self.setWindowTitle('QLineEditDemo') self.setGeometry(500,5...原创 2019-09-10 09:12:59 · 275 阅读 · 0 评论 -
9.RadioButton控件
def initUI(self): self.setWindowTitle('RadionButtonDemo') self.setGeometry(500,500,300,200) button1 = QRadioButton('radiobutton 1') button1.setChecked(True) b...原创 2019-09-10 11:00:50 · 147 阅读 · 0 评论 -
10.QCheckBox 复选框
3种状态 为选中0 半选中1 选中2def initUI(self): self.setWindowTitle('QCheckBoxDemo') self.setGeometry(500,500,300,200) checkBox1 = QCheckBox() checkBox1.setChecked(True) ...原创 2019-09-10 11:03:27 · 276 阅读 · 0 评论 -
11. QComboBox下拉列表控件
def initUI(self): self.setWindowTitle('QCheckBoxDemo') self.setGeometry(500,500,300,200) label = QLabel('请选择编程语言') cb = QComboBox() cb.addItem('C++') ...原创 2019-09-10 11:05:34 · 510 阅读 · 0 评论 -
12.QSlider滑块控件
def initUI(self): self.setWindowTitle('QSliderDemo') self.setGeometry(500,500,300,200) label = QLabel('你好 PYQT') label.setAlignment(Qt.AlignCenter) slider1 = ...原创 2019-09-10 11:07:34 · 281 阅读 · 0 评论 -
13.QSpinBox 计数器控件
def initUI(self): self.setWindowTitle('QSpinBoxDemo') self.setGeometry(500,500,300,200) label1 = QLabel('current value') label1.setAlignment(Qt.AlignCenter) s...原创 2019-09-10 11:09:14 · 120 阅读 · 0 评论 -
14. QDialog 对话框
对话框:QDialogQmessagBoxQColorDialogQFileDialogQFontDialogQInputDialogQMainWindowQWidgetQDialogclass QDialogDemo(QMainWindow): def __init__(self): super().__init__() self....原创 2019-09-10 11:14:04 · 147 阅读 · 0 评论 -
15.QMessageBox 消息对话框
1. 关于对话框2. 错误对话框3. 提问对话框4. 警告对话框5. 消息对话框有2点差异:显示的对话框图标可能不同显示的按钮是不一样的def initUI(self):self.setWindowTitle(‘QMessageBoxDemo’)self.setGeometry(500,500,300,200) button1 = QPushButton('关于...原创 2019-09-10 11:18:42 · 143 阅读 · 0 评论 -
16.QInputDialog 输入对话框
QInputDialog.getItemQInputDialog.getTextQInputDialog.getIntdef initUI(self): self.setWindowTitle('QInputDialogDemo') self.setGeometry(500,500,300,200) button1 = QPushButton...原创 2019-09-10 11:20:43 · 324 阅读 · 0 评论 -
17.QFontDialog 字体选择对话框
def initUI(self): self.setWindowTitle('QFontDialogDemo') self.setGeometry(500,500,300,200) fontButton = QPushButton('选择字体') fontLabel = QLabel('hello 测试字体') ...原创 2019-09-10 11:22:59 · 169 阅读 · 0 评论 -
25.用画刷填充图形区域
def paintEvent(self,event): qp = QPainter() qp.begin(self) qp.setPen(Qt.red) brush = QBrush(Qt.SolidPattern) qp.setBrush(brush) qp.drawRect(10,15,90,60...原创 2019-09-11 20:18:28 · 435 阅读 · 0 评论 -
24.绘制各种弧,圆形,椭圆,多边形,
def paintEvent(self,event): qp = QPainter() qp.begin(self) qp.setPen(Qt.blue) #绘制弧 rect = QRect(0,10,100,100)#左上角点,长度,宽 度 qp.drawArc(rect, 0, 50*16) # a...原创 2019-09-11 20:16:27 · 278 阅读 · 0 评论 -
23.绘制直线
def paintEvent(self,event): painter = QPainter() painter.begin(self) painter.setPen(Qt.blue) pen = QPen(Qt.red, 3, Qt.SolidLine) #Qt.DashLine 虚线 Qt.DashDotDotLine 点划线...原创 2019-09-11 20:13:30 · 127 阅读 · 0 评论 -
22.正弦曲线
def paintEvent(self,event): painter = QPainter() painter.begin(self) painter.setPen(Qt.blue) size = self.size() for i in range(1000): x = 100*(-1+...原创 2019-09-11 16:38:59 · 297 阅读 · 0 评论 -
21.绘图API
1.文本2.各种图形(直线,点,椭圆,弧,扇形,多边形等)3.图像QPainterpainter = QPainter()painter.begin(self)painter.drawText(…)painter.end()必须在painEvent事件方法中绘制各种元素本质上,窗口尺寸的改变,paintEvent就会触发,重新绘制def initUI(self): ...原创 2019-09-11 16:36:16 · 121 阅读 · 0 评论 -
19.QFileDialog 文件选择对话框
def initUI(self): self.setWindowTitle('QFileDialogDemo') self.setGeometry(500,500,300,200) button1 = QPushButton() button1.setText('加载图片') button1.clicked.con...原创 2019-09-10 11:27:38 · 209 阅读 · 0 评论 -
18.QColorDialog 颜色选择对话框
def initUI(self): self.setWindowTitle('QFontDialogDemo') self.setGeometry(500,500,300,200) fontButton1 = QPushButton('选择颜色') fontLabel = QLabel('hello 测试字体') ...原创 2019-09-10 11:24:52 · 254 阅读 · 0 评论 -
20.case QDiaglog
from PyQt5.QtWidgets import QMainWindow,QWidget,QDialog,QPushButton,QApplication,QDesktopWidget,QHBoxLayout,QVBoxLayout,QFormLayout,QGridLayout,\ QToolTip,QLabel,QLineEdit,QTextEdit,QRadioButton,Q...原创 2019-09-10 11:29:37 · 122 阅读 · 0 评论