注:这篇文章在底部的编辑部分有几个发展。在
我不明白为什么我的小程序抛出一个错误。在
似乎很多人都有同样的问题。我刚刚读了this article,它基本上说安装gtk是不可能的。当然不是这样。。。在
还有这个:import gtk not working on mac
让我们来解决这个问题。在
我认为控制台读出器中最相关的一行是GtkWarning: Screen for GtkWindow not set; you must always set a screen for a GtkWindow before using the window
。我已经在谷歌上搜索过了,但是我不知道如何在使用窗口之前“设置屏幕…”
which python
给/opt/local/bin/python
,我想这就是我想要的,因为我正在使用通过macports安装的库。在
我遵循了thispost中给出的过程,所以我确信我正在运行py27-pygtk
。在
#!/opt/local/bin/python2.7
import gtk, os
window = gtk.Window()
window.connect("destroy", gtk.main_quit)
image = gtk.Image()
window.add(image)
image.set_from_file(os.path.join("data", "image1.jpg"))
window.show_all()
gtk.main()
这是控制台读数:
^{pr2}$编辑:我在某处读到(一旦我找到链接就会发布链接),你需要一个名为x11的东西来使用gtk。所以我就跑了sudo port -v install xorg-server
。这没用。在
编辑2:刚下载xquartz from their website。但是,我想这是关键,我重新启动了我的电脑。现在我可以让我的程序正常运行了。但是,我仍然收到以下警告。我不知道这是什么意思。有什么想法吗?在
$ python imageHello.py
** (process:312): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (process:312): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (process:312): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
目前没有回答
相关问题 更多 >
编程相关推荐