seanwu1105 / vscode-qt-for-python

Qt for Python (PySide and PyQt) extension for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=seanwu.vscode-qt-for-python
MIT License
186 stars 15 forks source link

是否可以自行指定交给 pyuic.exe 的 .ui 文件名? #291

Closed hrpzcf closed 1 year ago

hrpzcf commented 1 year ago

因为我只给 pyuic.exe 传一个 .ui 文件名而不是完整路径,这样生成的 py 文件注释中就不会有我的 ui 文件完整路径,如图: 2023-03-21_160737

当我把 uic 的 option 设置为此值时: "qtForPython.uic.options": [ "-o", "${resourceDirname}${pathSeparator}${resourceBasenameNoExtension}.py", "${fileBasename}", ], 得到的报错信息是: C:/Python37/Scripts/pyuic5.exe -o f:\Python\xxx\ui\cloud_function.py cloud_function.ui f:\Python\xxx\ui\cloud_function.ui Error: one input ui-file must be specified 显然插件自行追加了一个命令:f:\Python\xxx\ui\cloud_function.ui

如果可以把当前右击的 .ui 文件所在目录(或右击的目录)作为 pyuic.exe 工作目录, 并且交给 pyuic5.exe 的是 .ui 文件名而不是完整路径,那么生成的 .py 文件头部注释中将不会显示我的 .ui 文件的完整路径

seanwu1105 commented 1 year ago

I see your point. This behavior could be changed in the next release. I think the extension will still append the target filename to the command but using the base name with extension only without the full absolute path for compatibility.

seanwu1105 commented 1 year ago

I decide to drop this feature as it is a special behavior only with PyQt5, and it can be nasty to patch the behavior in extension. I suggest you use PySide6, which does not put the absolute path into generated file comments.