[pygtk] pygtk-1.99.3

2001-10-08 Thread James Henstridge

I have just uploaded a new pygtk tarball.  This fixes many of the crashes
people had with the 1.99.2 release (these were mainly due to inadequate
testing after merging the python22-branch).

The package will soon be available from:
  ftp://ftp.gnome.org/pub/GNOME/earthquake/sources/pygtk/

Like before, this release requires python >= 2.2a4 and gtk+ >= 1.3.9 (plus
its dependencies).  Main features of this release:
  - crash fixes (me, msw)
  - fix reference leak in last reference handling (me)
  - gobject.new wrapper (msw)
  - make code generator output #line statements, so errors in the
overrides file give correct line number/filename (me)
  - split type definitions out of pango, gdk and gtk defs files so that
other modules which need to know about the type definitions of some
other module don't need to parse all the function/method defs (this
speeds up builds slightly).  (me)
  - add many missing wrappers (msw, zilch)
  - bug fixes (lots of people).

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] [patch] PYGTK_NO_THREADS patch

2001-10-08 Thread Christian Robottom Reis


this is not my day

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL


Index: gtkmodule.c
===
RCS file: /cvs/gnome/gnome-python/pygtk/gtkmodule.c,v
retrieving revision 1.53.2.9
diff -u -r1.53.2.9 gtkmodule.c
--- gtkmodule.c 2001/08/26 09:21:06 1.53.2.9
+++ gtkmodule.c 2001/10/09 05:12:20
@@ -75,28 +75,32 @@
  * Python/C function; thus, the initial lock count will always be one.
  */
 #  define INITIAL_LOCK_COUNT 1
