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 make some mini CRM application in python using gtk(pygtk), glade and started to develop it using quickly(which is awesome).

I'm created some dialogs and added listview to the GUI using glade) but when I try to add some items to the list dynamically, from the script that glade\quickly created so the application will show some data to the user that called from MySql (if there is another option ill be glad to here about..) it show alot of errors instead (in the terminal).

I looked for some tutorials but all I found is only tuts that explain how to create the list from scratch (not using quickly, and glade).

Here is the code:

This is the applicationWindow.py that created by quickly

I added basic code for buttons dialogs and so...

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

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

from ubuntucrm_lib import Window
from ubuntucrm.AboutUbuntucrmDialog import AboutUbuntucrmDialog
from ubuntucrm.PreferencesUbuntucrmDialog import PreferencesUbuntucrmDialog
from ubuntucrm.PopupcalendarDialog import PopupcalendarDialog
from ubuntucrm.NewcustomerDialog import NewcustomerDialog
from ubuntucrm.GlobalsearchDialog import GlobalsearchDialog

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

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

    self.AboutDialog = AboutUbuntucrmDialog
    self.PreferencesDialog = PreferencesUbuntucrmDialog
    #self.PopupcalendarDialog = PopupcalendarDialog

    # Code for other initialization actions should be added here.

    self.CalendarButton = self.builder.get_object("CalendarButton")
    self.contactsButton = self.builder.get_object("contactsButton")
    self.productsButton = self.builder.get_object("productsButton")
    self.OtherButton    = self.builder.get_object("OtherButton")

    #dialogs
    self.cal = PopupcalendarDialog()
    self.contactsDialog = NewcustomerDialog()
    self.globalsearcher = GlobalsearchDialog()

    #lists and modelers
    self.leftTree    = self.builder.get_object("leftTreeview")
    self.treeModeler = self.builder.get_object("liststorer1")


    #functions
def on_OtherButton_clicked(self, widget):
    print "you clicked OtherButton"

//here i tried somthing like:

    self.treeModeler.append(["bla bla","some text"])

//for example, "bla bla" loaded from some MySQL Database..

def on_productsButton_clicked(self, widget):
    print "you clicked producs button" 
    self.globalsearcher.run()


def on_contactsButton_clicked(self, widget):
    print "you clicked contactButton "
    self.contactsDialog.run()


def on_CalendarButton_clicked(self, widget):
    print "calling to calendar button"
    self.cal.run()

The error is:

 (ubuntucrm:10443): Gtk-CRITICAL **: gtk_list_store_get_value: assertion `column < priv->n_columns' failed

and the order is incorrect


|some text | bla bla |


instead of:


| bla bla | some text |


share|improve this question

2 Answers 2

up vote 0 down vote accepted

Always provide the full traceback and additional warnings/output. That said, your problem is in the following line of code:

    self.treeModeler.append("bla bla")

You should provide a list of items that corresponds to the columns in the Gtk.TreeModel. So if your model only has 1 string column, simple put some brackets around your string:

    self.treeModeler.append(["bla bla"])

Do you have more columns with different types? Provide them in your list:

    self.treeModeler.append(["bla bla", 1234, False, 1.234, GdkPixbuf.Pixbuf, None])

Edit to your edit: Remember that you add values to the Gtk.TreeModel columns, not Gtk.TreeView columns. See my screenshots in this answer and make sure you mapped each Gtk.TreeModel column to the correct Gtk.CellRendererText.

share|improve this answer

I got this error when I had the GtkCellRendererText text attribute set to a zero-based index on a column that did not exist.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.