Re: [pygtk] GtkTextTags and cursor position

2002-03-19 Thread James Henstridge

Pier wrote:

>Hi,
>I've a gtkTextBuffer with many tags applied, and I want to know if the
>cursor is into a region where for example a tag named "default" is
>applied: how can I do?
>
As with the Tk text widget, the insertion point is a special mark named 
"insert".  You can get a reference to this mark with the following:
  insertionpoint = buffer.get_insert()
or
  insertionpoint = buffer.get_mark("insert")

Then you can get a GtkTextIter that represents the position in the 
buffer where the insertion point is:
  iter = buffer.get_iter_at_mark(insertionpoint)

You can then check whether the tag is active at this point in the buffer 
with:
  if iter.has_tag(tag): ...

(this is the GtkTextTag object -- not the tag name, btw).

James.

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



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



Re: [pygtk] Setting the Colors in a ZVTerm

2002-03-19 Thread James Henstridge

Eric Gillespie wrote:

>This is the second time i've had to deal with this broken
>interface, this time broken in a different way.  See
>
>for the first time.
>
>What i ended up doing to work around that bug was this:
>
>from gnome.zvt import *
>from gtk   import *
>
>colors = [ (0, 0, 0),
>   (43690, 0, 0),
>   (0, 43690, 0),
>   (43690, 21845, 0),
>   (0, 0, 43690),
>   (43690, 0, 43690),
>   (0, 43690, 43690),
>   (43690, 43690, 43690),
>   (21845, 21845, 21845),
>   (65535, 21845, 21845),
>   (21845, 65535, 21845),
>   (65535, 65535, 21845),
>   (21845, 21845, 65535),
>   (65535, 21845, 65535),
>   (21845, 65535, 65535),
>   (65535, 65535, 65535),
>   (43690, 43690, 43690),
>   (0, 0, 0)
>   ]
>
>for i in range(len(colors)):
>colors[i] = (colors[i],)
>
>win = GtkWindow(WINDOW_DIALOG)
>term = ZvtTerm(80, 25)
>term.set_color_scheme(colors)
>term.show()
>win.add(term)
>
>win.show()
>
>mainloop()
>
>Ugly, but it worked.  Now i'm having to do this again and
>i discover that the interface has changed yet again.  Running
>that program merely gives me this error:
>
>Traceback (most recent call last):
>  File "fuck.py", line 29, in ?
>term.set_color_scheme(colors)
>  File "/usr/pkg/lib/python2.1/site-packages/gnome/zvt.py", line 66, in 
>set_color_scheme
>_zvt.zvt_term_set_color_scheme(self._o, color_list)
>TypeError: list items must be like (int,int,int)
>
>Strangely, eliminating the for loop doesn't change the error
>message!  I'm very confused.
>
>1) How can i work around this?
>
>2) Will this interface ever be repaired properly?
>
>Thanks in advance.
>
There is a fix for this in CVS now (I checked it in a few days ago). 
 The colour components are meant to be unsigned shorts, and I was using 
PyArg_ParseTuple's "h" format character to read the tuples. 
 Unfortunately this is for reading signed shorts, so any number greater 
than 0x7fff (32767) would cause the above exception.

Until the next release, you can work around the bug by subtracting 
0x from the larger numbers (the negative ints will be treated as 
ints > 0x7fff).

James.

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



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



Re: [pygtk] pygtk2 init error

2002-03-19 Thread James Henstridge

Pier wrote:

>Hi to all,
>I've download and install the pygtk2 rpm (version 1.99.8-2) for rawhide.
>When I start my program I ha the following error
>
>Traceback (most recent call last):
>  File "./Gnominide", line 3, in ?
>import  os, sys, time, gtk
>  File 
>"/usr/src/build/80068-i386/install/usr/lib/python2.2/site-packages/gtk/__init__.py", 
>line 19, in ?
>ImportError: /usr/lib/python2.2/site-packages/gtk/_gtkmodule.so: undefined symbol: 
>PyUnicodeUCS4_SetDefaultEncoding
>
>(gtk2 rpms ver2.0 from gtk.org)
>
>Any idea?
>
Sounds like you are using a PyGTK compiled against a python with wide 
unicode support (ie. 32 bit unicode characters, which don't limit you to 
the basic multilingual plane) with a python compiled without wide 
unicode characters.

Try downloading the pygtk-1.99.8 from ftp.gtk.org (I think that RPM you 
have is actually based on a snapshot between 1.99.7 and 1.99.8 judging 
by the build date, btw).

James.

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



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



Re: [pygtk] Questions about scrollbars and trees

2002-03-19 Thread James Henstridge

Jon Nelson wrote:

>On Tue, 19 Mar 2002 09:40:54 +0800
>"James Henstridge" <[EMAIL PROTECTED]> wrote:
>
>>You can use the plus and minus keys to expand and collapse the selected 
>>node in the ctree.
>>
>
>Cool!  In the meantime, I grabbed the key_press_event signal for the ctree,
>and checked for GDK.{Left,Right}.  If it was one of those, I did an
>"emit_stop_by_name" on key_press_event, and then performed a little
>magic to expand/collapse the current focus row.
>
>Would it be better to avoid the magic and try to emit a +/- keypress?
>
I think you can set this up in a gtkrc file for your application.  As 
GtkCTree uses the GTK Bindings API, you should be able to load a file 
holding something like:
  binding "my-ctree-bindings" {
bind "right" {
  "change_focus_row_expansion" (expand)
}
bind "left" {
  "change_focus_row_expansion" (collapse)
}
  }
  widget "widgetname" binding "my-ctree-bindings"

