[pygtk] Taking action when a window is raised

2006-03-08 Thread Graham Ashton
[I'm re-posting this from http://www.gnomedev.com/viewtopic.php?t=36]

Hi there. I'm trying to work out how to run a callback when my
application's main window is given top level focus. I'm using PyGTK,
but I think my question is really a general GTK+ one.

How are you supposed to do it? I can't find a signal on a GtkWindow
that I could connect to, which has left me stumped. I'm not sure how
else it would work.

I know it's possible (the wonderful gossip
[http://live.gnome.org/Gossip] does it), but a cursory scan of the
source didn't reveal anything obvious (to me).

Any pointers?

Cheers,

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


Re: [pygtk] Help with modal in Gtk::FileChooserDialog

2005-11-28 Thread Graham Ashton
On Monday 28 November, dannym wrote:

 Usually you just use a modal event loop:
 
 dialog = gtk.FileChooserDialog()
 answer = dialog.run() # hangs around until dialog is closed
 del dialog

Hi. Wouldn't it be better to say:

  dialog.destroy()

instead of

  del dialog

?

It was a long time ago that I did looked into this, but I found that
in order to avoid memory leaks in long running processes that
created/destroyed a lot of widgets, I had to explicitly call destroy()
myself. I confess I'm not even sure if del calls it for you...

-- 
Graham Ashton
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] SpinButton and a value of None

2005-11-28 Thread Graham Ashton
On Thursday 24 November, N. Volbers wrote:

 My second problem arises due to the fact that it should be possible  to 
 specify no value at all.

 [snip]
 
 Am I missing something obvious? I would appreciate any suggestions
 on this.

If you want a single widget that allows you to specify a positive
integer or nothing I think you'll need to look elsewhere.

You may be building a better UI if you add a checkbox to cover the
case where you don't want to specify an integer; i.e. ticking the box
de-sensitises the spin button and signifies None.

-- 
Graham Ashton
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] install a gconf schemas with distutils

