Re: [pygtk] multiple inheritance not possible with ExtensionClass?

2001-05-04 Thread James Henstridge

On Fri, 4 May 2001, Prabhu Ramachandran wrote:

> I was wondering if you should use something like Boost.Python instead
> of the Zope ExtensionClasses.  Boost.Python is very easy to use and
> doesn't have these problems with multiple inheritance.  Boost.Python
> is supposed to be easier to use than the ExtensionClass approach.
> Problem with boost is that it does require a rather ISO compliant c++
> compiler (but it does work with g++ 2.95.2).  Look here for details:
>
>  http://www.boost.org
>
>  http://www.boost.org/libs/python/doc/index.html
>
> Specifically for a comparison between boost and other systems look
> here
>
>   http://www.boost.org/libs/python/doc/comparisons.html

This doesn't look like it would help for pygtk.  PyGTK is not wrapping C++
classes -- it is all C code.  I have already written the code to interface
with the GObject system, and have a code generator to take care of most of
the binding.

James.

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



Re: [pygtk] multiple inheritance not possible with ExtensionClass?

2001-05-03 Thread James Henstridge

On Thu, 3 May 2001 [EMAIL PROTECTED] wrote:

>
> The following simple multiple inheritance hierarchy works fine:
>
> class A:
>   def __init__(self,v):
>   print "A init, v ==", v
>
> class B:
>   def __init__(self,v):
>   print "B init, v ==", v
>
> class C(A,B):
>   def __init__(self,v):
>   A.__init__(self, v)
>   B.__init__(self, v)
>
> c = C("qqq")
>
> However, if you change the definition of class C to
>
> class C(gtk.GtkButton,B):
>   def __init__(self,v):
>   gtk.GtkButton.__init__(self)
>   B.__init__(self, v)
>
> instantiating C leads to
>
> Traceback (most recent call last):
>   File "chk.py", line 17, in ?
>   c = C("qqq")
>   File "chk.py", line 15, in __init__
>   B.__init__(self, v)
> TypeError: unbound method __init__() must be called with instance as first 
>argument
>
> I guess this means multiple inheritance (and thus mixin capability) is not
> possible with subclasses of ExtensionClass objects.  Am I going to have to
> inject mixin methods into GtkObject to make them available?

I guess this is another place where ExtensionClass doesn't quite fit
correctly.  The two solutions I can see are:
  1) call "B.__dict__['__init__'](self, v)", so the type check on the
 first argument is not performed.

  2) Make your mixin a subclass of ExtensionClass.Base

Python would need to change a little for this to work without a hack :(
You can see the difference with this simple example:

>>> class A:
... def method(self):
... pass
...
>>> class B(ExtensionClass.Base, A):
... pass
...
>>> A.method

>>> B.method

>>> A.method(a)
>>> A.method(b)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: unbound method must be called with class instance 1st
argument
>>> B.method(b)
>>>

Note that mixins without constructors should work without problem.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] python-gtkhtml & Debian?

2001-05-02 Thread James Henstridge

On 2 May 2001, Tom Cato Amundsen wrote:

> I did also talk with the python-gnome maintainer, and I'm sure he will
> build the gtkhtml
> bindings as soon as gdk-pixbuf is patched.
>
> Regarding libtools-1.4, it has not yet hit unstable, so this might take
> a few weeks...

Given that libtool is included in the source package, it shouldn't matter
when various distros start packaging libtool.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] python-gtkhtml & Debian?

2001-05-01 Thread James Henstridge

On 2 May 2001, Tom Cato Amundsen wrote:

> On 01 May 2001 21:11:11 +0100, David Given wrote:
> > Are there any plans underway to Debianise the python-gtkhtml bindings? I need a 
>decent HTML renderer
> > (i.e., not GtkXmHTML) for my mailer app; unfortunately, because I'm targetting the 
>app for a Debian
> > package, I can't make it depend on the user compiling anything. All functionality 
>has to be available
> > from other Debian packages.
> >
> I did bug the libgdk-pixbuf2 maintainer, the bug report number is #86401.
> If you are a little more tecnical than me (I'm just a music teacher), you
> should try to talk to him. Redhat did patch python, but I think the correct
> thing is to patch libgdk-pixbuf2.

I just emailed Federico about the dynamic loading problem with gdk-pixbuf,
with a pointer about using libtool-1.4 to fix it.  So there may be an
official gdk-pixbuf version in the future without the problems.

I can't really help with the debian packaging of gtkhtml issue though :)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] How to disable the focus for buttons?

2001-05-01 Thread James Henstridge

On Tue, 1 May 2001, Carsten Roedel wrote:

> Hello,
> I am using pygtk for quite a while now and it did exceed my expectations
> by far. Good job James! However, I do have a question about the focus
> (rectangle) drawn arround buttons in general. Drawing a focus for entry
> widgets (like text) is reasonable, but for my taste, a focus for buttons
> is more in the way then helpful. I understand if this is a GTK problem,
> however, here is the question. How do I disable or UNSET the focus for
> buttons? I tried not to set CAN_FOCUS, but it doesn't seem to have an
> effect:
>
> button = GtkButton(title)
> self.pack_start(button, FALSE, FALSE)
> #button.set_flags(None) #CAN_FOCUS
> button.set_usize(-1, -1)
> button.set_relief(RELIEF_NONE)
> button.connect("clicked", self.button_click_event, handler)
>
> Is there a 'set_flag(DONT_FOCUS)' or any other way to unset it?

You are looking for the following:
  button.unset_flags(CAN_FOCUS)

It sounds like your problem is more with the theme, rather than the
ability to focus the button.  If this is the case, maybe you should should
try using a different theme (you could try the Raleigh theme, which is
quite similar to the new default theme that is in the development branch
of gtk).  Making the button unfocusable will probably also make it
impossible to get to the button via keyboard navigation.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] examples of gtk new tree/list widget stuff?

2001-04-25 Thread James Henstridge

On Wed, 25 Apr 2001 [EMAIL PROTECTED] wrote:

>
> Are there any readable examples of the new gtk tree/list stuff floating
> around?  The gtk/tests/testgtk.c files still uses the old stuff and the
> various gtk/tests/testtree*.c files don't really qualify as "readable",
> especially since I have no mental model of how this is supposed to work.
> Initially, I'm not interested in all the fancy bells and whistles these
> widgets support.  I just want to create a single-column list and add and
> remove items from it.  Python or C is fine.

Take a look at the create_list() function in
examples/pygtk-demo/pygtk-demo.py distributed with pygtk.  It creates a
simple list using the tree widget.

The basic model for using the new widget is something like this:

- create a GtkTreeModel.  The GtkListStore and GtkTreeStore are two
  models you might want to use.

  A model consists of a tree (or in the degenerate case, a list) of nodes.
  Each node has a number of columns.

- Create one or more GtkTreeView widgets.  These are views of the model.

- add GtkTreeViewColumn objects to the views.  You need to specify a
  GtkCellRenderer object for each TreeViewColumn.  The cell renderer uses
  a number of properties to render a cell in the view (such as the text to
  display, foreground and background colours, etc).  Each of these
  properties can be mapped onto a column in the model (so for instance,
  you could have a model that had one column that gave the text to display
  in the view, and one column to give the foregeround colour).

Hopefully this is enough to get started with the tree widget.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



[pygtk] ANNOUNCE: pygtk-0.6.8 and gnome-python-1.4.1

2001-04-23 Thread James Henstridge

I have just uploaded new versions of pygtk and gnome-python.  Pygtk will
be available at:
  ftp://ftp.gtk.org/pub/gtk/python/pygtk-0.6.8.tar.gz (when it gets moved)

And gnome-python is available at:
  ftp://ftp.gnome.org/pub/GNOME/stable/sources/gnome-python/gnome-python-1.4.1.tar.gz

I will also upload these to ftp.python.org.  Here is some of the news
items for pygtk (although it is not exhaustive):
- bug fixes to GtkNotebook, GtkCList.
- add some missing methods to GtkWidget
- a gdk-pixbuf wrapper module.
- install the code generator, so that other wrappers can use
  it as well.

And for gnome-python:
- updates to gtkhtml widget.
- pygtk updates (gdkpixbuf module, various bug fixes, install
  code generator).
- updated spec file to separate out devel portion of package.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] deriving classes from gtk.py

2001-04-22 Thread James Henstridge

On 22 Apr 2001, Bernhard Herzog wrote:

> Well, the ExtensionClass docs contain the following example, which is
> actually a bit different (i.e. I did not remember correctly) from the
> situation above (taken from the ExtensionClass.stx that comes with Zope
> 2.3.0:
>
>   from ExtensionClass import Base
>
>   class Spam:
>
> def __init__(self, name):
> self.name=name
>
>   class ECSpam(Base, Spam):
>
> def __init__(self, name, favorite_color):
> Spam.__init__(self,name)
> self.favorite_color=favorite_color
>
> and the docs go on to say:
>
> This implementation will fail when an 'ECSpam' object is
> instantiated.  The problem is that 'ECSpam.__init__' calls
> 'Spam.__init__', and 'Spam.__init__' can only be called with a
> Python instance (an object of type '"instance"') as the first
> argument.  The first argument passed to 'Spam.__init__' will be an
> 'ECSpam' instance (an object of type 'ECSPam').
>
> So at least mixin classes are a bit of a problem with ExtensionClasses
> (there's a solution to the problem given in the docs, however). It may
> well be that with Python 2.0 this is not an issue anymore.

This won't affect pygtk.  GtkWidgets won't work if you don't chain to
their constructor anyway, so I don't think this will be a problem.  This
hasn't been an issue with any of the examples I have tested.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Re: [pygtk] queue draw area?

2001-04-22 Thread James Henstridge

> > In other words, if I only update a small piece of the pixmap, is there
> > any way to synthesize the expose event to tell it to only update the
> > drawingarea from that small piece?

I have added the queue_draw_area() method to pygtk in CVS, so it should be
in the next release (along with a gdkpixbuf module and some other misc bug
fixes).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GtkHTML

2001-04-19 Thread James Henstridge

On 19 Apr 2001, Rob Brown-Bayliss wrote:

> > > Also, is there a python binding to Gecko from the mozilla project?
> >
> > See the pygme module in GNOME CVS.
>
> I grabbed pygme from the cvs, and it compiled and installed without
> error, only the test prog that came with it fails with an import error
> saying it cant find libgtkembedmoz.so yet as far as I can tell it had to
> have found this to build?
>
> I do have the file having installed the mozilla-devel rpm...
>
> Has any one had a go at this?  Could it be the famous redhat 7 compiler
> perhapse?

The readme file says there are a few environment variables you need to
set.  If libgtkmozembed.so is not in you library path, you will need to
set LD_LIBRARY_PATH to the directory where it is.  I think you will also
need to set MOZILLA_FIVE_HOME.

James.

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



Re: [pygtk] GtkHTML

2001-04-18 Thread James Henstridge

On 18 Apr 2001, Rob Brown-Bayliss wrote:

> On 02 Apr 2001 19:25:38 -0400, Jonathan LaCour wrote:
> > I would like to use the GtkHTML widget to create a simple editable text
> > space that can use HTML styles.  Is this possible?  I know that Ximian
> >
>
> Also, is there a python binding to Gecko from the mozilla project?

See the pygme module in GNOME CVS.

James.

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



Re: [pygtk] Memory usage

2001-04-18 Thread James Henstridge

On 18 Apr 2001, Rob Brown-Bayliss wrote:

> Hi,
>
> I am wondering about memory usage of python modules and pygtk objects.
>
> I have a little app that loads modules into memory to be used, and most
> of these load gtk widgets onto a notebook page.
>
> My app hides the notebook tabs, basically it looks and acts like the
> gnome control-center.
>
> Should I destroy the pages after use, currently I keep them as I expect
> the user to come back to them over and over, but I guess some could be
> used once and kept in memory for some time.
>
> Is it worth it to destroy the page?  most will only have a dozen or 20
> widgets...

If you remove the widget from the container, and don't retain any
references to it, the widget should get destroyed.

James.

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



Re: [pygtk] GnomeDocks

2001-04-18 Thread James Henstridge

On 18 Apr 2001, Rob Brown-Bayliss wrote:

> Hi
>
> I am trying to swap the toolbars in a gnome app and libglade.
>
> I have my toolbar from the glade file, and the dock to contain it.  The
> dock is empty so I do:
>
> Dock.append(toolbar,0)
>
> but this is giving me an error, I guess it's to do with the offset which
> I don't understand, from gnome/ui.py under GnomeDockBand
>
> def append(self, child, offset):
>   return _gnomeui.gnome_dock_band_append(self._o, child._o,
>  offset)
>

You can add GnomeDockItems to the GnomeDock with the add_item() method.
You don't usually have to play around with GnomeDockBands.

James.

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



Re: [pygtk] from gtk import *

2001-04-18 Thread James Henstridge

On Wed, 18 Apr 2001, Skip Montanaro wrote:

>
> James> I have no idea about this one.  "from gtk import *" works fine on
> James> my system (python 2.0, cvs glib,pango,gtk+):
>
> Try it with python 2.1... ;-)

Hmm.  They changed the meaning of the __all__ attribute for packages in
python 2.1.  It used to be for listing just modules contained in the
package.  Now it says that it lists all symbols exported by the package on
"from ... import *".

I guess you could try commenting out the __all__ declaration.

grumble.

James.

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



Re: [pygtk] from gtk import *

2001-04-18 Thread James Henstridge

On Wed, 18 Apr 2001, Skip Montanaro wrote:

>
> James> I have no idea about this one.  "from gtk import *" works fine on
> James> my system (python 2.0, cvs glib,pango,gtk+):
>
> Try it with python 2.1... ;-)

