DictionaryGrid.get_dictionaries_copy() only returns an empty list

Bug #829032 reported by Jo-Erlend Schinstad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Quickly Widgets
Incomplete
Undecided
Unassigned

Bug Description

get_dictionaries_copy() doesn't return a copy. Only an empty list.

Revision history for this message
Jo-Erlend Schinstad (joerlend.schinstad-deactivatedaccount) wrote :

Perhaps I've misunderstood the point of it. I do stuff like this:

keys = ["field1", "field2"]
dg = DictionaryGrid(keys=keys)

and then I do:

dicts = dg.get_dictionaries_copy().

This returns an empty list when dictionaries haven't been
set. I think this is confusing. If you've told it which keys to
use, but not added any dictionaries, then I think it should
return a list of dictionaries using the provided keys.

Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

There are no dictionaries in the grid, so there is nothing to return.

Changed in quidgets:
status: New → Invalid
Revision history for this message
Jo-Erlend Schinstad (joerlend.schinstad-deactivatedaccount) wrote :

Still, if there is data in the grid and you have set the keys, then shouldn't that be considered dictionaries? I thought the dictionaries were only meant as a convenient way of adding data to a grid?

Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

In your code sample, there are keys, but there are values. The purpose of the function is to get all the data, but in a copy so you can change the data without changing the model of the grid. Since there are no rows, there is no data. The function returns all the dictionaries it has, which is zero.

Sorry if I'm not being clear. Another way to look at it is that the keys are not data, but column headings. A row can have any dictionary it wants, it doesn't even have to have the keys in it. In such case, none of the dictionaries data would be displayed, but that's ok, the data would still be there.

Anyway, the upshot is, if there are no rows, there are no dictionaries, so I content that the function is working properly.

Revision history for this message
Jo-Erlend Schinstad (joerlend.schinstad-deactivatedaccount) wrote :

no, you misunderstood. There are rows with data in them. I've added it in the grid. I just didn't use the dictionaries parameter when I created the grid. But still, when I call get_dictionaries_copy(), I get an empty list.

I would've expected to see a dictionary representation of the data in the grid, even if I hadn't used the dictionaries parameter in the constructor.

Revision history for this message
Rick Spencer (rick-rickspencer3) wrote :

That's a bug then. Could you please paste in the code that causes that to happen. If there are rows with data, you should get back a copy.

Changed in quidgets:
status: Invalid → Incomplete
Revision history for this message
Jo-Erlend Schinstad (joerlend.schinstad-deactivatedaccount) wrote :

import gtk
from quickly.widgets.dictionary_grid import DictionaryGrid

win = gtk.Window()
win.set_title("This is a bug")
vbox = gtk.VBox()
hbox = gtk.HBox()
add_button = gtk.Button("Add row")
print_button = gtk.Button("Print dictionaries")
hbox.pack_start(add_button, True, True)
hbox.pack_start(print_button, True, True)

keys = ["first_name", "last_name"]
dg = DictionaryGrid(keys=keys)
dg.editable = True
vbox.pack_start(dg, True, True)
vbox.pack_start(hbox, False, False)
win.add(vbox)
win.show_all()

def print_dicts(widget):
    print(dg.get_dictionaries_copy())

def add_row(widget):
    dg.append_row({})

print_button.connect("clicked", print_dicts)
add_button.connect("clicked", add_row)
win.connect("delete-event", gtk.main_quit)
gtk.main()

Add some rows and print it out. You'll see that it returns just an empty list.

Revision history for this message
yuri (yusswarm) wrote :

sorry for off topic

Oneiric Ocelot 11.10
I also get empty Dictionary Grid.
Now installed quickly-widgets for 11.08

In use the code from tutorial until part "Display the List to the User" inclusively,
i.e code in these discussion was not used, just clean install by lesson.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.