Load the gtkrc file with gtk.rc_parse(), then call set_name() on your 
CTree so that the above binding affects it.  If you want the left/right 
bindings above for all CTrees in all apps, put the above in your 
~/.gtkrc file, with the following line:
  class "GtkCTree" binding "my-ctree-bindings"

(I may have gotten the syntax slightly off, as I didn't test this 
specific case.  Have a play around with it until it works).

In gtk 2.0, many more widgets can have their key bindings customised 
like 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
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] Setting the Colors in a ZVTerm

2002-03-19 Thread Eric Gillespie

This is the second time i've had to deal with this broken
interface, this time broken in a different way.  See

for the first time.

What i ended up doing to work around that bug was this:

from gnome.zvt  import *
from gtkimport *

colors = [ (0, 0, 0),
   (43690, 0, 0),
   (0, 43690, 0),
   (43690, 21845, 0),
   (0, 0, 43690),
   (43690, 0, 43690),
   (0, 43690, 43690),
   (43690, 43690, 43690),
   (21845, 21845, 21845),
   (65535, 21845, 21845),
   (21845, 65535, 21845),
   (65535, 65535, 21845),
   (21845, 21845, 65535),
   (65535, 21845, 65535),
   (21845, 65535, 65535),
   (65535, 65535, 65535),
   (43690, 43690, 43690),
   (0, 0, 0)
   ]

for i in range(len(colors)):
colors[i] = (colors[i],)

win = GtkWindow(WINDOW_DIALOG)
term = ZvtTerm(80, 25)
term.set_color_scheme(colors)
term.show()
win.add(term)

win.show()

mainloop()

Ugly, but it worked.  Now i'm having to do this again and
i discover that the interface has changed yet again.  Running
that program merely gives me this error:

Traceback (most recent call last):
  File "fuck.py", line 29, in ?
term.set_color_scheme(colors)
  File "/usr/pkg/lib/python2.1/site-packages/gnome/zvt.py", line 66, in 
set_color_scheme
_zvt.zvt_term_set_color_scheme(self._o, color_list)
TypeError: list items must be like (int,int,int)

Strangely, eliminating the for loop doesn't change the error
message!  I'm very confused.

1) How can i work around this?

2) Will this interface ever be repaired properly?

Thanks in advance.

-- 
Eric Gillespie <*> [EMAIL PROTECTED]
Software Developer
Progeny Linux Systems - http://progeny.com/
"When everyone has to reinvent the wheel, many people invent
 square wheels."
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] GtkTextTags and cursor position

2002-03-19 Thread Pier

Hi,
I've a gtkTextBuffer with many tags applied, and I want to know if the
cursor is into a region where for example a tag named "default" is
applied: how can I do?

Thank you
Pier Carteri



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



[pygtk] Geometry management help

2002-03-19 Thread Steve McClure

Can someone point me to some manual geometry management help somewhere? 
What I want is to pop up a GtkEntry widget in a cell of a GtkCList when
the user clicks on it.  It looks like in order to place the widget where
I want it I need to use the GtkFixed or GtkLayout widgets.  However, it
looks like I need to adjust the GtkCList child to fit into those
widgets. As soon as I call set_usize() on the CList in the container, a
recursive loop is started.

Any help/pointers/finger wagging would be greatly appreciated.
-- 
Steve McClure   430 10th St NW
Racemi  Suite N-210
http://www.racemi.com   Atlanta, GA 30318
[EMAIL PROTECTED] voice/fax: 404-892-5850

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



[pygtk] pygtk2 init error

2002-03-19 Thread Pier

Hi to all,
I've download and install the pygtk2 rpm (version 1.99.8-2) for rawhide.
When I start my program I ha the following error

Traceback (most recent call last):
  File "./Gnominide", line 3, in ?
import  os, sys, time, gtk
  File 
"/usr/src/build/80068-i386/install/usr/lib/python2.2/site-packages/gtk/__init__.py", 
line 19, in ?
ImportError: /usr/lib/python2.2/site-packages/gtk/_gtkmodule.so: undefined symbol: 
PyUnicodeUCS4_SetDefaultEncoding

(gtk2 rpms ver2.0 from gtk.org)

Any idea?

Pier


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



Re: [pygtk] Questions about scrollbars and trees

2002-03-19 Thread Jon Nelson

On Tue, 19 Mar 2002 09:40:54 +0800
"James Henstridge" <[EMAIL PROTECTED]> wrote:

> You can use the plus and minus keys to expand and collapse the selected 
> node in the ctree.

Cool!  In the meantime, I grabbed the key_press_event signal for the ctree,
and checked for GDK.{Left,Right}.  If it was one of those, I did an
"emit_stop_by_name" on key_press_event, and then performed a little
magic to expand/collapse the current focus row.

Would it be better to avoid the magic and try to emit a +/- keypress?

-- 
The Amazing* Jon Nelson <[EMAIL PROTECTED]>
C and Python Programmer, Code Gardener
Just because it's not broken doesn't mean we can't take it apart.
  (* may not actually amaze)
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/