473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1685
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

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

Similar topics

3
by: Peter Moscatt | last post by:
I am reasonably new to programming in Python. Up until now I have been using GUI widgets supplied by 'Tkinter' but starting to realise that Tkinter have limited widgets. I have been given the...
0
by: ndario | last post by:
i am working on some sort of template for my site and i am extending UserControl. inheritance goes like this UserControl | BaseUserControl (contains common functions for all user controls, no...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
10
by: James Stroud | last post by:
Hello All, I am interested in setting up a modest invoicing system for some consulting I am doing. I like the idea of managing this on the web and creating invoices and printing them from a...
44
by: jiang.haiyun | last post by:
Now i began to learn GUI programming. There are so many choices of GUI in the python world, wxPython, pyGTK, PyQT, Tkinter, .etc, it's difficult for a novice to decide, however. Can you draw a...
31
by: sdoty044 | last post by:
Just wondering on what peoples opinions are of the GUIs avaiable for Python? All I am doing is prompting users for some data (listbox, radio buttons, text box, ect...). Then I will have some...
12
by: default | last post by:
what would be the best python GUI toolkit, it must be cross platform. i have tried gtk, but it interface are real bad and its coding was difficult so i dropped it, the only remaining are qt4...
0
by: Stodge | last post by:
Hi folks, new to Boost Python and struggling to build a prototype at work. I thought I'd start with a conceptual question to help clarify my understanding. I already have a basic prototype working...
270
by: Jordan | last post by:
Hi everyone, I'm a big Python fan who used to be involved semi regularly in comp.lang.python (lots of lurking, occasional posting) but kind of trailed off a bit. I just wrote a frustration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.