2

在我使用 cx_freeze 冻结它(我正在使用 Gui2Exe 创建和运行 cx_freeze 脚本)以及使用 python 解释器运行它时,我的应用程序看起来不同了。

[因为我不允许发布图像,这里是 UI 的链接,编辑?]

脚本运行:

从命令行运行的应用程序

冻结运行:

应用程序在被 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

如果我能让应用程序看起来与从解释器运行时相同,我会更喜欢。

4

3 回答 3

2

为了让您工作,您必须下载 gtkruntime,将其安装在您的系统上,然后复制 lib 文件夹并共享您生成的构建文件夹,然后将 bin 文件夹 gtkruntime 的内容复制到您的构建文件夹,然后您就可以工作了。

于 2013-10-12T20:52:57.173 回答
0

我的安装:

  • Windows 7的
  • Python 2.7.9
  • GTK2 (python -m pip install pygtk)
    • pycairo (1.8.10) pygobject (2.28.3) pygoocanvas (0.14.2) pygtk (2.24.0) pygtksourceview (2.10.1)
  • cx-Freeze (python -m pip install cx-Freeze)
    • cx-冻结 (4.3.4)

cx-freeze 编译命令:

 \Py279\Scripts\cxfreeze  MyGUIapp.py --target-dir somewheredir --base-name=Win32GUI

(本质上,所有这些都无需任何设置命令文件即可完成,尽管可以创建一些 :))

一旦 cx-freeze 编译为 exe 并复制它认为需要的 dll,我会得到主题/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\

我得到窗户的外观和感觉。

在我的案例中找到的文件是:

  • libpixmap.dll
  • libsvg.dll
  • libwimp.dll

就这样。

加:

.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 应用程序的顶部窗口背景(这意味着每个用户都可以在那里设置自己的首选项)。

于 2015-06-10T12:26:51.483 回答
0

这只是 Blasito 答案的翻译:

“为了使其正常工作,首先在您的计算机上下载并安装 GTK-runtime。然后导航到 GTK-runtime 安装文件夹(在 Program Files 中)并将 lib 和共享文件夹复制到生成的构建文件夹。最后,复制将 bin 文件夹(在安装目录中)的内容放入 build 文件夹中。”

我可以验证这是否有效。

于 2017-08-31T05:17:03.597 回答