GTK List store `column < list_store->n_columns' failed

Programmierung für GNOME und GTK+, GUI-Erstellung mit Glade.
Antworten
Benutzeravatar
martinjo
User
Beiträge: 186
Registriert: Dienstag 14. Juni 2011, 20:03

Hallo, ich habe folgendes Programm ohne großartige Funktion und bekomme dort mehrere Fehlermeldungen:
verkaufsstatistiken_gtk_local.py:80: GtkWarning: gtk_list_store_get_value: assertion `column < list_store->n_columns' failed
self.window.show_all()
verkaufsstatistiken_gtk_local.py:80: Warning: g_object_set_property: assertion `G_IS_VALUE (value)' failed
self.window.show_all()
verkaufsstatistiken_gtk_local.py:80: Warning: g_value_unset: assertion `G_IS_VALUE (value)' failed
self.window.show_all()
verkaufsstatistiken_gtk_local.py:85: GtkWarning: gtk_list_store_get_value: assertion `column < list_store->n_columns' failed
gtk.main()
verkaufsstatistiken_gtk_local.py:85: Warning: g_object_set_property: assertion `G_IS_VALUE (value)' failed
gtk.main()
verkaufsstatistiken_gtk_local.py:85: Warning: g_value_unset: assertion `G_IS_VALUE (value)' failed
gtk.main()
Ich komme leider nicht dahinter an was es liegt und würde mich über Hilfe freuen. Hier der Code:

Code: Alles auswählen

#!/usr/bin/env python
#-*- coding: utf-8 -*-

import gtk
import csv

productfile = 'Data/product_product.csv'
salelinefile = 'Data/sale_line.csv'
templatefile = 'Data/product_template.csv'
salefile = 'Data/sale_sale.csv'
translationfile = 'Data/ir_translation.csv'

#basic class
class Base:
    # define exit
    def destroy(selb, widget, data=None):
        gtk.main_quit()

    def __init__(self):
        #define main window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.set_size_request(1100, 600)
        self.window.set_title("Sale Statistics")
        
        #create mainbox
        mainbox = gtk.VBox()
        
        #create calendar box
        calbox = gtk.HBox()
        
        #create calendar box entries
        time_period_label = gtk.Label("Set time periode")
        time_period_start_cal = gtk.Calendar()
        time_period_end_cal = gtk.Calendar()
        update_button = gtk.Button("Update")
        
        #add entries to cal box
        calbox.pack_start(time_period_label)
        calbox.pack_start(time_period_start_cal)
        calbox.pack_start(time_period_end_cal)
        calbox.pack_start(update_button)
        
        #add statistic box
        statistic_box_sw = gtk.ScrolledWindow()
        self.liststore = gtk.ListStore(str,str,str,str,str,str,str)
        self.liststore_sortable = gtk.TreeModelSort(self.liststore)
        self.treeview = gtk.TreeView(self.liststore_sortable)
        cell = gtk.CellRendererText()
        cell.set_property('editable', True)
        
        header_list = ["Produktcode",
                        "Produktname",
                        "Anzahl Verkäufe",
                        "Menge gesamt",
                        "Menge pro Verkauf",
                        "durchschnittlicher Verkaufspreis",
                        "Umsatz gesamt",
                        "Menge Lager"]
                        
        content_list = [['A','B','C','d','e','f','g'],['A','B','C','d','e','f','g'],['A','B','C','d','e','f','g']]
                        
        for n, i in enumerate(header_list):
            column = gtk.TreeViewColumn(i, cell, text=n)
            self.treeview.append_column(column)  

        for i in content_list:
            self.liststore.append([y for y in i])
            
        statistic_box_sw.add_with_viewport(self.treeview)
        
        #add to mainbox
        mainbox.pack_start(calbox)
        mainbox.pack_start(statistic_box_sw)
        
        #add mainbox to window
        self.window.add(mainbox)
        
        #show all windows
        self.window.show_all()
        #connect exit button with destroy function
        self.window.connect("destroy", self.destroy)

    def main(self):
        gtk.main()

if __name__ == "__main__":
    base = Base()
    base.main()
Benutzeravatar
martinjo
User
Beiträge: 186
Registriert: Dienstag 14. Juni 2011, 20:03

Ich hatte eine Spalte zu wenig im List Store Zeile 46 definiert, jetzt kommt die Fehlermeldung nicht mehr, auch die "content_list" sollte dann natürlich mehr Werte enthalten:
Antworten