Didn't realise it had been released (and released on my birthday :).

/me checks release notes to find what could be causing the problem

James.

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



Re: [pygtk] GtkItemFactory interface change?

2001-04-18 Thread James Henstridge

On Wed, 18 Apr 2001, Skip Montanaro wrote:

> In examples/neil/TAppli.py it creates an item factory thus:
>
> itemf = gtk.GtkItemFactory(gtk.GtkMenuBar, "", ag)
>
> This call fails under pygtk2, complaining that the first arg is supposed to
> be an integer.  After a little muddling around I found the __gtype__
> attribute of GObjects.  On more-or-less of a whim I tried modifying the
> above to
>
> itemf = gtk.GtkItemFactory(gtk.GtkMenuBar.__gtype__, "", ag)

I have been fiddling round with the handling of typecodes (and haven't
finished fiddling).  I will probably modify the code generator so that
functions expecting a GType argument will either accept an integer or an
object with a __gtype__ attribute.

>
> After making a couple other unrelated changes, this script seems to work
> (changes appended).  I worry about referencing the __gtype__ attribute
> directly, but didn't see any sort of "get_type" method.  Am I missing
> something?

I used to have get_type() functions to get the typecode, but switched over
to __gtype__ attributes.  For the classes in the gtk module, the __gtype__
attributes are of a special type that doesn't call the C level get_type()
function til it is needed.  This delays registration of the types until
they are needed.

Soon I will have support for creating new GTypes for user defined classes,
which will just set an integer as the __gtype__ attribute.  The code would
look something like this:
  class MyClass(gobject.GObject):
def __init__(self):
# can't chain up to parent class, or we would end up
# wrapping a GObject of the parent type.
self.__generic_init__()
  gobject.register_type(MyClass)

You could then add signals to MyClass, without them being added to the
parent class.

>
> On an unrelated note, I think standard practice should be to use "import
> gtk", not "from gtk import *", if for no other reason than that the gtk
> module defines the names TRUE and FALSE, which are fairly easy to clash
> with.

In all my new examples (see examples/pygtk-demo for one), I use "import
gtk".  By the time I have a stable 2.0 binding, I plan to have converted
all examples over to using "import gtk".  I recommend using "import gtk"
when people ask.

James.

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



Re: [pygtk] from gtk import *

2001-04-18 Thread James Henstridge

On Wed, 18 Apr 2001, Skip Montanaro wrote:

> James,
>
> In the April 8th snapshot, "from gtk import *" seems to only support the
> symbols GTK, GDK and _gtk.  This is no problem for me, but some of the
> examples fail to work.  Do you want patches against them that do the right
> thing?  Example:
>
> % cd examples/neil
> % python TAppli.py
> settings-notify: bell-percent = "80.00"
> settings-notify: bell-duration = "250"
> settings-notify: bell-pitch = "440"
> Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY
>   UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES.
>   if you don't know why you are getting this, you probably want to
>   use the stable branch which can be retrived from
>   ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with
>   cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+
> Traceback (most recent call last):
>   File "TAppli.py", line 138, in ?
>   app=Application(sys.argv)
>   File "TAppli.py", line 13, in __init__
>   self.w_window=GtkWindow()
> NameError: global name 'GtkWindow' is not defined

I have no idea about this one.  "from gtk import *" works fine on my
system (python 2.0, cvs glib,pango,gtk+):

Python 2.0 (#1, Nov 28 2000, 14:16:13)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> from gtk import *
settings-notify: bell-percent = "80.00"
settings-notify: bell-duration = "250"
settings-notify: bell-pitch = "440"
Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY
UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES.
if you don't know why you are getting this, you probably want to
use the stable branch which can be retrived from
ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with
cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+
>>> GtkWindow

>>>


James.

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



Re: [pygtk] deriving classes from gtk.py

2001-04-17 Thread James Henstridge

On 11 Apr 2001, Bernhard Herzog wrote:

> Skip Montanaro <[EMAIL PROTECTED]> writes:
>
> > Tim> hi,
> > Tim> i'd like to use pygtk widget classes as base classes to my own, like
> >
> > Tim> class myVBox (GtkVBox):
> > Tim>   ...
> >
> > Tim> now if i understand correctly, the python wrapping code in gtk.py
> > Tim> is planned to be rewritten in c. will this break code like above?
> >
> > I believe it should work.  The new version uses Digital Creations'
> > ExtensionClass to allow objects to be subclassed in Python.
>
> However, IIRC, calling a baseclass' method in a method has to be done
> slightly different. E.g.
>
> class MyBox(GtkBaseClass):
>
> def __init__(self):
> GtkBaseClass.__init__(self)

This works with ExtensionClass.  ExtensionClass is designed to create
types that act as much like python classes as possible, so it would be a
bug if this didn't work.

>
>
> will fail because type(self) isn't InstanceType. James pointed out some
> other pifalls in
> http://www.daa.com.au/pipermail/pygtk/2000-June/000104.html

The isinstance and issubclass functions were fixed in python 2.0 to work
with `class like' and `instance like' objects, rather than just class and
instance objects.  There are still a few problems but they haven't caused
any problems in the tests I have done so far (I think coercions still
special case InstanceType, but I don't think people will be coercing
widgets much :)

>
> AFAIK, the reason to use ExtensionClasses in the first place was to make
> sure that there is exactly one pygtk object for every GTK widget.
> Without ExtensionClasses you get circular references. In Python 2.1
> there'll be weak references which would provide a solution for this
> problem. Wouldn't it make more sense to rely on that?

Doing the 1-1 wrapper/object mapping was one of the reasons for changing.
Other reasons were making code generation easier, reducing memory usage
(due to removing one layer from the binding), and speed increase (startup
time is less because there is less python code to parse when importing
gtk).

The 2.1 weak references will help with the wrapper/object mapping circular
reference problem (I currently have an evil hack in gobjectmodule.c to get
the desired behaviour :).  Just remember that this wasn't the only reason
for using ExtensionClass.

James.

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



Re: [pygtk] GTKExtra for win32

2001-04-17 Thread James Henstridge

On Wed, 11 Apr 2001, Piotr Legiecki wrote:

> Hi
>
> I'v just installed python 2.0 for win32 and pygtk for win32. It seems to
> work now.
>
> I want to write easly portable program in python, but it is rather
> difficult anyway. I'd like to use some extra (GtkExtra) widgets with
> python, and it is possible only under linux. There is no easy way to
> make it work under win32.
>
> So may questions are:
> - is there port of GtkExtra for win32?
> - is there port of python bindings for GtkExtra for win32?
>
> Under w98 I even couldn't run testgtk.py (from pygtk examples) because
> of lack of GtkEXtra ;-(. Well, don't you think, that there is something
> missing in this portability problem?
>
> BTW. From pygtk examples I was able ro run all *2.py programs (ie
> hello2.py) but not *1.py (ie hello1.py). The error was: unable to find
> DLL... Is it normal? I use gtk dlla from the latest port of gimp1.2 for
> win32 (they are 1.3 gtk=unstable - why?).

The GtkExtra.py file should have come with pygtk.  It is not related to
the GtkExtra package (gtkextra.sourceforge.net or something), but just
contains some convenience functions I wrote while developing pygtk.  I
don't know why you don't have a copy of it.  I don't really recommend
people use those convenience functions in their own apps though.  The
MenuFactory stuff is superceded by GtkItemFactory (found in the gtk
module), and the dialog stuff is not implemented that well.

As for why the win32 dlls are marked as version 1.3, the reason is that
there has never been a stable 1.2 release of gtk for windows.  The version
used for the gimp port is based on an early snapshot of the 1.3 branch
(before the incompatible changes).

James.

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



Re: [pygtk] gdk-pixbuf bindings

2001-04-17 Thread James Henstridge

On 7 Apr 2001, John Fremlin wrote:

> Is anybody working on them? Would they be accepted into gnome-python?

I have some half complete bindings in CVS right now, and they will be in
the next release.

James.

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



Re: [pygtk] How to create a menu ?

2001-04-17 Thread James Henstridge

On Tue, 3 Apr 2001, Andre Luis Lopes wrote:

> Hi all
>
>I'm trying to create a menu for my application with tje following code :

1) Create a GtkMenuBar widget
2) add GtkMenuItem widget to menubar
3) create GtkMenu widget
4) use menuitem.set_submenu(menu) to associate the menu with the menuitem
5) create GtkMenuItems and add them to the GtkMenu

Alternatively you can use the GtkItemFactory object, which does all this
for you.

Take a look at some of the examples distributed with gtk for details.

James.

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



Re: [pygtk] GtkHTML

2001-04-17 Thread James Henstridge

On 2 Apr 2001, Jonathan LaCour wrote:

> I would like to use the GtkHTML widget to create a simple editable text
> space that can use HTML styles.  Is this possible?  I know that Ximian
> Evolution uses GtkHTML as the editor widget for the composer.  Can I
> utilize this functionality from python?  If not, are there plans for
> such bindings?

I haven't done the bindings for the GtkHTML interfaces used for editing
yet (they aren't the cleanest interfaces I have seen).  I am taking
patches though :)

James.

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



Re: [pygtk] new pygtk for gtk 2.0 snapshot

2001-04-17 Thread James Henstridge

On Tue, 17 Apr 2001, Skip Montanaro wrote:

> 
> James> This is a known problem or modify python to pass the
> James> RTLD_GLOBAL flag when dlopen'ing extensions.
> 
> James> The second option is easier (Red Hat has a patch to do it in
> James> their python rpms), 
> 
> Any pointers to RedHat's RTLD_GLOBAL patch would be appreciated.  I couldn't
> find it via their search mechanisms.

Don't have an exact reference (the patch is probably in their source
rpms).  The change is very simple.  Just edit Python/dynload_shlib.c, and
find the call to dlopen close to the bottom of the file.  The second
argument to dlopen() is a set of flags.  You can just or RTLD_GLOBAL
against the flags.  That is, changing the line:
handle = dlopen(pathname, RTLD_NOW);
to:
handle = dlopen(pathname, RTLD_NOW | RTLD_GLOBAL);

(there is no reason to change the second dlopen call, as Linux systems
have the RTLD_NOW flag).

The effect of this is that loaded extension modules can see each other's
symbols (plus the symbols of any other libraries pulled in by shared
library dependencies).  This could potentially cause symbol conflicts, but
in practice doesn't cause problems very often (most extensions only export
a single function -- the initmodulename() function.

I have some patches that fix the dynamic dependencies in glib, pango and
gtk+ (the gtk+ patch still isn't perfect -- the depdendencies for the
gdk-pixbuf modules are not quite right yet).  They make use of
features in libtool-1.3d (a beta release of 1.4).  You can find the
current set of patches attached to this bugzilla bug:
  http://bugzilla.gnome.org/show_bug.cgi?id=50707

At the moment, it is probably easier to patch python rather than 
gtk.  Owen says he doesn't want to switch the official gtk packages to the
newer libtool until libtool-1.4 is released.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GdkEvent and right button

2001-04-15 Thread James Henstridge

On Sun, 15 Apr 2001, David Robertson wrote:

