小编Jar*_*ear的帖子

Python 将 DXF 文件转换为 PDF、PNG 或 JPEG

有谁知道将 DXF 文件转换为 PNG 或 PDF 的方法吗?

我有一个巨大的 DXF 文件列表,我想将它们转换为图像以便更快地查看它们。

如果可能的话,如何提取 DXF 文件值,例如 DXF 文件中绘图的厚度或尺寸。

python pdf png jpeg dxf

5
推荐指数
1
解决办法
9635
查看次数

FileNotFoundError: [Errno 2] 没有这样的文件或目录:'tinycss2\\VERSION'

完整的错误是:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\grossj\\AppData\\Local\\Temp\\_MEI143642\\tinycss2\\VERSION'
[21148] Failed to execute script main
Run Code Online (Sandbox Code Playgroud)

完整的错误日志是:

Traceback (most recent call last):
  File "main.py", line 11, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\users\grossj\desktop\dxf-to-png-converter-master\dxf2png\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 489, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\svglib\svglib.py", line 42, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", …
Run Code Online (Sandbox Code Playgroud)

python import filenotfoundexception pyqt5 tinycss

5
推荐指数
1
解决办法
929
查看次数

当我下载视频时,Python如何从youtube-dl获取下载百分比

我想获取python的youtube-dl模块的下载百分比,原因是我想将其放入pyqt5中的进度条中。我在 youtube-dl 的 GitHub 或其他任何地方都没有找到相关文档,有人知道吗?

我在 google/stackoverflow/GitHub 上没有找到任何成功的答案。

def downloadYoutube(self):
        self.changeText()
        # try:
        self.lblState.setText('Downloading...')

        url = self.txtURL.text()
        if 'https://www.youtube.com/watch?' not in url:
            buttonReply = QMessageBox.critical(self, 'Error! :(', "{} is an invalid URL".format(url), QMessageBox.Ok, QMessageBox.Ok)
            return
        # if 'https://youtu.be/' not in url:
        #     buttonReply = QMessageBox.critical(self, 'Error! :(', "{} is an invalid URL".format(url), QMessageBox.Ok, QMessageBox.Ok)
        #     return
        if self.radAudio.isChecked() == True:
            ydl_opts = {
                'format': 'bestaudio/best',
                'extractaudio': True,
                'audioformat': "mp3",
                'noplaylist': True,
            }
        else:
            ydl_opts = {
                'noplaylist': True,
            }
        info_dict …
Run Code Online (Sandbox Code Playgroud)

python youtube youtube-dl

2
推荐指数
1
解决办法
7108
查看次数

python pyqt5 将文件名添加到 getSaveFileName

QFileDialog()我正在尝试为下面的图像添加默认名称。

这就是我得到的(没有文件名)

我得到什么

这就是我想要实现的目标,而无需手动输入它,我想传递file_name抛出的函数并让该名称显示在那里。 在此输入图像描述

这是我试图使其工作的代码:

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import *
import sys
class mainwindowUI(QMainWindow):
    def __init__(self):
        super(mainwindowUI, self).__init__()
        self.exportFiles('test.mp3')
    def exportFiles(self,file_name):
        filename, _ = QFileDialog.getSaveFileName(self, "Save audio file", "", "Audio Files (*.mp3)")
        if filename:
            print(filename)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = mainwindowUI()
    app.exec_()
Run Code Online (Sandbox Code Playgroud)

我尝试添加选项:

filename, _ = QFileDialog.getSaveFileName(self, "Save audio file", "", "Audio Files (*.mp3)", options=QFileDialog.setLabelText(file_name))
Run Code Online (Sandbox Code Playgroud)

但这是不正确的,我不知道如何让它发挥作用......

有人知道如何在保存文件对话框中添加文件名吗?

python qfiledialog pyqt5

2
推荐指数
1
解决办法
7628
查看次数

如何动态调整QGridLayout的大小和移动到1/4s

这是我当前的窗口布局,我希望将其分成 1/4,而不是 1/2。

在此输入图像描述

这就是我希望我的窗口看起来的样子,但我似乎找不到一种很好的方法来将其大小调整QGridLayout为我想要的方式,而且这种方式setColumnStretch仍然让我感到困惑,我不完全理解它是如何工作的。

在此输入图像描述

这是我的窗口布局代码:

self.pathRoot = QDir.rootPath()
self.labelFileName = QLabel(self)
self.labelFileName.setText("Search:")
self.labelFileName.resize(100, 30)
self.txtSearch = QLineEdit(self)
self.txtSearch.textChanged.connect(self.on_textChanged)
self.btnBack = QPushButton('Back', self)
self.btnBack.clicked.connect(self.back)
self.model = QFileSystemModel()
self.model.setRootPath(QDir.rootPath())
self.model.setFilter(QDir.NoDotAndDotDot | QDir.AllEntries | QDir.Dirs | QDir.Files)
self.proxy_model = QSortFilterProxyModel(recursiveFilteringEnabled = True, filterRole = QFileSystemModel.FileNameRole)
self.proxy_model.setSourceModel(self.model)
self.model.setReadOnly(False)
self.model.setNameFilterDisables(False)
self.indexRoot = self.model.index(self.model.rootPath())
self.treeView = QTreeView(self)
self.treeView.setModel(self.proxy_model)
self.adjust_root_index()
self.treeView.setRootIndex(self.indexRoot)
self.treeView.clicked.connect(self.on_treeView_clicked)
self.treeView.doubleClicked.connect(self.treeMedia_doubleClicked)
self.treeView.setAnimated(True)
self.treeView.setIndentation(20)
self.treeView.setSortingEnabled(True)
self.treeView.setDragEnabled(False)
self.treeView.setAcceptDrops(False)
self.treeView.setDropIndicatorShown(True)
self.treeView.setEditTriggers(QTreeView.NoEditTriggers)
self.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
self.treeView.customContextMenuRequested.connect(self.showContextMenu)
for i in range(1, self.treeView.model().columnCount()):
    self.treeView.header().hideSection(i)
self.gridLayout = QGridLayout()
self.gridLayout.addWidget(self.labelFileName, 0, …
Run Code Online (Sandbox Code Playgroud)

python pyqt qgridlayout pyqt5 qlayout

1
推荐指数
1
解决办法
1317
查看次数