2004-09-01 Thread Graham Ashton
On Thu, 2004-08-26 at 15:30, Guillaume Desmottes wrote:
 Hi!
 
 I would like to use distutils to install a gconf schemas.
 
 The distutils doc is very poor and I don't understand how to make that.
 
 The 'manual' command is: 
 GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` gconftool-2
 --makefile-install-rule my_file.schemas 

straw is packaged with distutils, and it does have gconf schemas.
They're currently commented out of setup.py so may not be working, but
it may be worth having a look at what they did there and trying to get
something similar to work.

http://cvs.gnome.org/viewcvs/straw/setup.py?rev=1.7view=auto

I recently packaged a Python app with the autotools, which I chose over
distutils purely as a learning exercise. If you fancy giving autotools a
go you may find it to be a useful example:

http://cvs.sourceforge.net/viewcvs.py/bandsaw/bandsaw/

I found the Gnome Blog autotools stuff quite a handy reference too. I
did consider writing up how to go about it, as I spent quite a while
digging around the net and asking questions on the #gnome-hackers IRC
channel in order to get it all sorted. Are there many people out there
who'd like to package pygtk apps with the autotools but aren't sure
where to start?

Arturo's applets tutorial has a good intro to it in the last chapter,
but it is fairly brief:

http://pygtk.org/articles/applets_arturogf/x207.html

--
Graham

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] About Fullscreen libglade windows

2004-09-01 Thread Graham Ashton
On Fri, 2004-08-27 at 21:48, Douglas Soares de Andrade wrote:

 How to make a form init the execution maximized using libglade. I already did 
 the window and it is work perfectly. 
 
 The only thing left to do is make it start maximized.

Just call maximize() on the window before you enter the main loop.

I've no idea how you're getting hold of the window object from glade,
but the pure gtk code would look something like this:

win = gtk.Window()
win.maximize()
win.show()
gtk.main()

You may not need the show() as glade shows things by default.

--
Graham

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Tray area

2004-08-19 Thread Graham Ashton
On Wed, 2004-08-18 at 19:12, Gabriele Erba wrote:
 Hi, I am new in Pygtk. I would like to know if is possible to use the
 tray notification area with Pytgk. I try to search in the documentation
 but with no result. 

You need to wrap the stuff in libegg. Ross Burton has a good tutorial on
wrapping gobjects that just so happens to do just that:

http://www-106.ibm.com/developerworks/linux/library/l-wrap/

--
Graham

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Glade XML wrapper and easy callbacks

2004-08-05 Thread Graham Ashton
On Thu, 2004-08-05 at 06:23, Sridhar R wrote:
 Graham Ashton [EMAIL PROTECTED] wrote:
  On Wed, 2004-08-04 at 01:40, Sridhar R wrote:
   Graham Ashton [EMAIL PROTECTED] wrote:
  
If anybody wants a really simple implementation to this kind of wrapper
class feel free to rip off the WidgetWrapper class hierarchy that I've
knocked up here (it's tiny):
   
http://cvs.sourceforge.net/viewcvs.py/bandsaw/bandsaw/src/bandsaw.py?view=markup
  
   But the signal connection part is a little bit weak.  How do you
   connect signals to some deeply nested widgets in that hierarchy?
  
  What do you mean by deeply nested?
 
   child of child of .. the toplevel widget. (may be wrong terminology).

Thanks. I don't understand why you think it doesn't work.
signal_autoconnect() does the nested widgets for you. Or am I missing
the point?

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Glade XML wrapper and easy callbacks

2004-08-05 Thread Graham Ashton
On Thu, 2004-08-05 at 13:09, Sridhar R wrote:
 So you *manually* enter the handler name for each widget in glade
 signal editor right?  That's a bit inconvinient, if you want to add
 another callback, say--Add callback in glade signal editor and define
 the method in code.  GWidget [1] automates this.

Ah, I see. I hadn't gathered that bit. I can see the attraction for the
automation, but it had never even occurred to me do it.

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Glade XML wrapper and easy callbacks

2004-08-04 Thread Graham Ashton
On Wed, 2004-08-04 at 01:40, Sridhar R wrote:
 Graham Ashton [EMAIL PROTECTED] wrote:
 
  If anybody wants a really simple implementation to this kind of wrapper
  class feel free to rip off the WidgetWrapper class hierarchy that I've
  knocked up here (it's tiny):
  
  http://cvs.sourceforge.net/viewcvs.py/bandsaw/bandsaw/src/bandsaw.py?view=markup
 
 But the signal connection part is a little bit weak.  How do you
 connect signals to some deeply nested widgets in that hierarchy?

What do you mean by deeply nested?

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Glade XML wrapper and easy callbacks

2004-08-03 Thread Graham Ashton
On Wed, 2004-07-28 at 16:54, Doug Quale wrote:
 Christian Robottom Reis [EMAIL PROTECTED] writes:
 
  The issue I raised was fear of namespace conflicts that would be
  introduced by this, but I think it's rather minor.
 
 I don't actually have a strong opinion whether that change would be
 good, bad or indifferent, so I was hoping someone smarter than me
 could give some good arguments one way or the other :)

Smarter? Not me. But I have experienced it both ways. At work we've got
a rather large app (80k lines of Python), a fair chunk of which is GUI
code. We use libglade and some classes that wrap it up in a similar
manner to many of the examples posted here. The basic principle is that
your GUI class inherits from our own GWidget type thing, in which you
write lines like this:

   list_store = self._widget.treeview.get_model()

We had minor disagreement when we initially started with these classes
as to whether that was more sensible than the aesthetically cleaner:

   list_store = self._treeview.get_model()

We approached it conservatively and ended up with _widget everywhere. A
year later I can confirm that it's a right pain in the arse. I don't
know of a single situation where the _widget has protected us from a
name space collision. You could reasonably point out that I wouldn't be
likely to notice as nothing is going to go blow up in my face. Still, I
attribute the lack of evidence to support _widget to the fact that we
try and keep our classes fairly small and directed, and put business
logic and UI control code in different classes (so there's nothing more
than widgets and callbacks in the GUI code in the first place).

I recently started an open soure app of my own and decided to experiment
with a different style. In my own app I would do this:

   list_store = self.treeview.get_model()

So far I'm enjoying the extra simplicity, but then my OS app is still
less than 1k lines. My classes aren't coming out larger or smaller than
they do at work though, and that's surely a more important issue.

If anybody wants a really simple implementation to this kind of wrapper
class feel free to rip off the WidgetWrapper class hierarchy that I've
knocked up here (it's tiny):

http://cvs.sourceforge.net/viewcvs.py/bandsaw/bandsaw/src/bandsaw.py?view=markup

It's small and clean and plenty good enough for small projects. Apart
from the automatic attribute access I'm a fan of being able to write
multiple classes to manage different parts of a GUI that just happen to
have been layed out in a single glade file. Band Saw's WidgetWrapper
allows you to do this:

  class Window(WidgetWrapper):

def __init__(self):
  WidgetWrapper.__init__(self, 'window1')  # window1 is in glade
  menu = Menu(self)
  ... blah blah ...

  class Menu(WidgetWrapper):

def __init__(self, window):
  WidgetWrapper.__init__(self, 'menu1', window)

The thing to note is that the Menu is passed the window, which already
has a glade.XML object within it. The Menu just re-uses the one that the
Window has already made, saving you the overhead of loading the glade
file twice (and saving you from having two windows pop up in the event
that your top level window is visible by default). Not rocket science,
but very handy.

It's by no means as clever as the one we've got at work, but that's
proprietary and I can't rip it off. It supports clever stuff like window
stacking (i.e. transiency), object tracking (to catch memory leaks) and
other nice goodies. None of it has been that hard to do.

--
Graham

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Rendering OptionMenu in a TreeView

2004-07-23 Thread Graham Ashton
On Wed, 2004-07-21 at 13:41, Gustavo J. A. M. Carneiro wrote:
 A Qua, 2004-07-21 às 11:07, Lorenzo Gil Sanchez escreveu:
  El mié, 21-07-2004 a las 11:54, Graham Ashton escribió:
  
   I'm using a rather old version of PyGTK though (2.0), and in my eternal
   optimism thought it worth checking whether or not it's possible to
   implement the CellEditable interface in the latest versions of PyGTK.
   
  We should ask Gustavo how is this going in PyGTK CVS
 
   I opened the bug report, but gave up for lack of time, thus delegated
 to Johan. ;-)

Fair! In the end we opted for putting widgets into a GtkTable (and to be
honest, it was probably a good thing to do anyway given the
circumstances under which we're doing it).

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Rendering OptionMenu in a TreeView

2004-07-21 Thread Graham Ashton
Hi. I need to display an OptionMenu in a TreeView cell, and am planning
on using Lorenzo's rather cunning technique of placing a separte Window
over the relevant cells when the cell is focused [1].

I'm using a rather old version of PyGTK though (2.0), and in my eternal
optimism thought it worth checking whether or not it's possible to
implement the CellEditable interface in the latest versions of PyGTK.

Is Lorenzo's Window hack still the best way to do it?

Thanks,

Graham.

[1] http://www.mail-archive.com/[EMAIL PROTECTED]/msg06091.html

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


GNOME platform bindings (was Re: [pygtk] Release Candidate 1: pygtk-2.2.0-RC1.tar.gz)

2004-03-09 Thread Graham Ashton
On Sun, 2004-03-07 at 19:02, Murray Cumming wrote:
 On Fri, 2004-03-05 at 16:14, Christian Robottom Reis wrote:
  Hey there,
  
  We're providing a new PyGTK release candidate for testing:
  
  http://www.gnome.org/~jdahlin/pygtk-2.2.0-RC1.tar.gz
 
 That's great. Well done, and I hope this means you'll try to put pygtk 
 on the GNOME Platform Bindings 2.7/2.8 schedule.

I'd love to see pygtk and gnome-python in the language bindings release
set, and was interested in finding out exactly what the issues are. As a
result I was talking with Murray and Christian (independently) on IRC
the other night, and suspect that the situation isn't quite as black and
white as it may have seemed (to me, at least). As I understand it this
is the situation:

  - We all want to see Python bindings in the release set.

  - Splitting packages that only wrap modules that are part of the 
GNOME Developer platform [1] is NOT a requirement, if those
bindings are ABI/API stable.

  - pygtk doesn't wrap any packages that aren't in the Developer
platform and would therefore not require structural changes in order
to be included.

  - gnome-python does wrap packages that aren't in the Developer
platform, and is consequently not (currently) suitable.

As Murray put it, the bottom line is don't break already-installed
applications. That's where the limitation on backwards compatible API
changes (and bindings for just the Developer platform packages) comes
from. So you can add API in unstable 2.5.x, but not in stable 2.6.1 or
2.6.2, etc. But after 2.6.0 you would be working on unstable 2.7/2.8
anyway and new API can go in there.

I'm not that familiar with the pygtk/gnome-python code, and it's not for
me to judge how easy any of the following would be to do (and I
appreciate that a lack of available resource limits our options).
Apologies if this is going over old ground, but it seems to me that the
following are possible ways forward:

  - Do nothing.

  - Work towards including pygtk in the GNOME 2.7/2.8 release schedule,
leaving gnome-python packaging as it is, just not included in
the release set.

  - Include pygtk in the 2.7/2.8 release schedule, and split
gnome-python into two packages, one containing API stable Developer
platform bindings, the remaining bindings in the other.

I understand the reluctance to go for the third option (but would be
willing to have a crack at doing the donkey work behind the split myself
if time/resource was the main stumbling block).

Failing that, if there's enough interest in getting pygtk included in
the release set, what do people think of the second option?

Regards,

Graham

[1] http://www.gnome.org/start/2.5/modules/

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Python in GNOME Platform Bindings 2.7/2.8?

2004-02-17 Thread Graham Ashton
On Tue, 2004-02-17 at 15:28, Dave Aitel wrote:

 I would be in to help, although I will freely admit that although I am
 am experienced C programmer, I've not written python bindings before.
 - -dave

I'd be up for helping too, but must confess to not having an enormous
amount of free time at the moment.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] multi-line cellrenderertext in C was: Re: VBox in a treeview?

2004-02-17 Thread Graham Ashton
On Tue, 2004-02-10 at 20:10, Abel Daniel wrote:

 I also tried the 'draw a pango layout on the widget' idea, but I
 decided against it. Can't exactly remember why, I think I had problems
 with setting the cell size. You set it to be big enough, right? So
 there will be a varying amount of space below each cell. Doesn't that
 look ugly?

I'm lucky in that I can cheat; all my rows are guaranteed to have the
same number of lines in them. I did notice that the standard text cell
renderer can cope with wrapping lines in rows and not making it look too
awful when I played with it, but I didn't play with it for long so have
no idea if it's nice to interact with.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Tooltips inside a TreeView

2004-02-10 Thread Graham Ashton
On Mon, 2004-02-09 at 21:53, David M. Cook wrote:
 On Mon, Feb 09, 2004 at 11:39:37AM +, Graham Ashton wrote:
 
  I was wondering if it's possible to do row specific tooltips.
 
 See http://bugzilla.gnome.org/show_bug.cgi?id=80980

Thanks for that. I'll see if I can do the nasty workaround for now (I'll
post it here if I have any joy).

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] VBox in a treeview?

2004-02-09 Thread Graham Ashton
On Fri, 2004-01-30 at 15:26, Graham Ashton wrote:
 Hi. I'm trying to put an arbitrary GTK widget inside a treeview cell,
 and am having difficulty finding out how to do it.

Apologies for responding to my own message, but I found a way to achieve
the same result (multi-line text inside a cell) by drawing a pango
layout directly onto the treeview widget. I started from code from Johan
Dahlin;

  http://www.mail-archive.com/[EMAIL PROTECTED]/msg05242.html

and Austin Henry:

  http://www.daa.com.au/pipermail/pygtk/2003-June/005351.html

Thanks very much guys, I'd never have worked it out without that code.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Tooltips inside a TreeView

2004-02-09 Thread Graham Ashton
I was wondering if it's possible to do row specific tooltips.

The Tooltips.set_tip method takes a widget as it's first parameter, so I
was wondering whether or not I'd need to insert an invisible widget
(e.g. EventBox) inside my Treeview somehow.

My other hypothesis involves binding a callback to the mouse movement
signals that works out which row the mouse is currently hovering over
and sets the whole TreeView's tooltip depending on which row it's over.
It's a bit stinky though, and I get the distinct impression that it
might be really hard (hence this message, asking if there's an easier
way).

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] VBox in a treeview?

2004-02-09 Thread Graham Ashton
On Mon, 2004-02-09 at 11:33, Graham Ashton wrote:

 Apologies for responding to my own message, but I found a way to achieve
 the same result...

Just to continue this monologue for a little longer, somebody requested
the code, so here it is...

-- 
Graham Ashton
class ChangeCellRenderer(gtk.GenericCellRenderer):

__gproperties__ = {
'variable': (gobject.TYPE_STRING, 'text', 'variable changed',
 '', gobject.PARAM_READWRITE),
'reason': (gobject.TYPE_STRING, 'reason', 'reason for this change',
   '', gobject.PARAM_READWRITE),
}
property_names = __gproperties__.keys()

def __init__(self):
self.__gobject_init__()

self.xpad = 3
self.ypad = 3

self.xalign = 0.0
self.yalign = 0.5

def __getattr__(self, name):
try:
return self.get_property(name)
except TypeError:
raise AttributeError

def __setattr__(self, name, value):
try:
self.set_property(name, value)
except TypeError:
self.__dict__[name] = value

def do_get_property(self, property):
if property.name not in self.property_names:
raise TypeError('No property named %s' % (property.name,))
return self.__dict__[property.name]

def do_set_property(self, property, value):
if property.name not in self.property_names:
raise TypeError('No property named %s' % (property.name,))
self.__dict__[property.name] = value

def on_render(self, window, widget, background_area,
  cell_area, expose_area, flags):
x_offset, y_offset, width, height = self.on_get_size(widget, cell_area)
width -= self.xpad * 2
height -= self.ypad * 2

layout = pango.Layout(widget.get_pango_context())
list_store = widget.get_model()

if self.reason:
reason = ('span size=smaller%s/span' % self.reason)
else:
reason = ('span size=smaller foreground=#cc'
  'lt;%sgt;'
  '/span' % 'Please assign a reason')

layout.set_markup('span size=smaller weight=bold%s/span\n%s' %
  (self.variable, reason))
layout.set_width(-1)  # turn off wrapping
widget.style.paint_layout(window, gtk.STATE_NORMAL, gtk.TRUE,
  cell_area, widget, 'dummy',
  cell_area.x + x_offset,
  cell_area.y + y_offset,
  layout)

def _get_row_height(self, widget):
layout = pango.Layout(widget.get_pango_context())
layout.set_markup('span size=smallerLine 1\nLine2/span')
pango_scale = 1024  # available as pango.SCALE in more recent pygtk
return (layout.get_size()[1] / pango_scale) + (self.ypad * 2)

def on_get_size(self, widget, cell_area):
calc_width = 200  # randomly picked to be less than treeview width
calc_height = self._get_row_height(widget)

if cell_area:
y_offset = self.yalign * (cell_area.height - calc_height)
y_offset = max(y_offset, 0)
else:
y_offset = self.ypad

x_offset = self.xpad
y_offset = self.ypad
return x_offset, y_offset, calc_width, calc_height


gobject.type_register(ChangeCellRenderer)
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

[pygtk] VBox in a treeview?

2004-01-30 Thread Graham Ashton
Hi. I'm trying to put an arbitrary GTK widget inside a treeview cell,
and am having difficulty finding out how to do it.

Is it possible to put (for example) a VBox with some labels inside it
inside a cell, by writing a GenericCellRenderer?

I've found the info on overriding the on_render() method, but have no
idea how to get that info back into the TreeView via the TreeViewColumn.

Do I need to set the user-data property on the GenericCellRenderer, or
something?

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] ANNOUNCE: Gnome-Python 2.0.0

2003-11-23 Thread Graham Ashton
On Tue, 2003-11-18 at 20:59, Gustavo J. A. M. Carneiro wrote:

   There's an example in the source dist (gnome-python/examples/nautilus),
 or here:
 http://cvs.gnome.org/bonsai/rview.cgi?cvsroot=/cvs/gnomedir=gnome-python/gnome-python/examples/nautilus

Thanks. It does look pretty straightforward. Very pleasing!

Cheers,

Graham

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] ANNOUNCE: Gnome-Python 2.0.0

2003-11-18 Thread Graham Ashton
On Tue, 2003-09-02 at 14:55, James Henstridge wrote:
 Gnome-Python 2.0.0 is now available at:
 http://ftp.gnome.org/pub/GNOME/sources/gnome-python/2.0/
 
 Gnome-Python provides bindings for the Gnome 2.x development platform 
 libraries.  It builds on top of PyGTK, and includes bindings for the 
 following:
 
 [snip]
 * support for writing panel applets and Nautilus views

I'm interesting in checking out how hard it is to write Nautilus views.
Does anybody have any pointers to examples, or info on where I could
start looking?

I've only found one paper on the internals of nautilus so far:

http://developer.gnome.org/doc/whitepapers/nautilus/nautilus-internals.html

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Segfault with get_ancestor()

2002-09-20 Thread Graham Ashton

Hi. I was wondering if anybody could confirm that I'm using the correct
technique to get a widget's parent container (and not necessarily it's
direct container).

My attempt (using get_ancestor()) segfaults if the widget isn't in a
container of the correct type. See below.

Admittedly, I'm slightly out of date; PyGTK 0.6.8 and Python 2.2.

Thanks.

% python
Python 2.2 (#2, Mar 11 2002, 13:24:00) 
[GCC 2.95.3 20010315 (release)] on linux2
Type help, copyright, credits or license for more information.
 import gtk
 e = gtk.GtkEventBox()
 b = gtk.GtkButton('Hello')
 e.add(b)
 b.get_ancestor(gtk.GtkEventBox.get_type())  # works fine
gtk.GtkEventBox instance at 0x8150fc4
 b.get_ancestor(gtk.GtkHBox.get_type())  # incoming...

Gtk-CRITICAL **: file gtkobject.c: line 1161 (gtk_object_ref): assertion
`object != NULL' failed.