-#  define PyGTK_BLOCK_THREADS  \
-   {   \
- gint counter = GPOINTER_TO_INT(g_static_private_get(&counter_key));   \
- if (counter == -INITIAL_LOCK_COUNT) { \
-   PyThreadState *_save;   \
-   _save = g_static_private_get(&pythreadstate_key);   \
-   Py_BLOCK_THREADS;   \
- } \
- counter++;\
- g_static_private_set(&counter_key, GINT_TO_POINTER(counter), NULL);   \
+#  define PyGTK_BLOCK_THREADS\
+   { \
+ if ( !getenv("PYGTK_NO_THREADS") ) {\
+ gint counter = GPOINTER_TO_INT(g_static_private_get(&counter_key)); \
+ if (counter == -INITIAL_LOCK_COUNT) {   \
+   PyThreadState *_save; \
+   _save = g_static_private_get(&pythreadstate_key); \
+   Py_BLOCK_THREADS; \
+ }   \
+ counter++;  \
+ g_static_private_set(&counter_key, GINT_TO_POINTER(counter), NULL); \
+  }  \
}
 
-#  define PyGTK_UNBLOCK_THREADS\
-   {   \
- gint counter = GPOINTER_TO_INT(g_static_private_get(&counter_key));   \
- counter--;\
- if (counter == -INITIAL_LOCK_COUNT) { \
-   PyThreadState *_save;   \
-   Py_UNBLOCK_THREADS; \
-   g_static_private_set(&pythreadstate_key, _save, NULL);  \
- } \
- g_static_private_set(&counter_key, GINT_TO_POINTER(counter), NULL);   \
+#  define PyGTK_UNBLOCK_THREADS  \
+   { \
+  if ( !getenv("PYGTK_NO_THREADS") ) {   \
+ gint counter = GPOINTER_TO_INT(g_static_private_get(&counter_key)); \
+ counter--;  \
+ if (counter == -INITIAL_LOCK_COUNT) {   \
+   PyThreadState *_save; \
+   Py_UNBLOCK_THREADS;   \
+   g_static_private_set(&pythreadstate_key, _save, NULL);\
+ }   \
+ g_static_private_set(&counter_key, GINT_TO_POINTER(counter), NULL); \
+  }  \
}
 
 
@@ -7162,7 +7166,7 @@
 #ifdef WITH_THREAD
  /* it is required that this function be called to enable the thread
   * safety functions */
- if (!g_threads_got_initialized)
+ if ( !g_threads_got_initialized && !getenv("PYGTK_NO_THREADS") )
  g_thread_init(NULL);
 #endif
 



[pygtk] [patch] PYGTK_NO_THREADS patch

2001-10-08 Thread Christian Robottom Reis


Hi James,

The attached patch adds a check for the environment variable
PYGTK_NO_THREADS and disables threading in runtime if it is set. This is a
very important patch to the orbit-python team because it will allow us to
run clients that are also CORBA servers and thus can service requests.

With this patch and Johan's ORBit-Python patch we can actually run the
echo test server with gtk.mainloop and have it work perfectly.

James, if you would rather have a bug created for this, just answer or
/topic on IRC. Thanks.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL

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



Re: [pygtk] pygtk - gtk Drawing Area - need help!

2001-10-08 Thread Matt Wilson

On Tue, Oct 09, 2001 at 11:19:42AM +0800, James Henstridge wrote:
> 
> Unfortunately, the GdkGC object in 1.99.x doesn't handle this shorthand
> for setting attributes like it did in 0.6.x -- this statement just sets an
> object attribute.  The set_foreground() method should work instead.

If you want, I can add it back in...

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



Re: [pygtk] pygtk - gtk Drawing Area - need help!

2001-10-08 Thread James Henstridge

On Mon, 8 Oct 2001, Skip Montanaro wrote:

>
> Tom> Can someone port this do pygtk2? Is enough functions wrapped yet to
> Tom> do this?
>
> >> from gtk import *
> >>
> >> def _on_expose(drawingarea, event):
> >> # get the GdkWindow
> >> window = event.window
> >>
> >> # get the GC
> >> gc = window.new_gc()
> >>
> >> # create a green color
> >> color = drawingarea.get_colormap().alloc(0x, 0x, 0x)
> >>
> >> # use this color for drawing
> >> gc.foreground = color

Unfortunately, the GdkGC object in 1.99.x doesn't handle this shorthand
for setting attributes like it did in 0.6.x -- this statement just sets an
object attribute.  The set_foreground() method should work instead.

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 set widget's foreground color?

2001-10-08 Thread James Henstridge

On Mon, 8 Oct 2001, Skip Montanaro wrote:

>
> How do I set the foreground color of a widget without using rc files or
> strings?  I've tried this (w being a displayed gtk.Button instance in my
> example)
>
> gc = w.window.new_gc()
> color = gtk.gdk.color_parse("red")
> w.modify_fg(gtk.STATE_NORMAL, color)
>
> and
>
> gc = w.window.new_gc()
> color = gtk.gdk.color_parse("red")
> gc.set_foreground(color)

parse_color isn't enough.  Basically, it just fills in the red, green and
blue members of of the GdkColor object.  In order for the colour to be
usable, it needs to be allocated in the widget's GdkColormap.

Currently you can do this with "widget.get_colormap().alloc(colour)".
This will set the pixel member of the GdkColor, which is the index into
the widget's colormap (or for TrueColor visuals, just the packed
representation of the colour).  This is what is really used by these
routines.

For 0.6.x, this process was all handled by the GdkColormap.alloc() method.
I haven't yet written the wrappers that would make GdkColormap.alloc in
1.99.x act this way as well.

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 set widget's foreground color?

2001-10-08 Thread Matt Wilson

No, you're changing the style that the label is using when drawing
itself on its parent.

Matt

On Mon, Oct 08, 2001 at 03:48:46PM -0500, Skip Montanaro wrote:
> 
> Matt> That means you want to modify the *label* inside the button:
> 
> Thanks, that works as I had hoped, but I thought Label widgets didn't have
> their own windows, so you had to make fg/bg changes to the window they lived
> in?
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to set widget's foreground color?

