này đã làm việc với một mức độ nào nhưng nó có vấn đề. Chương trình của tôi chạy ở cả chế độ console và chế độ GUI. Khi chạy từ bàn điều khiển với đối số --console
, nó chạy trong chế độ bàn điều khiển. Khi tôi làm theo các thủ tục dưới đây, điều này không làm việc nữa và chương trình của tôi chỉ là một ứng dụng GUI sau đó.
Mã nguồn sau đây đến từ tệp mẫu trong \Python\Lib\site-packages\cx_Freeze\samples\PyQt4\setup.py
. Bài học trong ngày. Đọc README.
# A simple setup script to create an executable using PyQt4. This also
# demonstrates the method for creating a Windows executable that does not have
# an associated console.
#
# PyQt4app.py is a very simple type of PyQt4 application
#
# Run the build process by running the command 'python setup.py build'
#
# If everything works well you should find a subdirectory in the build
# subdirectory that contains the files needed to run the application
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "simple_PyQt4",
version = "0.1",
description = "Sample cx_Freeze PyQt4 script",
executables = [Executable("PyQt4app.py", base = base)])
Nguồn
2010-05-21 12:40:55
Điều này dường như không hoạt động. Tôi đổi tên nó thành PYW nhưng nó vẫn xuất hiện. –