Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2819  / 3 Years ago, thu, november 18, 2021, 3:27:09

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 gladequickly 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 |





More From » quickly

 Answers
2

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.


[#35774] Thursday, November 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
howesale

Total Points: 224
Total Questions: 117
Total Answers: 116

Location: Nauru
Member since Thu, May 18, 2023
1 Year ago
;