Re: [pygtk] Highlighting all occurances of a string in a TextBuffer

2005-07-20 Thread Rich Burridge

John Finlay wrote:


Looks OK to me except last line should be:

   start = matchEnd

And I would create the tag in an initialization method.


Thanks, I'll adjust accordingly.




Are you sure that searchStr is in buffer?



No it wasn't. In fact, nothing was in the text buffer. Here was the code 
I had:


   buffer = gtk.TextBuffer()
   highlightText(buffer, searchStr)
   buffer.set_text(results)
   self.result_view.set_buffer(buffer)

A quick reordering of those lines fixed the problem.

M u s t   g e t   m o r e   s l e e p.
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Gtk.Image unused widget space size

2005-07-20 Thread mammique
Hi,

i use a Gtk.Image, with pixbuf set from a file, and i would like to know
the new size of the widget when resized, to adjust the pixmap to this
size. But the only thing i can get is the size of the displayed pixmap,
i need the size of the Gtk.Image containing it (gray borders that appear
on resize).

Is it possible ?

Thanks.

Best regards.

Camille.

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


Re: [pygtk] Highlighting all occurances of a string in a TextBuffer

2005-07-20 Thread John Finlay

Rich Burridge wrote:



Hi all,

I'm trying to write a function that will highlight all occurances of the
string searchStr in the TextBuffer buffer. This is what I've currently 
got

that doesn't work.


def highlightText(buffer, searchStr):
buffer.create_tag("red_foreground", foreground="red")
start, end = buffer.get_bounds()
finished = False

while finished == False:
res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)
if not res:
finished = True
else:
matchStart, matchEnd = res
buffer.apply_tag_by_name("red_foreground", matchStart, 
matchEnd)

start = matchStart


What's happening is that:

res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)

is always returning None.  Any clues to what I'm doing wrong would be
appreciated, or a pointer to some other Pygtk code that does something
similar.


Looks OK to me except last line should be:

   start = matchEnd

And I would create the tag in an initialization method.

Are you sure that searchStr is in buffer?

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


[pygtk] Highlighting all occurances of a string in a TextBuffer

2005-07-20 Thread Rich Burridge


Hi all,

I'm trying to write a function that will highlight all occurances of the
string searchStr in the TextBuffer buffer. This is what I've currently got
that doesn't work.


def highlightText(buffer, searchStr):
buffer.create_tag("red_foreground", foreground="red")
start, end = buffer.get_bounds()
finished = False

while finished == False:
res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)
if not res:
finished = True
else:
matchStart, matchEnd = res
buffer.apply_tag_by_name("red_foreground", matchStart, matchEnd)
start = matchStart


What's happening is that:

res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)

is always returning None.  Any clues to what I'm doing wrong would be
appreciated, or a pointer to some other Pygtk code that does something
similar.

Thanks.

--
Rich Burridge   Email: [EMAIL PROTECTED]
Sun Microsystems Inc. (MPK14-260),  Phone: +1.650.786.5188
4150 Network Circle,AIM/YAHOO: RicBurridge
Santa Clara, CA 95054   Blog:  http://blogs.sun.com/richb
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] Re: Themes and Stand Alone GTK

2005-07-20 Thread Brian Campbell
>Two simple questions:

>1) There's a way to set the theme that an app will use, without
>setting it globally or for the user? Like, just that app will use a
>different theme...

>2) Using Python or py2exe to generate a standalone executable requires
>the installation of the gtk runtime for win32, there's a way to pack
>the runtime in some way that doesn't require installing the whole
>package? Like, a private gtk installation on the apps dir.

I can answer #1 for you.  You can have an application specific stylesheet,
which you can read in intialization with gtk.rc_parse(filename), or you can
use an inline style sheet, embedding in the code, which you can parse with
gtk.rc_parse_string(string).  An inline style looks something like this:
my_style_string = """
style "white_background" {
fg[NORMAL] = "#00"
bg[NORMAL] = "#FF"
text[NORMAL] = "#00"
base[NORMAL] = "#FF"
}
widget "*.white_bgd" style "white_background"
"""
gtk.rc_parse_string(my_style_string)

I think you got a good answer to #2 already...


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


[pygtk] howto get the directory size

2005-07-20 Thread Ogz
With such a code: gnomevfs.async.get_file_info(uri),
fileinfo_callback, options = gnomevfs.FILE_INFO_DEFAULT |
gnomevfs.FILE_INFO_GET_MIME_TYPE)

ıt is possible to get the size of the file by using fileinfo_callback function. 

Is there a way like this for directories? When i apply it for a
directory name, i get 4MB, fix size wich doesnt include the sub files
or directories size.
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] question about handle pending events (Hussein Vastani)

2005-07-20 Thread Gustavo J. A. M. Carneiro
On Wed, 2005-07-20 at 10:17 +0100, Stephen Kennedy wrote:
> > > Ok so i read that if I have
> > > 
> > > while gtk.events_pending():
> > > gtk.main_iteration(False)
> > > 
> > > inserted at the right places in my callback (which can be long 
> > > computational 
> > > ), my application would look response since it will get an opportunity to 
> > > handle other user events while completing the callback. Consider a case 
> > > where 
> 
> I have found generators to be perfect for this kind of scenario.
> In my app, there often are 5+ tasks in process and I don't need
> to write any code to interrupt them if the app exits.
> 
> http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.009.htp

  See also:
http://www.gnome.org/~gjc/gtasklet/gtasklets.html

  Regards.

-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic

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


[pygtk] question about handle pending events (Hussein Vastani)

2005-07-20 Thread Stephen Kennedy
> > Ok so i read that if I have
> > 
> > while gtk.events_pending():
> > gtk.main_iteration(False)
> > 
> > inserted at the right places in my callback (which can be long 
> > computational 
> > ), my application would look response since it will get an opportunity to 
> > handle other user events while completing the callback. Consider a case 
> > where 

I have found generators to be perfect for this kind of scenario.
In my app, there often are 5+ tasks in process and I don't need
to write any code to interrupt them if the app exits.

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.009.htp

Stephen.
-- 
Stephen Kennedy <[EMAIL PROTECTED]>
http://meld.sf.net visual diff and merge

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