Re: [pygtk] GtkTree documentation
On Sun, 2003-07-27 at 17:27, Colin Fox wrote: > On Sun, 2003-07-27 at 10:32, David M. Cook wrote: > <...> > The markup example worked nicely, but the pango example doesn't work. It > seems that the init_store() function is expecting the last field of the > row to be a parent flag, which is no longer true. However, even when > setting the line from "if row[-1]==0" to "if row[-3]==0", it still > complains that the column number is out of range. > > Any idea why? Ok, now I know. There are two more changes that have to be made to use the Pango solution (which I prefer, since it seems more programmatically friendly to set an attribute than it does to put markup around a string). First, the 'if' must be changed to 'if row[-3]==0'. Secondly, the column definition line now needs to read: COLUMN_TYPES = [gobject.TYPE_STRING]*2 + [gobject.TYPE_BOOLEAN]*2 + \ [gobject.TYPE_INT] cf signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree documentation
On Sun, 2003-07-27 at 10:32, David M. Cook wrote: > Or you can use the weight attribute: > > import pango > ... > treedata = [[0, 'Mahler, Gustav', 1, '', 2, 1, 3, 0, 4, pango.WEIGHT_BOLD], > [0, '', 1, 'Symphony No 1', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], > <..> > [0, '', 1, 'String Quartet No 5', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL]] > ... > column = gtk.TreeViewColumn(column_titles[i], cell, text=i, > editable=ncols+i, visible=ncols+i, > weight=ncols+2) > The markup example worked nicely, but the pango example doesn't work. It seems that the init_store() function is expecting the last field of the row to be a parent flag, which is no longer true. However, even when setting the line from "if row[-1]==0" to "if row[-3]==0", it still complains that the column number is out of range. Any idea why? -- Colin Fox <[EMAIL PROTECTED]> CF Consulting Inc. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree documentation
On Sun, 2003-07-27 at 05:40, David M. Cook wrote: > There's a tutorial here: > > http://liw.iki.fi/liw/texts/gtktreeview-tutorial.html > > Don't forget the examples that come with the pygtk distribution. I'm using gentoo, which apparently has a (slightly) broken pygtk installation. There are no demos. I'll add that to the gentoo bugzilla. > I whipped > up my own example of a multi-column treeview. It demonstrates a few things: > Thanks very much! This is exactly what I needed. Colin -- Colin Fox <[EMAIL PROTECTED]> CF Consulting Inc. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree documentation
On Sun, Jul 27, 2003 at 10:01:15AM -0600, Jim Ray wrote: > In the attached example how would you ensure that the parent always is > bold? You can use markup: treedata = [[0, 'Mahler, Gustav', 1, '', 2, 1, 3, 0], [0, '', 1, 'Symphony No 1', 2, 0, 3, 1], [0, '', 1, 'Symphony No 9', 2, 0, 3, 1], [0, 'Prokofiev, Sergei', 1, '', 2, 1, 3, 0], [0, '',1, 'Alexander Nevsky', 2, 0, 3, 1], [0, '', 1, 'Piano Concerto No 3', 2, 0, 3, 1], [0, 'Bartok, Bela', 1, '', 2, 1, 3, 0], [0, '', 1, 'Concerto for Orchestra', 2, 0, 3, 1], [0, '', 1, 'String Quartet No 5', 2, 0, 3, 1]] ... column = gtk.TreeViewColumn(column_titles[i], cell, markup=i, editable=ncols+i, visible=ncols+i) Or you can use the weight attribute: import pango ... treedata = [[0, 'Mahler, Gustav', 1, '', 2, 1, 3, 0, 4, pango.WEIGHT_BOLD], [0, '', 1, 'Symphony No 1', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], [0, '', 1, 'Symphony No 9', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], [0, 'Prokofiev, Sergei', 1, '', 2, 1, 3, 0, 4, pango.WEIGHT_BOLD], [0, '', 1, 'Alexander Nevsky', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], [0, '', 1, 'Piano Concerto No 3', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], [0, 'Bartok, Bela', 1, '', 2, 1, 3, 0, 4, pango.WEIGHT_BOLD], [0, '', 1, 'Concerto for Orchestra', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL], [0, '', 1, 'String Quartet No 5', 2, 0, 3, 1, 4, pango.WEIGHT_NORMAL]] ... column = gtk.TreeViewColumn(column_titles[i], cell, text=i, editable=ncols+i, visible=ncols+i, weight=ncols+2) Dave Cook ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree documentation
In the attached example how would you ensure that the parent always is bold? -- Jim Ray <[EMAIL PROTECTED]> ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree documentation
On Sun, Jul 27, 2003 at 03:05:47AM -0700, Colin Fox wrote: > Is there any documentation or examples that show how to use the new > GtkTree code in python? Especially with a libglade generated interface? > > A working tree example would be ideal. There's a tutorial here: http://liw.iki.fi/liw/texts/gtktreeview-tutorial.html Don't forget the examples that come with the pygtk distribution. I whipped up my own example of a multi-column treeview. It demonstrates a few things: * How make certain cells editable. Here I use two "control" columns at the end of my row (store column 2 & 3) that control whether a cell is editable and visible. How the renderer uses these columns is set with column = gtk.TreeViewColumn(column_titles[i], cell, text=i, editable=ncols+i, visible=ncols+i) which means that the renderer will get the text to render from column i and determine whether the cell is editable and visible using the values in column ncols+i. See the properties for the different renderers to see what other keywords you can use. * A callback for the "edited" signal which actually sets the new text that you type in a cell. I use set_data/get_data to retrieve the actual store column that the renderer corresponds to (you could also pass it as user_data when connecting the callback). * How to get a selection, this is in the on_delete_button_clicked callback. Dave Cook try: import pygtk; pygtk.require('2.0') except: # Hope for the best... pass import gobject import gtk from gtk import mainquit import gtk.glade GLADEFILE = 'simple_treestore.glade' COLUMN_TITLES = ('Composer', 'Title') COLUMN_TYPES = [gobject.TYPE_STRING]*2 + [gobject.TYPE_BOOLEAN]*2 treedata = [[0, 'Mahler, Gustav', 1, '', 2, 1, 3, 0], [0, '', 1, 'Symphony No 1', 2, 0, 3, 1], [0, '', 1, 'Symphony No 9', 2, 0, 3, 1], [0, 'Prokofiev, Sergei', 1, '', 2, 1, 3, 0], [0, '', 1, 'Alexander Nevsky', 2, 0, 3, 1], [0, '', 1, 'Piano Concerto No 3', 2, 0, 3, 1], [0, 'Bartok, Bela', 1, '', 2, 1, 3, 0], [0, '', 1, 'Concerto for Orchestra', 2, 0, 3, 1], [0, '', 1, 'String Quartet No 5', 2, 0, 3, 1]] def on_delete_button_clicked(treeview): selection = treeview.get_selection() select_tuple = selection.get_selected() if select_tuple: store, iter = select_tuple store.remove(iter) def edited_callback(renderer, path_string, newtext, treeview): colno = renderer.get_data('colno') if colno!=None: indices = path_string.split(':') path = tuple( map(int, indices) ) store = treeview.get_model() iter = store.get_iter(path) store.set_value(iter, colno, newtext) def add_columns(treeview, column_titles): ncols = len(column_titles) for i in range(ncols): cell = gtk.CellRendererText() column = gtk.TreeViewColumn(column_titles[i], cell, text=i, editable=ncols+i, visible=ncols+i) cell.set_data('colno', i) cell.connect("edited", edited_callback, treeview) treeview.append_column(column) def init_store(store, rows): for row in rows: if row[-1]==0: iter = store.append(None) parent = iter else: iter = store.append(parent) store.set(iter, *row) def main(): xml = gtk.glade.XML(GLADEFILE) treeview = xml.get_widget('treeview') add_columns(treeview, COLUMN_TITLES) xml.signal_autoconnect(globals()) store = gtk.TreeStore(*COLUMN_TYPES) init_store(store, treedata) treeview.set_model(store) gtk.main() if __name__=='__main__': main() http://glade.gnome.org/glade-2.0.dtd";> True window1 GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False 240 240 True False True False 0 3 True True GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_ETCHED_IN GTK_CORNER_TOP_LEFT True True True False False True 0 True True True True Delete Row True GTK_RELIEF_NORMAL 0 False False ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] GtkTree documentation
Hi, all. Is there any documentation or examples that show how to use the new GtkTree code in python? Especially with a libglade generated interface? A working tree example would be ideal. Thanks, Colin -- Colin Fox <[EMAIL PROTECTED]> CF Consulting Inc. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] GtkTree{Model,Store} API additions in PyGTK.
This email describes the API additions that have been made to the GtkTreeStore and GtkListStore classes in PyGTK in order to make them more friendly to Python programmers. It is cc'd to the GTK# mailing list at the request of one of the developers, but should mainly be useful to Python programmers. The description below is of what is currently in CVS. Most of the functionality is in released versions, but some is recent. There is no special wrapper for GtkTreePaths in PyGTK. Since a tree path is really just an ordered list of indices, we represent them as tuples of integers. In places where a GtkTreePath must be passed to GTK, the following Python types will be accepted: * strings: these get parsed by gtk_tree_path_new_from_string(). The syntax is like "1:2:3:4". * tuples of integers: as described above. * integers: treated as a path of length one. Useful for GtkListStores, as will become apparent. By accepting integers as length-one tree paths, the user can just pass in integers for GtkListStore methods, and think of them as row numbers. They don't even need to think about paths. Sequence/mapping behaviour: GtkTreeStore and GtkListStore implement the __getitem__/__setitem__ API. You pass in a tree path as a key and get a "row object" as the value. The row object basically combines a pointer to the tree model and a GtkTreeIter for the row. It in turn looks like a sequence -- one item per column in the model. You can get and set columns in the row through this interface. The best way to explain this is with some examples: liststore = gtk.ListStore(str, str, int) # create list store treestore = gtk.TreeStore(int, str, str) # and a tree store ... # fill in some rows row = liststore[42] # get the row object for the 42nd row in the list print row[2] # print 3rd column in row print liststore[42][2] # or the two operations can be combined # print first column of first child of the second top level node print treestore[1,0][0] # assignment works too liststore[42][2] = 42 # you can also assign to the entire row in one go treestore[1,0] = (5, 'foo', 'bar') # or delete rows del liststore[42] If you have a GtkTreeIter for a row, you can also get the corresponding row object for it with "store[iter]". As well as looking like a sequence, row objects have the following attributes: * next: next sibling row object * parent: parent row object * model: the GtkTreeModel for this row * path: the tree path of this row. * iter: a GtkTreeIter pointing at this row. Iteration: tree and list stores implement the Python iteration API. This means that you can easily do things like print the value of the first column for every row in a list store: for row in liststore: print row[0] For tree stores, this only iterates over the toplevel of the tree. Each row object has an iterchildren() method that can be used to iterate over the child rows if desired (if you directly iterate over the row, you will get the columns). Extra optional argument on append/prepend/insert methods: I added an additional optional argument to the insert, insert_before, insert_after, prepend and append methods. If passed, the additional argument is interpreted as a sequence of values of the columns in the new row. For instance: liststore.append(('foo', 'bar', 42)) This makes the list store feel a lot more like the standard Python list objects. James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] GtkTree problem
I'm trying to create and app that displays two db related trees and be able to select for addition insertion and moving stuff around. I've browsed the faq's the tree examples and I've gotten to the point where I've created the widget with glad and I see two empty trees just waiting to be filled up. I'm trying to implement a method that will fill a tree by giving the method the window instance ,the tree (text)I'm talking about and a dictionary containing the data I want to show. So I'm using mytree(self.w,t,sons) Let's take a look at mytree's constructor def __init__(self,win,tree,sons): print "win is %s tree is %s"%(win,tree) combined="%s.%s"%('win',tree) twin=eval(combined) print twin the output I get when I print twin is: now all methods I try to use like connect ,append etc... are returned with an error: AttributeError: 'GtkObject' object has no attribute 'append' The docs and examples do the connects and appends at this stage so I'm a bit confused. Anyhelp will be realy appriciated. regards - -- Lior Kesos , [EMAIL PROTECTED] Aduva re.search("meaning",self) KISS - Keep It Simple Stupid. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkTree examples?
Thanks for the pointers. I haven't tried it out yet but it looks like it'll do the trick. I just want to be able to display pixmaps with the text and it supports just that. -- Mike On Mon, Nov 19 @ 13:45, Jon Nelson wrote: > On Mon, 19 Nov 2001 17:08:02 -0200 (BRST) > "Christian Robottom Reis" <[EMAIL PROTECTED]> wrote: > > > On Mon, 19 Nov 2001, Michael Gilfix wrote: > > > > > Hi all. Could someone please post a simple example of using > GtkTree? > > > I found the one example provided with pygtk that uses it > difficult > > > to follow as it seems to play some tricks with dicts. I'm > looking to > > > build a tree recursively out of directories. Some hints would > be > > > great. > > > > Don't use GtkTree, use GtkCTree. > > See the Kiwi codebase for an example of realworld usage > > (http://www.async.com.br/kiwi/) > > Ah, but GtkCTree can't handle non-text items (like buttons, > entry fields, etc...) > > > -- > Jon Nelson\|/ \|/ Gort, > [EMAIL PROTECTED]"@'/ ,. \`@" Klaatu > C and Python Programmer /_| \__/ |_\ barada > Motorcycle Enthusiast\__U_/ nikto. `-> (jnelson) -- Michael Gilfix [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree examples?
On Mon, 19 Nov 2001 17:08:02 -0200 (BRST) "Christian Robottom Reis" <[EMAIL PROTECTED]> wrote: > On Mon, 19 Nov 2001, Michael Gilfix wrote: > > > Hi all. Could someone please post a simple example of using GtkTree? > > I found the one example provided with pygtk that uses it difficult > > to follow as it seems to play some tricks with dicts. I'm looking to > > build a tree recursively out of directories. Some hints would be > > great. > > Don't use GtkTree, use GtkCTree. > See the Kiwi codebase for an example of realworld usage > (http://www.async.com.br/kiwi/) Ah, but GtkCTree can't handle non-text items (like buttons, entry fields, etc...) -- Jon Nelson\|/ \|/ Gort, [EMAIL PROTECTED]"@'/ ,. \`@" Klaatu C and Python Programmer /_| \__/ |_\ barada Motorcycle Enthusiast\__U_/ nikto. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree examples?
On Mon, 19 Nov 2001, Michael Gilfix wrote: > Hi all. Could someone please post a simple example of using GtkTree? > I found the one example provided with pygtk that uses it difficult > to follow as it seems to play some tricks with dicts. I'm looking to > build a tree recursively out of directories. Some hints would be > great. Don't use GtkTree, use GtkCTree. See the Kiwi codebase for an example of realworld usage (http://www.async.com.br/kiwi/) Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] GtkTree examples?
Hi all. Could someone please post a simple example of using GtkTree? I found the one example provided with pygtk that uses it difficult to follow as it seems to play some tricks with dicts. I'm looking to build a tree recursively out of directories. Some hints would be great. -- Mike -- Michael Gilfix [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
On Fri, 4 May 2001, Alexandre Fayolle wrote: > On Thu, 3 May 2001, mallum wrote: > > > wierd this is what I was doing. But with 8 bit vals ; > > > > eg - my_col=window.get_colormap().alloc(0,255,255) > > > > with you 16 bit vals it seem to work ! > > Yes this is very confusing at first (esp. when combined with the Gtk Color > selector which returns float values in the [0,1] range...) The colour selector APIs that returned arrays of floats have been deprecated in favour of ones that use GdkColor's in gtk 2.0, which should get rid of some of the confusion :) James. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
On Thu, 3 May 2001, mallum wrote: > wierd this is what I was doing. But with 8 bit vals ; > > eg - my_col=window.get_colormap().alloc(0,255,255) > > with you 16 bit vals it seem to work ! Yes this is very confusing at first (esp. when combined with the Gtk Color selector which returns float values in the [0,1] range...) Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
wierd this is what I was doing. But with 8 bit vals ; eg - my_col=window.get_colormap().alloc(0,255,255) with you 16 bit vals it seem to work ! mallum on Thu, May 03, 2001 at 01:37:18PM +0200, Alexandre Fayolle wrote: > On Thu, 3 May 2001, mallum wrote: > > > I've been having this problem as well with a clist. Unfortunatly the solution >given here > > wont work for me as I only want to change individual row colors rather than > > all of them. Would it be possiblke to reverse individual row foreground and > > background colors - this would do for me ? > > > I'm sorry I missed the beginning of the thread, so this message might be > completely unrelated. If so please excuse me. > I don't know how to specifically reverse the colors of a row, but this is > how I change the background color a an individual row in a GtkCList > > After the widget is realized, I allocate a new color: > > my_col=window.get_colormap().alloc(65535,51400,51400) > > and then I use list.ser_background(row,my_col), with row being the row > number of the list. Since a GtkCTree is a GtkCList, this should work too? > > Alexandre Fayolle > -- > http://www.logilab.com > Narval is the first software agent available as free software (GPL). > LOGILAB, Paris (France). > ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
I've been having this problem as well with a clist. Unfortunatly the solution given here wont work for me as I only want to change individual row colors rather than all of them. Would it be possiblke to reverse individual row foreground and background colors - this would do for me ? many thanks; mallum on Fri, Apr 13, 2001 at 08:41:45PM +0800, James Henstridge wrote: > On 13 Apr 2001, Rob Brown-Bayliss wrote: > > Also, I would like to set the background of a GtkCtree to white, but > > cant seem to make it work. > > Modify your gtkrc file so that the bg[PRELIGHT] for the style applied to > CTrees widget. > > Programatically, this would be something like: > style = ctree.get_style().copy() > style.bg[STATE_PRELIGHT] = ctree.get_colormap().alloc('white') > ctree.set_style(style) > > But this will make things look weird in some themes, so it is usually > better to modify the theme colours. > ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
On Thu, 3 May 2001, mallum wrote: > I've been having this problem as well with a clist. Unfortunatly the solution given >here > wont work for me as I only want to change individual row colors rather than > all of them. Would it be possiblke to reverse individual row foreground and > background colors - this would do for me ? I'm sorry I missed the beginning of the thread, so this message might be completely unrelated. If so please excuse me. I don't know how to specifically reverse the colors of a row, but this is how I change the background color a an individual row in a GtkCList After the widget is realized, I allocate a new color: my_col=window.get_colormap().alloc(65535,51400,51400) and then I use list.ser_background(row,my_col), with row being the row number of the list. Since a GtkCTree is a GtkCList, this should work too? Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
On 13 Apr 2001, Rob Brown-Bayliss wrote: > > > The CTree widget can do everything Tree does, and is less broken. > > Hi, I have seen several people in this list mention that the Tree widget > is broken, and the CTree also broken, but less broken > > How do you define broken in this case? Could some one highlight the > problems for me? in some cases, GtkTree stops redrawing correctly (and the expanders stop working when this happens), and the GtkTree widgets don't really act like widgets when they are not the root of the tree. > > Also, I would like to set the background of a GtkCtree to white, but > cant seem to make it work. Modify your gtkrc file so that the bg[PRELIGHT] for the style applied to CTrees widget. Programatically, this would be something like: style = ctree.get_style().copy() style.bg[STATE_PRELIGHT] = ctree.get_colormap().alloc('white') ctree.set_style(style) But this will make things look weird in some themes, so it is usually better to modify the theme colours. James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
> The CTree widget can do everything Tree does, and is less broken. Hi, I have seen several people in this list mention that the Tree widget is broken, and the CTree also broken, but less broken How do you define broken in this case? Could some one highlight the problems for me? Also, I would like to set the background of a GtkCtree to white, but cant seem to make it work. I saw a reference to setting a node background in gtk.py and tried but creating a GdkColor widget: white = GdkColor(255,255,255) my_ctree.node_set_background(my_ctree.node_nth(4),white) But it made the backgound black. So I tried (1,1,1) and had the same effect... Though I would reather set the whole widget background to white than individual nodes (like is done in pygme and the controlcentre) thanks... -- Rob Brown-Bayliss ---==o==--- www.ZOOstation.cc ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
On Mon, 9 Apr 2001, David Robertson wrote: > > I am trying to build a simple tree using the following code: > > mytree = GtkTree() > myitem = GtkTreeItem("something") > mytree.append(myitem) > > my question is, how to actually build the nodes and leafelets... I have the > GTK reference but it is in C and I had given up on C 10 years ago so it is > pretty greek to me. Any help on any functions or classes I am overlooking > would be appreciated. I tried tinkering with GtkTreeItem.set_submenu to no > avail. You can use the set_subtree() method of the tree item to specify a GtkTree as a subtree. I don't recommend using GtkTree though, as it is fairly broken. The CTree widget can do everything Tree does, and is less broken. > > Thanks for your help. > > Another quick question. Is there an actual reference for the python GTK > wrapper? Not yet. James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkTree?
GtkTree is broken use GtkCTree which is crap but at least works. If you relly must use GtkTree here is a trivial example which shows that dnd is broken #!/usr/bin/env python from gtk import * from GDK import * class myTree(GtkTree): def __init__(self): GtkTree.__init__(self) self.targets = [('text/plain', 0, -1)] self.createTreeItems(self) aSubTree = GtkTree() self.children()[2].set_subtree(aSubTree) self.createTreeItems(aSubTree) def createTreeItems(self, aTree): for i in range(4): aTreeItem = GtkTreeItem("tree item " + str(i)) aTree.append(aTreeItem) aTreeItem.drag_dest_set(DEST_DEFAULT_ALL, self.targets, ACTION_COPY | ACTION_MOVE) aTreeItem.drag_source_set(SHIFT_MASK | BUTTON1_MASK, self.targets, ACTION_COPY | ACTION_MOVE ) aTreeItem.connect('drag_data_get', self.dndDragDataGet_cb) aTreeItem.connect('drag_data_received', self.dndDragDataReceived_cb) aTreeItem.show() def dndDragDataGet_cb(self,w,context,selection_data,info, time): dnd_string = "hello world" selection_data.set(selection_data.target, 8, dnd_string) def dndDragDataReceived_cb(self,item, context, x, y, data, info, time): if data and data.format == 8: msg = "Drop data of type %s was:\n\n%s" % \ (data.target, data.data) print msg if __name__ == '__main__': gtkWindow = GtkWindow(WINDOW_TOPLEVEL) gtkWindow.connect("destroy", mainquit) gtkWindow.add(myTree()) gtkWindow.show_all() mainloop() nb show_all is broken for gtkTree so you have to call show all over the place There is probably a better example in the testgtk.py stuff. (hmm I just looked and couldn't see one) If your building your tree from something which is tree like (such as a file system or DOM) than the easyist way is with a recursive function. The only examples I have of this are in C so I didn't bother including them. A word of warning if you use GtkCTree it gets very confused if you set a node as branch and then don't add any leaves to it or vica verca. On Tue, 10 Apr 2001 00:59:02 David Robertson wrote: > > I am trying to build a simple tree using the following code: > > mytree = GtkTree() > myitem = GtkTreeItem("something") > mytree.append(myitem) > > my question is, how to actually build the nodes and leafelets... I have > the > GTK reference but it is in C and I had given up on C 10 years ago so it > is > pretty greek to me. Any help on any functions or classes I am overlooking > would be appreciated. I tried tinkering with GtkTreeItem.set_submenu to > no > avail. > > Thanks for your help. > > Another quick question. Is there an actual reference for the python GTK > wrapper? > no > ___ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > rob ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] GtkTree?
I am trying to build a simple tree using the following code: mytree = GtkTree() myitem = GtkTreeItem("something") mytree.append(myitem) my question is, how to actually build the nodes and leafelets... I have the GTK reference but it is in C and I had given up on C 10 years ago so it is pretty greek to me. Any help on any functions or classes I am overlooking would be appreciated. I tried tinkering with GtkTreeItem.set_submenu to no avail. Thanks for your help. Another quick question. Is there an actual reference for the python GTK wrapper? ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] GtkTree and GtkCTree
BDY.RTF
Re: [pygtk] GtkTree
> Hi, > I am have been playing with GtkTree for a while now and I cant seem to > figure out how to get the Tree to show in collapsed mode. Because if you > create all the trees they are automatically expanded, and I dont want that > effect. GtkTreeItem's have a collapse() method, you can use that to re-collapse them. Sorry I don't have any code handy, but I think this is what you're looking for. -Rob - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
[pygtk] GtkTree
Hi, I am have been playing with GtkTree for a while now and I cant seem to figure out how to get the Tree to show in collapsed mode. Because if you create all the trees they are automatically expanded, and I dont want that effect. Does anyone have any code that I can look at where people used GtkTrees. Thanks, any help will be appreciated. - Lex - To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
[pygtk] GtkTree
I remember there was an exemple of GtkTree in a forwarded email some weeks ago. I lost it. Can send it again? Xanks :) -- --- Marc POINOT Alias: marcvsEmail: [EMAIL PROTECTED] ONERA -MFE/DSNA/ELSATel: 01.46.73.42.84 Info: [EMAIL PROTECTED] 29, Div. LeclercFax: 01.46.73.41.66 Site: 92322 Chatillon FRANCE Project: elsAWeb: http://www.onera.fr To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]