我使用cx_freeze(我正在使用Gui2Exe创建并运行cx_freeze脚本)以及使用python解释器运行它时,我的应用程序看起来有所不同。
[因为我不允许发布图片,这里是UI的链接,编辑?]
脚本运行:
Application as run from the command line
冻结运行
Application as run after being frozen by cx_freeze
我已尝试在cx_freeze脚本中包含但不包括清单文件,但我不确定是什么原因导致应用程序UI发生如此剧烈的变化。
以下是cx_freeze脚本:
# ======================================================== #
# File automagically generated by GUI2Exe version 0.5.3
# Copyright: (c) 2007-2012 Andrea Gavana
# ======================================================== #
# Let's start with some default (for me) imports...
from cx_Freeze import setup, Executable
# Process the includes, excludes and packages first
includes = ['ast', 'gobject', 'gtk']
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = ['BeautifulSoup', 'mechanize', 'pygtk']
path = []
# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.
# No custom code added
# The setup for cx_Freeze is different from py2exe. Here I am going to
# use the Python class Executable from cx_Freeze
GUI2Exe_Target_1 = Executable(
# what to build
script = "moodle-downloader.py",
initScript = None,
base = 'Win32GUI',
targetDir = r"md",
targetName = "moodle-downloader.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = True,
appendScriptToLibrary = True,
icon = r"C:\Users\Nasser.Al-Hilal\Dropbox\CodeN\Projects\Applications\Personal\MoodleDownloader\res\md.ico"
)
# That's serious now: we have all (or almost all) the options cx_Freeze
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.
setup(
version = "0.3",
description = "An app to assist in downloading assignment submissions from Moodle LMS.",
author = "Nasser Al-Hilal",
name = "Moodle Downloader",
options = {"build_exe": {"includes": includes,
"excludes": excludes,
"packages": packages,
"path": path
}
},
executables = [GUI2Exe_Target_1]
)
# This is a place where any post-compile code may go.
# You can add as much code as you want, which can be used, for example,
# to clean up your folders or to do some particular post-compilation
# actions.
# No post-compilation code added
# And we are done. That's a setup script :-D
如果我能让应用程序看起来与从解释器运行时看起来一样,我更愿意。
答案 0 :(得分:2)
为了您的工作,您必须下载gtkruntime,将其安装在您的系统上,然后复制lib文件夹并共享您生成的构建文件夹,然后复制bin文件夹的内容gtkruntime您的构建文件夹,然后您就可以了。 / p>
答案 1 :(得分:0)
我的安装:
cx-freeze compile命令:
\Py279\Scripts\cxfreeze MyGUIapp.py --target-dir somewheredir --base-name=Win32GUI
(实际上,所有完成都没有任何设置命令文件,尽管可以创建一些:))
一旦cx-freeze编译为exe并复制dll它认为需要我得到motif / x11外观/感觉然而,当我从somewheredir
添加所有.dll文件时:
\Py279\Lib\site-packages\gtk-2.0\runtime\lib\gtk-2.0\2.10.0\engines\
为:
somewheredir\lib\gtk-2.0\2.10.0\engines\
我看到了窗户的感觉。
在我的案例中找到的文件是:
全部。
加:
通过在用户的主文件夹.gtkrc-2.0
中创建c:\Users\myuser
,可以实现一些进一步的设计自定义影响。即可以影响使用的默认字体和大小,窗口背景颜色等。例如,以下代码(来自其他地方的提示)
style "win32-font" {
# make default font larger
font_name = "Sans 12"
# set the background to a light grey
bg[NORMAL] = "#f6f6f6"
}
class "*" style "win32-font"
放置在c:\Users\myuser\.gtkrc-2.0
中的将更改默认值'字体大小和更改用户运行的pygtk应用程序的顶部窗口背景(意味着每个用户可以在那里设置自己的首选项)。
答案 2 :(得分:0)
这只是Blasito答案的翻译:
“为了使其正常工作,首先在您的计算机上下载并安装GTK-runtime。然后导航到GTK-runtime安装文件夹(在Program Files中)并复制lib并将文件夹共享到生成的build文件夹。 ,将bin文件夹的内容(在安装目录中)复制到build文件夹中。“
我可以验证这是否有效。