| | |
help with treeview property setting
![]() |
•
•
Join Date: Nov 2006
Posts: 3
Reputation:
Solved Threads: 0
I am trying to get to grips with treeviews in pygtk/gtk and am stuck on setting the alignment of the columns.
No matter what I try I cannot change the alignmenthttp://ubuntuforums.org/images/smilies/eusa_wall.gif
Here is the code I found on the web which I am using to change different lines to see the effect and thus learn how they work. However I added the line self.cell1.set_property('alignment', pango.ALIGN_CENTER) and it makes no difference. I have tried right align too with no joy!
Can anyone help me please?
No matter what I try I cannot change the alignmenthttp://ubuntuforums.org/images/smilies/eusa_wall.gif
Here is the code I found on the web which I am using to change different lines to see the effect and thus learn how they work. However I added the line self.cell1.set_property('alignment', pango.ALIGN_CENTER) and it makes no difference. I have tried right align too with no joy!
Can anyone help me please?
Python Syntax (Toggle Plain Text)
def __init__(self): # Create a new window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("TreeViewColumn Example") self.window.set_size_request(400, 200) self.window.connect("delete_event", self.delete_event) # create a liststore with one string column to use as the model self.liststore = gtk.ListStore(str, str, str, 'gboolean') # create the TreeView using liststore self.treeview = gtk.TreeView(self.liststore) # create the TreeViewColumns to display the data self.tvcolumn = gtk.TreeViewColumn('Pixbuf and Text') self.tvcolumn1 = gtk.TreeViewColumn('Text Only') # add a row with text and a stock item - color strings for # the background self.liststore.append(['Open', gtk.STOCK_OPEN, 'Open a File', True]) self.liststore.append(['New', gtk.STOCK_NEW, 'New File', True]) self.liststore.append(['Print', gtk.STOCK_PRINT, 'Print File', False]) # add columns to treeview self.treeview.append_column(self.tvcolumn) self.treeview.append_column(self.tvcolumn1) # create a CellRenderers to render the data self.cellpb = gtk.CellRendererPixbuf() self.cell = gtk.CellRendererText() self.cell1 = gtk.CellRendererText() # set background color property self.cellpb.set_property('cell-background', 'yellow') self.cell.set_property('cell-background', 'cyan') self.cell1.set_property('cell-background', 'pink') self.cell1.set_property('alignment', pango.ALIGN_CENTER) # add the cells to the columns - 2 in the first self.tvcolumn.pack_start(self.cellpb, False) self.tvcolumn.pack_start(self.cell, True) self.tvcolumn1.pack_start(self.cell1, True) # set the cell attributes to the appropriate liststore column # GTK+ 2.0 doesn't support the "stock_id" property if gtk.gtk_version[1] < 2: self.tvcolumn.set_cell_data_func(self.cellpb, self.make_pb) else: self.tvcolumn.set_attributes(self.cellpb, stock_id=1) self.tvcolumn.set_attributes(self.cell, text=0) self.tvcolumn1.set_attributes(self.cell1, text=2, cell_background_set=3) # make treeview searchable self.treeview.set_search_column(0) # Allow sorting on the column self.tvcolumn.set_sort_column_id(0) # Allow drag and drop reordering of rows self.treeview.set_reorderable(True) self.window.add(self.treeview) self.window.show_all()
Thanks for your kind answer. I took the liberty to check
http://www.pygtk.org/pygtk2reference...ktreeview.html
all I can say is "ouch!", that is one complex thing! No wonder you are lost!
http://www.pygtk.org/pygtk2reference...ktreeview.html
all I can say is "ouch!", that is one complex thing! No wonder you are lost!
No one died when Clinton lied.
•
•
Join Date: Nov 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Thanks for your kind answer. I took the liberty to check
http://www.pygtk.org/pygtk2reference...ktreeview.html
all I can say is "ouch!", that is one complex thing! No wonder you are lost!
hey, no offence intended.....I just presumed that if you did not know what they were, you would know the answer.
And yep....it is making my head hurt!
Stupid thing is I could have had the application finished now in MS but as I only use Linux now at home want to do it in python. Needless to say I am less than impressed that it has taken me days now of searching and am still no nearer the answer. Also I dont seem to get any response from other forums either.
I can only guess this is something python/pygtk/gtk just cant do even though the sparse help suggests otherwise:eek:
![]() |
Similar Threads
- resolution setting vb.net (VB.NET)
- resolution setting vb.net (IT Professionals' Lounge)
- Text input box alignment question (HTML and CSS)
- Use of DataGrid (ASP.NET)
Other Threads in the Python Forum
- Previous Thread: Upper Case Letters
- Next Thread: Schedule program
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework ideas import inches input java launcher library line lines linux list lists loop mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame pysimplewizard python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib






