[Tutor] gtk.TreeView displays all right on Windows, but can't see the values on Ubuntu

Timo timomlists at gmail.com
Wed Apr 25 09:11:32 CEST 2012


Op 25-04-12 06:41, Lion Chen schreef:
> Hi, All,
Hi, please fix your formatting, the indentation is a big mess and makes 
it impossible to read. You should also ask your question on the PyGTK 
mailing list, not here.

> first thanks the people who gave helps to me, :)
>
> now i encountered another question...
> my first program LionCalculator, works ok on Windows, but there is a
> problem on Ubuntu.
>
> LionCalculator has a function that can store the previous calculation
> results to the
> gtk.ListStore((gobject.TYPE_STRING, gobject.TYPE_BOOLEAN,
> gobject.TYPE_STRING))
>
> for i in xrange(12):
> self.results_store.append(["F%d" % (i+1), None, None])
>
> when pressed F1--F12 or click the gtk.CellRendererRadio, the gtk.Entry
> will get the corresbonding values stored in ListStore.
>
> when i run the program on Windows, no problem, i can see everything that
> should display on the screen. but when i run it on Ubuntu, i can't see
> the "F1" -- "F12" in the ListStore, can't see the calculation results
> that should also display on ListStore, only the gtk.CellRendererRadio
> showed.
> i don't understand...
>
> and when i add "print ...get_store()[0][0]" and run it again, it print
> "F1"! strange... and when i press F1 or F2..., the result will copy to
> the entry,
> although it does not display in the TreeView, strange...
>
> the following are codes:
>
> #in class ResultsView......
> def make_view(self):
> # make ListStore for storing results
> self.results_store = gtk.ListStore(gobject.TYPE_STRING,
> gobject.TYPE_BOOLEAN,
> gobject.TYPE_STRING)
>
> #to store 12 calculation results, the results_store[0][0] is "F1--F12"
> for i in xrange(12):
> self.results_store.append(["F%d" % (i+1), None, None])
>
> self.results_view = gtk.TreeView(self.results_store)
>
> #f_renderer is for "F1" -- "F12"
> f_renderer = gtk.CellRendererText()
> f_renderer.set_property( 'editable', False )
> f_renderer.set_property("size", 5)
> f_renderer.set_property("cell-background", "cyan")
>
> #when clicked bt_renderer, it will copy the corresbonding values to
> gtk.entry
> bt_renderer = gtk.CellRendererToggle()
> bt_renderer.set_property('activatable', True)
> bt_renderer.set_property("radio", True)
> bt_renderer.set_property("cell-background", "grey")
> bt_renderer.connect("toggled", self.ready_cp, self.results_store)
>
> #txt_renderer is for storing calculation results
> txt_renderer = gtk.CellRendererText()
> txt_renderer.set_property( 'editable', False )
> txt_renderer.set_property("size", 5)
> txt_renderer.set_property("cell-background", "green")
>
> #i guess the problem is in the following, but i don't know where it
> exactly is, ok in Windows, can't show in Ubuntu...
> bt_column = gtk.TreeViewColumn("F1--F12")
> bt_column.pack_start(f_renderer, True)
> bt_column.pack_start(bt_renderer, False)
> bt_column.set_attributes(f_renderer, text=0)
> #set active to be clickable. and the bt_columen is
> #corresbonding to results_store columne 1
> bt_column.add_attribute(bt_renderer, "active", 1)
>
> #and txt_column is corresbonding to the store column 2
> txt_column = gtk.TreeViewColumn("Calculation Results ", txt_renderer,
> text=2)
> self.results_view.append_column(bt_column)
> self.results_view.append_column(txt_column)
>
> self.results_view.show()
>
> return self.results_view
>
> #in class LionCalc....
> def __init__(self):
> ......
> self.results_view = ResultsView()
> right_vbox.pack_start(self.results_view.make_view(), True, True, 0)
>
> win.show_all()
>
> could anybody give me help? thanks.
>



More information about the Tutor mailing list