Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 4404  / 2 Years ago, wed, august 31, 2022, 9:24:12

I'm developing an application using Quickly. I have a Gtk.TreeView with a Gtk.ListStore as its model. The selection mode of the Gtk.SelectionMode is set to Gtk.SelectionMode.MULTIPLE.



The problem is that the Gtk.SelectionMode does not behave as it should:




  • Only one row can be selected at a time.

  • Impossible to select multiple rows using the Ctrl or Shift key.

  • Once a row is selected, it can't be deselected using the Ctrl key.

  • Nothing happens when I press the arrow keys.



The problem can be easily reproduced by creating a new Ubuntu application using Quickly (or you can download a test application below).



$ quickly create ubuntu-application test
$ cd test
$ quickly design


Create a TreeView with a ListStore as its model. Set the mode of the GtkTreeSelection to 'Multiple'. Add some columns and values to the ListStore. Add some TreeViewColumns with CellRendererTexts to the Treeview.



$ quickly run -v


Note you can't select multiple rows.



Some things I've already tried, but did not change anything:




  • Setting the selection mode in the code.



    self.ui.selection.set_mode(Gtk.SelectionMode.MULTIPLE)



    or



    self.ui.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)


  • Moving the GtkTreeSelection <child> below the GtkTreeViewColumn <child> in the UI file.


  • Deleting the GtkTreeSelection from the UI file and setting the selection with



    self.ui.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)




Am I overlooking something obvious? Or could this be a bug?



On a side note, if you set the selection to 'Single', it's also not possible to deselect the row.



EDIT



If you'd like to help me out, you can download a test application here instead of creating a new project with Quickly on your own. Please note you need Quickly to run it.



$ cd test
$ quickly run


I've implemented some callbacks for testing purposes in test/test/TestWindow.py. You can find the UI definition in test/data/ui/TestWindow.ui.


More From » 13.04

 Answers
2

I found the solution to my own problem.



The 'can-focus' property of the Gtk.TreeView is set to False by default. Setting this to True fixes the strange selection behavior, as well as other strange behavior that might occur, like not being able to resize a column while its 'resizable' property is set to True.


[#31296] Thursday, September 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atchcommo

Total Points: 114
Total Questions: 130
Total Answers: 101

Location: Cook Islands
Member since Sat, Oct 16, 2021
3 Years ago
atchcommo questions
Fri, May 13, 22, 08:22, 2 Years ago
Wed, Mar 9, 22, 20:14, 2 Years ago
;