简体   繁体   English

如何在OS X Mavericks上使用Glade正确安装PyGObject

[英]How to properly install PyGObject with Glade on OS X Mavericks

I'm using OS X Mavericks with system Python 2.7. 我正在将OS X Mavericks与系统Python 2.7一起使用。

I installed PyGObject, GTK+ and glade as I descripted below, but Python doesn't see gtk.glade module. 如下面所述,我安装了PyGObject,GTK +和Glade,但是Python没有看到gtk.glade模块。

All libraries from Homebrew: 来自Homebrew的所有库:

brew install libglade
brew install gtk+
brew install pygobject

Also, I set PYTHONPATH in .bash_profile to: 另外,我在.bash_profile中将PYTHONPATH设置为:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages

When I run Python and try import pygtk or gtk - all works fine. 当我运行Python并尝试导入pygtk或gtk时-一切正常。 But when I try to load gtk.glade I get no module error. 但是,当我尝试加载gtk.glade时,没有模块错误。

So I'll try install pygobject with --verbose mode and I noticed, that installer couldn't find libglade: 因此,我将尝试使用--verbose模式安装pygobject,我注意到,该安装程序找不到libglade:

checking for LIBGLADE... no
…
The following modules will be built:
atk
pango
pangocairo
gtk with 2.24 API
gtk.unixprint

The following modules will NOT be built:

gtk.glade

I assumed that pygobject installer can't find path to libglade (which is installed to /usr/local/Cellar/libglade/2.6.4). 我假设pygobject安装程序找不到libglade的路径(已安装到/usr/local/Cellar/libglade/2.6.4)。

How and what path should I change? 我应该如何以及改变什么路径? Or what else to do? 还是要做什么?

Thanks in advance! 提前致谢!

I had exactly the same problem and the following DID NOT work: 我遇到了完全相同的问题,以下DID无法正常工作:

brew install --verbose --glade pygtk

But the following DID work on Mavericks with Python 2.7: 但是以下DID可在具有Python 2.7的Mavericks上运行:

brew install --verbose --with-libglade pygtk

See also this discussion 另请参阅此讨论

PyGObject support for Gtk+2 is rater limited as Gtk+2 wasn't created with full Introspection support. 对Gtk + 2的PyGObject支持受到等级限制,因为Gtk + 2并非完全由自省支持创建的。

If you're using PyGobject don't use PyGtk, they are different things. 如果您使用的是PyGobject,请不要使用PyGtk,这是不同的事情。 In any case, why you need to use libglade? 无论如何,为什么需要使用libglade? To support old Software? 支持旧软件? If that's the case, don't use PyGObject, use whatever version the Software was made with. 如果是这种情况,请不要使用PyGObject,而应使用软件制作时使用的任何版本。

If you need to parse Glade files to build a GUI, use Gtk+ included GtkBuilder object, libglade was deprecated long long long long ago. 如果需要解析Glade文件以构建GUI,请使用包含Gtk +的GtkBuilder对象,很久很久以前不推荐使用libglade。

See gi.repository Windows , in particular differences with Gtk+2 and Gtk+3. 请参见gi.repository Windows ,尤其是与Gtk + 2和Gtk + 3的区别。 Also, see How can a program that uses GUI be constructed? 另请参阅如何构造使用GUI的程序? for how to build a Glade GUI using PyGObject, Python2.7 and GtkBuilder (this is what I suppose you need). 有关如何使用PyGObject,Python2.7和GtkBuilder构建Glade GUI(这是我想您需要的)。

Need to include the "--glade" config option to Brew when installing, this causes the recipe/formula to make the bindings. 安装时需要在Brew中包括“ --glade”配置选项,这将导致配方/配方进行绑定。

  1. Need to install 'glade'; 需要安装“ glade”; this will also install 'libglade' 这也会安装'libglade'
  2. Then install pygtk with the following option "brew install --glade pygtk" 然后使用以下选项安装“ pygtk”:“ brew install --glade pygtk”

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

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