使用.move将控件水平移动到特定的位置, 被称为绝对布局 AbsoluteLayout.py """ 绝对布局 """ import sys, math from PyQt5.QtWidgets import * class AbsoluteLayout(QWidget): def __init__(self): super(AbsoluteLayout, self).__init__() self
通过点击按钮, 执行html中的javaScript函数 PyQtCallJS.py """ PyQt5调用JavaScript代码 PyQt5和JavaScript交互 什么叫交互 PyQt5 <-> JavaScript """ import os from PyQt5.QtWidgets import * from PyQt5.QtCore import QTimer, QDateTime from PyQt5.QtG
可以直接将html写在python里面做显示 """ 加载内部的HTML """ import os from PyQt5.QtWidgets import * from PyQt5.QtCore import QTimer, QDateTime from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWebEngineWidgets import * import
构造网页显示器, 在界面上显示对应的网址内容 WebEngineView.py """ 用Web浏览器控件(QWebEngineView)显示网页 PyQt5和Web的交互技术 同时使用Python和Web开发程序, 混合开发 python + JavaScript + HTML5 + CSS QWebEngineView() """ from PyQt5.QtWidgets import * from PyQ
加载本地的html文件 LocalHtml.py """ 加载本地的html页面 """ import os from PyQt5.QtWidgets import * from PyQt5.QtCore import QTimer, QDateTime from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWebEngineWidgets import * im
构造一个悬浮的组件, 然后将主要的组件添加到这个悬浮组件上 DockWidget.py """ 停靠控件(QDockWidget) """ import sys, math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * class DockDemo(QMainWindow): def __init__(self):
主要介绍节点的删除, 节点的添加, 节点的修改 ModifyTree.py """ 添加, 修改和删除树控件中的节点 """ import sys from PyQt5.QtWidgets import * class ModifyTree(QWidget): def __init__(self): super(ModifyTree, self).__init__() self.setWindowT
Hi音乐 两大平台全音乐搜索、收听与下载的简洁网络音乐播放器 源码:Gitee 码云 简介 Hi音乐 是基于 Python 开发的简洁网络音乐播放器。 功能特性 基础功能 集成酷狗音乐、酷我音乐歌曲搜索与下载(未来将会支持更多的平台) 支持歌词同步滚动,进度条控制音乐进度 多种播放模式选
第一步先设置图片的尺寸, 第二步设置表格尺寸的宽和高 CellImageSize.py """ 设置图片的大小 setIconSize(QSize(width, height)) """ import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.Qt import * class CellImageText(QWidget): d
使用QTableWidgetItem(图片, 文字)实现图文并排 CellImageText.py """ 在单元格中实现图文混排的功能 """ import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * class CellImageText(QWidget): def __init__(self): super(CellImageText,
QAbstractScrollArea 一、描述 是一个滚动区域的低级抽象 二、继承 QFrame 三、功能作用 3.1 设置水平和垂直滚动条 3.2 滚动条策略 3.3 角落控件 四、信号 继承父类 测试代码: from PyQt5.Qt import * import sys if __name__ == '__main__': app =QApplication(sys
QFrame详解 一、描述 是一个基类,可以选择直接使用,主要用来控制一些边框样式:凸起,凹下,阴影,线宽 二、继承 QWidget 三、功能作用 3.1 创建QFrame对象 3.2 框架形状 3.3 框架阴影 3.4 框架的几个线宽 3.5 框架样式 3.6 框架矩形 四、信号 继承自父类 测试代码: from PyQt5.Qt
设置控件的样式,然后将控件放入到表格中 """ setCellWidget:将控件放到单元格 setItem: 将文本放到单元格 setStyleSheet: 设置控件的样式(QSS) 在单元格中放置控件 """ from PyQt5 import QtGui, QtWidgets, QtPrintSupport from PyQt5.QtWidgets import QMainWindow from PyQt
PyQt5学习之按钮单击事件信号与槽关联 用到的方法代码中都有标注,直接上代码 代码: import sndhdr import sys from PyQt5.QtWidgets import QHBoxLayout,QApplication,QMainWindow,QWidget,QPushButton class QuitApplication(QMainWindow): def __init__(self): supe
QRadioButton 详解 一、描述 一般用于给用户提供若干选项中的单选操作。 二、继承 QAbstractButton 三、功能作用 import sys from PyQt5.Qt import * if __name__ == '__main__': app = QApplication(sys.argv) window = QWidget() window.setWindowT
设计一个文本编辑框,然后将打印的内容导向到图像编辑器上,通过绘图编辑器对文本编辑框的内容进行打印 """ 使用打印机 """ from PyQt5 import QtGui, QtWidgets, QtPrintSupport from PyQt5.QtWidgets import QMainWindow from PyQt5.QtWidgets import * import sys class PrintS
通过点击菜单栏的按钮,在状态栏显示5秒的文字 """ 创建和使用状态栏 """ import sys, math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * class StatusBar(QMainWindow): def __init__(self): super(StatusBar, sel
PyQt5学习之第一个窗口 用到的方法代码中都有标注,直接上代码 代码: import sys from PyQt5.QtWidgets import QMainWindow,QApplication,QDesktopWidget from PyQt5.QtGui import QIcon #添加图标 class FirstMainWin(QMainWindow): #初始化 def __init__(self,parent=
构造工具栏, 然后根据工具栏绑定事件,同时将文字放在图标的下方 """ 创建和使用工具栏 工具栏默认按钮: 只显示图标, 将文本作为悬停时 工具栏按钮有3种显示状态 1.只显示图标 2.只显示文本 3.只显示图标和文本 """ import sys, math from PyQt5.QtWidgets import * from PyQt
QCommandLinkButton学习记录 一、描述 命令链接是windows vista引入的新控件,它的用途类似于单选按钮的用途,因为它用于在一组互斥选项之间进行选择,命令链接按钮不应单独使用,而应作为向导和对话框中单选按钮的替代选项。外观通常类似于平面按钮的外观,但是除了普通按钮文本之外,
QPushButton详解 一、描述 用来给用户点击,来完成某种动作的控件,一般是矩形,一般作为登录按钮,注册按钮,关闭按钮 二、继承 继承自QAbstractButton 三、功能作用 (1)创建按钮控件 import sys from PyQt5.Qt import * if __name__ == '__main__': app = QApplication(sys.ar
使用menuBar()获取菜单栏, 使用.addMenu("文件")构造单个菜单, 使用.addAction("新建") 进行按钮的添加 下面主要是添加两个菜单栏,作为布局 """ 创建和使用菜单 """ import sys, math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import *
下面使用了4中不同的时间格式来显示不同的时间情况, 如日期和时间的显示等 """ 输入各种风格的日期和时间 QDataTimeEdit """ """ 日历控件 QCalendarWidget """ import sys, math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore
设置日期的最小和最大范围,同时设置点击事件, 将点击的日期显示在label控件上 """ 日历控件 QCalendarWidget """ import sys, math from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * class MyCalendar(QWidget): def __init__(self):
将LineEdit的文本拖拽到下拉框中 """ 让控件支持拖拽动作 A.setDragEnabled(True) 可以进行拖拽 B.setAcceptDrops(True) 可以接收拖拽 B需要两个事件 1. dragEnterEvent 将A拖到B触发 2. dropEvent 在B的区域放下A时触发 """ import sys, math from PyQt5.QtWidgets import