質問

dialog = gtk.FileChooserDialog("Open..",
                           None,
                           gtk.FILE_CHOOSER_ACTION_OPEN,
                           (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                            gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)

I want to use the above code for file browsing- but when I give the following import

import pygtk
pygtk.require('2.0')

import gtk

I get Error: No module named 'pygtk'

Do I need to give pygtk as a module inside my application folder? Do say with steps. Thank you.

役に立ちましたか?

解決

pygtk is the old and deprecated gtk Python api. Do not use it unless you have a legacy application. The correct way nowadays is to use GObject-introspection to use Gtk3 from Python. Which is also really awesome as it makes Python a first-class supported language, with no wrappers necessary.

from gi.repository import Gtk
dlg = Gtk.FileChooserDialog()
dlg.show()

他のヒント

You should look at this: http://rox.sourceforge.net/desktop/node/245.html

It shows some problems. Good luck on fixing it :).

Edit:

Test PyGTK Installation

This has lots of info on pip install (windows): How do I install pip on Windows?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top