2001-10-08 Thread Skip Montanaro


Matt> That means you want to modify the *label* inside the button:

Thanks, that works as I had hoped, but I thought Label widgets didn't have
their own windows, so you had to make fg/bg changes to the window they lived
in?

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



Re: [pygtk] how to set widget's foreground color?

2001-10-08 Thread Matt Wilson

That means you want to modify the *label* inside the button:

import gtk

def click(b, *args):
label = b.get_child()
b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))
label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("green"))

def mainquit(*args):
gtk.main_quit()

def _test():
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("title")
window.connect("destroy", mainquit)

close = gtk.Button(label="press me!")
close.connect("clicked", click)
window.add(close)

window.show_all()

gtk.main()

if __name__ == "__main__":
_test()

On Mon, Oct 08, 2001 at 03:24:54PM -0500, Skip Montanaro wrote:
> 
> Matt> On Mon, Oct 08, 2001 at 11:09:51AM -0500, Skip Montanaro wrote:
> >> 
> >> gc = w.window.new_gc()
> >> color = gtk.gdk.color_parse("red")
> >> gc.set_foreground(color)
> 
> Matt> You'd be surprised, but it's actually the background that you want
> Matt> to modify here.
> 
> Matt> w.modify_bg(gtk.STATE_NORMAL, color)
> 
> Yeah, I guess I would be surprised, since I was hoping to change the color
> of the text in the widget, not the background of the button.  ;-) Calling
> modify_bg does change the background color of the button, but that's not
> quite what I was after.
> 
> Maybe I should have phrased my question differently.  How do I change the
> text color in a button?  I thought that would have been covered by asking
> how to change the foreground color in a widget.  Given this code:
> 
> import gtk
> 
> def click(b, *args):
> gc = b.window.new_gc()
> color = gtk.gdk.color_parse("red")
> b.modify_bg(gtk.STATE_NORMAL, color)
> color = gtk.gdk.color_parse("green")
> b.modify_fg(gtk.STATE_NORMAL, color)
> 
> def _test():
> window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> window.set_title("title")
> window.connect("destroy", gtk.mainquit)
> 
> close = gtk.Button(label="press me!")
> close.connect("clicked", click)
> window.add(close)
> 
> window.show_all()
> 
> gtk.mainloop()
> 
> if __name__ == "__main__":
> _test()
> 
> after I click the button, when the button is in STATE_NORMAL, the background
> is red, however the text is still black.
> 
> -- 
> Skip Montanaro ([EMAIL PROTECTED])
> http://www.mojam.com/
> http://www.musi-cal.com/
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to set widget's foreground color?

2001-10-08 Thread Skip Montanaro


Matt> On Mon, Oct 08, 2001 at 11:09:51AM -0500, Skip Montanaro wrote:
>> 
>> gc = w.window.new_gc()
>> color = gtk.gdk.color_parse("red")
>> gc.set_foreground(color)

Matt> You'd be surprised, but it's actually the background that you want
Matt> to modify here.

Matt> w.modify_bg(gtk.STATE_NORMAL, color)

Yeah, I guess I would be surprised, since I was hoping to change the color
of the text in the widget, not the background of the button.  ;-) Calling
modify_bg does change the background color of the button, but that's not
quite what I was after.

Maybe I should have phrased my question differently.  How do I change the
text color in a button?  I thought that would have been covered by asking
how to change the foreground color in a widget.  Given this code:

import gtk

def click(b, *args):
gc = b.window.new_gc()
color = gtk.gdk.color_parse("red")
b.modify_bg(gtk.STATE_NORMAL, color)
color = gtk.gdk.color_parse("green")
b.modify_fg(gtk.STATE_NORMAL, color)

def _test():
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("title")
window.connect("destroy", gtk.mainquit)

close = gtk.Button(label="press me!")
close.connect("clicked", click)
window.add(close)

window.show_all()

gtk.mainloop()

if __name__ == "__main__":
_test()

