472,119 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Extending python to our own gtk inherited Widgets

varuns
39
hi
i extended python to my own widgets inherited from gtk.
But when i try to run command
Expand|Select|Wrap|Line Numbers
  1. python2.5 -c "import mygtk"
it displays following error
Expand|Select|Wrap|Line Numbers
  1. "TypeError: mro() returned base with unsuitable layout ('gtkmy.MyChoice')"
  2. ...
  3. ..
  4.  
  5. "** (-c:13962): WARNING **: couldn't make the type `gtkmy.MyList' ready"
  6. "TypeError: multiple bases have instance lay-out conflict
  7. (!) [13962:   33.658] --> Caught signal 11 (at (nil), invalid address) <--
  8. (!) Direct/Thread: Canceling 'Fusion Dispatch' (13964)!
  9. Aborted (core dumped)
  10. "
my widget heirarchy is as shown
GtkVBox -- > GtkMyDisplayable --> GtkMyScreen --> GtkMyList --> GtkMyFileBrowser

what i think is python is trying to initialize GtkMyList first before its parent thats why the error "instance lay-out conflict". If i m correct than can any one help me out with a question:: how to serialize the initialization process? (ie parent class gets initialized before child class.) And if i m wrong than whats this error for?

kindly help

Varun
Aug 13 '07 #1
3 1554
bartonc
6,596 Expert 4TB
That sure looks like it's coming from the C API and not from the Python that we all know and love.

By "extending", I'm guessing that you mean you are writing and compiling the extension in C.
Aug 13 '07 #2
varuns
39
i figured out the problem. I thought, i followed code writing standard of Gtk, but not i did some mistake and the .defs file generator (h2def.py) was unable to generate the "scheme" for interface (GTypeInterface) (i have to still figure that out). But i edited directly the generated .defs file.
Generated scheme for my interface looked like
Expand|Select|Wrap|Line Numbers
  1. ;; -*- scheme -*-
  2.        ; object definitions ...
  3.        (define-object MyChoice
  4.          (in-module "Gtk")
  5.         (c-name "GtkMyChoice")
  6.         (gtype-id "GTK_TYPE_MY_CHOICE")
  7.        )
but it should look like

Expand|Select|Wrap|Line Numbers
  1. ;; -*- scheme -*-
  2.        ; interface definitions ...
  3.        (define-interface MyChoice
  4.          (in-module "Gtk")
  5.          (c-name "GtkMyChoice")
  6.          (gtype-id "GTK_TYPE_MY_CHOICE")
  7.          (prerequisites "GtkMyImage") #----> quotes should contain object name of corresponding #included file;(i think so, not so sure, i just checked how pygtk people have written there .defs file). In my case its #include "gtkmyimage.h"   
  8.        )
I made these changes and the error was gone.


By "extending", I'm guessing that you mean you are writing and compiling the extension in C.
yes, i m trying to write something similar to pygtk, as we can access gtk api's from python using wrapper functions and Python APIS like Py_ArgParseTuple, Py_BuildValue etc etc........, so that i can just use python scripts instead of long C code and also i m learning and using python because manipulation of data is really easy in Python.

Also i have posted solution for "undefined variable gdk_keyval_convert_case" for directFB at http://www.thescripts.com/forum/thread657353.html
Aug 13 '07 #3
varuns
39
generator (h2def.py) was unable to generate the "scheme" for interface (GTypeInterface) (i have to still figure that out).
hi
replying to myself..

i consulted authors of pygtk group and the information they provided is
h2def.py never generate scheme as define-interface, they generate it as define-objects. You need to manually edit it.

Also You could try defsgen.py:

http://svn.gnome.org/viewcvs/pygtk/t...en.py?view=log

which uses ctypes to generate .defs - its more comprehensive in
generating .defs.

else you can change manually object to interface and use scanvirtuals.py

http://svn.gnome.org/viewcvs/pygtk/t...ls.py?view=log

to retrive the virtual methods.

cheers
Aug 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Peter Moscatt | last post: by
reply views Thread by ndario | last post: by
5 posts views Thread by vbgunz | last post: by
10 posts views Thread by James Stroud | last post: by
44 posts views Thread by jiang.haiyun | last post: by
31 posts views Thread by sdoty044 | last post: by
12 posts views Thread by default | last post: by
270 posts views Thread by Jordan | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.