![](https://img-blog.csdnimg.cn/20200509110525335.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
【PyQt5】
.
Giyn
个人博客:https://giyn.work
联系邮箱:490601115@qq.com
展开
-
【PyQt5】{17} —— QTextBrowser文本浏览框
QTextBrowserQTextBrowser类为富文本浏览器提供了超文本导航,通常用作程序日志的输出窗口,默认只读。但只是默认,后期可以自行修改# -*- coding: utf-8 -*-"""Created on Sat May 9 17:14:37 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QTextBrowser, QVB原创 2020-05-16 08:58:07 · 12577 阅读 · 6 评论 -
【PyQt5】{16} —— QTextEdit文本编辑框(制作一个简易的记事本)
QTextEditQTextEdit类提供了一个部件,用于编辑和显示纯文本和富文本。QTextEdit的一些方法和属性:toPlainText():获取文本setText():设置文本textChanged:文本改变信号(在文本每次发生改变时发射)clear():清空文本setPlaceholderText():设置占位字符串(只有在文本编辑框中没有任何文本时才会显示)一个简易的记事本:# -*- coding: utf-8 -*-"""Created on Sat May原创 2020-05-15 10:55:11 · 1949 阅读 · 2 评论 -
【PyQt5】{15} —— 汉化对话框的按钮
# -*- coding: utf-8 -*-"""Created on Sat May 9 14:46:56 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBoxclass Simple_Window(QWidget): def __init__(self): super(Simple_Window,原创 2020-05-14 10:24:00 · 775 阅读 · 1 评论 -
【PyQt5】{14} —— 与对话框进行交互
# -*- coding: utf-8 -*-"""Created on Sat May 9 14:33:28 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QMessageBoxclass Simple_Window(QWidget): def __init__(self): super(Si原创 2020-05-13 16:05:20 · 340 阅读 · 1 评论 -
【PyQt5】{13} —— QMessageBox对话框
QMessageBoxQMessageBox类提供了一个模式对话框,用于通知用户或询问用户问题并接收答案。在图形用户界面中,对话框(又称对话方块)是一种特殊的视窗,用来在用户界面中向用户显示信息,或者在需要的时候获得用户的输入响应。之所以称之为“对话框”是因为它们使计算机和用户之间构成了一个对话——或者是通知用户一些信息,或者是请求用户的输入,或者两者皆有。—— 维基百科对话框可以增加程序与用户的交互能力,有时可以避免一些失误,如文件忘记保存:QMessageBox提供了多种对话框:以原创 2020-05-13 08:50:24 · 1561 阅读 · 1 评论 -
【PyQt5】{12} —— 连接带参数的槽函数
# -*- coding: utf-8 -*-"""Created on Sat May 9 12:16:58 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayoutclass Simple_Window(QWidget): def __init__(self): super(Simple_原创 2020-05-12 11:08:09 · 1595 阅读 · 1 评论 -
【PyQt5】{11} —— 一个信号与多个槽函数连接
# -*- coding: utf-8 -*-"""Created on Sat May 9 11:50:03 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayoutclass Simple_Window(QWidget): def __init__(self): super(Simple_原创 2020-05-12 09:33:26 · 4711 阅读 · 1 评论 -
【PyQt5】{10} —— 信号与信号连接
# -*- coding: utf-8 -*-"""Created on Sat May 9 11:39:49 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayoutclass Simple_Window(QWidget): def __init__(self): super(Simple_原创 2020-05-11 13:05:20 · 1458 阅读 · 2 评论 -
【PyQt5】{9} —— 多个信号连接同一个槽函数
QPushButton 控件的 pressed 信号和 released 信号分别是在按钮被 点击 和 释放 的瞬间发出,以此来实现多个信号连接同一个槽函数:# -*- coding: utf-8 -*-"""Created on Sat May 9 11:11:21 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayo原创 2020-05-11 10:19:00 · 3172 阅读 · 3 评论 -
【PyQt5】{8} —— 一个信号连接一个槽函数
PyQt5 的按钮控件 QPushButton 被点击之后会发射一个 clicked 信号,然后再通过 QLabel 的 setText 方法改变文本控件的内容,以此来实现一个信号连接一个槽函数:# -*- coding: utf-8 -*-"""Created on Sat May 9 11:11:21 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPu原创 2020-05-11 09:08:23 · 451 阅读 · 1 评论 -
【PyQt5】{7} —— 信号和槽
信号和槽信号和槽用于两个对象之间的通信,是Qt的代表性特征。简单地,可以理解为信号就是一个事件的发生,例如鼠标点击,键盘输入等;而槽就是一个函数,用于执行接收信号后的操作。通过信号可以决定调用哪个槽函数。我们可以拿生活中的红绿灯来类比信号和槽机制:red−>stop()red->stop()red−>stop()green−>go()green->go()green−>go()图片来源信号和槽只有在连接后才可以起作用:红绿灯的例子:traffic原创 2020-05-10 12:24:54 · 254 阅读 · 1 评论 -
【PyQt5】{6} —— QGridLayout网格布局
QGridLayoutQGridLayout类将部件布置在网格中。user_label: (0, 0),第1行第1列user_line: (0, 1),第1行第2列pwd_label: (1, 0),第2行第1列pwd_line: (1, 1),第2行第2列# -*- coding: utf-8 -*-"""Created on Sat May 9 09:08:54 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets imp原创 2020-05-10 10:31:04 · 944 阅读 · 1 评论 -
【PyQt5】{5} —— QFormLayout表单布局
QFormLayout类QFormLayout类以表单布局的形式管理输入窗口部件及其相关标签的形式。# -*- coding: utf-8 -*-"""Created on Sat May 9 08:47:57 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QFormLayoutclass Simple_Window(QWidg原创 2020-05-10 08:45:50 · 811 阅读 · 1 评论 -
【PyQt5】{4} —— 嵌套布局
嵌套布局布局管理器除了可以添加控件,还可以添加子布局。通常嵌套布局有以下两种方式:# -*- coding: utf-8 -*-"""Created on Fri May 8 23:56:28 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout, QHBoxLayout, QLineEditclass Simple_Wind原创 2020-05-09 15:14:43 · 929 阅读 · 1 评论 -
【PyQt5】{3} —— QVBoxLayout 和 QHBoxLayout 垂直和水平布局
QVBoxLayoutQVBoxLayoutQVBoxLayout 和 QHBoxLayoutQHBoxLayoutQHBoxLayout 分别是垂直和水平布局管理器QVBoxLayoutQVBoxLayout类垂直排列部件。# -*- coding: utf-8 -*-"""Created on Fri May 8 23:20:44 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QW原创 2020-05-09 14:31:51 · 995 阅读 · 1 评论 -
【PyQt5】{2} —— 使用move方法进行布局管理
PyQt5 中的坐标体系:图片来源向右为 xxx 轴正方向,向下为 yyy 轴正方向。使用 move(x,y)move(x, y)move(x,y) 可以对窗口进行布局。# -*- coding: utf-8 -*-"""Created on Fri May 8 23:03:21 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton原创 2020-05-09 12:03:02 · 4428 阅读 · 1 评论 -
【PyQt5】{1} —— 把代码封装成类
# -*- coding: utf-8 -*-"""Created on Fri May 8 22:30:19 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButtonclass Simple_Window(QWidget): def __init__(self): super(Simple_Window, self)原创 2020-05-09 11:03:21 · 509 阅读 · 1 评论 -
【PyQt5】{0} —— QLabel 和 QPushButton
QLabel在 PyQt 中,QLabel 部件提供文本或图像显示:# -*- coding: utf-8 -*-"""Created on Fri May 8 21:52:56 2020@author: Giyn"""import sysfrom PyQt5.QtWidgets import QApplication, QLabelif __name__ == "__main__": app = QApplication(sys.argv) # 实例化一个QApplic原创 2020-05-09 08:45:11 · 624 阅读 · 1 评论