[pygtk] Trying to wrap a gobject

2009-07-20 Thread gabriele lanaro
Hi, I'm try to wrap the eggtrayicon like in the tutorial at this page:
http://www.ibm.com/developerworks/linux/library/l-wrap/

The tutorial il very old, but It's better than the faq, so I have a problem:
I generate with h2defs and eggtrayicon.h the trayicon.defs file
I wrote a trayicon.override
I wrote a simple Makefile to generate the trayicon.c
Now I encounter this error:

pygobject-codegen-2.0 --prefix trayicon\
--register `pkg-config --variable=defsdir pygtk-2.0`/gdk-types.defs \
--register `pkg-config --variable=defsdir pygtk-2.0`/gtk-types.defs \
--override trayicon.override \
trayicon.defs  trayicon.c
Could not write getter for GdkDevice.axes: No ArgType for GdkDeviceAxis*
Could not write getter for GdkDevice.keys: No ArgType for GdkDeviceKey*
Could not write getter for GdkDragContext.targets: No ArgType for GList*
Could not write getter for GdkDrawable.handle: No ArgType for gulong*
Traceback (most recent call last):
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 1717, in module
sys.exit(main(sys.argv))
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 1708, in main
sw.write(py_ssize_t_clean)
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 1340, in write
self.write_classes()
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 1438, in
write_classes
instance.write_class()
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 284, in
write_class
substdict['tp_getset'] = self.write_getsets()
  File /usr/share/pygobject/2.0/codegen/codegen.py, line 703, in
write_getsets
handler.write_return(ftype, 0, info)
  File /usr/share/pygobject/2.0/codegen/argtypes.py, line 89, in
write_return
self.__class__.__name__
RuntimeError: write_return not implemented for UCharArg
make: *** [trayicon.c] Error 1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* eggtrayicon.c
 * Copyright (C) 2002 Anders Carlsson ander...@gnu.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include string.h
#include libintl.h

#include eggtrayicon.h

#include gdk/gdkx.h
#include X11/Xatom.h

#ifndef EGG_COMPILATION
#ifndef _
#define _(x) dgettext (GETTEXT_PACKAGE, x)
#define N_(x) x
#endif
#else
#define _(x) x
#define N_(x) x
#endif

#define SYSTEM_TRAY_REQUEST_DOCK0
#define SYSTEM_TRAY_BEGIN_MESSAGE   1
#define SYSTEM_TRAY_CANCEL_MESSAGE  2

#define SYSTEM_TRAY_ORIENTATION_HORZ 0
#define SYSTEM_TRAY_ORIENTATION_VERT 1

enum {
  PROP_0,
  PROP_ORIENTATION
};
 
static GtkPlugClass *parent_class = NULL;

static void egg_tray_icon_init (EggTrayIcon *icon);
static void egg_tray_icon_class_init (EggTrayIconClass *klass);

static void egg_tray_icon_get_property (GObject*object,
	guint   prop_id,
	GValue *value,
	GParamSpec *pspec);

static void egg_tray_icon_realize   (GtkWidget *widget);
static void egg_tray_icon_unrealize (GtkWidget *widget);

static void egg_tray_icon_update_manager_window (EggTrayIcon *icon);

GType
egg_tray_icon_get_type (void)
{
  static GType our_type = 0;

  if (our_type == 0)
{
  static const GTypeInfo our_info =
  {
	sizeof (EggTrayIconClass),
	(GBaseInitFunc) NULL,
	(GBaseFinalizeFunc) NULL,
	(GClassInitFunc) egg_tray_icon_class_init,
	NULL, /* class_finalize */
	NULL, /* class_data */
	sizeof (EggTrayIcon),
	0,/* n_preallocs */
	(GInstanceInitFunc) egg_tray_icon_init
  };

  our_type = g_type_register_static (GTK_TYPE_PLUG, EggTrayIcon, our_info, 0);
}

  return our_type;
}

static void
egg_tray_icon_init (EggTrayIcon *icon)
{
  icon-stamp = 1;
  icon-orientation = GTK_ORIENTATION_HORIZONTAL;
  
  gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
}

