pyqt5
coding上下求索
学无止境,吾将上下而求索!
QQ:743701947 欢迎一起交流学习
The greater the ability, the greater the responsibility.
展开
-
pyqt5 嵌入web
from PyQt5.QtWidgets import QWidget, QApplication, QGridLayoutfrom PyQt5.QtWebEngineWidgets import QWebEngineViewimport sysclass Demo(QWidget): def __init__(self): super(Demo, self).__init()__ self.resize(800, 600) self.s.原创 2021-12-01 11:51:26 · 8440 阅读 · 0 评论 -
pyqt5中,设置图标不生效问题
解决:1、在主程序代码页最上面加上import ctypesctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")2、在调用UI的类里面加上self.setWindowIcon(QIcon("不喜欢香菜.ico"))原创 2021-10-23 16:36:52 · 8970 阅读 · 0 评论 -
pyqt5生成托盘时去掉任务栏显示
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool | Qt.WindowStaysOnTopHint )原创 2020-11-27 17:05:57 · 8263 阅读 · 0 评论 -
PyQt5小应用之检测中文字数
# -*- coding: utf-8 -*-'''Author: LQDQQ: 743701947Date: 2020/06/20'''from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QTextEdit, QLineEdit, QLabelfrom PyQt5.QtGui import QFontfrom PyQt5.QtCore import pyqtSignal, QThreadimport s.原创 2020-06-20 08:53:58 · 7841 阅读 · 0 评论 -
PyQt5中实现标题栏中放大按钮禁用并显示出来(缩小按钮和关闭按钮正常,可以拉伸界面大小)
self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint)其中Qt是通过PyQt5.QtCore导入。效果如下:原创 2020-04-22 01:01:43 · 8959 阅读 · 0 评论 -
PyQt5中QPropertyAnimation的应用
# -*- coding: utf-8 -*-from PyQt5.Qt import *import sysimport timeimport numpy as npclass BallCartoon(QMainWindow): n = 0 flag = 0 ani_w = None def __init__(self): su...原创 2020-03-31 20:28:50 · 9695 阅读 · 4 评论 -
python之pygame制作音乐盒(多张图片多首音乐)
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2程序:# -*- coding: utf-8 -*-'''pygame制作音乐盒'''import sys# import timeimport pygamedef ps_bt20(): # 开启音乐盒 ''' 此函数可以打开音乐盒,音乐盒是用pygame这个包完成...原创 2018-07-21 11:55:35 · 8725 阅读 · 0 评论 -
python+pygame制作音乐盒
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2在打包发布的时候要注意,需要把相关图片和音乐放在和.exe文件相同的目录下。import sysimport pygame# pygame.init()pygame.mixer.init()print("播放音乐1")path = r"**.mp3"path1 = r"**.jpg"s...原创 2018-07-19 21:43:08 · 8062 阅读 · 0 评论 -
python程序打包发布方法整理
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2 写在前面的话,在开始打包之前,要创建一个新的文件夹,这个文件夹是你放.exe的地方,然后,把你的.py程序和程序里面用到的所有你创建的东西都拷贝到这个新建的文件夹里面。同时,里面关于文件路径的地方,都要改成当前路径。如果只是单一的python程序,打包发布***.exe的步骤如下:1.p...原创 2018-07-19 13:42:17 · 16939 阅读 · 2 评论 -
PyQt5+Qt designer实战
PyQt5+Qt designer 制作计算器配置说明:Anaconda 4.2.0 (64-bit)Python 3.5.2首先,在Qt designer里面设计界面:打开 Qt designer后,设计界面如下所示:保存为clat.ui。然后将其转为py文件:之后会生产clat.py文件。打开后,代码如下:# -*- coding: utf-8...原创 2018-07-13 17:36:20 · 83309 阅读 · 23 评论 -
运用Pyqt5实现简易时钟
小练手:直接上程序,比较简单,没做过多的美化。# -*- coding: utf-8 -*-from PyQt5.QtWidgets import QApplication, QWidget, QLCDNumber, QDesktopWidget, QVBoxLayoutfrom PyQt5.QtGui import *from PyQt5.QtCore import *impor...原创 2018-07-03 19:32:27 · 5258 阅读 · 0 评论 -
pyqt5版本灭霸响指
灵感来自github上的一个作品,链接在这里。它的作者是仿照的这个github项目,链接在这里。然后这两个作品都是网页版本的,我就想用pyqt5去实现一下,挺有意思的。点击链接获取代码。...原创 2019-05-06 09:37:06 · 8529 阅读 · 0 评论 -
pyqt5中QTabWidget的相关操作
首先,下面贴上designer处理的界面文件(转换成py后的):# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'TabWidget.ui'## Created by: PyQt5 UI code generator 5.12.1## WARNING! All changes ...原创 2019-05-06 19:25:08 · 13327 阅读 · 2 评论 -
pyqt5与matplotlib完美结合
具体用到了matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg直接上代码(这里给出的只是一个简单的框架,告诉你怎么去写):# -*- coding: utf-8 -*-'''TODO:LQD'''import sysimport numpy as npimport matplotlib.pyplot as pltfrom ...原创 2019-05-09 18:06:35 · 14696 阅读 · 2 评论 -
pyqt5中QThread在使用时出现重复emit
在PyQt5中使用QThread的时候,要注意把所有QThread的对象在主类中的init(或者放在所有类函数的外面)中进行实例化,不然可能在多个QThread互相调用的时候,emit重复的信号。一般比较正确的写法如下所示,基本照着这种框架搭建都是没问题的。# -*- coding: utf-8 -*-import sysimport timefrom PyQt5.QtWidgets...原创 2019-05-29 21:33:15 · 8823 阅读 · 0 评论 -
designer使用中布局的诀窍
在使用designer设计界面时,当你想要控件随着窗口大小的改变而改变,这时候需要对整个界面进行布局,以栅格布局为例:1、点击界面中的空白地方,然后点击红色圈出来的地方,这样就完成了基本的全窗口布局。2、这时候,可能控件的形状和位置会发生很大的变化,不要慌,分两步走,首先是位置,在窗口里面,可以随意拖动控件,将其摆放在适合的位置。然后是位置,这时候将控件拉大缩小的操作往往...原创 2019-05-29 22:02:02 · 7705 阅读 · 0 评论 -
关于pyqt5中界面背景的问题
插入背景的方式有两种:1、用qt designer。在里面对样式表进行修改。2、在类里面重写resizeEvent函数。代码如下:def resizeEvent(self, event): # TODO:调整背景图片自适应界面大小 palette = QPalette() pix = QPixmap('resources/background.jpg') ...原创 2019-06-22 16:19:21 · 6777 阅读 · 0 评论 -
PyQt5实现多窗口切换的框架
直接上程序,一看就懂,看了就会写。# -*- coding: utf-8 -*-'''多窗口反复切换,只用PyQt5实现'''import sysfrom PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QPushButtonclass FirstUi(QMainWindo...原创 2018-12-25 19:57:46 · 31779 阅读 · 11 评论 -
python中pygame循环播放3首音乐和3张图片
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2程序:import sysimport pygamepygame.init()pygame.mixer.init()print("播放音乐")path = r"jj.mp3"path1 = r"tu1.jpg"path2 = r"ts.mp3"path3 = r"tu2.jpg"...原创 2018-07-22 22:21:40 · 13505 阅读 · 5 评论 -
python+pyqt5+qt designer小程序
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2qt designer设计界面如下:转换成py文件后,csz.py程序如下:# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'csz.ui'## Created by: PyQt5 U...原创 2018-07-23 14:56:33 · 14351 阅读 · 16 评论 -
python之绘图小软件
我在用tensorflow进行训练数据的时候,因为种种原因,服务器上matplotlib这个包用不了,于是乎,我就得把训练批次和训练精度保存到txt形式的文件里面,然后拿到电脑上绘图。这样来来回回就比较麻烦,于是乎,我就写了个绘图小软件,直接放入txt文件的路径,就可以绘制曲线图了。具体数据格式如下,截取其中前几个:1 acc 0.22 acc 0.054 acc 0.3...原创 2018-10-16 09:55:44 · 10066 阅读 · 0 评论 -
pyqt5在QMainWindow中布局的问题
引言:在pyqt5中使用了父类为QMainWindow的话,在里面使用布局类,QGridLayout,QHBoxLayout ,QVBoxLayout 时,发现不好用。解决:如果是在以QWidget为父类的自定义类中使用这三个布局类的话,是很好用的,但是在QMainWindow中使用的时候要多写几句话。具体如下所示:widget = QWidget()widget.setLa...原创 2018-12-16 17:14:30 · 8796 阅读 · 0 评论 -
pyqt5中QToolButton无法使用的解决
当你使用pyqt中的QToolButton的时候,如果想实现按下和抬起分别实现不同的功能,必须要加上这句话:self.btn_1.setCheckable(True)设置一个toolbutton的基础代码为: self.btn_1 = QToolButton(self) self.btn_1.setText('start') self.btn_1.setCheckable(Tr...原创 2018-12-16 19:58:52 · 8686 阅读 · 0 评论 -
pyqt5中QLineEdit里面的内容回车发送的方法
在PyQt5中QLineEdit里面的内容回车发送的方法是和PyQt4中不同的,主要是信号槽的写法的改变导致的。具体不同如下:在PyQt4中,我们要进行回车发送的时候,一般这么写: self.connect(self.lineEdit, SIGNAL("returnPressed()"), self.lineEdit_function)但是在PyQt5中,写法有所改变,一般这么写...原创 2018-12-23 15:00:37 · 18473 阅读 · 0 评论 -
pyqt5多线程正确的开启姿势
# -*- coding: utf-8 -*-import sysfrom PyQt5.QtCore import QThread, pyqtSignalfrom PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QMessageBox, \ QPushButton, QLineEdit, QLabel, QTo...原创 2019-01-07 20:24:20 · 13661 阅读 · 6 评论 -
PyQt5关于QThread的小demo看完就会
# -*- coding: utf-8 -*-'''PyQt5关于QThread的使用小demo'''import sysimport timeimport numpy as npimport matplotlib.pyplot as pltfrom PyQt5.QtCore import QThread, pyqtSignalfrom module import csialg...原创 2019-01-10 15:13:20 · 9890 阅读 · 0 评论 -
pyqt5 QProgressBar清空进度条
在停止和开始进度条的同时,将进度条清空的动作也是常常需要用到的。具体用法如下:self.progressBar = QProgressBar(self)self.progressBar.reset()原创 2019-02-21 17:54:14 · 9241 阅读 · 0 评论 -
pyinstaller打包发布后的exe文件打开控制台闪退解决
解决步骤:1、先打开一个cmd2、cd到你的exe文件目录3、输入 .\***.exe原创 2019-04-10 15:38:07 · 12034 阅读 · 0 评论 -
pyqt5之将textBrowser的内容写入txt文档
try: StrText = self.textBrowser.toPlainText() qS = str(StrText) f = open('/***/test.txt', 'w') print(f.write('{}'.format(qS))) f.cl...原创 2018-10-01 11:10:52 · 16639 阅读 · 2 评论 -
pyqt5之控件大乱斗
# -*- coding: utf-8 -*-import sysimport timefrom PyQt5.QtWidgets import QApplication, QPushButton, QLabel, QWidget, QMainWindow, QLineEdit, QMessageBox,\ QTextEditfro...原创 2018-09-26 16:38:58 · 7938 阅读 · 0 评论 -
python之当你发现QTimer不能用时。。。
# -*- coding: utf-8 -*-import numpy as npfrom PyQt5.QtCore import QTimer, QObjectfrom PyQt5.QtWidgets import QWidget, QApplicationimport sysimport timeclass my_timer(QWidget): def __init...原创 2018-09-19 22:53:47 · 9003 阅读 · 0 评论 -
python之小软件的多种功能记录
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2程序:import sysfrom PyQt5.QtGui import QMoviefrom PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QMessageBox, QDialogfrom PyQt5.QtC...原创 2018-07-29 21:04:57 · 7695 阅读 · 0 评论 -
随笔2
相关配置:Anaconda 4.2.0 (64-bit)Python 3.5.2程序:from PyQt5.QtCore import *from PyQt5.QtWidgets import *from PyQt5.QtGui import *import sysclass WorkThread(QThread): trigger = pyqtSignal()...原创 2018-07-30 22:48:37 · 7619 阅读 · 0 评论 -
python之multiprocessing.Process()的用法
# -*- coding: utf-8 -*-'''multiprocessing.Process()例程'''from PyQt5.QtWidgets import QWidget, QPushButton, QMessageBox, QApplicationimport numpy as npimport matplotlib.pyplot as pltimport time...原创 2018-09-11 13:06:02 · 10329 阅读 · 0 评论 -
python之pyqt5通过按钮改变Label的背景颜色
首先是界面的布置,代码如下所示,使用的是Designer。# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'untitled.ui'## Created by: PyQt5 UI code generator 5.6## WARNING! All changes made in...原创 2018-09-14 15:47:57 · 17848 阅读 · 1 评论 -
qt designer 里面的布局问题记录
在用pyqt5进行操作的时候,用到了qt designer来进行界面的制作。当所有的控件都设定好了后,对每个控件进行了单独的布局操作,但是,当程序运行了之后发现界面不会随着窗口的拉伸而改变,当窗口放到很大的时候,界面的位置就发生了偏移,不在中间的位置。 这时候,使用qt designer里面的弹簧可以解决这个问题。如上图所示,运用这两个弹簧控件可以将界面控制在...原创 2018-09-14 22:27:37 · 10289 阅读 · 0 评论 -
python之关于QTimer.singleShot()的应用记录
# -*- coding: utf-8 -*-'''关于QTimer.singleShot()的应用记录'''import timeimport numpy as npimport matplotlib.pyplot as pltimport winsoundimport sysimport sklearnfrom PyQt5.QtWidgets import QApplic...原创 2018-09-15 18:36:20 · 12569 阅读 · 0 评论 -
python之pyqt5+QProgressBar+statusBar+toolBar+toolButton的结合运用
# -*- coding:utf-8 -*-'''pyqt5加QProgressBar加statusBar加toolBar加toolButton'''from PyQt5.QtWidgets import QApplication, QWidget, QToolButton, QMainWindow, QProgressBarfrom PyQt5.QtCore import Qtim...原创 2018-09-17 13:15:03 · 9634 阅读 · 0 评论 -
python之把animation的动态图嵌入pyqt5的界面中
# -*- coding: utf-8 -*-'''python技巧之把animation的动态图嵌入pyqt5的界面中'''import sysimport numpy as npfrom PyQt5 import QtWidgets, QtCorefrom PyQt5.QtWidgets import QApplication, QMainWindow, QMenu, QV...原创 2018-09-18 21:33:30 · 10680 阅读 · 0 评论 -
pyqt5移动鼠标显示坐标
# -*- coding: utf-8 -*-import sysfrom PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel)from PyQt5.QtCore import Qtclass AppDemo(QMainWindow): def __init__(self): super(Ap...原创 2019-04-11 11:02:52 · 16083 阅读 · 3 评论