当前位置: 首页 > news >正文

PyQt6实例_批量下载pdf工具_界面开发

目录

前置:

代码:

视频: 


前置:

1 本系列将以 “PyQt6实例_批量下载pdf工具”开头,放在 【PyQt6实例】 专栏
2 本系列涉及到的PyQt6知识点:
线程池:QThreadPool,QRunnable;
信号与槽:pyqtSignal,pyqtSlot;
界面:QTextEdit,QLabel,QLineText,QPushButton,QMainWindow,QWidget;
布局:QHBoxLayout,QVBoxLayout;
弹框:QFileDialog,QMessageBox。
3 本系列后续会在B站录制视频,到时会在文末贴出链接。本人还是建议先看博文,不懂的再看视频,这样效率高,节约时间。

代码:

from datetime import datetime
from PyQt6.QtCore import (
QSize,Qt
)
from PyQt6.QtWidgets import(
QApplication,
QMainWindow,
QLabel,
QLineEdit,
QPushButton,
QFileDialog,
QTextEdit,
QHBoxLayout,
QVBoxLayout,
QWidget
)

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('PDF Downloader')
        self.setMinimumSize(QSize(600,400))

        label1 = QLabel('存储pdf网址txt文件所在目录:')
        self.txtdir_lineedit = QLineEdit()
        self.choicedir_btn = QPushButton('打开目录')
        self.choicedir_btn.clicked.connect(self.choicedir_btn_clicked)
        label2 = QLabel('设置下载后pdf存储目录:')
        self.savedir_lineedit = QLineEdit()
        self.savedir_btn = QPushButton('设置目录')
        self.savedir_btn.clicked.connect(self.savedir_btn_clicked)

        self.execute_btn = QPushButton('执行')
        self.execute_btn.clicked.connect(self.execute_btn_clicked)
        self.stop_btn = QPushButton('停止')
        self.stop_btn.clicked.connect(self.stop_btn_clicked)

        label3 = QLabel('运行日志:')
        label4 = QLabel('其他信息:')
        self.excutelog_textedit = QTextEdit()
        self.excutelog_textedit.setReadOnly(True)
        self.otherlog_textedit = QTextEdit()
        self.otherlog_textedit.setReadOnly(True)

        layout0 = QHBoxLayout()
        layout0.addWidget(label1)
        layout0.addWidget(self.txtdir_lineedit)
        layout0.addWidget(self.choicedir_btn)

        layout1 = QHBoxLayout()
        layout1.addWidget(label2)
        layout1.addWidget(self.savedir_lineedit)
        layout1.addWidget(self.savedir_btn)

        layout2 = QHBoxLayout()
        layout2.addWidget(self.execute_btn)
        layout2.addWidget(self.stop_btn)

        layout3 = QVBoxLayout()
        layout3.addWidget(label3)
        layout3.addWidget(self.excutelog_textedit)

        layout4 = QVBoxLayout()
        layout4.addWidget(label4)
        layout4.addWidget(self.otherlog_textedit)

        layout5 = QHBoxLayout()
        layout5.addLayout(layout3)
        layout5.addLayout(layout4)

        layout = QVBoxLayout()
        layout.addLayout(layout0)
        layout.addLayout(layout1)
        layout.addLayout(layout2)
        layout.addLayout(layout5)

        widget = QWidget()
        widget.setLayout(layout)

        self.setCentralWidget(widget)
        pass
    def choicedir_btn_clicked(self):
        dir_name = QFileDialog.getExistingDirectory(self,"打开存储pdf网址txt文件所在目录")
        if dir_name:
            self.txtdir_lineedit.setText(dir_name)
        pass
    def savedir_btn_clicked(self):
        dir_name = QFileDialog.getExistingDirectory(self, "指定下载后pdf存储的目录")
        if dir_name:
            self.savedir_lineedit.setText(dir_name)
        pass
    def execute_btn_clicked(self):
        pass
    def stop_btn_clicked(self):
        pass
    def insert_executelog(self,msg:str):
        pre_str = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} {msg}"
        self.excutelog_textedit.append(pre_str)
        pass
    def insert_otherlog(self,msg:str):
        pre_str = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} {msg}"
        self.otherlog_textedit.append(pre_str)
        pass
    pass

if __name__ == '__main__':
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec()
    pass

视频: 

https://www.bilibili.com/video/BV1V2ZcYCE6N/
https://www.bilibili.com/video/BV1V2ZcYCELF/

http://www.dtcms.com/a/99431.html

相关文章:

  • MDK中结构体的对齐、位域、配合联合体等用法说明
  • C#:第一性原理拆解属性(property)
  • 分享一个Pyside6实现web数据展示界面的效果图
  • Springboot学习笔记3.20
  • SmolDocling文档处理模型介绍
  • Python 循环全解析:从语法到实战的进阶之路
  • 人工智能之数学基础:矩阵的相似变换的本质是什么?
  • DeepSeek网络拓扑设计解密:如何支撑千卡级AI训练的高效通信?
  • 缓存 vs 分布式锁:高并发场景下的并发控制之道
  • 【C++】类和对象(二)默认成员函数之拷贝构造函数、运算符重载、赋值运算符重载
  • <tauri><rust><GUI>基于rust和tauri,实现一个大寰电爪PGHL(串口设备)定制化控制程序
  • java pom文件加入这个可以将打包好的jar 双击运行
  • 积分赛——光敏控制多功系统设计
  • 区块链赋能,为木材货场 “智” 造未来
  • vue在线录音系统
  • Redis延时队列在订单超时未报到场景的应用补充说明
  • 利用 VSCode 配置提升 vibe coding 开发效率
  • 找python大数据就业,我应该学习Java哪些知识
  • dav_pg8_vacuum
  • c#的.Net Framework 的console 项目找不到System.Window.Forms 引用
  • VMware中新建Ubuntu虚拟机系统,并安装Anaconda
  • 1--当「穷举」成为艺术:CTF暴力破解漏洞技术从入门到入刑指南(知识点讲解版)
  • Android Architecture Components 深入解析
  • 【力扣刷题|第十七天】0-1 背包 完全背包
  • Linux进程管理的相关知识点以及我的相关笔记链接
  • 算法为舟 思想为楫:AI时代,创作何为?
  • Redis的ZSet有序集合
  • 深度剖析:U盘突然无法访问的数据拯救之道
  • 27. 移除元素【数组专题】Java\Python\JS\Go\C++
  • IP综合实验