Re: [pygtk] problems porting pygtk app to pygobject on Fed. 14

2011-03-15 Thread John Lumby

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] problems porting pygtk app to pygobject on Fed. 14

2011-03-15 Thread John Lumby

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

2011-03-14 Thread John Stowers

> 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__() 

What idiom is this? Why are you constructing self.myobject that way? Why
are you not just super() or chaining up in __init__(self)?


> 
> 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 
> 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.

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). Poke about by
printing .__file__ of things which successfully import.

It feels like you are changing far too many things at once, and there is
many subtle ways the libraries could be interacting poorly.

I would start again, chuck everything is ~/bin/ and slowly make it work
one at a time by setting LD_LIBRARY_PATH, PYTHONPATH, GI_TYPELIB_PATH,
etc.

Or just use JHbuild to sandbox everything.

Good luck,

John


> 
> 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

2011-03-14 Thread John Lumby

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 
    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/


Re: [pygtk] problems porting pygtk app to pygobject on Fed. 14

2011-03-13 Thread John Stowers
On Sun, 2011-03-13 at 18:34 -0400, John Lumby wrote:
> 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

Firstly, F-14 is probably too old. This pygobject+g-i has moved a lot in
the last few months.

pygi-convert is a hint only, it should not produce working code out of
the box.

With that said, my experiences are
* on F15/Natty pygobject/g+i works well
* use glib (i.e. static bindings) and GObject (from gi.repository import
GObject)
* callbacks and user_data optional parameters are the usual source of
pain
* use named arguments to constructors

Here is a new app written in pygobject+g-i

https://github.com/nzjrs/gnome-tweak-tool

John

___
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

2011-03-13 Thread John Lumby

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 

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 
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