> 
> First off, thanks for the help on GtkTree. I switched to a 1 column GtkCTree
> and made it work well.
> 
> On to the new problem:
> 
> glib 1.2.8
> gtk 1.2.8
> python 1.5.2
> 
> I am trying to figure how to check if the right mouse button is pressed
> using:
> GdkEvent.type
> 
> here is what I get:
> left mouse button pressed = 4
> left mouse button released = 7
> right mouse button pressed = 4
> right mouse button released = 7
> (whick in GDK.py means button pressed and released)

A button_press_event will be emitted when any button is pressed.  Look at
event.button to see the number of the button pressed.  1 is left and 3 is
right.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] unset buttons of a druid

2001-04-15 Thread James Henstridge

On Sun, 15 Apr 2001, christian folini wrote:

> Hi there,
> 
> i want to hide the back and the next button of a gnome druid.
> This works well with
>
> druid.set_buttons_sensitive(FALSE, ...
> 
> Now the problem arises, when i click the next button to get to the
> next page. The back button is set. This is tolerable, but after
> moving back to the first page using this button, the 'back'-button
> on the first page has reappeared. 
> 
> So how to you control your buttons efficiently. Do you follow
> the flow of the druid with signals emitted?
> 
> any help would be appreciated.

Are you using a GnomeDruidPageStart as the first page of your druid?  If
you are, then the sensitivity of the back button should be taken care of
for you here.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GtkTree?

2001-04-13 Thread James Henstridge

On 13 Apr 2001, Rob Brown-Bayliss wrote:

>  
> > The CTree widget can do everything Tree does, and is less broken.
> 
> Hi, I have seen several people in this list mention that the Tree widget
> is broken, and the CTree also broken, but less broken
> 
> How do you define broken in this case?  Could some one highlight the
> problems for me?

in some cases, GtkTree stops redrawing correctly (and the expanders stop
working when this happens), and the GtkTree widgets don't really act like
widgets when they are not the root of the tree.

> 
> Also, I would like to set the background of a GtkCtree to white, but
> cant seem to make it work.

Modify your gtkrc file so that the bg[PRELIGHT] for the style applied to
CTrees widget.

Programatically, this would be something like:
  style = ctree.get_style().copy()
  style.bg[STATE_PRELIGHT] = ctree.get_colormap().alloc('white')
  ctree.set_style(style)

But this will make things look weird in some themes, so it is usually
better to modify the theme colours.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] new pygtk for gtk 2.0 snapshot

2001-04-12 Thread James Henstridge

On Thu, 12 Apr 2001, Skip Montanaro wrote:

> 
> James> I put together a new snapshot while at GUADEC ...
> 
> Thanks very much.  I found it and it installed just fine.
> 
> James> It will work fine with the glib/gtk+ 1.3.3 releases (along with
> James> whatever version of pango was released at the time).
> 
> I'm having a bit of a problem with pango.  The following simple script gets
> a number of GRuntime-CRITICAL errors, then repeatedly tries to open
> /usr/local/lib/pango/modules/pango-basic-x.so.la, which fails, finally
> terminating with a floating point exception:
> 
> import gtk
> win = gtk.GtkWindow()
> t = gtk.GtkTextView()
> win.add(t)
> win.connect("destroy", gtk.mainquit)
> win.show_all()
> gtk.mainloop()
> 
> Does it run for you?  If so, I have some config problems.  If not, perhaps
> there is something wrong with pango and/or glib and/or libtool.

This is a known problem.  You have to either have to modify the pango and
gtk+ makefiles and build with cvs or 1.3d libtool so that all the pango,
gdk-pixbuf and input method modules have correct dependencies, or modify
python to pass the RTLD_GLOBAL flag when dlopen'ing extensions.

The second option is easier (Red Hat has a patch to do it in their python
rpms), but the first is probably the correct fix.  I talked with the gtk+
maintainers at GUADEC, and they don't want to rely on the beta version of
libtool in the official packages.  Hopefully libtool 1.4 will be released
soon though.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] pygtk and python 2.0

2001-04-12 Thread James Henstridge

On Thu, 12 Apr 2001, Piotr Legiecki wrote:

> Hi. I'm using debian (unstable) and pygtk 0.6.6. I have both python 1.5
> and python 2.0 (as python2) installed and noticed that testgtk.py (from
> examples directory) shows me a warning:
> 
> piotrlg@xunil:/usr/share/doc/python-gtk/examples/testgtk$ python2
> testgtk.py 
> WARNING: Python C API version mismatch for module _gtk:
>   This Python has API version 1009, module _gtk has version 1007.
> Hello

You compiled pygtk against 1.5 headers, and are using it with 2.0.  This
would happen with any other python module you happened to compile this
way.

You should recompile pygtk with the 2.0 headers.  If the python executable
is not python 2.0, you can use the following:
  PYTHON=`which python2` ./configure --prefix=/pythons/prefix
  make

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] deriving classes from gtk.py

2001-04-12 Thread James Henstridge

On Wed, 11 Apr 2001, Tim Goetze wrote:

> hi,
> 
> i'd like to use pygtk widget classes as base classes to my own, like
> 
> class myVBox (GtkVBox):
>   ...
> 
> now if i understand correctly, the python wrapping code in gtk.py is
> planned to be rewritten in c. will this break code like above?

the development version of pygtk uses ExtensionClass, which is a module
that allows creation of types in C extension modules that can be
subclassed.  So the above code will continue to work.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GtkTree?

2001-04-12 Thread James Henstridge

On Mon, 9 Apr 2001, David Robertson wrote:

> 
> I am trying to build a simple tree using the following code:
> 
> mytree = GtkTree()
> myitem = GtkTreeItem("something")
> mytree.append(myitem)
> 
> my question is, how to actually build the nodes and leafelets... I have the
> GTK reference but it is in C and I had given up on C 10 years ago so it is
> pretty greek to me. Any help on any functions or classes I am overlooking
> would be appreciated. I tried tinkering with GtkTreeItem.set_submenu to no
> avail.

You can use the set_subtree() method of the tree item to specify a GtkTree
as a subtree.  I don't recommend using GtkTree though, as it is fairly
broken.

The CTree widget can do everything Tree does, and is less broken.

> 
> Thanks for your help.
> 
> Another quick question. Is there an actual reference for the python GTK
> wrapper?

Not yet.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GtkCList with widgets as clients?

2001-04-12 Thread James Henstridge

On Fri, 6 Apr 2001, David Given wrote:

> Does anyone know how to put widgets in the cells of a GtkCList? The
> documentation is sparse, to say the least; for the thing I want to do (editing
> a list of configuration settings), I reckon this would be the most intuitive
> way of doing it.

The GtkCList widget doesn't support embedding widgets

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] new pygtk for gtk 2.0 snapshot

2001-04-12 Thread James Henstridge

On Tue, 3 Apr 2001, Skip Montanaro wrote:

> 
> James> I just put up a new snapshot of devel pygtk at:
> James>   http://www.gnome.org/~james/pygtk2-SNAP-20010330.tar.gz
> 
> I managed to get all the prerequisite stuff installed, but can't build the
> pygtk snapshot.  When compiling gtkobject-support.c I get (long lines
> wrapped):

They went and made some changes after my last snapshot, which broke the
pygtk build (as you noticed :)

I put together a new snapshot while at GUADEC, but didn't get round to
announcing it on any mailing lists.  You can grab it from
  http://canvas.gnome.org/~james/pygtk2-SNAP-20010408.tar.gz

It will work fine with the glib/gtk+ 1.3.3 releases (along with whatever
version of pango was released at the time).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] new pygtk for gtk 2.0 snapshot

2001-03-31 Thread James Henstridge

On Fri, 30 Mar 2001, Skip Montanaro wrote:

> 
> James> I just put up a new snapshot of devel pygtk at:
> James>   http://www.gnome.org/~james/pygtk2-SNAP-20010330.tar.gz
> 
> James> It requires python >= 2.0 and recent CVS checkouts of glib, pango
> James> and gtk+ to compile.  It is not fully up to date with all the API
> James> additions/changes, but it compiles and runs.
> 
> *sigh*...
> 
> I realize the gnome folks are trying to do me a favor by making it harder
> for me to build glib, pango and gtk+ so that it is correspondingly harder to
> shoot myself in the foot, but I'd like to experiment with James's new
> release and find it frustrating that I should need to know the ins and outs
> of autoconf and/or automake.  Would someone please tell me how to create
> ./configure?  I tried "autoconf" in the glib dir and got a configure script,
> but also this error (and a bunch of warnings about AC_TRY_RUN):

I have never tried building gtk on win32, so probably won't be able to
help that much.  From posts to gtk-devel-list, it sounds like you need CVS
libtool in order to compile it on win32.  I don't know about the other
details.

It probably has build problems on x11 too, because the gtk-2.0.m4 autoconf
macro I was using is broken (it uses gtk-config-2.0 macro, which doesn't
exist anymore -- there is a bug in bugzilla about this).

As far as pygtk goes, you probably want to use the snapshot tarball,
rather than CVS, as the tarball is built with the CVS version of automake
(needed for python support).

James.

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



Re: gladepyc (was Re: [pygtk] how to contribute)

2001-03-30 Thread James Henstridge

On Thu, 29 Mar 2001, Fabien COUTANT wrote:

> On Thursday, 29 March 2001, you (Alexandre Fayolle) wrote:
> > On Thu, 29 Mar 2001, Fabien COUTANT wrote:
> > 
> > > PS: this will be used to complete a tool I wrote:
> > > http://www.fcoutant.freesurf.fr/gladepyc.html
> > 
> > This could be a very useful tool. What has stopped me using glade so far
> > is the lack of Windows support which is one of the target of the
> > application I'm working on. I think I'll give a try to gladepyc soon.
> 
> Hello Alexandre,
> 
> Gladepyc will happily generate code that runs on Unix, Vms as well as
> Windows.
> 
> There is glitch however:  non-ASCII characters are encoded with UTF-8 on
> Windows' Gtk and ISO-Latin1 (or other 8-bit encoding) on Unix' Gtk (1.2
> at least); So if you have some of those characters entered in Glade's
> XML on one side, they are not rendered correctly on the other side.  It
> works perfect only if you use the generated code on the same platform
> that Glade's XML was designed on.

Well, with gtk 2.0, hopefully this sort of issue will be a thing of the
past, as it uses utf8 on all platforms.

> 
> That said, Glade for Windows seemed reasonably stable, from what I
> tested a few months ago.  All this GTK/Glade stuff for Windows is
> unofficial though -- yet.

There are ports of glade (see the gtkada website) and libglade available
for win32.  I usually recommend libglade to most people, as some of the
stuff it does is non trivial (uline accel handling is the big one).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



[pygtk] new pygtk for gtk 2.0 snapshot

2001-03-30 Thread James Henstridge

I just put up a new snapshot of devel pygtk at:
  http://www.gnome.org/~james/pygtk2-SNAP-20010330.tar.gz

It requires python >= 2.0 and recent CVS checkouts of glib, pango and gtk+
to compile.  It is not fully up to date with all the API 
additions/changes, but it compiles and runs.

This release also has support for creating new signals, complete with a
class closure.  See examples/gobject/signal.py for an example:
  http://cvs.gnome.org/lxr/source/gnome-python/pygtk/examples/gobject/signal.py

Currently you can only use it to add signals to existing GTypes.  Creating
new GTypes is not currently supported due to some required glib APIs not
having been implemented yet.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Problems handling 'insert_text' signal

2001-03-28 Thread James Henstridge

On Wed, 28 Mar 2001, Agustín Fernández wrote:

> If I try to connect some function to the insert_text signal of a 
> gtk_text I have some problems:
> 
> 1)  I get some garbage at the end of new_text (not a problem since I can 
> cut it since I know new_text_length)
> 
> 2) As position I get a PyCObject object instead of a int.

That signal argument is actually a pointer to an int (int *) -- not an
int.  In GTK+, the signal argument is marked as a pointer, so my code
doesn't know what type it is.  This makes that signal argument unusable.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] cursors in win32

2001-03-27 Thread James Henstridge

On Tue, 27 Mar 2001, Paul Spencer wrote:

> Hi all,
> 
> 
> 
> I would like to set a busy cursor during a lengthy calculation.  I have
> discovered that I can do the following:
> 
> ...
> win = self.get_window()
> cur = gtk.cursor_new(cursor_idx)
> win.set_cursor(cur)
> ...
> 
> where cursor_idx is one of the ones listed in GDK.py under GdkCursorTypes.
> However, it doesn't set the cursor for everything (read child widgets), just
> the widget (say the GtkWindow) on which it was called.  I would like to
> cursor to stay the same over the entire window ... do I need to enumerate
> all children of all widgets to make this happen?  Once I am done, how do I
> restore the default windows cursor?  Finally, can I use the Windows busy
> cursor (whatever the user has selected)?