after I click the button, when the button is in STATE_NORMAL, the background
is red, however the text is still black.

-- 
Skip Montanaro ([EMAIL PROTECTED])
http://www.mojam.com/
http://www.musi-cal.com/
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to set widget's foreground color?

2001-10-08 Thread Matt Wilson

On Mon, Oct 08, 2001 at 11:09:51AM -0500, Skip Montanaro wrote:
> 
> gc = w.window.new_gc()
> color = gtk.gdk.color_parse("red")
> gc.set_foreground(color)

You'd be surprised, but it's actually the background that you want to
modify here.

w.modify_bg(gtk.STATE_NORMAL, color)

Cheers,

Matt


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



Re: [pygtk] pygtk - gtk Drawing Area - need help!

2001-10-08 Thread Skip Montanaro


Tom> Can someone port this do pygtk2? Is enough functions wrapped yet to
Tom> do this?

>> from gtk import *
>> 
>> def _on_expose(drawingarea, event):
>> # get the GdkWindow
>> window = event.window
>> 
>> # get the GC
>> gc = window.new_gc()
>> 
>> # create a green color
>> color = drawingarea.get_colormap().alloc(0x, 0x, 0x)
>> 
>> # use this color for drawing
>> gc.foreground = color
>> 
>> # draw a line
>> drawingarea.draw_line(gc, 0, 0, 200, 200)
>> 
>> 
>> # the usual stuff
>> win = GtkWindow()
>> win.connect("destroy", mainquit)
>> win.show()
>> 
>> # create the drawing area
>> drawingarea = GtkDrawingArea()
>> drawingarea.connect("expose-event", _on_expose)
>> drawingarea.show()
>> win.add(drawingarea)
>> 
>> # enter the mainloop
>> mainloop()

I came up with this:

#!/usr/bin/env python

import gtk

def _on_expose(drawingarea, event):
# get the GdkWindow
window = event.window

# get the GC
gc = window.new_gc()

# create a green color
color = gtk.gdk.color_parse("green")

# use this color for drawing
gc.foreground = color

# draw a line
drawingarea.window.draw_line(gc, 0, 0, 200, 200)


# the usual stuff
win = gtk.Window()
win.connect("destroy", gtk.mainquit)
win.show()

# create the drawing area
drawingarea = gtk.DrawingArea()
drawingarea.connect("expose-event", _on_expose)
drawingarea.show()
win.add(drawingarea)

# enter the mainloop
gtk.mainloop()

Everything seems to work (no errors), but the line is drawn in black.  Note
that the DrawingArea widget doesn't support draw_* directly.  I had to dive
into the underlying Gdk widget for that.

Suggested fix(es)?

-- 
Skip Montanaro ([EMAIL PROTECTED])
http://www.mojam.com/
http://www.musi-cal.com/
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



[pygtk] how to set widget's foreground color?

2001-10-08 Thread Skip Montanaro


How do I set the foreground color of a widget without using rc files or
strings?  I've tried this (w being a displayed gtk.Button instance in my
example)

gc = w.window.new_gc()
color = gtk.gdk.color_parse("red")
w.modify_fg(gtk.STATE_NORMAL, color)

and

gc = w.window.new_gc()
color = gtk.gdk.color_parse("red")
gc.set_foreground(color)

but neither had any effect.  I'm using the 2.0 API and the new
ExtensionClass-less PyGtk API.

Thanks,

-- 
Skip Montanaro ([EMAIL PROTECTED])
http://www.mojam.com/
http://www.musi-cal.com/
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] pygtk - gtk Drawing Area - need help!

2001-10-08 Thread Tjabo Kloppenburg

hi martin!

> > Is there sample code somewhere, or a geek who knows all this? :-)
> Maybe here's a geek who knows these things... :)
> ...

great - I'll try this out!


graçias!
  tk.

-- 
+ Tjabo Kloppenburg + taponet.de + de,en +
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk