Re: [pygtk] Trouble with widgets in a canvas

2000-01-31 Thread James Henstridge

The canvas does not always work well with no-window widgets (ones that
paint themselves directly onto their parent's window (done for speed)).
The easiest way around this problem is to pack the widget inside a
GtkEventBox.

Alternatively, if you just want a bit of text on the canvas, you may as
well use the text canvas item:
 item = canvas.root.add('text', text='Some text', x=42, y=21,
font='some-x-font', fill_color='red',
anchor=ANCHOR_SW)

The other benefit of this is that the text will be shaped rather than
being enclosed in a solid colour rectangle.  Note that for
GnomeCanvasText, the (x,y) coords give the position of the anchor point.
You use the anchor property to set where the anchor is located.

James.

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


On Mon, 31 Jan 2000, Douglas P. Mennella wrote:

> Hello,
> First off, I'm a brand newbie and it's possible that all I need is a
> reference.  Secondly,
> here it goes:
> 
> I was trying to modify the canvas example that came with pygnome.
> Instead of creating rectangles I wanted to create a label and drag it
> around.  The trouble is that the label doesn't
> seem to be redrawing itself.  In fact, if I minimize and then
> un-minimize, the label disappears.
> Do I need to connect to some event or something?  Here's the code and
> what I've got installed:
> 
> % rpm -qa | grep py
> pygtk-libglade-0.6.3-1
> python-devel-1.5.2-7
> pythonlib-1.23-1
> pygtk-0.6.3-1
> pygnome-1.0.50-1
> python-1.5.2-7
> python-docs-1.5.2-7
> 
> Any help would be appreciated.
> -Doug
> 
> ---
> #! /usr/bin/env python
> 
> from gtk import *
> from gnome.ui import *
> from GDK import *
> 
> from libglade import *
> 
> gladexml = GladeXML(
> filename='/home/doug/Projects/project2/project2.glade',
>  domain='/home/doug/Projects/project1')
> 
> canvas = gladexml.get_widget('canvas1')
> l=GtkLabel('Hey')
> l.show()
> w1=canvas.root().add('widget', widget=l,
> x=10,y=10,height=50,width=50)
> 
> appbar=gladexml.get_widget('appbar1')
> remember_x = 0
> remember_y = 0
> def item_event(widget, event=None):
> print widget
> if event.type == GDK.BUTTON_PRESS:
> if event.button == 1:
> # Remember starting position.
> global remember_x, remember_y
> remember_x = event.x
> remember_y = event.y
> appbar.set_status('(%i, %i)' % (remember_x, remember_y))
> #widget.raise_to_top()
> return TRUE
> 
> elif event.type == GDK.MOTION_NOTIFY:
> if event.state & GDK.BUTTON1_MASK:
> global remember_x, remember_y
> # Get the new position and move by the difference
> new_x = event.x
> new_y = event.y
> 
> widget.move(new_x - remember_x, new_y - remember_y)
> #widget.raise_to_top()
> 
> remember_x = new_x
> remember_y = new_y
> 
> return TRUE
> return FALSE
> 
> w1.connect('event', item_event)
> def shutdown(widget,event=None):
> print canvas.root().children()
> mainquit(widget)
> 
> gladexml.get_widget('app1').connect('destroy', shutdown)
> 
> mainloop()
> 
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



[pygtk] Trouble with widgets in a canvas

2000-01-31 Thread Douglas P. Mennella

Hello,
First off, I'm a brand newbie and it's possible that all I need is a
reference.  Secondly,
here it goes:

I was trying to modify the canvas example that came with pygnome.
Instead of creating rectangles I wanted to create a label and drag it
around.  The trouble is that the label doesn't
seem to be redrawing itself.  In fact, if I minimize and then
un-minimize, the label disappears.
Do I need to connect to some event or something?  Here's the code and
what I've got installed:

% rpm -qa | grep py
pygtk-libglade-0.6.3-1
python-devel-1.5.2-7
pythonlib-1.23-1
pygtk-0.6.3-1
pygnome-1.0.50-1
python-1.5.2-7
python-docs-1.5.2-7

Any help would be appreciated.
-Doug

---
#! /usr/bin/env python

from gtk import *
from gnome.ui import *
from GDK import *

from libglade import *

gladexml = GladeXML(
filename='/home/doug/Projects/project2/project2.glade',
 domain='/home/doug/Projects/project1')

canvas = gladexml.get_widget('canvas1')
l=GtkLabel('Hey')
l.show()
w1=canvas.root().add('widget', widget=l,
x=10,y=10,height=50,width=50)

appbar=gladexml.get_widget('appbar1')
remember_x = 0
remember_y = 0
def item_event(widget, event=None):
print widget
if event.type == GDK.BUTTON_PRESS:
if event.button == 1:
# Remember starting position.
global remember_x, remember_y
remember_x = event.x
remember_y = event.y
appbar.set_status('(%i, %i)' % (remember_x, remember_y))
#widget.raise_to_top()
return TRUE

elif event.type == GDK.MOTION_NOTIFY:
if event.state & GDK.BUTTON1_MASK:
global remember_x, remember_y
# Get the new position and move by the difference
new_x = event.x
new_y = event.y

widget.move(new_x - remember_x, new_y - remember_y)
#widget.raise_to_top()

remember_x = new_x
remember_y = new_y

return TRUE
return FALSE

w1.connect('event', item_event)
def shutdown(widget,event=None):
print canvas.root().children()
mainquit(widget)

gladexml.get_widget('app1').connect('destroy', shutdown)

mainloop()


To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] Any Chance the Next release will support?