This is possibly a bug in the win32 port.  If a cursor is not specified
for a particular GdkWindow, it is supposed to use the cursor of its parent
window (this is why you can change the default cursor in X by setting the
cursor for the root window).  Unless you are setting the cursor on other
windows, it should work.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] signal

2001-03-27 Thread James Henstridge

On Tue, 27 Mar 2001, berger patrick wrote:

> Hi all,
> 
> i have a little problem with signal function
> 
> i have this in a window class :
> ok_button.connect("button_press_event", ok_clicked(entry))

First of all, you probably want to connect the function ok_clicked, rather
than the return value (which would be None in this case) from calling it :)

> 
> 
> and the function :
> 
> def ok_clicked(ancestor):
>   text = GtkEditable.get_chars(ancestor, 0, -1)

Here, why don't you just use ancestor.get_chars() directly?

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] libglade, pyglade and gettext.py

2001-03-27 Thread James Henstridge

On Tue, 27 Mar 2001, Danie Roux wrote:

> How can I translate strings in my .glade files? I saved the strings in a
> seperate file from glade. And made that file part of my POTFILES.IN. And I
> do get the strings in my .pot files to translate. But it doesn't show.
> 
> The rest of my program does translate.

This is a bit of a problem.  Libglade performs translation using the C
level gettext routines.  However, both the gettext.py in gnome-python and 
the one in Python >= 2.0 are in pure python.  I know someone did a python
wrapper for the C gettext routines.  It could be used to set the correct
translation domain for use by libglade.

I should email Barry Warsaw about this problem and see what he thinks (it
would be pretty easy for the python 2.0 gettext.py to use an extension
module that wraps the C gettext API if available).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] why doesnt signal_connect return an id

2001-03-26 Thread James Henstridge

On Mon, 26 Mar 2001, Anthony Tekatch wrote:

> 
> Well I managed to solve the problem by creating a semaphore/flag that can be checked 
>by the signal handler function. I suppose this will do for now.
> 
> What do you mean by "connect the signals manually" ?

calling the get_widget() method of the GladeXML object to get a reference
to the widget, then calling connect() for each signal you want.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] why doesnt signal_connect return an id

2001-03-26 Thread James Henstridge

On Mon, 26 Mar 2001, Anthony Tekatch wrote:

> 
> I want to use the id generated from a signal connect in signal_handler_block(id) but 
>signal_connect returns None.
> 
> testsignal = widgets.signal_connect("on_entry2_changed", calculate.top)
> print testsignal

Because it potentially connects more than one signal.  Unfortunately, this
makes it a bit difficult to use signal_handler_block.  Alternatively, you
could connect the signals manually if this is a problem.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] How to get widget size

2001-03-26 Thread James Henstridge

On Mon, 26 Mar 2001, Eduardo Ferro wrote:

> Hi!
> 
> I need to get the "actual" widget size of a Window, but when i
> request the size with size_request() it return me the minimal size
> that can use this widget :-?

That is the correct behaviour for the size_request() method (it returns
the ammount of space the widget requests).  You want the space allocated
to the widget.  That can be found with the get_allocation() method:

  x, y, width, height = widget.get_allocation()

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] GtkNotebook: multi rows for tabs

2001-03-25 Thread James Henstridge

On Sun, 25 Mar 2001, Yotam Medini wrote:

> 
> This is probbaly more of a Gtk+ question.
> Is there a way to ask a GtkNotebook widget
> to put its tabs on more than just one row?
> -- yotam

Not to my knowledge.  You can tell the GtkNotebook to allow scrolling of
the tabs though (notebook.set_scrollable(TRUE)).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Scroll dude

2001-03-23 Thread James Henstridge

On Fri, 23 Mar 2001, Eduardo Ferro wrote:

> Hi!
> 
> I have a ScrolledWindow with a GtkHBox() in it (added with
> add_with_viewport). Inside the GtkHBox i have some buttons and i want
> to change the scroll of the ScrolledWindow when some of the buttons
> get the focus... I only have some experience with Scrolled window
> containing GtkText or other kind of widget that control the scroll but
> i don`t understand how can i control the Scroll bar to see the
> correct part of the HBox
> 
> Any suggestion, reading, or function to control this scrolls bars, and
> what widget must to do this control???
> 
> Thanks in advance and sorry for my poor english

You can get references to the two adjustments (horizontal and vertical) of
the scrolled window.  You can use the set_value method of the adjustment
to change what the scrolled window shows.  Both the scrollbar and scrolled
window contents listen for changes to the adjustment (in fact, the
scrollbar works by changing the value of the adjustment when you use it).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Who has taken gnome.util?

2001-03-23 Thread James Henstridge

On Fri, 23 Mar 2001, Michele Campeotto wrote:

>   Why does the gnome.util module isn't in gnome-python 1.4? I need 
> gnome.util.datadir_file() what can I do?

Are you using packages?  Maybe the package missed that file.  It is
definitely in the tarball, and should get installed (although it isn't
mentioned in my sample RPM spec file :(

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] keeping track of stacking order of canvas itesm

2001-03-21 Thread James Henstridge

On Wed, 21 Mar 2001, Skip Montanaro wrote:

> 
> How does one discover and/or keep track of the stacking order of
> GnomeCanvasItems?  Based upon the methods I've discovered so far
> (raise_/lower & raise_to_top/lower_to_bottom), there's no way to do either
> of the following:
> 
> * figure out the stacking order
> 
> * raise or lower a group of items while maintaining their same relative
>   relationship
> 
> Here's an example.  Suppose I have a canvas widget that contains a mix of
> ellipse, polygon and rect items.  I want to raise or lower all of one type
> of item as a group and maintain the relative stacking order of all items of
> the same group.  Let's suppose the stacking order is (bottom to top):
> 
> r1, r2, e1, p1, r3, p2
> 
> After I raise the polygons one level, I have
> 
> r1, r2, e1, r3, p1, p2
> 
> Now, if I raise the polygons again, I will either have
> 
> r1, r2, e1, r3, p1, p2
> 
> (if p1 was raised first) or
> 
> r1, r2, e1, r3, p2, p1
> 
> (if p2 was raised first)
> 
> To prevent the second case from happening, I have to know the stacking order
> so I can first raise p1, then raise p2.

If you asked Federico, he would probably say you should have the two items
in a group if you always move them together.  However, if you just want to
know the stacking order, you can use the group.children() method which
returns a list of children of a canvas group.  That should do what you
want.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] problem with setting style of a widget

2001-03-21 Thread James Henstridge

On Wed, 21 Mar 2001, Angelo Cano wrote:

> img.make_pixmap() returns a GtkPixmap and you need a GdkPixmap.
> You can get the GdkPixmap from the GtkPixmap:
> 
> gtkpixmap = img.make_pixmap ()

faster to just use get_pixmap()

> gdkpixmap, mask = gtkpixmap.get ()
> style.bg_pixmap[STATE_NORMAL] = gdkpixmap
> 
> The only problem is that pygtk (0.6.3) dumps core ;)
> 
> ** ERROR **: file gtkmodule.c: line 512 (PyGtkStyleHelper_SetItem): should not be 
>reached
> aborting...
> Aborted (core dumped)

That bit of code is broken in that version of pygtk.  Grab the latest
gnome-python tarball from http://download.gnome.org/.  If you don't want
to compile the gnome features, run configure, make and make install from
the pygtk directory of the tarball.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] problem with setting style of a widget

2001-03-21 Thread James Henstridge

On 21 Mar 2001, satish  k wrote:

> Hi.
> 
> i have a problem with setting the style of widget.
> i want to set the bg style of the widget using bg_pixmap.
> 
> My code is some thing like this.
> 
>   win=GtkWindow()
>   style=win.get_style ().copy ()
> img = GdkImlib.Image("test.png") 
> img.render()
>   pix = img.make_pixmap ()
> style.bg_pixmap[STATE_NORMAL]=pix
>   win.set_style(style) 
>   win.show_all()
> 
> I get the following error :
>  style.bg_pixmap[STATE_NORMAL]=pix
> TypeError: can only assign a GdkPixmap or None   
> 
> is pix not of type GdkPixmap? if so how to solve this problem?

It is not of the type GdkPixmap.  It is a GtkPixmap widget.  Use the
following:
  pix, mask = img.get_pixmap()

That will give you a GdkPixmap.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Patch to help embedded use

2001-03-21 Thread James Henstridge

On 20 Mar 2001, Maciej Stachowiak wrote:

> 
> OK to commit?

Yep.  This looks fine.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


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



Re: [pygtk] Can I build This in PyGnome?

2001-03-19 Thread James Henstridge

On 20 Mar 2001, Rob Brown-Bayliss wrote:

> Hi.
>
> I want to build an application based around a frame work or shell in a
> manner similar to Evolution or the Gnome Control Center.   Is this
> possible with Python and PyGnome?
>
> To be more specific I want to build a container window that then loads
> other apps into it's window to run.  The Other apps will be written
> specifically for the container, I don't expect to be able to load any
> old thing.
>
> I guess Bonobo is one solution, but I do not really need to use Bonobo
> as I do not expect my modules will be usefull in other apps.

Well, if all the things you are going to be putting in this container are
python programs, why not say that they all have to be python modules which
have a function called get_toplevel(), which returns the toplevel widget
for that module, which can then be shown in your container.

If you need languages other than python, or multiple processes, you may be
able to do something with the GtkPlug/GtkSocket widgets.

James.


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



Re: [pygtk] Gtk runs well on Windows ?

2001-03-19 Thread James Henstridge

On Mon, 19 Mar 2001, D-Man wrote:

> | But can Gtk run well on windows ? (a newbie's
> | question,
> | but I haven't found any answer on internet.) and can
> | pyGtk provide wxPython's funtionalities shown in their
> | demo ?
> 
> GTK runs pretty well on windows (see www.gimp.org/win32).  The gimp
> uses it, and it was the reason Tor began porting GTK.  The gimp runs
> quite well.  I don't know whether the gimp or gtk is the cause of most
> of the gimp's crashes.  Search on google for Hans Breuer.  He has
> windows ports of a number of useful apps, some of them python related,
> on his web site.

Note that gtk+ 2.0 will probably run significantly better on win32 than
the 1.3 betas (based on a snapshot from the devel branch before all the
nice new features were added) which are currently used for gimp, etc.  The
wrapper for gtk 2.0 should also use less memory :)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Unmapping a window ?

2001-03-19 Thread James Henstridge

On Mon, 19 Mar 2001, mallum wrote:

> Aloha all;
>
> Im writing a little pygtk program to provide a launcher frontend to the
> Stella Atari emulator.
>
> I want the app to 'hide', launch the stella application ( currently using
> system() ) , then reappear when stella is closed down.
>
> Im using win.hide() but the window dosn't seem to want to unmapp. However it
> does when I remove the system() command. Any ideas on how to accomplish this
> correctly ?

Maybe try putting the following in your app before calling system:
  while events_pending()
mainiteration()

James.


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



Re: [pygtk] Problems using draw_array()

2001-03-17 Thread James Henstridge

On Fri, 16 Mar 2001, dblank wrote:

> Hello, I have just begun to work with gtk under Python. Almost everything 
> works as advertised, except I can't seem to get draw_array() to work. I think 
> I may be doing something wrong. Here's my sample code:
> 
> import Numeric
> from gtk import *
> 
> class Example(GtkWindow):
> def __init__(self):
> win = GtkWindow()
> win.connect("destroy", mainquit)
This bit is wrong.  To subclass a Gtk object, call its constructor, just
like for any other python object.

> self.pic = GtkDrawingArea()
> self.pic.show()
> win.add(self.pic)
Use self rather than win here.

> self.pic.connect("expose_event", self.on_exposure)
> self.pic.set_events(GDK.EXPOSURE_MASK)
> 
> self.pixmap = create_pixmap(win, 50, 50)
> gc = self.pixmap.new_gc()
> 
> self.buff = Numeric.ones((50, 50, 3), 'b')
> draw_array(self.pixmap, gc, 0, 0, 0, self.buff)

Use the constant for the fifth argument here (GDK.RGB_DITHER_NONE
corresponds to 0 here).

> self._o = win._o
Don't do this.  If you chain to the GtkWindow constructor, it shouldn't be
necessary.

> 
> def on_exposure(self, widget, event):
> gc = self.pic.get_style().fg_gc[STATE_NORMAL]
> self.pic.draw_pixmap(gc, self.pixmap, 0, 0, 0, 0, 50, 50)
> 

You need to push the GdkRGB visual before creating widgets that will use
the GdkRGB functions.  So add the following line here:

  push_rgb_visual()
> example = Example()

and optionally, have pop_rgb_visual() afterwards.

> example.show()
> mainloop()
> 
> 
> I get a core dump if I run the above. Any hints you can provide would be much 
> welcomed!
> 
> (I'm running Python2.0, and I have Numpy (Numeric-17.3.0) installed, with  
> pygtk-0.6.6. draw_array is defined, but crashes when called.)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] How do i get to show them on the same row.

2001-03-15 Thread James Henstridge

again, please turn off html email.  The python code you included in your
message was almost unreadable, which reduces the chances of someone
helping you.

On Thu, 15 Mar 2001, Eduardo Soto wrote:

>  taking your examples I declared the following:
[snip]
>  
> 
> I want to show them on the same row.
> 
> I want the password entry to show * when written on.

In answer to your question, it looks like you are using a GtkVBox, which
lays out its children vertically (in a column).  If you want your widgets
to be layed out horizontally, use a GtkHBox.

Take a quick browse through the GTK+ Tutorial.  Even if you don't
understand all the example code in it (it is in C), it should explain a
bit about how GTK's geometry management works.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] configure_event for all widgets?

2001-03-15 Thread James Henstridge

On Thu, 15 Mar 2001, Prabhu Ramachandran wrote:

> hi,
> 
> This might be a stupid question, but I have spend hours playing with
> things, looking at docs etc.  Basically, I want to capture a
> configure_event for some Gtk widget that I derive a class from.  I
> find that apart from the GtDrawingArea none of the other widgets are
> able to emit the 'configure_event'.  Each widget seems to have its own
> quirks.  I did do a
> 
>self.add_events (GDK.ALL_EVENTS_MASK)
> 
> so that it can handle all events.  Attached at the end is the code.
> Change TESTWID at the top to look at the events that the particular
> widget can handle.
> 
> Would appreciate if someone could explain why it behaves like this.
> Believe me, I have looked far and wide for explanations!  I am not on
> the pyGtk list so please CC me in on any messages.
> 
> I am sorry that this mail is long, I thought that the code might be
> useful to some folks.

Well, given that not all widgets have their own windows (GtkLabels come to
mind), using configure_event is not the most reliable signal.

I would recommend using the size_allocate signal, which is used in the
geometry management code of GTK.  This signal takes a single argument -- a
GtkAllocation structure.  Unfortunately, this signal argument is just
marked as a pointer in the gtk code, so is inaccessible to python (pygtk
just hands you an opaque cobject).

To get around this, connect to size_allocate with connect_after, so that
your handler gets called after the class handler (which sets the
widget->allocation pointer), and use the get_allocation() method I added
for accessing the allocation.  So your code may look like this:

  def size_allocate(widget, allocation):
x, y, width, height = widget.get_allocation()
# do what you want here

  widget.connect_after("size_allocate", size_allocate)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] How to assign a picture .gif to a GtkButton

2001-03-15 Thread James Henstridge

First of all, you only need to post your question once to the list, and
please turn off HTML email when posting to a mailing list.

On Thu, 15 Mar 2001, Eduardo Soto wrote:

> Hello, this is my first program. 
> taking your examples I declared the following:
> 
> b1 = GtkButton (´Stop´)

In GTK+, a GtkButton is a container widget.  When you give an argument to
the GtkButton constructor, it creates a GtkLabel with that text and puts
it in the button.

> 
> b1.connect(´clicked´, self.stop)
> 
> I want to assign a picture called stop.gif

To put an image in the button, you first need to be able to load the image
into python, create a GtkPixmap widget, and put that in the
button.  Currently, only the GdkImlib module can load gif files for use by
pygtk, so creating the GtkPixmap widget would look something like this:
  import gtk, GdkImlib

  im = GdkImlib.Image('stop.gif')
  pix, mask = im.get_pixmap()
  pixmap = gtk.GtkPixmap(pix, mask)

You then want to create the button with the pixmap widget inside, instead
of a GtkLabel:
  button = gtk.GtkButton()
  button.add(pixmap)
  pixmap.show()  # if you use show_all() on the toplevel, this call isn't needed

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] how do I pass the GTK window pointer to a C extension?

2001-03-15 Thread James Henstridge

On Thu, 15 Mar 2001, Joseph VanAndel wrote:

> I want to write a Python/Gtk/Glade application that uses a
> C/C++ extension to render images of weather radar data.  
> 
> Given that I'm rasterizing large amounts of polar coordinate
> data, I'm quite certain that I need to do the calculations
> in C/C++, rather than in Python.)
> 
> 1) Which type of widget is best to use to contain these
> rendered images?  
> 
> Should I use a GtkPlotCanvas?
> 
> 2) What's the simplest way to pass a pointer to the Gtk
> window to my C/C++ extension?
> 
> It looks like I can pass "self._o" to my  extension, and
> then my extension would have the form:
> 
> static PyObject *_wrap_MyDraw(PyObject *self, PyObject
> *args) {
> 
> PyObject *canvas;
> if (!PyArg_ParseTuple(args, "O!:MyDraw", &PyGtk_Type,
> &canvas))
> return NULL;
> 
> MyDraw(GTK_PLOT_CANVAS(PyGtk_Get(canvas)));
> Py_INCREF(Py_None);
> return Py_None;
> } 
> 
> Is there any simpler way of doing this?

Well, if you just need to render an image to the screen, it may be easiest
to use the draw_array() function in pygtk, which draws a NumPy array
(MxNx3) to a window.  This way, your extension would only need to know how
to render your polar coordinate data into the array.  This is probably
easiest if you don't know much about the GTK+ programming in C.

Then you can use a drawing area with an expose_event signal handler that
simply calls draw_array.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] I want to know i can set active a item in a GtkOptionMenu

2001-03-14 Thread James Henstridge

On Wed, 14 Mar 2001 [EMAIL PROTECTED] wrote:

> The child in a GtkOptionMenu is a GtkMenu with some GtkMenuItems , but
> i want to set active a especific choice. i use gtk_menu.set_active(pos
> index) but this don´t work. Thanks

Either call the activate() method on the actual menu item, or use the
option_menu.set_history(index) method on the option menu (the first is
easier if you have a reference to the menu item, the second easier if you
have its index).

James.


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



Re: [pygtk] newly expanded widget extends outside scrolledwindow-how to adjust?

2001-03-14 Thread James Henstridge

On Wed, 14 Mar 2001, George Young wrote:

> [gtk+-1.2.8, pygtk-0.6.6, python 2.1a2, linux]
> I have a bunch of widgets in a vbox inside a scrolledwindow.
> If a user clicks on button that makes it's widget open up much bigger(higher),
> the new content may extend below the bottom of the scrolled window.  
> 
> But the new content is what the user just asked for, so I need to force it 
> to be visible by programatically adjusting the scrollbar.  
> 
> If the widget is bigger than the scrolledwin, then the top of the widget should be
> aligned to the top of the scrolledwin, else the bottom of the widget should be 
> set to the bottom of the scrolledwin.
> 
> I assume I need somehow to find the pixel location, within the parent vbox, 
> of the bottom and top of the target widget and then fiddle the scrolledwin's
> vertical 'adjustment', but I have no idea how to do this...

Call the widget.get_allocation() method on the child.  This will return an
(x, y, width, height) tuple.  You can then use this to set the value of
the scrollbar's GtkAdjustment.

James.


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



Re: [pygtk] Python 2.1 / Gtk+ 2.0

2001-03-14 Thread James Henstridge

On Wed, 14 Mar 2001, Skip Montanaro wrote:

> 
> Okay, I'm confused.  On the one hand, James says:
> 
> James> First of all, there will never be a gtk 1.4 (they decided that
> James> about a year ago)...
> 
> then later writes:
> 
> James> I don't think the C API has really changed much since 1.4 (or
> James> maybe earlier; 1.4 was the first release I started writing
> James> extensions for).
> 
> Are these two different 1.4's you're referring to?  I'm particularly
> interested in this because I am gearing up to work on a project that will
> use 2.0.

You have taken my response out of context :)  The question was whether
pygtk worked with python 2.1, and I was saying that the C API (of
python) has not changed incompatibly for a long time.

BTW, gtk+ HEAD (what will be gtk+ 2.0) is already very good.  It has
replacement text and tree widgets; both with model/view split.  GTK+ now
also does flicker free drawing and exposure compression by default, so gtk
apps should look as smooth as Tk apps (while gtk+ is in fact faster than
Tk, many people seem to beleive otherwise, because gtk+ 1.2 
flickers).

Then there is pango.  This handles all the internationalised text issues
(multiple scripts, different text directions, etc).  Now all of the GTK+
functions that display text to the screen take UTF-8 character
strings.  By setting the python's default encoding to UTF-8, pygtk allows
you to pass in python unicode strings to these functions, and they will be
handled appropriately.  Pango also has an Xft backend, which allows for
anti aliased text rendering on the X11 target for servers with the RENDER
extension (ie. XFree86 4.0.x).

There are also more targets in 2.0 -- win32 and linux-fb have been
incorporated into the main sourcetree in addition to x11 (there was a
win32 port before, but was never integrated into the main tree).  You can
simply recompile pygtk with another target and it should work.  I am
considering changing the pygtk build process so that you can install pygtk
for more than one target, and "import gtk" decides which to use, allowing
your app to run both on x11 and framebuffer automatically.

James.


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



Re: [pygtk] Position of buttons

2001-03-14 Thread James Henstridge

On Wed, 14 Mar 2001, Eduardo Ferro wrote:

> Hi!
> 
> I have an aplication that have a VerticalBox with 2 widget, the first
> is a HorizontalBox and the last one is a Button, i need that the
> button only ocupies (verticaly) the minumun (just to read the label)
> and the HorizontalBox use the rest.
> 
> Whe i start the aplication the button only ocupies the minimun but
> when i change the dimensions the buttons use half of the window
> size...
> How can i change this behaviour??

When packing the button, set the expand argument to FALSE:
  box.pack_start(child, expand=FALSE)

The exapnd setting for each child is used to work out how any space larger
than the minimum size required for the box is allocated among the
children.  The fill setting says whether the child should fill the area
allocated to the widget.  If it is false, it will just use the space it
requested.

James.


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



Re: [pygtk] Python 2.1 / Gtk+ 2.0

2001-03-14 Thread James Henstridge

On Wed, 14 Mar 2001, Peter Kese wrote:

> 
> Hi!
> 
> I am planning a project based on pygtk in which I am planning to use
> 
>   Python 2.1
>   NumPy 18.0  - makes use of new Python 2.1 features
>   PyGtk   - as I need to be portable to Unix and Windows
>   GdkPixbuf
> 
> As it is probably going to take me months to complete it, I thought it
> might be wise to start the project with Gtk 1.4 or 2.0.

First of all, there will never be a gtk 1.4 (they decided that about
a year ago).  Note that 2.0 is still under development at the moment, so
is not a great platform to target unless you are willing to track
development.  However, gtk 2.0 should be out soon.

> 
> Therefore I am wondering:
> 1) are there any PyGtk for Gtk 1.4 / 2.0 beta available, (when, how)

The HEAD branch of CVS is targeted at 2.0, but currently is not up to date
(will not compile with current HEAD glib/pango/gtk+).  There are some
snapshots I made available at:
  http://www.gnome.org/~james/

> 2) does PyGtk 0.6.X compile with Python 2.1

No reason why it shouldn't.  I don't think the C API has really changed
much since 1.4 (or maybe earlier; 1.4 was the first release I started
writing extensions for).

James.


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



Re: [pygtk] What docs to use?

2001-03-13 Thread James Henstridge

On Tue, 13 Mar 2001, Skip Montanaro wrote:

> I'm brand new to GTK and PyGTK, though I have a lot of Python experience and
> enough widget experience with Tkinter and Motif to understand most of GTK's
> concepts.  I'm poking my way through the GTK tutorial at
> 
> http://www.gtk.org/tutorial/
> 
> but that doesn't seem to map quite one-to-one with 
> 
> from gtk import *
> 
> (or does it and I haven't gotten far enough through it to make the
> connection yet?).
> 
> I understand there are two interfaces exposed through PyGTK.  Which bits of
> GTK documentation correspond to the more object-oriented gtk.py?

The procedural interface in _gtk (which is closer to the C API) will be
going away in the upgrade to gtk 2.0 (I am using a new code generator that
produces the object oriented wrapper directly, using ExtensionClass).

There is a fairly simple mapping between the C API and the object oriented
python API.  The file MAPPING in the pygtk distribution should give enough
information about the mapping for the C GTK tutorial to be useful.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] How to get screen width and height

2001-03-12 Thread James Henstridge

On Mon, 12 Mar 2001, Andre Luis Lopes wrote:

> Hi all
> 
>Someone knows how to get the screen width and height ? I'm needing it to 
> be able to set a top level window size.
> 
>   I'm using :
> 
>   window = GtkWindow(WINDOW_TOPLEVEL)
>   window.set_usize(800, 600)
> 
>   But, it would be better if I could use :
> 
>   window = GtkWindow(WINDOW_TOPLEVEL)
>   window.set_usize(screen_widht, screen_height)
> 
>Some volunteer to help me on this ?

You can use the screen_width() and screen_height() functions found in the
gtk module for this.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] How i can get a pixmap from a GtkCList

2001-03-12 Thread James Henstridge

On Mon, 12 Mar 2001, Luigi Vellucci wrote:

> I use the atribute clist.get_pixmap(row,col) but i see this error
> TypeError: gtk_clist_get_pixmap requires exactly 4 arguments; 3 given  ,
> but i dont know which argument i have missed. Thanks

This is a bug in pygtk.  I am checking a fix into cvs right now.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Q: size of Image item on canvas?

2001-03-09 Thread James Henstridge

On Fri, 9 Mar 2001, NickB wrote:

> How do I put an Image onto a canvas with its natural size?
> 
> The  operation  ..add('image', image=XXX,
> x=XX,
> y=XX,
> width=XX,
> height=XX)
> 
> - takes explicit location and size information.
> 
> So how do I pass the information so the image appears it's natural size?
> 
> The operation wants the info since it complains if it is left out, so it
> is not default behaviour?

You can get the image's width/height with image.rgb_width or
image.rgb_height.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] RTLD_GLOBAL problem solved.

2001-03-09 Thread James Henstridge

On Fri, 9 Mar 2001, Danie Roux wrote:

> I had a lot of problems in Debian with the imlib library not wanting to display my 
>theme or any other image I wanted.
> 
> Loading this dummy module before anything else solves the problem:
> 
[snip]
> 
> But I have to call dlclose for every library I open right? So where do I do
> that? Is there  some way in Python that I can ensure a piece of code is run,
> even when the interpreter exits unexpectedly?

If you want the library to stay open for the duration of the python
session (which it will if you import GdkImlib), then don't worry about
dlclosing it.

> 
> btw, I can't tell you what a relieve it is to finally run my program on a stock
> Debian system. 
> 
> And for those that haven't followed it all, Debian is not to blame.

There are reasons why this is not implemented in pygtk directly.  First of
all, there is no guarantee that libgdk_imlib.so will be the correct soname
for the library (on systems that don't have the devel portion of imlib
installed, they may only have libgdk_imlib.so.1).  On HP-UX machines, it
would be called libgdk_imlib.sl.  If there was a newer incompatible imlib
and libgdk_imlib.so pointed to it, while the python binding was built
against the old one, then this may cause problems.

By all means, use this code to get your app working, but note that it
isn't portable :)  As I said before, the correct fix is to use the new
libtool to build imlib when it is released, so the shared library
dependencies can be corrected.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] selection_add_handler() implemented?

2001-03-08 Thread James Henstridge

On Fri, 9 Mar 2001, Brian Keck wrote:

> On Fri, 09 Mar 2001 08:36:57 +0800, James Henstridge wrote:
> >On Thu, 8 Mar 2001, Brian Keck wrote:
> >> Is selection_add_handler() implemented?
> >> I can't see it in the source.
> >What is selection_add_handler() supposed to do?  I searched through the
> >gtk and gdk sources/headers, and there is no mention of a function by that
> >name.
> 
> I saw it in woody's libgtk-doc 1.0.6-4, in 
 ^^^
GTK+ 1.0.6 is from the obsolete 1.0 branch.  Selections are one of the
things that changed in GTK+ 1.2.  There should be an updated version of
the tutorial distributed with gtk+ 1.2.x, and available on www.gtk.org.

In 1.2, you use the widget.selection_add_target() method to set up the
selection types you will handle.  Then connect to the selection_get
signal to provide the selection data (with the selection_data.set
method).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] selection_add_handler() implemented?

2001-03-08 Thread James Henstridge

On Thu, 8 Mar 2001, Brian Keck wrote:

> 
> Hello,
> 
> Is selection_add_handler() implemented?
> I can't see it in the source.

What is selection_add_handler() supposed to do?  I searched through the
gtk and gdk sources/headers, and there is no mention of a function by that
name.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Right place for some Q's on python-libglade?

2001-03-08 Thread James Henstridge

On 8 Mar 2001, Bill Anderson wrote:

> I've been surfing the archives for the last day and noticed a numbe rof
> libglade related posts. Are they on-topic here? (Yes, I am using Python)

This is a good enough place for pygtk/libglade questions (I am author of
both :)

> 
> If not, pardon the OTness of this post. (and let me know the appropriate
> place, if any) :^)=
> 
> Now on to the questions.
> 
> I hvae a little glade gui-ed app that has a GNOME About box. Whenever I
> run the app, it always starts with the About box dialog open, and with a
> version number of 0.0.
>  o How do I not have it show in the beginning?

In the object properties dialog, uncheck the visible option.  Then you
will have to show() the window before you can see it.

>  o How do I get it to show when the about button is clicked?

In glade, define a handler for the for the clicked signal of the button
(or if it is a menu item, the activate signal).

Then in your python script, do the following:
  def handler(widget, xml):
about = xml.get_widget('the-name-of-the-about-box')
about.show()
  xml.signal_connect('what-i-called-the-handler', handler, xml)

>  o How do I set the version?

At your program startup, do the following to import the GNOME libraries:
  import gnome
  gnome.app_version = "version-string"
  import gnome.ui, libglade

(make sure you set app_version before importing gnome.ui).

> 
> 
> Also, are then any examples that deal with getting data frmo entries
> (various types, including the Gnome Druid)? I;ve seen plenty that just
> show how to put something up, but next to nothing that shows actual use,
> even so much as printing the entries.

The usual way is to give the widget you want to manipulate a unique name,
use get_widget() get a reference to the widget, then call its methods.

> 
> Admittedly, at this point I prefer to use libglade in python, and I have
> had less than stellar luck finding docs/examples for that combo. I do
> have access to a site to publish them, and intend to do so as I get
> them.

In gnome-python 1.4.0, there is a small example of libglade use (I
converted over the pygtk/examples/glade/glade.py example from the old
pyglade to libglade).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Using standard Python network stuff with PyGtk.

2001-03-06 Thread James Henstridge

On Tue, 6 Mar 2001, Joakim Ziegler wrote:

> So this might be a simple question, but there aren't any docs, so I thought
> it would be ok to ask.
> 
> I'm making a small graphical frontend to some scripts and functions I already
> have in Python. These scripts use Python network and HTTP stuff to fetch
> data. How do I use that in combination with the GTK main loop so that the GUI
> doesn't freeze when I'm doing network stuff? Will I have to use threads? Does
> anyone have any sample code to point me to?

Pygtk exports the input_add() routine, which can be used to connect IO
handlers to the GTK main loop, which is what you need to do async IO.

As far as I can tell, most of the python networking library (httplib,
urllib, etc)seems to be synchronous (unless I have missed something).  So
you would either have to write your own async networking code, you may be
stuck with threads.

When doing any threaded programming, just remember that you need to
surround gtk calls in other threads with threads_enter() and
threads_leave(), otherwise bad things happen in gtk.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] stopping 'delete_event'

2001-03-05 Thread James Henstridge

On Mon, 5 Mar 2001, Michele Campeotto wrote:

> Hi guys,
>   I want to connect to the 'delete_event' of a GnomeApp and decide in
> the handler if the window must be closed or not. The GTK+ docs says
> that returning TRUE from the handler will do the job, but this isn't
> working on pygtk.
> 
> def delete_event_handler():
> if foo is not None:
> return TRUE
> mainquit()

The delete event signal has widget and event arguments.  If your handler
doesn't accept these arguments, you get an error.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Any examples?

2001-03-05 Thread James Henstridge

On Mon, 5 Mar 2001, Eduardo Ferro wrote:

> Hi!
> 
> Anyone have a example of how can i log the stdout of a system call
> throught a scrolled window???
> I suposes that it a very normal to use python+gtk for this task, but I
> can`t find a good example of it.
> I actually use a timer to perodically read from a pipe, but this
> solution don`t seems very good.
> 
> Anyone know some program that do this using python+gtk to check the
> code???

So you want to display the text read from a pipe to a text window?

If so, then you want to use the input_add() function, which adds a
callback that will be called when there is info to be read/written
on the fd (depends on the flags passed to input_add).  I don't have any
example code for this at the moment though.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Finally got my pygtk widget compiled in Debian BUT ...

2001-03-05 Thread James Henstridge

On Mon, 5 Mar 2001, Danie Roux wrote:

> > modify the imlib build
> > procedure so that the image loader modules are dynamically linked back to
> > gdk_imlib.
> 
> Does that mean that each user would have to rebuild either Python or
> gnome-python? 'Cause that's not gonna work. The program is an archiver that
> makes life easier for novices. And I can't ask them to first rebuild this or
> that :-(

It sucks.  Currently released libtool don't let you do the fix to imlib
properly (it can't link one library to another uninstalled libtool
library).  This can only be fixed with libtool 1.4 and I have no idea when
that will be released.

I have a bug filed against GTK+ so that hopefully GTK+ 2.0 won't have
these problems.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Finally got my pygtk widget compiled in Debian BUT ...

2001-03-05 Thread James Henstridge

On Mon, 5 Mar 2001, Danie Roux wrote:

> Hi,
> 
> I've had a whole of lot of trouble with this gtk widget I wrote and
> wrapped in gnome-python. The module compiled and worked on RedHat, but
> would only compile on Debian. When I run it it would stop with
> "Undefined
> symbol ..."
> 
> Turned out the problem was that RedHat patched Python so that modules
> are
> loaded with RTLD_GLOBAL.
> 
> So after specifying that the module should link against all known
> libraries, it now runs. BUT it spits out a lot of errors like this:
> 
> /usr/bin/convert: No such file or directory
> gdk_imlib ERROR: Cannot load image:
> /usr/share/themes/E-Brushed/gtk/bc.xpm
> All fallbacks failed.
> 
> So what library do I still need to link in? Imagemagick is installed and
> 
> the convert program does exist. My current LDSHARED looks like this:
> 
> -L/usr/X11R6/lib -L/usr/lib -lICE -lIIOP -lORBit -lORBitCosNaming
> -lORBitutil -lSM -lX11 -lXext -lXi -lart_lgpl -laudiofile -lc -ldb -ldl
> -lesd -lgdk -lgdk_imlib -lglib -lgmodule -lgnome -lgnomesupport
> -lgnomeui -lgnorba -lgtk -ljpeg -lm -lpng -ltiff -lz -rdynamic -shared
> 
> Yes I know it's too much. I'm desperate. :-)

This is a bit of a FAQ :)

Either modify python to use RTLD_GLOBAL, or modify the imlib build
procedure so that the image loader modules are dynamically linked back to
gdk_imlib.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] GtkTextView and GtkTextBuffer python bindings?

2001-03-04 Thread James Henstridge

On Sun, 4 Mar 2001, Marco Bosch wrote:

> Hello,
> 
> I would like the new GtkTextView and GtkTextBuffer widgets which
> are available in  gtk+-1.3.2. However, it seems that pygtk doesn't
> contain bindings for them yet (at least, I checked pygtk-0.6.6).

pygtk 0.6.6 will not work with gtk 1.3.x (or 2.0 when it comes out).  The
head branch in CVS is where I am doing development against devel
gtk.  That has a binding for the new text and tree widgets among other
things.  Currently it doesn't work though (I haven't kept up with the API
changes for the last month or so).

> 
> Is there already a python binding available somewhere or is anybody
> planning on writing a binding?

It won't be usable for a while.  You should really be waiting for the gtk
2.0 release before using it for anything important though.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Setting a bitmap label on a button

2001-03-02 Thread James Henstridge

On Fri, 2 Mar 2001 [EMAIL PROTECTED] wrote:

> > I'm trying to change the label on a button at run time, to a bitmap for which I
> > have the data. The code fragment I'm using is:
> [...]
> 
> I seem to be having absolutely no luck with this.
> 
> Becasue I couldn't get create_bitmap_from_data to work, I'm now trying this
> instead:
> 
>   def set_label_to_bitmap(w, xbm):
>   pipefp = popen2.popen2("xbmtopbm | ppmtoxpm")
>   pipefp[1].write(xbm)
>   pipefp[1].close()
>   pixdata = pipefp[0].readlines()
> 
>   pixmap = gtk.create_pixmap_from_xpm_d(w, None, pixdata)
>   c = w.children()
>   if c:
>   c[0].destroy()
>   w.add(pixmap)
>   pixmap.show()
> 
> Yes, I know it's ugly. But even this doesn't work! I'm getting an exception
> of create_pixmap_from_xpm_d:

Well, you aren't passing the data in the form create_pixmap_from_xpm_d
expects.  If you look at an XPM file, you will notice that it is a C
declaration for an array of strings (you can actually include an XPM
directly into a C program).  It is this array of strings that
create_pixmap_from_xpm_d expects -- not the lines of the XPM file itself.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] libglade?

2001-02-25 Thread James Henstridge

On Sun, 25 Feb 2001, Russell Nelson wrote:

> First, I want to gush over libglade.  It makes development of a
> program *incredibly* easy.  You define how the program should look,
> then you create snippets of code which implement the program.  And so,
> you have a program!  If you're still creating pygtk widgets by hand,
> give it up.
> 
> I have three libglade questions:
> 
> 1) Is it so much more efficient to store the name of a widget in a
> variable than to use the WidgetWrapper trick to access it using
> win['widget']?

Looking up widgets with libglade is just a simple dictionary lookup, so it
shouldn't be a speed problem.

> 
> 2) I want to catch a button_press_event on a GtkDrawable.  It *ought*
> to be sufficient to define a signal handler for it, however I also had 
> to do this:
> mapd = w.get_widget('map')
> mapd.set_events(GDK.EXPOSURE_MASK | GDK.BUTTON_PRESS_MASK)
> Is this strictly necessary or did I do something wrong?

Go to the basic page of the properties dialog in glade, and select the
events you want set for your widget.

> 
> 3) Is there a program which can take a .glade file, and modify a .py
> file so that it matches the signal definitions with a
> GladeSignalHelper class?  It would be even cooler if I could just
> click on a signal in glade, and have a text editor bring up the
> associated code.  Of course, you'd need glade to print events to
> stdout, and a text editor to read them.

I have considered writing such a program to help use libglade with C, but
never got around to doing it.  I don't believe there is such a program for
python though.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] further along with copy and pasting but stuck again

2001-02-24 Thread James Henstridge

On Sat, 24 Feb 2001, rob wrote:

> hi,
> 
> I'm trying to get copy and pasting to work by followitg the gtk turtorial
> on it.
> I'm trying to translate their first code example into python but am getting
> the following error
> 
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.0/site-packages/gtk.py", line 125, in
> __call__
> ret = apply(self.func, a)
>   File "./xmlToTree03.py", line 275, in selection_received
> if atom_name(atom):
>   File "/usr/local/lib/python2.0/site-packages/gtk.py", line 2645, in
> atom_name
> return _gtk.gdk_atom_name(atom)
> TypeError: an integer is required
> 
> this is my bit of code
> 
> SELECTION_PRIMARY =  1
> 
> def nodePaste_cb(self,item,domNode):
> targets_atom = atom_intern("TARGETS", FALSE)
> item.selection_convert(SELECTION_PRIMARY, targets_atom,
> time.time())
> 
> def selection_received(self,widget,selection_data,data):
> if selection_data.length < 0:
> print ("selection retrieval failed")
> return
> if selection_data.type != SELECTION_TYPE_ATOM:
> print ("selection targets was not returned as atoms")
> return
> atoms = selction_data.data

Well, selection_data.data is a string, so the elements of atoms here would
be single characters.  You could convert it to the list of atoms with a
call like:

  atoms = struct.unpack('i' * (len(selection_data.data)/4),
selection_data.data)

(this may be wrong for non 32bit platforms)

> 
> for atom in atoms:
> if atom_name(atom):
> print atom_name(atom)
> else:
> print "Bad atom"
> return
> 
[snip]
> 
> can any one spot what I'm doing wrong?

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Widget Labels

2001-02-23 Thread James Henstridge

On Fri, 23 Feb 2001, cfox wrote:

> On Fri, 23 Feb 2001, James Henstridge wrote:
> 
> > On Thu, 22 Feb 2001, cfox wrote:
> >
> > > Actually, my problem is that I need to be able to change various labels
> > > after the widgets have been created.
> > 
> > Your menu item contains a GtkLabel as a child, so you can do the following
> > to change the text:
> >   label = menuitem.children()[0]
> >   label.set_text('whatever')
> >
> 
> Yes, that works great! But is there any guarantee that the label widget
> will always be the first child? This seems a bit fragile.
> 
> And is it the first child in every widget case? Radio, Button, Menu, etc?

The button and menu item widgets all derive from GtkBin, which is a
container that holds only a single child, so you can be pretty certain
that it will be the label :)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Creating a GdkFont

2001-02-23 Thread James Henstridge

On Thu, 22 Feb 2001, Michele Campeotto wrote:

> Hi all, 
>   how can I create a GdkFont from its xfd? (apart from creating a
> GnomeFontPicker, setting the font name and then retrieving the
> font...)
> 
> Thanks for your time

Use the load_font() function.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Widget Labels

2001-02-22 Thread James Henstridge

On Thu, 22 Feb 2001, cfox wrote:

> Actually, my problem is that I need to be able to change various labels
> after the widgets have been created.
> 
> All of my windows were created in Glade, and I'm just using pyglade to
> create my interface.
> 
> This application is pretty dynamic, and I need to be able to change button
> texts during the operation of the program.
> 
> Your solution for setting the label widget works perfectly. I guess what
> would work for me would be if I could get a handle on the label portion of
> an active widget (in this case, a GtkRadio and a GtkButton). Any ideas?

Your menu item contains a GtkLabel as a child, so you can do the following
to change the text:
  label = menuitem.children()[0]
  label.set_text('whatever')

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] GTK-GLarea

2001-02-22 Thread James Henstridge

On Thu, 22 Feb 2001, Nahuel Greco wrote:

> Now that PyOpenGL has new mantainer, etc, there will be support for
> gtkglarea widget from python?? (im using debian gnome-python)

PyGtk has had support for the GtkGLArea widget for a long time.  If you
have the widget installed on your system while compiling pygtk, then the
wrapper will get compiled.  It just wraps the GtkGLArea -- not OpenGL, so
you use PyOpenGL functions to render stuff, and the gtkglarea wrapper to
switch GLX contexts and process input.  There is a simple example program
included with pygtk.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] get_colormap().alloc(...) on Solaris

2001-02-21 Thread James Henstridge

On Thu, 22 Feb 2001, Brad Tonkes wrote:

> I'm having trouble with a Solaris (8) install of gnome-python (1.0.53, gtk
> 1.2.8) with respect to get_colormap().alloc().  Most easily reproduced with:
> 
> from gtk import *
> w = GtkWindow()
> w.get_colormap().alloc('red')  # Works fine.
> w.get_colormap().alloc(0, 0, 0)# Generates a bus error and dumps core.
> 
> Any rgb trio gives the same result.  GdkColor(r, g, b) works just fine, which
> is perhaps not surprising.  The example above also works just fine on a linux
> box with the same versions of gnome-python and gtk.  Is this most likely a
> problem with the gtk libs or with the python bindings?  Any help appreciated.

Please try this with gnome-python 1.4.0 (available from your closest 
ftp.gnome.org mirror (which would be mirror.aarnet.edu.au)).  I think this
problem should be fixed now.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] GdkImlib?

2001-02-20 Thread James Henstridge

On Tue, 20 Feb 2001, Russell Nelson wrote:

> I'm trying to figure out how to make GdkImlib work with a drawing
> area.  I've got a glade-written pygtk application (GPS interface) and
> I want to load a pixmap into a drawing area.  I'm trying to use the
> following code in the configure event for the drawing area, but I get
> the following error after the last line below:
> 
> TypeError: gdk_draw_pixmap, argument 3: expected GdkWindow, instance found
> 
> map_pixmap = create_pixmap(win, win.width, win.height, -1)
> draw_rectangle(map_pixmap, widget.get_style().white_gc, TRUE,
>0, 0, win.width, win.height)
> img = GdkImlib.Image('page01.gif')
> img.render()
> pix = img.make_pixmap()
  Change this to:
  pix, mask = img.get_pixmap()
> draw_pixmap(map_pixmap, widget.get_style().white_gc, pix, 0,0, 0,0, 
>win.width,win.height)

If the pixmap has some transparency, then you will want to set the
clipmask for the GC first.  If it is just a normal square pixmap, you can
ignore the mask.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Raising a window

2001-02-19 Thread James Henstridge

On Mon, 19 Feb 2001, Carsten Roedel wrote:

> I use the (half) private 'raise' method of GdkWindow.
> 
> Example:
> 
> theApp = GtkWindow()
> --- snip --- snip --- snip ---
> theApp.get_window()._raise()

This function was never meant to be half private.  I just got the pattern
for getting round a keyword conflict wrong in old versions.  The new
release allows you to use GdkWindow.raise_() instead (_raise still works
though).

For the gtk 2.0 rewrite the code generator automatically detects methods
with names that conflict with keywords and appends an underscore.

So don't hesitate to use the GdkWindow._raise() or
GdkWindow.raise_() methods :)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Syntax for setting up GtkCombo?

2001-02-19 Thread James Henstridge

On Mon, 19 Feb 2001, Steven M. Castellotti wrote:

> 
>   I seem to be having some syntactic difficulty getting a GtkCombo widget set 
>up. I have a hashtable full of strings which I would like to turn into items in the
> GtkCombo Box and later be able read back which was selected (somewhat like an 
>optionmenu, but I want the user to be able to add to the available list).
> 
>   Here's a sample of my code:
> 
> import gtk
> 
> current_combo = gtk.GtkCombo()
> current_gtklist = gtk.GtkList()
> 
> item_list = itemData.keys()
> item_list.sort()
> 
> for each in item_list:
> current_listitem = gtk.GtkListItem( itemData[each] )
> current_gtklist.append_items( current_listitem )
> 
> current_combo.set_popdown_strings(current_gtklist)

The set_popdown_strings() function is a convenience function for setting
up the combo.  It takes a list of strings to use in the combo box.  So you
could change your code to something like this:
  current_combo.set_popdown_strings(map(lambda x: itemData[x], item_list))

Or add the listitems you are creating with:
  current_combo.list.add(current_listitem)

(the GtkCombo already has a GtkList in it -- you don't create another one
for it).

Lastly, the append_items function is used to append multiple GtkListItem's
(so it takes a list of items).  Usually it is easier just to use the
add() method.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Stock pixmaps?

2001-02-19 Thread James Henstridge

On Mon, 19 Feb 2001 [EMAIL PROTECTED] wrote:

> Does anyone know how to find the files that the stock UI pixmaps are stored in?
> I want to set a GnomePixmap widget to one of these. Note that I can't use
> GnomeStock for this (I have to build my UI with Glade, and Glade doesn't know
> about GnomeStock).

Stock pixmaps are inside libgnomeui.so.  You can find them in png format
in the libgnomeui/pixmaps directory of the gnome-libs source tree.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] how to get the current Window Position?

2001-02-19 Thread James Henstridge

On Mon, 19 Feb 2001, Markus Gritsch wrote:

> Michele Campeotto wrote:
> 
> > > Does someone know how to get the position of a window on the screen?
> > >  I can
> > > set the position with
> > >
> > > mainwindow.set_uposition(500, 200)
> > >
> > > but I cannot find a way to get the current position.
> >
> > You can use
> >   GtkWindow.get_window().x
> >   GtkWindow.get_window().y
> > but this has a problem, it returns the pos of the _client_ window
> > wothouth wm decorations, so when you use set_uposition the window gets
> > moved down and right by some pixels... if somebody has a solution, my
> > ears are fully open
> 
> Well, IMHO GtkWindow.get_window().x gives me the *relative* position of
> the widget in its parent window, not the absolute position on the screen.

In the gnome-python 1.4.0 release (and pygtk 0.6.7, when I put out the
tarball), you can use the root_origin or deskrelative_origin attributes of
the GtkWindow, which are tuples giving the coordinates of the window.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] gnome-python 1.4.0

2001-02-19 Thread James Henstridge

On Mon, 19 Feb 2001, Tom Cato Amundsen wrote:

> On Mon, Feb 19, 2001 at 10:47:32AM +0800, James Henstridge wrote:
> > There is a new gnome-python tarball included in the gnome 1.4 beta.  I
> > haven't announced it, as I am waiting on the full gnome 1.4 release.
> > 
> > If you find any bugs in it, please report them so I can fix them before
> > the full release.
> > 
> gtkhtml.py is not installed when ./configure --with-gtkhtml

I have no idea what would be causing that problem.  On my system it gets
installed without problem.  I haven't changed any of the logic used to
decide whether to install it.

Good to hear that it works well for you.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



[pygtk] gnome-python 1.4.0

2001-02-18 Thread James Henstridge

There is a new gnome-python tarball included in the gnome 1.4 beta.  I
haven't announced it, as I am waiting on the full gnome 1.4 release.

If you find any bugs in it, please report them so I can fix them before
the full release.

It is available from your favourite gnome mirror as
/pub/GNOME/stable/sources/gnome-python/gnome-python-1.4.0.tar.gz

I haven't made a corresponding pygtk tarball yet, but you can compile just
pygtk by changing to the pygtk directory before running configure and
make.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] problem with closing gtkwindows

2001-02-18 Thread James Henstridge

On 18 Feb 2001, Guenther Starnberger wrote:

> hi,
> 
> i have a problem with closing/reopening gtkwindows. (i am using
> glade/libglade.)
> 
> in a programm i open a gtkwindow foo with foo.show().
> 
> closing the window with foo.hide() and reopening it with foo.show()
> works.
> 
> but when i close the window with the windowmanager i can't reopen
> it. i only get an empty window and the following error message:
> 
> ->8-->8-->8-->8-->8-->8-->8--
> Gtk-CRITICAL **: file gtkstyle.c: line 522 (gtk_style_attach):
> assertion `style != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkstyle.c: line 1128
> (gtk_style_set_background): assertion `style != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkstyle.c: line 3532 (gtk_paint_flat_box):
> assertion `style != NULL' failed.
> ->8-->8-->8-->8-->8-->8-->8--
> 
> i tried to make an handler for the signal "destroy" which calls
> foo.hide(). the handler gets called, but the error is still the same.

