简体   繁体   English

python 2.7上的pygtk.glade“没有名为glade的模块”

[英]pygtk.glade 'no module named glade' on python 2.7

I am using Python 2.7 on windows I want to install a software called febrl on python which requires pygtk.glade I have installed all the modules that were specified in the software manual, especially PYGTK all-in-one but i get an error when i try to import pygtk.glade (i have no error when i do : import pygtk)我在 Windows 上使用 Python 2.7 我想在 python 上安装一个名为 febrl 的软件,它需要 pygtk.glade 我已经安装了软件手册中指定的所有模块,尤其是 PYGTK 一体机,但是当我遇到错误时尝试导入 pygtk.glade(当我这样做时没有错误:导入 pygtk)

import pygtk.glade
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named glade

Is there a way to install glade for python on windows?有没有办法在windows上为python安装glade? Thank you谢谢

Gtk.Builder and friends are already in the Gtk module included. Gtk.Builder 和朋友已经包含在 Gtk 模块中。 So, if you所以,如果你

from gi.repository import Gtk

you have access to the builder.您可以访问构建器。 You do not need Glade inside your python code.你的python代码中不需要Glade。 Glade is an external tool (separate from Python) which generates an XML file (normally called yourproject.ui, yourproject.glade or so), which is the description of the GUI you designed. Glade 是一个外部工具(独立于 Python),它生成一个 XML 文件(通常称为 yourproject.ui、yourproject.glade 左右),它是对你设计的 GUI 的描述。

In your code you then have to make an instance of GtkBuilder, and read the XML file.在您的代码中,您必须创建一个 GtkBuilder 实例,并读取 XML 文件。 This will generate all the widgets and make them available in your program.这将生成所有小部件并使它们在您的程序中可用。

Have a look at this tutorial .看看这个教程

That same XML is also usable in many other languages using a similar process - call GtkBuilder, etc.同样的 XML 也可以使用类似的过程在许多其他语言中使用 - 调用 GtkBuilder 等。

maybe you need to do from pygtk import glade也许你需要做from pygtk import glade

check this for more information: http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm查看更多信息: http : //www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm

在下面运行此命令,它可以解决所有缺少的依赖项:

apt-get install python python-gtk2 python-glade2 libgtk2.0-dev libsqlite3-0

By running pip search glade I get this通过运行pip search glade我得到了这个

BabelGladeExtractor (0.2dev-r288) - Babel Glade XML files translatable strings extractor BabelGladeExtractor (0.2dev-r288) - Babel Glade XML 文件可翻译字符串提取器

BD (0.0.5) - Bangladesh Details with postal code BD (0.0.5) - 带有邮政编码的孟加拉国详细信息

GladeBuilder (0.1.0) - Easy way to get and set values/properties of Gtk2/Gtk3 widgets. GladeBuilder (0.1.0) - 获取和设置 Gtk2/Gtk3 小部件的值/属性的简单方法。

SPE (0.8.3.c) - Python IDE with Blender, Kiki, PyChecker, Remote debugger, Uml and wxGlade support SPE (0.8.3.c) - 带有 Blender、Kiki、PyChecker、远程调试器、Uml 和 wxGlade 支持的 Python IDE

I am pretty sure doing either我很确定这样做

pip install GladeBuilder

of

pip install SPE

will solve it.会解决它。 But then again you are on windows so it really depends.但话又说回来,你在窗户上,所以这真的取决于。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM