[pygtk] Removing the cursor

Edward Catmur ed at catmur.co.uk
Mon Aug 21 06:24:02 WST 2006


On Sun, 2006-08-20 at 18:10 -0400, Mike Bernson wrote:
> I set use the following to make the widget uneditable.
> 
> widget.props.editable = False
> 
> widget is gtk.Entry widget has an Editable interface and this should set
> the widget to non-editable.
> 
> The entry widget does not allow any edit which I thought should also
> turn off the insert cursor. This is not the case
> 
> Here is a simple program that show the problem
> 
> import gtk
> 
> window = gtk.Window()
> entry = gtk.Entry()
> entry.props.editable = False
> window.add(entry)
> window.show_all()
> 
> gtk.main()

Ah, yeah. Use

entry.props.editable = False
entry.props.can_focus = False
entry.props.has_focus = False

Alternatively if you want to prevent selecting text and copying the
entry content, just use 

entry.props.sensitive = False

However the latter is not to be preferred; allowing users to select and
copy text is more friendly.


Ed



More information about the pygtk mailing list