Well, by the time the destroy signal is emitted, the window is already
destroyed :)

Try the following:
  def delete_event(widget, event):
  widget.hide()
  return TRUE
  window.connect("delete_event", delete_event)

That should cause the window to be hidden and not destroyed when the
delete event is received (ie. when the window manager close button is
used).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Keyboard Accelerators question

2001-02-16 Thread James Henstridge

On Fri, 16 Feb 2001, Markus Gritsch wrote:

> How can I access 'state' and 'keyval' of the structure with PyGTK?

event.state and event.keyval :)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Keyboard Accelerators question

2001-02-16 Thread James Henstridge

On Fri, 16 Feb 2001, Markus Gritsch wrote:

> > > Markus Gritsch wrote:
> > >
> > > ok, I figured out, how to put an underscore under a letter in a label,
> > > but I still wonder, how to trigger a function with a keyboard
> > > accelerator.
> >
> > First of all, get a reference to the label in the button like so:
> >   label = button.children()[0]
> >
> > Next, call the parse_uline function of the label:
> >   keysym = label.parse_uline('The _Label I want')
> >
> > This will set the label with the correct underline, and return the keysym
> > for the accelerator with any modifiers (ctrl, or whatever) you want:
> >
> > Next, add an accelerator to some accel group
> >   accel_group.add(keysym, modifiers, 0, button, 'clicked')
> >
> > (and make sure the accel group is attached to the window you want it to
> > work from).  Now when the accelerator is pressed, the clicked signal of
> > the button will be emitted (the same as happens when the button is really
> > clicked).
> 
> Thanks for your detailed description.  Fortunately I came up with the same
> solution.
> 
> The problem which remains is, how can I bind a keyboard accelerator to
> something else than a signal of an object?  For example to some arbitrary
> function.  A suggested solution was to create an invisible button, and bind
> a keyboard accelerator to it's clicked signal which in turn calls my
> function, but I think there must be a more elegant way.

