By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,283 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,283 IT Pros & Developers. It's quick & easy.

Extending python to our own gtk inherited Widgets

varuns
P: 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
Share this Question
Share on Google+
3 Replies

bartonc
Expert 5K+
P: 6,596
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
P: 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
P: 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.