473,554 Members | 3,075 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extending python to our own gtk inherited Widgets

39 New Member
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. ..
  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 -- > GtkMyDisplayabl e --> GtkMyScreen --> GtkMyList --> GtkMyFileBrowse r

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

Aug 13 '07 #1
3 1703
6,596 Recognized Expert Expert
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
39 New Member
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_ArgParseTupl e, 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_conv ert_case" for directFB at http://www.thescripts.com/forum/thread657353.html
Aug 13 '07 #3
39 New Member
generator (h2def.py) was unable to generate the "scheme" for interface (GTypeInterface ) (i have to still figure that out).
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:


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

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


to retrive the virtual methods.

Aug 16 '07 #4

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

Similar topics

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 lead that I should look at other sources for GUI widgets - namely TCL. I have just done a search for 'tcl' files on my 'Fedora 3' installation...
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 ascx, just cs) | MyUserControl (visulay designed concrete control to be put in
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 confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an...
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 browser. However, I'm not really sure where to start. I've played with some CMS applications, but they seem more for blogging (mamba, wordpress, etc.)....
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 comparison among them on easy coding, pythonish design, beautiful and generous looking, powerful development toolkit, and sufficient documentation,...
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 text output, maybe a scrolling text message as things are happening. I have some minor things I need to do, for example, if Checkbutton X is...
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 and wx, i would like to know if one of these or any other toolkit is capable of creating good-looking GUI's, like in other apps, for e.g, .net apps....
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 nicely but I'm having a few issues, which I may post about later. A brief functional rundown of what I'm trying to prototype. Hopefully my...
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 inspired rant on my blog, and I thought it was relevant enough as a wider issue to the Python community to post here for your discussion and...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.