static void
egg_tray_icon_class_init (EggTrayIconClass *klass)
{
  GObjectClass *gobject_class = (GObjectClass *)klass;
  GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;

  parent_class = g_type_class_peek_parent (klass);

  gobject_class-get_property = egg_tray_icon_get_property;

  widget_class-realize   = egg_tray_icon_realize;
  widget_class-unrealize = egg_tray_icon_unrealize;

  g_object_class_install_property (gobject_class,
   PROP_ORIENTATION,
   g_param_spec_enum (orientation,
		  _(Orientation),
		  _(The orientation of the tray.),
		  

Re: [pygtk] Help passing a widget to another class instance

2009-07-20 Thread Kim Adil
Solved:

I had to add a self.xxx variable to the init method of the page class 
and make it equal to the pparent, so that the save method on the page 
class had a variable it could access. I would be interested in what 
people consider good practice in this sort of situation.

Kim

Kim  wrote:
 Hi,

 I have a class for a glade window, that contains a notebook and I have 
 another class for notebook pages. I want to pass the (pointer to) 
 notebook widget when I create the the page object, so I can change the 
 notebook's tab label from a method in the page class (ie save button on 
 the page) but I get the error:

 print self.pparent.get_current_page()
 AttributeError: load_data_page instance has no attribute 'pparent'

 code snips below. Question is how do you pass the widget (or pointer) 
 from one object to another?


 Thanks,
 Kim

 class load_data_page:
 __init__() functions
 def __init__(self,pparent):
 self.gladefile = bp2.glade
 self.wTree = gtk.glade.XML(self.gladefile, vbox4)
 self.pageWidget = self.wTree.get_widget(vbox4)
 self.entryDescription = self.wTree.get_widget(entryDescription)
 self.entryUserid = self.wTree.get_widget(entryUserid)
 self.entryUserid.set_text(os.environ['USERNAME'])
 self.entryUserid = self.wTree.get_widget(entryTimestamp)
 self.entryUserid.set_text(time.strftime(%d/%m/%Y %H:%M:%S, 
 time.localtime()))
 self.buttonLoad = self.wTree.get_widget(buttonLoad)
 dic = {on_buttonLoad_clicked : self.loadFile,
 }
 self.wTree.signal_autoconnect(dic)

 def loadFile(self,data):
 self.entryDescription.set_text('hello')
 print ''
 print pparent.get_current_page()


 class win_main:
 An application to help manage  things you intend to do
 def __init__(self):
 #Set the Glade file
 self.gladefile = bp2.glade 
 self.wTree = gtk.glade.XML(self.gladefile, window1)
 self.wTree3 = gtk.glade.XML(self.gladefile, toolbar2)
 self.wTree2 = gtk.glade.XML(self.gladefile, menu4)
 self.wTree4 = gtk.glade.XML(self.gladefile, label13)
 self.menu41 = self.wTree2.get_widget(tbm3datafile)
 dic = {on_win_main_destroy : self.aquit,}
 self.notepad = self.wTree.get_widget(notebook1)

 ...







 .
 ___
 pygtk mailing list   pygtk@daa.com.au
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://faq.pygtk.org/
   

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Help passing a widget to another class instance

2009-07-20 Thread Xenofon Papadopoulos
self.get_parent().set_tab_label_text( self, blahblah )


On Mon, Jul 20, 2009 at 2:04 PM, Kim Adil ka...@proactiveindustrial.netwrote:

 Hi,

 I have a class for a glade window, that contains a notebook and I have
 another class for notebook pages. I want to pass the (pointer to)
 notebook widget when I create the the page object, so I can change the
 notebook's tab label from a method in the page class (ie save button on
 the page) but I get the error:

print self.pparent.get_current_page()
 AttributeError: load_data_page instance has no attribute 'pparent'

 code snips below. Question is how do you pass the widget (or pointer)
 from one object to another?


 Thanks,
 Kim

 class load_data_page:
__init__() functions
def __init__(self,pparent):
self.gladefile = bp2.glade
self.wTree = gtk.glade.XML(self.gladefile, vbox4)
self.pageWidget = self.wTree.get_widget(vbox4)
self.entryDescription = self.wTree.get_widget(entryDescription)
self.entryUserid = self.wTree.get_widget(entryUserid)
self.entryUserid.set_text(os.environ['USERNAME'])
self.entryUserid = self.wTree.get_widget(entryTimestamp)
self.entryUserid.set_text(time.strftime(%d/%m/%Y %H:%M:%S,
 time.localtime()))
self.buttonLoad = self.wTree.get_widget(buttonLoad)
dic = {on_buttonLoad_clicked : self.loadFile,
}
self.wTree.signal_autoconnect(dic)

def loadFile(self,data):
self.entryDescription.set_text('hello')
print ''
print pparent.get_current_page()


 class win_main:
An application to help manage  things you intend to do
def __init__(self):
#Set the Glade file
self.gladefile = bp2.glade
self.wTree = gtk.glade.XML(self.gladefile, window1)
self.wTree3 = gtk.glade.XML(self.gladefile, toolbar2)
self.wTree2 = gtk.glade.XML(self.gladefile, menu4)
self.wTree4 = gtk.glade.XML(self.gladefile, label13)
self.menu41 = self.wTree2.get_widget(tbm3datafile)
dic = {on_win_main_destroy : self.aquit,}
self.notepad = self.wTree.get_widget(notebook1)

 ...







 .
 ___
 pygtk mailing list   pygtk@daa.com.au
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://faq.pygtk.org/

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] liststore column names

2009-07-20 Thread Imre Horvath
Hi!

How can I get the column names in a liststore?

Thanks in advance:
Imre Horvath

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] liststore column names

2009-07-20 Thread Walter Leibbrandt
Imre Horvath wrote:
 How can I get the column names in a liststore?

[column.get_title() for column in treeview.get_columns()]

I assume you are referring to the column names of a gtk.TreeView, since 
gtk.ListStores don't have column names.

-- 
Walter Leibbrandt  Software Developer
Recent blogs:
* Conquering the CellRendererWidget
http://www.translate.org.za/blogs/walter/en/content/conquering-cellrendererwidget

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] liststore column names

2009-07-20 Thread Imre Horvath
Thank you, this works, previously I try to get it from ListStore...

Imre Horvath

On Mon, 2009-07-20 at 15:14 +0200, Walter Leibbrandt wrote:
 Imre Horvath wrote:
  How can I get the column names in a liststore?
 
 [column.get_title() for column in treeview.get_columns()]
 
 I assume you are referring to the column names of a gtk.TreeView, since 
 gtk.ListStores don't have column names.
 

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/