In that case, you should probably just connect to the key_press_event of
the widget in question and look for the appropriate key presses, and
return TRUE if you decide to handle the event.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Ioctl question

2001-02-15 Thread James Henstridge

On Thu, 15 Feb 2001, Eduardo Ferro wrote:

> Hi!
> 
> I have a python question not directily related with pygnome nor pygtk,
> but i supose that all off you know a lot off python, so sorry for the
> Offtopic (and for my english)

Yes, this is offtopic :)  The python newsgroup is a better place to ask
general python questions.

> 
> I must do a call to a ioctl but this ioctl return me a estructure, i
> test some ioctl without parameter, or with structures, and it works,
> but the structure didn change... i don`t have any examples off ioctls
> with python...
> 
> Is this chunk of code correct:
> 
>chdr = struct.pack('BB',0,0)
>fcntl.ioctl(self.cd.fileno(),CDROMREADTOCHDR,chdr)

Change this line to:
 chdr = fcntl.ioctl(self.cd.fileno(),CDROMREADTOCHDR,chdr)

>print struct.unpack('BB',chdr)
> 
> it allways print (0,0) but this ioctl change the structure...
> 
> Any ioctls examples? any url about this issue?
> 
> Thanks in advance and sorry for the offtopic

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] Keyboard Accelerators question

2001-02-15 Thread James Henstridge

On Thu, 15 Feb 2001, Markus Gritsch wrote:

> Markus Gritsch wrote:
> 
> > I have managed to bind a keyboard accelerator (Ctrl-s) to the clicked
> > signal of a button with something like this:
> >
> > accel_group = GtkAccelGroup()
> > button.add_accelerator('clicked', accel_group, GDK.s,
> > GDK.CONTROL_MASK, 1)#GTK_ACCEL_VISIBLE)
> > window.add_accel_group(accel_group)
> >
> > *) How can I connect a keyboard accelerator to something else, e.g. a
> > function?
> > *) How can I put an underscore under a letter in the label of the
> > button to give a hint for the keyboard accelerator?
> 
> ok, I figured out, how to put an underscore under a letter in a label,
> but I still wonder, how to trigger a function with a keyboard
> accelerator.

First of all, get a reference to the label in the button like so:
  label = button.children()[0]

Next, call the parse_uline function of the label:
  keysym = label.parse_uline('The _Label I want')

This will set the label with the correct underline, and return the keysym
for the accelerator with any modifiers (ctrl, or whatever) you want:

Next, add an accelerator to some accel group
  accel_group.add(keysym, modifiers, 0, button, 'clicked')

(and make sure the accel group is attached to the window you want it to
work from).  Now when the accelerator is pressed, the clicked signal of
the button will be emitted (the same as happens when the button is really
clicked).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



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



Re: [pygtk] python-glade and hidden windows

2001-02-15 Thread James Henstridge

[EMAIL PROTECTED] wrote:
> 
> I'm using Glade to define a number of frames that I want to embed in my
> application. I'm loading the window containing the frame, reparenting the frame
> to where I want it, and then destroying the window.
> 
> Unfortunately, all Glade windows seem to appear shown by default. That is, you
> load the window from the Glade file, and it's automatically mapped without any
> further action. Because I'm destroying the window almost immediately, this is
> causing lots of slow and ugly flicker.
> 
> Is there any way to make the window appear unmapped? Then I can remove the
> frame and destroy the window without anything ever appearing on the screen.

Yes.  Unset the 'visible' option for the widget in glade.  Libglade is
simply doing what the glade file tells it to.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/

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



Re: [pygtk] Window position

2001-02-05 Thread James Henstridge

On Tue, 6 Feb 2001, Eduardo Ferro wrote:

> Hi!
>
> I am trying to set the absolute position of a top window, but i can`t
> find the function. I test the set_position but it is`t that i want, i
> want to set the x and y position of the window
> Any suggestions???

Try the set_uposition method.

James.


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



Re: [pygtk] gnome-python gtkhtml help offered

2001-02-05 Thread James Henstridge

On Mon, 5 Feb 2001, Tom Cato Amundsen wrote:

> On Mon, Feb 05, 2001 at 10:41:50AM +, [EMAIL PROTECTED] wrote:
> > [...]
> > > It is really simple to build them yourself on debian, it is just
> > > apt-get source python-gnome
> > > cd python-gnome-1.0.53
> > > apply my patch
> > > dpkg-buildpackage -rfakeroot -us -uc
> >
> > Do you know when this patch will be included in the main Debian distribution?
> > The program I'm working on needs an HTML widget, too; as it involves a lot of
> > rather complex dependencies I'd rather avoid forcing the user to patch their
> > system to make it work. Currently I'm using GtkXmHtml, which sucks to a largish
> > extent.
> >
> I have not talked to the python-gnome maintainer, but I'll file a bug
> and send him the patch today. The problem is loading of graphics. In the
> callback function for the 'url_requested' signal I get an error message
> and the program exits. I have not investigated this very much, I have
> never needed to learn that much about shared libs.

As well as sending me the patch, please file it in bugzilla.gnome.org, so
I don't forget about it ([EMAIL PROTECTED] will redirect to bugzilla
now, but you may as well go directly to bugzilla).

>
> The function:
> def on_url_requested(self, html, fn, handle):
> """This is called when the widget need to load images
> """
> s = open(fn, 'r').read()
> self.__html.write(handle, s)
>
> The errror message:
> python1.5: error while loading shared libraries: 
>/usr/lib/gdk-pixbuf/loaders/libpixbufloader-png.so: undefined symbol: g_malloc0

So we see the RTLD_GLOBAL problem turn up again :)

The fix is to either modify your copy of python to use the RTLD_GLOBAL
flag when it dlopen()'s an extension module, or relink all the image
loader modules for gdk-pixbuf so that they link to all the libraries that
they actually use (this is easiest to do with libtool-1.3b where you can
link against not yet installed libtool libraries, but if you have already
installed the package once, you can just link the module against the
installed gdk-pixbuf library).  The second option is probably the better
(but more work to do), and would fix it for all other apps that dlopen
libraries that link to gdk-pixbuf.

For gtk 2.0 development, I end up relinking all the pango, gtk IM and
pixbuf modules just to get things to load :)

>
> I am running a mix of potato/testing/unstable, but the libraries causing
> the trouble is from unstable.

James.


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



Re: [pygtk] Problem inheriting from GtkWindow

2001-02-04 Thread James Henstridge

On Sun, 4 Feb 2001, Buzz Megg wrote:

> Why does this code snippet start throwing Gtk-CRITICAL warnings?
> 
> #! /usr/bin/env python
> 
> import gtk
> 
> class wv_TopWindow(gtk.GtkWindow):
> def __init__(self):
> gtk.GtkWindow.__init__(self)
> self.set_usize(400,400)
> 
> self.connect("destroy",self.quit())
> self.connect("delete_event",self.quit())
> self.show()
> 
> def quit(self,*args):
> self.hide()
> self.destroy()
> gtk.mainquit()
> 
> def main():
> win = wv_TopWindow()
> gtk.mainloop()
> 
> if __name__ == "__main__": main()
> 
> 
> The results are as follows:
> Gtk-CRITICAL **: file gtkmain.c: line 534 (gtk_main_quit): assertion 
> `main_loops != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkmain.c: line 534 (gtk_main_quit): assertion 
> `main_loops != NULL' failed.

Here because you are calling mainquit() more times than you call
mainloop() (both on delete_event and destroy).

> 
> Gtk-CRITICAL **: file gtkwidget.c: line 3539 
> (gtk_widget_set_style_internal): assertion `style != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkstyle.c: line 522 (gtk_style_attach): assertion 
> `style != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkstyle.c: line 1128 (gtk_style_set_background): 
> assertion `style != NULL' failed.
> 
> Gtk-CRITICAL **: file gtkstyle.c: line 3532 (gtk_paint_flat_box): assertion 
> `style != NULL' failed.

These may be caused by performing operations on a destroyed widget
(although I am not totally sure).

James.


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



<    1   2   3   4   5   6   7   8   9   10   >