Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to build an application that will prompt the user for a string, and then add that string to a Scrolling Listview object using quickly and PyGTK.

I've been following this tutorial:

http://developer.ubuntu.com/resources/app-developer-cookbook/multimedia/creating-a-simple-media-player/

When I hit the add button, the prompt comes up properly and I'm able to enter the string. The column appears correctly but the list ends up being blank. What am I doing wrong?

import gettext
from gettext import gettext as _
gettext.textdomain('spiderweb')

from gi.repository import Gtk # pylint: disable=E0611
import logging
logger = logging.getLogger('spiderweb')

from spiderweb_lib import Window
from spiderweb.AboutSpiderwebDialog import AboutSpiderwebDialog
from spiderweb.PreferencesSpiderwebDialog import PreferencesSpiderwebDialog
from quickly import prompts
from quickly.widgets.dictionary_grid import DictionaryGrid
import os


# See spiderweb_lib.Window.py for more details about how this class works
class SpiderwebWindow(Window):
    __gtype_name__ = "SpiderwebWindow"

    def finish_initializing(self, builder): # pylint: disable=E1002
        """Set up the main window"""
        super(SpiderwebWindow, self).finish_initializing(builder)

        self.AboutDialog = AboutSpiderwebDialog
        self.PreferencesDialog = PreferencesSpiderwebDialog       

        # Code for other initialization actions should be added here.
        self.supported_web_formats = [".net",".html", ".com"]


    def on_addbutton_clicked(self, widget, data=None):
        #let the user choose a path with the directory chooser
        response, string = prompts.string("Enter a string", "Please enter string:", "Sample Text")

        #make certain the user said ok before working
        if response == Gtk.ResponseType.OK:

           #make a list of the supported media files
           media_files = Gtk.ListStore(str)
           #add a dictionary to the list of media files
           media_files.append({"String":string})

           #remove any children in scrolled window
           for c in self.ui.scrolledwindow1.get_children():
               self.ui.scrolledwindow1.remove(c)

           #create the grid with list of dictionaries
           #only show the File column
           media_grid = DictionaryGrid(media_files, keys=["File"])

           #show the grid, and add it to the scrolled window
           media_grid.show_all()
           self.ui.scrolledwindow1.add(media_grid)
share|improve this question

closed as too localized by Bruno Pereira Nov 11 '12 at 20:25

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.