Newbie Help PyCObject

Daniel Mooney danang at xtra.co.nz
Thu Apr 19 11:21:14 EDT 2001


NOTE python V 1.5 - redhat 7 linux
The problem I have is a signal sent to my python program(from
gtkmozembed) is
taking the argument  in as PyCObject when I would like a text string (I
think this is because
it is set as "const char*aURI" in the C/C++? program it is comming from
- (see below gtkmozembed.h)
PS I have tried deleting the "const" part in the gtkmozembed.h file and
recompiled
(I think it is set deeper inside mozilla and that is beyond this newbie)

Is there a way to extract the text part of PyCObject or ??
see below for example C/C++? that works (the way I would like to do in
python)- TestGtkEmbed.cpp

PS I won't be checking for replies for approx 12 hours as it is very
early in the morning here
Thanks in advance from Daniel   danang at xtra.co.nz
below :
            part of my python code
            stdout from my code
            part of gtkmozembed.h
            part of TestGtkEmbed.cpp (this works)
*************************************************
part of my python code
(that takes in uri as PyCObject)
------------------------------------------
from gtk import *
from gtkmozembed import *


def open_uri_cb(args,uri):
    print "message open_uri"
    print (uri)
    return FALSE

#create window etc here

moz = GtkMozEmbed()

moz.connect("open_uri",open_uri_cb)

#show widgets etc here
**************************************************
***************************************************
stdout from my python code
--------------------------------------------
message open_uri
<PyCObject object at 8400cf8>
***************************************************
***************************************************
Part of gtkmozembed.h (C header where signal is from ?)
note: (const char*aURI)
-------------------------------------------
struct _GtkMozEmbedClass
{
  GtkBinClass parent_class;

  void (* visibility)          (GtkMozEmbed *embed, gboolean
visibility);
  void (* destroy_brsr)        (GtkMozEmbed *embed);
  gint (* open_uri)            (GtkMozEmbed *embed, const char *aURI);
};
***********************************************************************
***********************************************************************
part of TestGtkEmbed.cpp  (C source of a test prog that works (the way i
want it to))
(g_print line  prints to stdout a test URL eg. http://python.org)
-------------------------------------------------------------
gint
open_uri_cb          (GtkMozEmbed *embed, const char *uri,
TestGtkBrowser *browser)
{
  g_print("open_uri_cb %s\n", uri);

  // interrupt this test load
  if (!strcmp(uri, "http://people.redhat.com/blizzard/monkeys.txt"))
    return TRUE;
  // don't interrupt anything
  return FALSE;
}
**************************************************************************






More information about the Python-list mailing list