3

i have a small GUI that i created, and when it fires up, the 'first' gtk.Entry that i have created is always highlighted (in a series of entries).

essentially, here is how i create it:

my_entry = gtk.Entry(1)
my_entry.set_width_chars(1)
my_entry.set_alignment(0.5)
my_entry.set_text('1')

i then go on to create several more entries. i then call 'show' on them all at the same time, and then use 'pack_start' to put them into a vbox.

whenever i start the GUI, the '1' is highlighted. how can i remove this highlight?

thanks. just can't figure this one out.

Cœur
  • 37,241
  • 25
  • 195
  • 267
jasonmclose
  • 1,667
  • 4
  • 22
  • 38
  • The highlight is what happens when a GtkEntry that has text in it is focused. What do you want to happen instead -- should some other widget be focused on startup? – Jussi Kukkonen Nov 27 '13 at 13:08
  • 2
    i would prefer that no widget has focus. is that possible? if not, i guess i could give one of the buttons on the page the focus. i just see the end-users not liking this field being highlighted on startup. – jasonmclose Nov 27 '13 at 14:41
  • Is it possible to focus it, but NOT have it all highlighted? I would like for the text position to be at the very end. I know, I know 2 years later, but it's worth a shot :) – TuxForLife Nov 10 '15 at 09:08
  • 1
    And @jasonmclose, if you still need help, let me know lol, I just don't know how to do the opposite! – TuxForLife Nov 10 '15 at 09:09
  • 1
    I'm having the same problem! Anyone know what's up with this? Very annoying! – Stretto Sep 11 '17 at 13:00
  • I also have this problem, but in ruby-gtk. I am writing a wrapper over ImageMagick finally (gimp is annoying me too much, in particular the user-interface changes), and all is fine - but I have one gtk-entry right now, and on startup, the entry is in-focus AND everything is selected in that entry, which is annoying. In theory I should be able to do .set_focus(false) and .select_region(0, 0) to disable both, but somehow it does not work, and I can not find out why. For some reason gtk wants to focus and select everything,.... it is annoying because it distracts from the buttons on the bottom. – shevy Feb 15 '21 at 16:44
  • 1
    Interestingly I made a bit of progress; I set the entry to disallow any modifications, and after everything else just used Thread.new {} with a miniscule sleep(), and in that thread made the gtk-entry editable again. The net result was that it was NOT in focus and NOT highlighted. So this is weird to me ... I think there may be some bug involved perhaps? But whatever the reason, this tiny hack allowed me to continue. Not sure how this is with pygobject but I assume if the behaviour is on the C-GTK level then pygobject should behave similarly to ruby-gtk3 (which also uses introspection). – shevy Feb 15 '21 at 17:27

0 Answers0