Hi, Darren Hart

> When I tab into a gtk.Entry, all the text gets selected.  When I click in
> it, my cursor get's placed, and no text is selected.  Since the default for
> my particular application will be to replace the text, I would like to
> select it all when I click in it.  I've tried calling entry.select_region(0=
> ,-1)
> from various signal handlers, but it always seems to get undone.  Can
> someone suggest a solution?
> 
> Thanks.
> 
> -- =
> 
> Darren Hart

I tried to make a simple script.
Following sample shows a simple window that contains two entries.
Each entry can select entire text by clicking.

---------------------------
import sys
import pygtk
if sys.platform != 'win32':
    pygtk.require('2.0')
import gtk


class simpleWindow:
    def __init__(self):
        self.wind = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.wind.set_border_width(2)
        self.wind.set_size_request(400, 300)

        self.wind.connect('delete_event', self.__on_quit)

        vbox = gtk.VBox()
        entry = gtk.Entry()
        entry.connect('event', self.__on_entry_clicked)
        vbox.pack_start(entry)
        
        entry = gtk.Entry()
        entry.connect('event', self.__on_entry_clicked)
        vbox.pack_start(entry)

        self.wind.add(vbox)
        self.wind.show_all()
        
        gtk.main()

    def __on_entry_clicked(self, widget, event, data=None):
        if event.type == gtk.gdk.BUTTON_RELEASE:
            widget.select_region(0, -1)

    def __on_quit(self, widget, event=None):
        print '-- quit --'
        gtk.main_quit()
        return False

def main():
    wind = simpleWindow()

if __name__ == '__main__':
    main()
_______________________________________________
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/

Reply via email to