Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 3201  / 2 Years ago, sun, october 9, 2022, 11:25:31

I use a Gtk.IconView widget in my app to select different types of elements. The way the IconView works is the following:




  • Do one click to select the item

  • Do an additional double-click to activate the item



I've always found it confusing that an additional double click is needed, when most button-like widgets in the desktop just require a single click. Now I've just had feedback from a couple of users that find it confusing (someone thought it was a bug that clicking on the button "did nothing"), so I've decided to look into how to change that behaviour.



Ideally, I'd like the IconView to behave as follows:




  • Hover to select an item (optional)

  • Single-click activates the item



Now I haven't found anything obvious in the widget's properties to make it behave like that. Does anyone know how or if that could be achieved?



Gtk.IconView in action


More From » python

 Answers
1

One solution (but only for the single click activation) is of cause to use the selection_changed signal of the IconView (because the IconView selection is single click based).



A sample that assumes a working on_item_activated signal would be:



def on_icon_view_selection_changed(self, widget):
self.on_item_activated(widget, widget.get_selected_items()[0])

[#37997] Tuesday, October 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
coffekne

Total Points: 114
Total Questions: 122
Total Answers: 126

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
;