Re: [pygtk] python and GTK+-3 - possible?
J Stowers wrote: From what I understand, pygobject can only provide GTK3 and pygtk can only provide GTK2. pygtk.py (what gets executed above) lives in pygobject. This, for historical reasons lived there to help easy the pain of the pygtk-1 - pygtk-2 transition. This is why you see pygtk.require(2.0) at the top of some programs (although this has not been necessary for some time). pygtk.py does some things with sys.path to choose which native code gets imported. We might start requiring people to call pygtk.require(2.0) again in future, depending on the parallel installation capabilities of the static parts of pygobject, however I think that discussion is ongoing, and not something you should worry about (Dieter, J5, is that correct, I have been AFK for a while) Actually I think it's possible that 'from gi.repository import Gtk' may give you GTK+2; I think it depends on which (version of) GTK was introspected into whichever gi repository your python finds. Not suggesting this is what you want - just my experience. This is not correct. One can choose the version of the typelib to be loaded; e.g. import gi gi.require_version(Gtk, 2.0) from gi.repository import Gtk Gtk.Switch -- Fails But the annotations are most up to date in the Gtk-3 overrides, so I would suggest letting it choose the most recent typelib by default, that is from gi.repository import Gtk Gtk.Switch --- Works And gives you gtk+-3. If you want to use gtk+-2 I suggest you stick with pygtk. Thanks for the explanation. I am starting to get it. Would this be a true statement regarding the role that pygobject plays: (Please correct it) pygobject today provides two different roles : 1. support for pygtk to use static bindings to Gobject, Gio, Gdk, Gtk. Support for Gtk is for GTK+2 only, not GTK+3 2. support for python apps to use dynamic python bindings for Gobject, Gdk, Gio, Gtk and others, each introspected from their respective packages. GTK version can be altered by choice of package during introspection and also overridden in the application by require, but support is intended for GTK+3. ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] problems porting pygtk app to pygobject on Fed. 14
j stowers wrote: What idiom is this? Why are you constructing self.myobject that way? Why are you not just super() or chaining up in __init__(self)? It is known as idiot idiom aka trial and error. If I omit that line, it fails later on at a line reading self.vbox = Gtk.VBox() with a complaint about wrong number of parameters for GObject.__init__() ERROR:root:Could not find any typelib for Gdk ERROR:root:Could not find any typelib for Gtk Traceback (most recent call last): File /home/lumby/pythonapps/togglegobj.py, line 24, in from gi.repository import Gdk, Gtk, GObject ImportError: cannot import name Gdk Any idea why it can't find Gdk and what I could look for to fix it? No idea. Many many things could have gone wrong. Check where the typelibs are installed and check if they can be found with the GI_TYPELIB_PATH environment variable (IIRC). Thanks again John - yes, it is certainly related to the typelibs. On this custom system, the girepository-1.0 directory does not have a typelib for gtk. It has just these typelibs: Atk-1.0 xrandr-1.3 xlib-2.0 xft-2.0 xfixes-4.0 libxml2-2.0 freetype2-2.0 fontconfig-2.0 cairo-1.0 Gio-2.0 GObject-2.0 GModule-2.0 GLib-2.0 GL-1.0 GIRepository-2.0 DBusGLib-1.0 DBus-1.0 On the F14, there are many more including gtk. Now, the strange thing (to me) is that these were all (except one, Atk) installed during the make install phase of building gobject-introspection-0.10.3 itself. I would (I think) have expected each one to be put there by its own package. How does gobject-introspection know which packages to build typelibs for? There does not appear to be any configure option for this. The Atk typelib was built by the Atk build process, which did this /usr/local/bin/g-ir-compiler --includedir=. Atk-1.0.gir -o Atk-1.0.typelib Am I supposed to run g-ir-compiler on similar ${package}.gir's of the other packages? I will give that a try but again if you or someone can say how this is supposed to be done I would appreciate. Cheers, John Lumby ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] problems porting pygtk app to pygobject on Fed. 14
John Lumby wrote: Thanks again John - yes, it is certainly related to the typelibs. On this custom system, the girepository-1.0 directory does not have a typelib for gtk. It has just these typelibs: Atk-1.0 xrandr-1.3 xlib-2.0 xft-2.0 xfixes-4.0 libxml2-2.0 freetype2-2.0 fontconfig-2.0 cairo-1.0 Gio-2.0 GObject-2.0 GModule-2.0 GLib-2.0 GL-1.0 GIRepository-2.0 DBusGLib-1.0 DBus-1.0 Never mind - I realized I had built glib and gtk without the --enable_introspection flag. I've rebuilt all the gxxx packages with introspection and that populated the girepository-1.0 directory with the missing typelibs. Now it works just fine. Thanks again for the help Cheers, John Lumby ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] python and GTK+-3 - possible?
R Park wrote: From what I understand, pygobject can only provide GTK3 and pygtk can only provide GTK2. So if your code includes 'import pygtk' then that is by definition gtk2 you are using, and if instead you have 'from gi.repository import Gtk' then that can only be Gtk3. Many thanks. Actually I think it's possible that 'from gi.repository import Gtk' may give you GTK+2; I think it depends on which (version of) GTK was introspected into whichever gi repository your python finds. Not suggesting this is what you want - just my experience. Check the source to my app, it's gtk3 and uses some of the new gtk3 widgets (such as ComboBoxText for example): https://github.com/robru/gottengeography Thanks again. That helped. I got mine working now (with a GTK+3 Light Switch) Cheers, John ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] python and GTK+-3 - possible?
R Park wrote: On Sun, Mar 13, 2011 at 4:39 PM, John Lumby wrote: Is it posible today, using some combination of python and pygtk-family packages Not with PyGTK. It is the intention of the maintainers that PyGTK dies a slow, gentle death alongside GTK2. The future of GTK3 is available in python through gobject-introspection in the pygobject package, thanks to the hard work of J5, Tomeu, et al. Ah, thanks, that is reassuring. Actually I meant the term pygtk-family to include pygobject, since (I think) they share same home? Anyway, would you please provide a little more detail on how I would build and run the app? Do I specify Gtk.require('3.0') in the app? If not, at what point in the build/run process does something tell something else to use GTK3 structures and libs instead of GTK2, given they are both installed on my system? Does it make any difference if I use Python2 or Python3, again given they are both on my system. And, do you have an example or building and running? My attempts to run my test app against GTK3 all fail with import errors, no doubt because I have built and installed things myself, and I find it difficult to know what is going on. E.g. if I run using python (which is Python2.26) I get ERROR:root:Could not find any typelib for Gtk Traceback (most recent call last): File /home/lumby/pythonapps/togglegobj.py, line 20, in module from gi.repository import Gtk ImportError: cannot import name Gtk And if I run using python3 I get Traceback (most recent call last): File /home/lumby/pythonapps/togglegobj.py, line 20, in module from gi.repository import Gtk ImportError: No module named gi.repository Cheers John ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] python and GTK+-3 - possible?
J Lumby wrote My attempts to run my test app against GTK3 all fail with import errors, no doubt because I have built and installed things myself, and I find it difficult to know what is going on. Further to that - I have discovered this line in the current pygobject/Makefile.am (2.2.28 and pulled from git just now) pkgpyexecdir = $(pyexecdir)/gtk-2.0 i.e. hard-coding gtk-2; which apparently results in all python-related files being installed into ${prefix}/lib/python2.6/site-packages/gtk-2.0 And (not sure but I think) that prevents use of gtk-3.0 packages and may explain my difficulties. Are you using your own modified configure script / Makefile? Cheers, John ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] problems porting pygtk app to pygobject on Fed. 14
J Stowers wrote: Firstly, F-14 is probably too old. This pygobject+g-i has moved a lot in the last few months. Thanks John. Eventually I got it working on that F-14 system (without upgrading any packages). * use glib (i.e. static bindings) and GObject (from gi.repository import GObject) Here is a new app written in pygobject+g-i https://github.com/nzjrs/gnome-tweak-tool After looking at your Tweaker and tinkering a bit, in my case, the key statements appear to have been: from gi.repository import Gdk, Gtk, GObject ... class ToggleBut(Gtk.Window): def __init__(self, parent=None): self.mywindow = Gtk.Window.__init__(self) self.myobject = GObject.__init__() After that, things fell into place. Now I still need some help if poss: I took this same python app unchanged to another system where I have built packages myself. It is python 2.6, but all other packages are the latest versions as of very recently. The original pygtk form of the app works fine there, but this pygobject-form fails like so: ERROR:root:Could not find any typelib for Gdk ERROR:root:Could not find any typelib for Gtk Traceback (most recent call last): File /home/lumby/pythonapps/togglegobj.py, line 24, in module from gi.repository import Gdk, Gtk, GObject ImportError: cannot import name Gdk Any idea why it can't find Gdk and what I could look for to fix it? I have stared at install directories and can't see anything amiss - e.g. the set of files in and under: F14's /usr/lib/python2.7/site-packages/gtk-2.0/gi custom-sys's /usr/local/lib/python2.6/site-packages/gtk-2.0/gi appear to be the same (names, not content) except for a couple of libtool xxx.la's in the custom one. I can easily upgrade python to 2.7 if that might help but would prefer to have some idea what I am looking for. Cheers, John Lumby ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] python and GTK+-3 - possible?
Is it posible today, using some combination of python and pygtk-family packages and the current GTK+-3.0.2, (pulled from git if need be), to code a python application that exploits new features in GTK+-3? E.g. one of the new widgets? If so, could someone say how. If not, will it be? CheersJohn Lumby ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] problems porting pygtk app to pygobject on Fed. 14
I am having trouble trying to port a pygtk/python2.6/linux-fedora-14 application to use pygobject. My first try was to convert using pygi-convert.sh, and when I ran that converted .py, I got File /home/lumby/pythonapps/togglegobj_from_convert.py, line 17, in module pyGtk.require('2.0') NameError: name 'pyGtk' is not defined The converter had converted the line pygtk.require('2.0') into the pyGtk.require('2.0') I don't know the converter would leave calls to anything named pygtk if the objective is to remove all reference to pygtk.Anyway, I commented that line out and then I got File /home/lumby/pythonapps/togglegobj_from_convert_plus_chg1.py, line 89, in module instance = ToggleBut() File /home/lumby/pythonapps/togglegobj_from_convert_plus_chg1.py, line 35, in __init__ self.vbox = Gtk.VBox(False, 85) TypeError: GObject.__init__() takes exactly 0 arguments (2 given) Now I am completely baffled.The TypeError error message displays line 27 which reads gobject.GObject.__init__(self) but the previous line in the traceback refers to line 35, the one instantiating self.vbox. I've attached the original and converted files at the end. I then turned to the examples provided by pygobject and found one that includes gtk functions: cairo-demo.py so I ran that and I got File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/share/doc/pygobject2-2.21.5/examples/cairo-demo.py, line 81, in expose ctx = Gdk.cairo_create(da.window) File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: argument 0: Must be Gdk.Drawable, not NoneType Traceback (most recent call last): File /usr/lib/python2.7/site-packages/gtk-2.0/gi/types.py, line 40, in function return info.invoke(*args) TypeError: main_quit() takes exactly 0 argument(s) (1 given) At this point I am not confident I can get this working.Can anyone help me? I am looking for an example of a working python app that uses pygobject to perform gtk functions. And/Or some definitive rules on what a python skeleton for this looks like. If the answer is along the lines of the converter, examples and doc are a bit out of date, they will be updated then that's fine, if someone can state that. CheersJohn Lumby some package versions (up to date Fedora 14 ) python-devel-2.7-8.fc14.1.i686 dbus-python-0.83.0-7.fc14.i686 python-libs-2.7-8.fc14.1.i686 pygobject2-devel-2.21.5-3.fc14.i686 gobject-introspection-devel-0.9.3-1.fc14.i686 pygtk2-devel-2.17.0-7.fc14.i686 gobject-introspection-0.9.3-1.fc14.i686 python-2.7-8.fc14.1.i686