为 GUI 开发设置 PySide/Qt [英] Setting up PySide/Qt for GUI development

查看:57
本文介绍了为 GUI 开发设置 PySide/Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试设置 PySide/Qt 以与 Python3.3 一起使用.我已经安装

I have been trying to setup PySide/Qt for use with Python3.3. I have installed

PySide-1.2.0.win32-py3.3.exe 

我从here获取的,我已经安装了

that I took from here and I have installed

qt-win-opensource-4.8.5-vs2010

我取自这里.

我使用 pyside-uic.exe .ui 文件(我使用 QtDesigner 创建)生成了 .py 文件"http://qt-project.org/wiki/QtCreator_and_PySide" rel="nofollow">如 PySide Wiki 中所述.

I generated .py files from .ui files (that I made using QtDesigner) using pyside-uic.exe as is explained in PySide Wiki.

制作 .py 文件是有效的.当我发现我需要使用 Qt4.8 如 Qt-forums 上的解释时,我停止使用它.使用 Qt4.8 它不起作用.

Making .py files was working when I was using Qt5.1/QtCreator. I stopped using it when I found that I need to use Qt4.8 as explained on Qt-forums. With Qt4.8 it isn't working.

  • 我想使用 PySide 开发 GUI.
  • 我想要一个用于制作骨架 GUI 的拖放界面,所以我使用的是 QtDesigner.
  • 我使用的是 Windows 7

我想使用cx-freeze将开发的GUI打包成.exe文件.

I want to package the GUI developed into .exe files using cx-freeze.

我的问题简而言之
使用 QtDesigner 制作 .ui 的正确工具是什么?如何使用 PySide 将它们转换为 .py 文件以在 Python 中使用?

My problem in short
What are the correct tools to use to make .ui with QtDesigner? How to convert them to .py files for use in Python using PySide?

cx_freeze 可以把我的普通文件转成.exe 可以用来把Qt/PySide 制作的GUI 转成.exe 文件吗?在分发 GUI 的 .exe 的其他计算机上是否需要 Qt 还是它是自包含的?

cx_freeze is able to make my normal files to .exe Can it be used to convert the GUI made by Qt/PySide into .exe files? Would Qt be needed on other computers where the .exe of the GUI is distributed or would it be self-contained?

我用过

cxfreeze testGUI.py  --include-modules=PySide

制作exe及相关文件.一个目录 dist 是用许多文件创建的.运行时什么也没发生.所以我用命令行来找出原因.错误是

to make the exe and related files. A directory dist was created with many files. On running nothing happened. So I used command line to find out the reason. The errors are

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module>
    exec(code, m.__dict__)
  File "testGUI.py", line 12, in <module>
  File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1558, in _find_and_load
  File "C:\Python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1525, in _find_and_load_unlocked
  File "C:\Python33\lib\site-packages\PySide\__init__.py", line 55, in <module>
    _setupQtDirectories()
  File "C:\Python33\lib\site-packages\PySide\__init__.py", line 11, in _setupQtDirectories
    pysideDir = _utils.get_pyside_dir()
  File "C:\Python33\lib\site-packages\PySide\_utils.py", line 87, in get_pyside_dir
    return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__)))
  File "C:\Python33\lib\site-packages\PySide\_utils.py", line 83, in _get_win32_case_sensitive_name
    path = _get_win32_long_name(_get_win32_short_name(s))
  File "C:\Python33\lib\site-packages\PySide\_utils.py", line 58, in _get_win32_short_name
    raise WinError()
FileNotFoundError: [WinError 3] The system cannot find the path specified.

有人知道这个堆栈跟踪是什么意思吗?

Anyone knows what this stacktrace means?

这里有很多win32.但我有 Windows 7 64 位.我使用的是 32 位 Python,并且所有模块都安装了 32 位.这会导致问题吗?我认为它不应该,因为我为简单的 Python 脚本制作的其他 exe 执行得很好.

There is a lot of win32 in here. But I have Windows 7 64-bit. I am using 32-bit Python and all modules were installed 32-bit. Could that cause a problem? I don't think it should as other exe I made for simple Python scripts were executing fine.

推荐答案

关于 FileNotFoundError,几天来我在打包一个 python 3 应用程序时遇到了问题.在 Windows 7 64 位机器上它运行良好.当我在 win7 32bit 上构建它并尝试运行 .exe 文件时,我收到了所有这些文件错误.看到这个帖子后,我检查了pyside的版本.在 win64 上它是 1.1.2 在 win32 上它是 1.2.0我在win32上卸载了pyside 1.2.0,下载安装了1.1.2 win32版本.它现在工作正常.在 1.2.1 发布之前,这可能是一个临时措施.

Regarded FileNotFoundError, I had a problem packaging a python 3 application with this for a few days. On a windows 7 64 bit machine it worked fine. When I built it on win7 32bit and tried to run the .exe file, I got all those file errors. After seeing this thread I checked the versions of pyside. On the win64 it was 1.1.2 on the win32 it was 1.2.0 I uninstalled pyside 1.2.0 on win32 and downloaded and installed the 1.1.2 win32 version. It now works ok. This could be a stop gap measure until 1.2.1 is released.

这篇关于为 GUI 开发设置 PySide/Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