2000-01-31 Thread Fred L. Drake, Jr.


Matt Wilson writes:
 > If we make a permanent mapping between gtk widgets and python objects,
 > we're going to have to think very hard to make sure that we get the
 > memory management right.  As soon as your have circular references

  I'm supposed to be looking into support for weak references for
Python (which I've been too busy to look at so far).  This is
definately one of the more important applications; I'll be keeping
this in mind.


  -Fred

--
Fred L. Drake, Jr.
Corporation for National Research Initiatives
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] pyglade/libglade ignores default-width/default-height ?

2000-01-31 Thread James Henstridge

I suppose I should put in a message stating that the pyglade module is
deprecated.  It is probably better to use the libglade module, which uses
libglade rather than being pure python.  It handles the default_width and
default_height attributes correctly.

James.

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


On Sun, 30 Jan 2000, Kelly Lynn Martin wrote:

> I've got a teeny .glade file (written as I try to figure out glade and
> company) that has distinctly different behaviour when I build it as a
> glade project vs. running it in libglade with glade.py frm the
> examples/ directory.  The pyglade version ignores the default window
> size specifications and doesn't connect some of my signals the way
> glade does.  Is this me using glade wrong, or is this a pyglade
> deficiency?
> 
> The .glade file is appended.
> 
> Kelly
> 
> 
> 
> 
> 
>   Glade-hello
>   glade-hello
>   
>   src
>   pixmaps
>   C
>   False
>   True
>   False
>   True
>   True
>   True
>   True
>   interface.c
>   interface.h
>   callbacks.c
>   callbacks.h
>   support.c
>   support.h
>   
> 
> 
> 
>   GtkWindow
>   window1
>   True
>   
> delete_event
> gtk_widget_destroy
> Sat, 29 Jan 2000 04:23:33 GMT
>   
>   
> destroy
> on_window1_destroy
> Sat, 29 Jan 2000 04:30:05 GMT
>   
>   window1
>   GTK_WINDOW_TOPLEVEL
>   GTK_WIN_POS_NONE
>   False
>   100
>   100
>   True
>   True
>   True
> 
>   
> GtkButton
> button1
> True
> True
> 
>   clicked
>   gtk_widget_destroy
>   window1
>   Sat, 29 Jan 2000 04:24:01 GMT
> 
> Hello World
>   
> 
> 
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



[pygtk] zterm

2000-01-31 Thread Javi Román

Hi:

I am having trouble using zterm (pygnome librRY) . Scroll don't work
correctly: cursor pass the window limits. How can i fix it?

Thanks.
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]