Gtk-WARNING **: invalid cast from (NULL) pointer to `GtkObject'

Gtk-WARNING **: invalid cast from (NULL) pointer to `GtkObject'

Gtk-WARNING **: invalid cast from (NULL) pointer to `GtkObject'
Segmentation fault

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Alt + Arrow behaviour

2002-09-12 Thread Graham Ashton

On Tue, 2002-09-10 at 17:58, Christian Reis wrote:
 On Tue, Sep 10, 2002 at 05:39:11PM +0100, Graham Ashton wrote:
  
  The only problem is that every time I press the Alt-arrow combination
  the focus moves around between the various widgets in the interface
  (i.e. just as it normally does).
 
 You'll need to emit_stop_by_name(key_press_event) inside your callback
 if you don't want any other handlers to run. And maybe return gtk.TRUE,
 too; these things are a bit confusing to me still.

It worked a treat, thanks very much.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] How to set background of a label! HELP!!!

2002-07-01 Thread Graham Ashton

On Mon, 2002-07-01 at 01:04, Jacek Pliszka wrote:
 On Sun, 30 Jun 2002, Matt Wilson wrote:
 
 I added event_box as John suggested and background did work.
 
 But foreground does not. Is there a simpl way to do it?

Try this:

http://www.moeraki.com/pygtktutorial/ch-settingwidgetattributes.html#WIDGET_STYLES

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Access to gtk snoop function

2002-06-04 Thread Graham Ashton

On Sun, 2002-06-02 at 06:50, Seth Kurtzberg wrote:
 Does anyone know whether the gtk function:
 
   gtk_key_snooper_install()
 
 is available from within pygtk?

No, it's not. I don't know why. I asked a similar question myself a few
weeks ago (check the archives around May 15th).

 I can add it if necessary; perhaps, though, it is already there and I
 didn't find it? 

I'd happily help you test it (it would be rather useful to me).

Is there any interest from the developers in patches for stuff like
this?

-- 
Graham Ashton [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] small patch for libglade.py

2002-05-30 Thread Graham Ashton

On Thu, 2002-05-16 at 22:42, Charles Waldman wrote:
 
 If you try to do GladeXML(somefile.glade) where somefile.glade
 does not exist or is not readable, you get a WARNING: document is not
 well-formed message.  This error message is misleading; it does not
 lead one to the real cause of the problem.  Hence this trivial patch:
 
 --- libglade.py.orig  Thu May 16 16:32:26 2002
 +++ libglade.py   Thu May 16 16:34:01 2002
 @@ -11,6 +11,8 @@
  class GladeXML(_gtk.GtkData):
   def __init__(self, filename=None, root=None, domain=None, _obj=None):
   if _obj: self._o = _obj; return
 + open(filename, 'r')  ##raises an exception if file does not exist
 + close(filename)   ## or is not readable

I would have thought the intention of the code would be more apparent
(i.e. no need for comment) if you said something like (untested):

  if not os.path.exists(filename):
  raise IOError, No such file or directory: '%s' % filename

In general, if you can re-write your code to make the comment redundant,
it's usually a good idea.

Cheers.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Re: FAQ Question: Snooping keystrokes

2002-05-15 Thread Graham Ashton

On Wed, 2002-05-15 at 13:30, Christian Reis wrote:
 On Tue, May 14, 2002 at 07:43:51PM +0100, Graham Ashton wrote:
  
  I notice that to capture a key press you don't specify
  GDK.KEY_PRESS_MASK, yet you can still connect the window to the
  key_press_event. Why does this work? 
 
 The window widget listens to the key press events by default, so it
 isn't necessary.

Well I thought this might be the case, so I modified my call to
set_events() to be add_events() instead, but still had no joy. I shall
see if I can get to the bottom of it, and if I do I'll post my findings.

Thanks for all the info. I've no idea why get_events() returns 0 on a
realized widget.

  While we're on the subject of key snooping, why doesn't PyGTK have a
  binding to the GTK+ global key snooper, which would surely be a better
  way to do all this? Is it just that nobody needed it?
 
 Global key snooper? What's this?

There's very little documentation on it in the GTK+ reference manual,
but it works. It's called gtk_key_snooper_install():

http://developer.gnome.org/doc/API/gtk/gtk-general.html#GTK-KEY-SNOOPER-INSTALL

-- 
Graham Ashton [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Re: FAQ Question: Snooping keystrokes

2002-05-15 Thread Graham Ashton

On Wed, 2002-05-15 at 13:30, Christian Reis wrote:
 
 Anybody know precisely which widgets lack X windows?

I don't want to keep flogging a dead horse here (especially as John has
already posted the answer), but for reference, I just found them listed
(along with discussion) in the rather excellent PyGTK Tutorial (about
half way down the page):

  http://www.moeraki.com/pygtktutorial/sec-eventhandling.html

-- 
Graham Ashton [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Re: FAQ Question: Snooping keystrokes

2002-05-14 Thread Graham Ashton

On Tue, 2002-05-14 at 16:08, Christian Reis wrote:
 On Sun, May 12, 2002 at 02:56:30AM -0400, Evan Hughes wrote:
 
How can I detect whenever the user hits a key or moves the mouse?
 
 Added FAQ questions 3.2, 3.3 and 3.4:
 
 http://www.async.com.br/faq/pygtk/index.py?req=index

Very nice, thanks. Is it okay for anybody (who's confident of the
answer) to update the FAQ with the wizard, or are there a few people who
take responsibility for keeping it current?

I ask because there is a bug in the example code in 3.2; the print
statement in wakeup() has bad variable substitution formats in it. This
would do nicely (for PyGTK 0.6.x):

def wakeup( widget, event, *args ):
print Event %d woke me up % event.type

I think that question 3.3 might benefit from a link to the GtkEventBox
widget too, incase people are trying to bind events to a widget that
doesn't have it's own X window.

I notice that to capture a key press you don't specify
GDK.KEY_PRESS_MASK, yet you can still connect the window to the
key_press_event. Why does this work? 

My reading of the docs lead me to believe that you need to do this:

w.add_events(GDK.KEY_PRESS_MASK)

in order to get

w.connect(key_press_event, wakeup)

to work at all (but I've tested your example, and it works -- mine
doesn't, see below). There's a more explicit example here (the fact that
nobody replied made me wonder if it was just me that was confused):

  http://www.daa.com.au/pipermail/pygtk/2002-May/002757.html

While we're on the subject of key snooping, why doesn't PyGTK have a
binding to the GTK+ global key snooper, which would surely be a better
way to do all this? Is it just that nobody needed it?

-- 
Graham Ashton [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Handling events with GtkEventBox

2002-05-02 Thread Graham Ashton

Hi.

I'm trying to handle key_press_events for widgets that don't have their
own GdkWindow (e.g. a GtkLabel).

The following snippet of code attempts to capture mouse clicks and key
presses on the label, by wrapping the label in a GtkEventBox. It works
with the button_press_event, but not the key_press_event.

import gtk, GDK

window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)

label = gtk.GtkLabel()
label.set_text(Press a key, any key...)

ebox = gtk.GtkEventBox()
ebox.add(label)
ebox.set_events(GDK.KEY_PRESS_MASK | GDK.BUTTON_PRESS_MASK)
ebox.connect(button_press_event, gtk.mainquit)
ebox.connect(key_press_event, gtk.mainquit)
ebox.realize()

window.add(ebox)
window.show_all()
gtk.mainloop()

I'm fairly new to this, am I doing anything wrong? I'm using PyGTK 0.6.8
on Python 2.2.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] Memory usage question

2002-05-01 Thread Graham Ashton

On Wed, 2002-05-01 at 02:07, James Henstridge wrote:

 I've been experimenting with libglade from Python, and have found that I
 can use up an awful amount of memory incredibly quickly by destroying
 and re-creating widgets. I've written a small script that demonstrates
 it.

 If you could run this under memprof to see which allocations are using 
 the most memory?

Thanks for the reply.

I've downloaded memprof. Can you give me some pointers on what to do
with it and what should I look for? (I can execute my script from
memprof okay, but I'm not sure what to look out for)

 What if you change the labe.destroy() calls to this?: vbox.remove(label)

No change, unfortunately. It eats approximately 1MB per second.

 If you feel like it, you could also try the latest pygtk 1.99.x release 
 to see if it has the same problem (much of the code has been rewritten 
 for the 2.0 release of both pygtk and libglade).

I will definitely be having a look at that at some point, but for the
moment I have to stick with the old versions as porting the rest of our
code base over to 2.0 would be a big job.

How solid are the 2.0 python bindings, in comparison to the older
versions?

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Memory usage question

2002-04-30 Thread Graham Ashton

Hi.

I've been experimenting with libglade from Python, and have found that I
can use up an awful amount of memory incredibly quickly by destroying
and re-creating widgets. I've written a small script that demonstrates
it.

There is a small window with a label and a button on it. When you click
the button the label gets replaced repeatedly with a new copy. It's the
while loop in the recreate_label() function that does the replacement,
and causes the memory gobbling.

#!/usr/bin/env python
#
# $Id$


import gtk, libglade, time


def recreate_label(signal, label, vbox):
label.destroy()
while 1:
wtree = libglade.GladeXML(project1.glade, label)
label = wtree.get_widget(label)
vbox.pack_start(label)
vbox.reorder_child(label, 0)
label.destroy()


if __name__ == __main__:
wtree = libglade.GladeXML(project1.glade, window1)
window = wtree.get_widget(window1)
button = wtree.get_widget(button)
button.signal_connect(clicked, recreate_label,
  wtree.get_widget(label),
  wtree.get_widget(vbox1))
window.show()
gtk.mainloop()

If anybody would like the Glade file that goes with it to play around,
drop me a line and I'll post it. It's only short.

So my question is - am I doing something wrong (most likely), or is this
a leak? I'm using the latest stable pygnome (i.e. on GNOME 1.4), with
Python 2.2, all compiled from source.

Thanks.

-- 
Graham Ashton

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] The right widget (for arranging graphics)

2002-02-26 Thread Graham Ashton

On Mon, Feb 25, 2002 at 10:59:14AM +0100, Johan Dahlin wrote:
 m?n 2002-02-25 klockan 03.26 skrev Graham Ashton:
  
  If I want to arrange these thumbnails in a grid of image previews
  (similar to the way Nautilus arranges preview images when in View as
  Icons mode),
 
 GnomeCanvas is a complicated, but has a lot of features.  I'm not sure
 how much features you want from the widget but GnomeIconList might work
 for you.

Looks good - I'll have a play with it and see if it does the job.

Thanks for the tip.

-- 
Graham Ashton [EMAIL PROTECTED]
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



[pygtk] Problems building gnome.applet

2001-05-25 Thread Graham Ashton

I'm trying to get up and running developing GNOME applets with Python and
am having problems building in support for gnome.applet, which doesn't
actually get built. 

In short, I think I'm missing libraries and am wondering if anybody knows
which package I should install.

I'm compiling gnome-python-1.4.1 on an unstable Debian box, with the
Ximian GNOME Debian packages and built python 2.1 from source. I'm not
convinced it's a Ximian packaging problem as I scoured the ftp.gnome.org
sources directory for packages that look related and didn't find anything.

Here is a snippet of output from a fresh run of gnome-python's ./configure
that illustrates the problem:

checking for GTK - version = 1.2.6... yes
checking for imlib-config... /usr/bin/imlib-config
checking for IMLIB - version = 1.8.2... yes
checking for gnome-config... /usr/bin/gnome-config
checking if /usr/bin/gnome-config works... yes
checking for orbit-config... /usr/bin/orbit-config
checking for orbit-idl... /usr/bin/orbit-idl
checking for working ORBit environment... yes
checking for gnorba libraries... yes
checking extra library applets... Unknown library `applets'

checking extra library capplet... -rdynamic -lcapplet -lgnomeui
-lart_lgpl -lgdk_imlib -lSM -lICE -lgtk -lgdk -lgmodule -lXi -lXext -lX11
-lgnome -lgnomesupport -lesd -laudiofile -ldb -ldl -lORBitCosNaming
-lORBit -lIIOP -lORBitutil -lglib -lm -lgnorba
checking for libglade-config... /usr/bin/libglade-config
checking for libglade... yes

I've been unable to find any GNOME applet library anywhere, much to my
frustration! The capplet stuff is there, but I don't think that's related.

Can anybody point me in the right direction? All the non-applet 
pygnome/examples/ run fine. Any pointers would be much appreciated.

delboy% python
Python 2.1 (#6, May 21 2001, 13:28:32) 
[GCC 2.95.3 20010315 (Debian release)] on linux2
Type copyright, credits or license for more information.
 import gnome
 import gnome.ui
 import gnome.applet
Traceback (most recent call last):
  File stdin, line 1, in ?
ImportError: No module named applet
 

-- 
Graham Ashton
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk