Re: [pygtk] #gtk channel on irc.freenode.org
On Sat, Sep 29, 2007 at 10:29:15AM -0700, Steven Brown wrote: > Use #gtk+ And there's also #pygtk, #kiwi. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] How to add a keyboard shortcut to a widget?
On Sun, Apr 15, 2007 at 06:12:15AM -0300, Gabriel Falcão wrote: >self.desktop = gtk.gdk.get_default_root_window() >self.deskEvent = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS) >gtk.binding_entry_add_signal(self.deskEvent, gtk.keysyms.F12, > gtk.keysyms.Control_L, 'button-press-event') I've only gotten it to work by subclassing a gtk widget as in the FAQ example. Can you subclass egg.TrayIcon? 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] How to add a keyboard shortcut to a widget?
On Sat, Apr 14, 2007 at 11:49:47PM -0300, Gabriel Falcão wrote: > I want to "connect" a keyboard keys combo ato emit a signal in some widget. > Using glade its easy, mas i cant use glade. > How i add this feature directly from code? > > im using pygtk2.8 See http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.034.htp 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] Best pattern for keyboard accelerators in dialog
On Fri, Jan 26, 2007 at 08:49:51AM +, Richard Taylor wrote: > I would like to provide keyboard accelerators that move the focus to the > appropriate Widget. I want to underline a letter in each label and link > Alt- to switch to the Edit widget alongside the Label. I would like > these accelerators to work regardless of which widget has the focus. Easiest is label.set_use_underline(True) label.set_mnemonic_widget(widget) but that's global. I don't know of a way to make that only work in a sub-widget. http://pygtk.org/docs/pygtk/class-gtklabel.html#method-gtklabel--set-mnemonic-widget Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] handling events
On Sun, Oct 22, 2006 at 09:57:47AM +0200, Pascal DUCHATELLE wrote: > I could add a status bar to each notebook page but this is no elegent way... I'd put the status bar handling code in its own module. Then import that module wherever it's needed. If you want to reduce coupling in your code, you could adapt one of the publish/subscribe examples from the Python Cookbook. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK .app bundle for MacOS X?
On Wed, Oct 18, 2006 at 09:29:27PM -0700, David M. Cook wrote: > Both of them also have a tendency to > overdo dependencies IMO. I should take that back about dependencies. Darwinports does a pretty straightforward job with this: david-cooks-computer:~ davidcook$ sudo port install py-gtk2 ---> Installing pkgconfig 0.21_0 ---> Installing glib2 2.12.4_0 ---> Installing atk 1.12.2_0 ---> Installing zlib 1.2.3_0 ---> Installing libpng 1.2.10_2+darwin_8 ---> Installing freetype 2.1.10_1 ---> Installing fontconfig 2.3.2_2+macosx ---> Installing render 0.9_0 ---> Installing xrender 0.9.0_0+darwin_8 ---> Installing Xft2 2.1.7_0 ---> Installing cairo 1.2.4_1 ---> Installing pango 1.14.3_0 ---> Installing jpeg 6b_1 ---> Installing tiff 3.8.2_0+darwin_8 ---> Installing gtk2 2.10.3_0 ---> Installing libxml2 2.6.23_0 ---> Installing libglade2 2.6.0_1 ---> Installing python24 2.4.3_1+darwin_8 ---> Installing py-numeric 24.2_0+darwin_8+macosx ---> Installing py-cairo 1.2.2_0 ---> Installing py-gobject 2.12.1_0 ---> Installing py-gtk2 2.10.1_0 Apart from the iffy inclusion of numeric, there don't seem to be any unneeded dependencies (your session might look a little different as I've already installed stuff like tetex, which brings in a lot of dependencies). ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK .app bundle for MacOS X?
On Wed, Oct 18, 2006 at 11:39:51PM +0200, Wolfgang Keller wrote: > I'm looking for a way that allows a clueless Python scripting dilettant like > me to build a double-clickable .app bundle of a PyGTK application for MacOS > X. > > Any ideas? Such as e.g. a pre-made "empty" .app bundle that includes already > the Python interpreter and a compiled PyGTK module? I don't know of such an app bundle. You could compile all the packages yourself. I've done it before, but it's very tedious as you often have to backtrack to get dependencies and fuss over the config settings. Instead, I would suggest darwinports: http://darwinports.opendarwin.org/ Or fink: http://fink.sf.net They've done all this work for you. I prefer darwinports (though I'd much rather have an RPM based system than either of those). You do have to use *their* copy of python (unless there's a way to get around that.) Both of them also have a tendency to overdo dependencies IMO. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Wait until a thread is ended
On Thu, Sep 28, 2006 at 09:16:20PM +0200, Adolfo González Blázquez wrote: > I would like to know if someone can point me a solution to make a > function run as a separate thread, and wait until it is ended, without > blocking the gui. > In my application, i'm getting a long file listing using glob(), and i > want this function to run as a thread, so the user can stop it using a > button in the gui (right now, the gui freezes till glob is ended), and > then run another function to fill the treeview (this now works without > blocking the gui, using generators). . Use a callback to handle the result and call it from your thread with gtk.idle_add(). Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] event handling
On Sun, Sep 03, 2006 at 08:37:13AM +0200, Pascal DUCHATELLE wrote: > dic = {"on_mainWindow_destroy" : gtk.main_quit, > "on_hello_key_press_event" : self.hellorecompile} > followed by this: > self.wTree.signal_autoconnect(dic) > Is there a way to use the second solution but also pass > an argument like in the first one ? You can use a tuple in your dic. See http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq22.004.htp Also, you can use a closure: foo = 5 baz = 6 def my_handler(*args): print foo print baz dic = {"some_handle" : my_handler} Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] The "row-changed" in gtk.TreeModel Signal
On Mon, Aug 07, 2006 at 09:10:26AM -0700, Shehnaaz Kagdi wrote: > 2) Whenever this happens - > self.liststore.append(["john","smith", > "blabla","bla"]) > I would like the treeview to display the latest > data/row in the liststore You shouldn't need to call row_changed after an append. Is your treeview not getting updated after an append?. In your case, you would only need to do that only if, say, you kept a reference to the the list, e.g. l = ["john", ...] and changed it via the reference "behind the ListStore's back", e.g. l[0] = "bob" Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] button queue
On Mon, Jul 31, 2006 at 07:11:56AM -0700, Mr Jason Cupp wrote: > I am pretty new to pygtk. I wrote a program where there are several buttons that are connected to a method that plays different wav files using pymedia. My problem is that if I keep pressing buttons while a wav is being played, it queues the events and just keeps playing audio files for the events that were racked up. I want a button to only work when an audio file is not being played. === You should make the button insensitive in your "click" callback, and then make it sensitive again when the program is ready. If the button action is also a menu item, you can use the action API. See sections 16.1 and 16.7 of the tutorial. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Implementing command history with a gtk.Entry
On Mon, Jul 24, 2006 at 10:47:44AM -0700, N. French wrote: > My problem is: how do I catch the up/down arrow keypresses? I was I know of two ways to catch the up/down arrows: - connect to the key-press event - Create your own Entry subclass with up/down arrow keybindings See the FAQ for the latter, which is the more elegant solution if you are not using glade. Unfortunately, I don't think gtk lets you add keybindings to an existing instance (i.e. from a glade widget tree), which seems like a bug to me. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Bug in TreeView.scroll_to_cell()
On Thu, Jul 13, 2006 at 03:21:02PM +0200, Alessandro Pellizzari wrote: > It works pretty good until circa row 900, showing the cell at the top of > the treeview, then it begins going wrong, showing cell 930 (or similar) > at the top and not scrolling down, even for cell, e.g., 1200, which goes > out of the visible area. Try doing the scroll_to_cell in an idle_add callback. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Setting gtk.TreeViewColumn width
On Tue, Jul 11, 2006 at 01:26:35PM -0600, Adam Olsen wrote: > I guess I should have specified that I looked there. I can only see a way > to set a max width, a min width, and a fixed width. I'd just like to set > the width, but allow the user to be able to resize it as well. Yeah, you're right, that is confusing. Here's what I use: tvc.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) tvc.set_resizable(True) tvc.set_fixed_width(self.width) Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Setting gtk.TreeViewColumn width
On Tue, Jul 11, 2006 at 11:00:50AM -0600, Adam Olsen wrote: > Is there a way to set gtk.TreeViewColumn widths programmatically? Yes. Take a look at the API reference at pygtk.org. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Need help with Tree/List view
On Fri, Jun 09, 2006 at 03:31:49PM -0400, Hussein Vastani wrote: > Now my question is. How do I indicate to the user which cell in the row is > editable. If he/she has selected a particular row, then there is no clear This seems to be a problem with a lot of themes that use a really thin, hard to see focus indicator. The only way I know how to fix it is to modify the style to give a thicker more visible focus indicator. Take a look at the gtkrc for the LargePrint theme. You can change this just for the TreeView widgets in your app. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] how to install pyGTK
On Tue, May 30, 2006 at 09:14:13AM -0700, arya jain wrote: > am not able to install the graphic tool kit pyGTK from the site You need to install the following: Gtk+/Win32 Development Environment: http://gladewin32.sourceforge.net/modules/news/ pycairo and pygtk: http://www.mapr.ucl.ac.be/~gustin/win32_ports/ Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] gtk.TreeModelRowIter.next
On Tue, May 16, 2006 at 10:54:40PM -0700, Brian wrote: > It says: > > When there are no more rows left the StopIteration exception is raised. > > But I can't find out any more about the StopIteration. ie. where is it > defined, where do you import it from. I can't find it in any of the > gtk.Constants, treeview, treemodel, etc.. It's already loaded into __builtins__, so you don't have to import anything. dir(__builtins__) Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] New Gtk/PyGtk Book
On Tue, Apr 25, 2006 at 11:47:26AM -0700, [EMAIL PROTECTED] wrote: > I'd definitely love to see a Python/Glade book. Is there a better way of > quickly developing linux apps? Add in Kiwi and let Gazpacho mature some more, and I'd say no, but I've never really given PyQt or wxPython much of a chance. I also really like the Netbeans/Jython combination for non-native apps. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK on Mac OS X
On Thu, Apr 06, 2006 at 04:13:13PM -0400, Pierre Thibault wrote: > PyGTK is mostly used by Linux users, is it the case? I think it works fairly well on win32 as well. On OS X an X Windows System (X11) server is required as gtk2 has not been ported. This is included on the OS X install disc, and it's easy to install and run, but it's not something I'd expect the average Mac user to be particularly comfortable with. Wxpython supposedly has native look and feel on the Mac, but the one wxpython app I run on my Mac, Audacity, doesn't look altogether quite right to my eyes. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK on Mac OS X
On Wed, Apr 05, 2006 at 05:26:27PM -0400, Pierre Thibault wrote: >*** Could not run GLIB test program, checking why... Try setting PKG_CONFIG_PATH, e.g. env PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11R6/lib/pkgconfig ./configure Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] gtk.binding_entry_add with existing object
I want to do something like what's described in http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.034.htp except I want to do it for existing entry objects loaded from a glade file. Is this possible? TIA, Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] how to get selected rows at the time user selects a row ('cursor-changed' does not do it)
On Mon, Feb 06, 2006 at 10:04:51PM +0200, Nikos Kouremenos wrote: > thanks Dave. your recipe (hehe Cook :-*) works. /me wonders if PyGTK > REF says it, else needs to be added in a FAQ It's in the FAQ: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.011.htp Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] how to get selected rows at the time user selects a row ('cursor-changed' does not do it)
On Sun, Feb 05, 2006 at 03:48:17PM +0200, Nikos Kouremenos wrote: > so which signal to connect to so when user has a row selected and goes > to select another one (with SHIFT) when he presses the row I can get > both 2? (cursor-changed returns 1) Use the selection objects "changed" signal. The GTK reference gives the caveat One of the important things to remember when monitoring the selection of a view is that the "changed" signal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a "changed" signal when nothing has happened (mostly as a result of programmers calling the select_path() or select_iter() methods on an already selected row). So you have to check for the actual selected rows in your callback. def on_selection_changed(selection): model, selectedRows = selection.get_selected_rows() # do something with rows ... ... treeview.get_selection().connect("changed", on_selection_changed) Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Adding columns to a TreeView/TreeStore?
On Wed, Feb 01, 2006 at 03:26:11AM +1100, John Pye wrote: > The issue appears to be that there is no way of adding columns to a > *TreeStore* -- so I must copy the data from the existing TreeStore to a > new one with an extra column, then re-set the model for the TreeView to > the new TreeStore. > Is there a better way? I imagine this could be slow in some cases where > there is a lot of data. Make your TreeStore have just one column of objects and use a cell data function for each treeview column. Then you can dynamically add attributes for the new columns. See http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html#sec-CellDataFunction Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Getting selected rows.
On Thu, Oct 06, 2005 at 03:15:21PM +0200, Robert Bigaignon wrote: > PS : I use PyGTK 1.99, so unfortunately get_selected_rows() is not > available. The trick with that old version was to visit each selected row with TreeSelection.selected_foreach() and save it in a list. But you really should upgrade. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] New version of the PyGTK Reference Manual
On Tue, Sep 20, 2005 at 10:35:03AM -0700, John Finlay wrote: > gobject.spawn_async() functions, The docs say Eventually you must call g_spawn_close_pid() on the child_pid, in order to free resources which may be associated with the child process. Looks like something left over from the C docs? Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Undo and Redo
On Sun, Sep 04, 2005 at 09:51:11AM +0200, N. Volbers wrote: > Look at "Documentation" and then at the "Developer's Guide". This is a > very nice introduction to an undo mechanism that basically works like > this: If you call an undoable function, then it must return an > undo-tuple which contains the name of a function f and the appropriate > arguments x,y,..., so that f(x,y,...) will undo the last action. This > will also enable you to offer a "redo" mechanism for free! This seems more Pythonic to me than the Java-ish Action base class method. If you wanted to get fancy, you could use a decorator, so you just decorate the methods you want un/redoable. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] what is equal to a list box?
On Thu, Sep 01, 2005 at 01:15:42PM -0500, nephish wrote: > is always down. like what i think a list box is, but cant seem to find that. > you know, just a box with a list of items that can be selected in it. You want a TreeView with a ListStore. See the tutorial. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] progress bar question
On Sun, Aug 21, 2005 at 11:20:21PM +0200, dimitri pater wrote: > def progress_timeout(pbobj): > new_val = pbobj.pbar.get_fraction() + 0.01 > if new_val > 1.0: > new_val = 0.0 > pbobj.pbar.set_fraction(new_val) You need to execute a main loop iteration here. while gtk.events_pending(): gtk.main_iteration() BTW, you should use spaces instead of tabs for indentation (at least I assume that's why your indentation is getting lost). 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] Installing pygtk on OS X
On Fri, Aug 12, 2005 at 02:23:13PM -0400, Jared Dziedzic wrote: > I'm having a lot of issues installing pygtk on OS X (10.3). I was wondering > how everyone else installed it. Fink ends up messing up python by installing > two versions (regular python for Mac, then python on X11). Don't install Fink's Python or pygtk. Just install gtk2 and then use the setup script in the pygtk source. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Documentation recommendations
On Fri, Aug 12, 2005 at 07:15:01AM -0400, Andrew Conkling wrote: > OK, Dave, I'll check it out; thanks. What would it do in, say, Xfce? If the default doesn't work, you can fall back on the Netscape('firefox') or Netscape('mozilla') browser objects, e.g. # untested code! import webbrowser # webbrowser doesn't know firefox yet, but you can use the # Netscape('firefox') browser object. browsersToTry = [webbrowser, webbrowser.Netscape('firefox'), ...] for browser in browsersToTry: try: browser.open(...) except webbrowser.Error: continue break else: # should be executed if we fall thru to the end popupErrorDialog('Can't find a browser.') Note that the user can configure the default browser if neccessary with the BROWSER environment variable. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Documentation recommendations
On Thu, Aug 11, 2005 at 05:33:06PM -0400, Andrew Conkling wrote: > chintzy. The only other option of which I can think is some HTML > pages, but I don't know how I'd use them in my program (other than > launching a browser). Well, that might not be so bad. Take a look at the webbrowser module in the standard lib. It tries to be somewhat cross-platform, i.e. using KDE or Gnome to launch the browser, or the default the user has set in OS X or windows. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK for MacOS X?
On Wed, Aug 10, 2005 at 04:35:31PM +0200, Wolfgang Keller wrote: > is there a PyGTK installer for MacOS X available somewhere? I use darwinports to install gtk (but not pygtk), and then just use the setup script in the pygtk tarball. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] pyGTK Chapter in new book
On Sat, Aug 06, 2005 at 09:22:00PM -0400, Dave Aitel wrote: > http://www.amazon.com/exec/obidos/tg/detail/-/0764596543/ Good job. If you search inside the book for pygtk, you can read a few pages of that section. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] sorting in treeView
On Sat, Aug 06, 2005 at 04:29:24PM +, Vinay Reddy wrote: > In case of a tie while sorting on a particular column other columns > are considered at all. I want the sorting function to sort based on > the other columns in case of a tie (in the main column). Use a sort function. See the tutorial: http://pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-SortingTreeModelRows Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Updating the app
On Wed, Jul 06, 2005 at 09:23:44AM -0300, Jose de Paula Eufrasio Junior wrote: > I'm making a pygtk app and got several fields wich values are inserted > (like textviews, spinbuttons) and these values can be changed with > values from other widgets on the app. > I'm not very friendly to the idea of a 'refresh' button, and like to > know from you guys what's the best manner to do it... You probably want to use the Observer pattern. A simplified Pythonic version would be something like def addCallback(self, cb): self._callbacks.append(cb) ... def notify(self, *args, **kw): for cb in self._callbacks: cb(self, *args, **kw) You can find a lot fancier variants (e.g. publish/subscribe) of this on the web. You can also create your own gobject signals or watch for changes in gobject properties. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] need advises on treeview use for memory puprose
On Tue, Jul 05, 2005 at 04:10:25PM +0200, [EMAIL PROTECTED] wrote: > I'm using lot of treeviews. > Is it better in memory purpose to: > 1. use the gtk.treestore as data storage. (have an entry in the model > for each simple type str ... or use a more complex object ?). It's a lot more flexible and easier to manage to append objects (I use dictionaries) to the store and then use a data_func to display the data. Also, If you have large amounts of data, consider implementing the UI with ListStoress instead of TreeStores. GTK's TreeStore is just not very efficient for large datasets. > 2. have an independent data storage. (when a row is selected, we search > the name of the selectedComponent, find it in the dataStorage and modify > the dataStorage). Depends on how much data you have and how much the user is expected to display at any one time. You would probably want to implement some kind of lazy loading for a large dataset if they user will only be accessing a small part of it at any one time. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] gtk.TreeStore with variable column count ?
On Wed, Jun 01, 2005 at 08:54:52AM +, Adrian Immler wrote: > how can i create a gtk.TreeStore with a variable count of the columns ? > how can i add/remove columns from a TreeStore ? I don't think it's possible to add/remove columns from an existing store. Instead I would suggest using objects (which could just be dictionaries) in your TreeStore together with a TreeView data func. This gives you lots of flexibility. Alternatively, you could get a TreeModelFilter from your model. See the tutorial for more info. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Detect that all windows are closed
On Sun, May 29, 2005 at 09:11:34PM +0200, Calle Erlandsson wrote: > But this create a new problem: When I've closed all the windows the app > is still running because I haven't run the gtk.main_quit(). > How do I solve this problem? The function gtk.window_list_toplevels() may be helpful here. Just check after destroying a window for how many are left. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Adding large amounts of data to a ListStore
On Thu, May 26, 2005 at 04:50:35AM -0400, Jody Steele wrote: > self.list.set_sort_func(0, self.__Sort,(column0.get_sort_order,0)) > self.list.set_sort_func(1, self.__Sort,(column1.get_sort_order,1)) > self.list.set_sort_func(2, self.__Sort,(column2.get_sort_order,2)) I'm guessing these sort funcs are eating up the time. I would keep track of the total time spent in these sort funcs by incrementing some global variables. Or use the profiler. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Adding large amounts of data to a ListStore
On Thu, May 26, 2005 at 04:13:20AM -0400, Jody Steele wrote: > for i in data: > row = (i,data[i].size_str(),data[i].date) > self.iter = self.list.append(row) Has a sort_column_id been set before this point (well, it would have to be if you are reusing the store)? According to the tutorial "Once a sort column ID has been set on a TreeModel implementing the TreeSortable interface it cannot be returned to the original unsorted state. You can change the sort function or use a default sort function but you cannot set the TreeModel to have no sort function." A costly sort func could be causing the slow down. You might try creating a trivial default sort func like sort_func = lambda *args: 0 And setting that before appending rows. Or perhaps just throwing the model away after each use? Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Adding large amounts of data to a ListStore
On Thu, May 26, 2005 at 03:49:23AM -0400, Jody Steele wrote: > Currenty I am using the append() function to insert data into my > ListStore, and that is all fine and dandy except when the dataset is > fairly large (7520 entries in one test). > > It ended up taking about 500 seconds to insert all of the data into the > list. It sounds like something is really wrong. I can load over 13000 items into my ListStore in a few seconds on an AMD64, and about 10 seconds on a 1.5GHz G4. And this is appending python objects (dictionaries), using a data_func to render them, and with column autosizing turned on. Could you give us a few more details about what kind of objects you are loading into your ListStore and how you are loading them? Are you doing anything in between appends? For example, printing debug info can really slow things down, so try running your script with "python foo > /dev/null". Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GNOME Bindings or GTK
On Wed, May 25, 2005 at 08:49:17PM -0400, Martin Grondin wrote: > I'm using Glade-2 to create a GUI for a program I'm working on and I was > wondering if the gnome bindings (via import gnome and gnome.ui) are > deprecated. I thought I heard that elsewhere but I am not sure. If they > aren't deprecated are they planned in the near future to be taken out or > is it safe to create this as a GNOME app? They're not deprecated AFAIK, but using a gnome project adds a lot of dependencies that don't add much to usability IMO. You won't be able to run gnome apps under win32, for example, whereas a pure gtk app will run quite well there with the gladewin runtime. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Inheriting window with widgets
On Tue, May 17, 2005 at 06:22:46PM -0400, Samantha wrote: > 2. If #1 is not available, here is what I am trying to do. I have a main > window with a tree on the left side of a window. The tree is in a > table. When the user clicks on a tree widget(?), something happens on > the right side. I have been able to send a window as an argument to the > function that does things on the right side of the window, but the > widgets embedded in the window (being sent as an argument) doesn't > appear to get inherited. I learned that I cannot have more than one type > of gtkWidget in a gtkWindow, so I am not sure how I can go about > accomplishing what I am trying to do. This is usually called "master/detail". The tree is your master and the the right side is the detail. I'd do this with a paned window, with a notebook on the right hand side that has "Show Tabs" set to "No" (programatically: notebook.set_show_tabs(gtk.FALSE); I'd leave the tabs visible while testing). Each page of the notebook will contain the different widgets you want to show, so you just have to switch pages in response to the tree selection to show the correct widget. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Signal emitted when a row in TreeView is selected?
On Sun, May 15, 2005 at 04:23:37PM +0100, Magnus Therning wrote: > I can't seem to find what signal will be emitted when a row in a > TreeView (with ListStore) is selected. I've tried the following signals: You connect to the TreeView's selected object's "changed" signal, then in your call back you check for what actually is selected. Assuming multiple selection mode: treeview.get_selection().connect("changed", self.on_selection_changed, ...) ... def on_selection_changed(selection, ...): model, paths = selection.get_selected_rows() if paths: ... I'm sure this is in the FAQ somewhere. Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] ANNOUNCE: Gazpacho 0.5.3
On Mon, Apr 11, 2005 at 12:46:51PM -0300, Christian Robottom Reis wrote: > This is Kiwi used to do, what Kiwi2 does, Kiwi2? Where? Dave Cook ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Is there an automated way to create IconSources/IconSets/IconFactories ?
On Thu, Nov 18, 2004 at 11:12:48AM -0500, Chris Lambacher wrote: > I am attempting to use UIManager to generate a ToolBar and a MenuBar. > I want to add icons that are not stock icons, but UIManger requires > that you use stock icons. That means that an IconFactory needs to be > created for the icons I wish to use. IconSets need to be added to the > IconFactory for each icon and IconSources have to be added to the > IconSets. I have my icons and I could just write a module to create > the IconFactory (I want to share the icons between several related > projects), but given that I can specify my menus and toolbars in XML I > was wondering if there was a way to do the equivalent for IconFactory > creation. Styles obviously do something similar to this. Can I > create a partial style and just grab the IconFactory for that style > and run the set_default method? I do it the way you describe, and it's a very simple bit if code. Using XML seems like it would actually be more work. (I'd probably use a dictionary, now instead of a list of tuples.). import gtk '''Registers new icons with gtk. Tries to use already existing icons if they are available, otherwise it loads them from files.''' ICON_INFO = [ ('gnome-stock-mic', 'gnome-stock-mic.png'), ('gnome-stock-midi', 'stock_midi.png'), ('gnome-stock-attach', 'stock_attach.png'), ('classicollect-composer', 'composer.png'), ('classicollect-work', 'work.png'), ('classicollect-role', 'role.png'), ('classicollect-artist', 'artist.png'), ('classicollect-performance', 'performance.png') ] def register_iconsets(icon_info): iconfactory = gtk.IconFactory() stock_ids = gtk.stock_list_ids() for stock_id, file in icon_info: # only load image files when our stock_id is not present if stock_id not in stock_ids: pixbuf = gtk.gdk.pixbuf_new_from_file(file) iconset = gtk.IconSet(pixbuf) iconfactory.add(stock_id, iconset) iconfactory.add_default() register_iconsets(ICON_INFO) 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] Packing widgets inside a Cell
On Wed, Oct 27, 2004 at 06:56:19PM -0300, Fernando San Mart?n Woerner wrote: > I need to pack a gtk.Expander inside a cell in a treeview, is this > possible?, Not currently. For any particular widget you want in a cell a CellRenderer needs to be implemented. gtk+ 2.4 has CellRenderers for text (which can be editable), pixbufs, and toggle buttons, and 2.6 will have combobox and progressbar renderers. > do i use pack_start() method? pack_start is for "packing" CellRenderer's into a TreeViewColumn. 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] ctree "look" pygtk2.2/gtk2.4
On Thu, Oct 21, 2004 at 10:17:44AM -0300, Christian Robottom Reis wrote: > On Thu, Oct 21, 2004 at 02:12:19PM +0100, Stuart Hughes wrote: > > I did see those, but I wanted the style to have the little box with a > > '+' in it for unexpanded nodes and '-' for expanded nodes. Also I > > wanted little lines connecting them. > Oh. I believe you can get that effect through styling/themeing; I guess I don't think you can get the connecting lines that way, though. 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] initialize a combo list
On Tue, Oct 05, 2004 at 05:12:21PM -0400, Thomas Mills Hinkle wrote: > Okay -- that's what I'd thought. So we return to the problem, > unfortunately. In my case, connecting to the 'changed' signal is too > expensive -- it makes response visibly sluggish while the user types. Yeah, I was thinking that would be a problem. > So, currently, I'll keep connecting to the focus-out signal on the Entry > widgets... none of this explains why the ComboBoxEntry and ComboBox > don't provide signals for the popup event... oh well. The only other think I can think of is to force the rendering of the popup to be dynamic by using a modify_func on the filter. I would have thought that using a visible_func would be enough for this, but apparently the state of the model still has to change for it to refilter. I would put in an RFE in bugzilla. 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] initialize a combo list
On Mon, Oct 04, 2004 at 06:22:30AM -0400, Thomas Mills Hinkle wrote: > Will the refiltering really happen automatically if I just make the > function call Entry.get_text() directly? (if so, when does this happen? > If not, I still need to connect the refilter() call to some event) Ah, I remember now that I had to call model.row_changed to get my filter to refilter (each row has a visible attribute that can change). In your case you might want to connect to the changed signal on the entries and refilter in your callback. 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] initialize a combo list
On Mon, Oct 04, 2004 at 05:32:28AM -0400, Thomas Mills Hinkle wrote: > I am using the ComboBoxEntry but I was still hoping for an answer to the > above query -- how to connect to the combo-list popup event. In my case, > I have a very large model which gets filtered based on other > EntryWidgets in my GUI -- currently I do the filtering when the focus > leaves the other widgets, but this isn't quite what I want because it > creates a confusing pause for some users (depending on the speed of > their system and size of the data their working with). It makes more > sense for that pause to happen when they click the little arrow on the > ComboBoxEntry and only then. Is there a way to connect to this event? I would suggest using a TreeModelFilter with a custom visible func, e.g. entries = [refs to your entries here] filter = mymodel.filter_new() filter.set_visible_func(visible_func, entries) cbentry.set_model(filter) ... def visible_func(model, iter, entries): # test model values against entry values This should track changes in the model and the entries without any "manual" intervention. 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] initialize a combo list
On Sun, Oct 03, 2004 at 02:43:58PM +0200, Matthias Teege wrote: > I have a lot of combo widgets in a small application. The data for the > combo-list-items come from a database. It is necessary to update the > combo-lists when the user clicks on the combo item. So I try to > connect to the button_press event on the combo-widget with > combo.connect("button_press_event", button_press), but if i click the > combo nothing happens. You might consider using ComboBoxEntry instead. Then you can use a model for the popup list. Then you just need to make sure the model tracks the changes in the database. 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] pygtk + glade: code decomposition best practices?
On Thu, Sep 30, 2004 at 01:18:04PM +0300, Ruslan wrote: > I would like to ask people using pygtk + glade to share their approach > on code decomposition. For example, there is GUI(made in glade) - > Notebook with different pages containing a lot of widgets that needs to > be connected with signals handlers. Having one main class that gets all > widgets from glade file and contains all signal handlers seems not very > good approach. Probably for each Notebook page should be created > separate class to handle GUI signals from page widgets, maybe there is > some kind of software pattern for handling such cases... > Anyway if someone has any suggestions/ideas, you are welcome. I put my XML object in a module, essentially making it globally available in the application, so I can do from myxml import XML # XML is a gtk.glade.XML object ... foowidget = XML.get_widget('foo') XML.signal_connect('on_baz_clicked', self.bazmethod) allowing me to access the widgets and handlers wherever I need them. 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] Using ListStores for popup menus (ala ComboBoxEntries)
On Wed, Sep 15, 2004 at 06:28:37AM -0400, Thomas Mills Hinkle wrote: > Currently, I'm using popup menus in TreeViews as a hack since I can't > pack a ComboBoxEntry into a TreeView. It would be convenient to use the > same TreeModel for both these popup menus and ComboBoxEntries elsewhere > inthe UI. Has anyone else implemented this? For a list or a tree? Should be pretty trivial for a list. I've done this for 2 CBE's and a tree with 2 levels. I catch the selection event in the first CBE and then set the model for the second CBE to a TreeModelFilter of the original model re-rooted to the selected row. Apparently 2.6 will have direct support for tree handling with ComboBoxes so you don't have to do it this hackish way. http://www.gtk.org/plan/2.6/ 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] CList
On Tue, Sep 14, 2004 at 02:37:40PM -0400, Jamey Cribbs wrote: > Every few months, I grab the latest version of pygtk and attempt to > duplicate the CList functionality using TreeView, but to no avail. I > have done a lot of reading, attempted to use > Liststore/TreeModelSort/TreeView combinations, read up on how to handle > large datasets, etc.. Not only does this seem WAY more complicated than > it needs to be, it also is slower than the CList. How large are the datasets we're talking about here, just so we have a reference? > Basically, I use the CList as a multi-column listbox to show rows from a > database. I know that this can easily be done using TreeView. Where it > gets complicated is when you want to sort the TreeView or refresh the > data from the database and you want the current sort and selected record > to be shown. In other words, when I refresh the view or when I return > to the view from editing a single record, I want it to be sorted the > same way it was, with the same selected record showing. First, it's essential to keep clear the distinction between the view and the model (ListStore in this case). When you say "refresh the view", do you mean is that you're clearing the model and reloading the data into it? You shouldn't need to do this very often. When you make changes to the model, they should be automatically reflected in the view. How are you writing the data to the model? Also, it would help to see some code. Dave Cook > This is very complicated using TreeViews, especially because I have > resorted to using TreeModelSort in order to try and speed up the very > slow sort times when refreshing data in a view. > > Anyway, sorry to rant. I really just want to know how long I can count > on CList being in pygtk2. CList is a great widget and it handles all of > my needs just fine. > > Thanks. > > Jamey > > Confidentiality Notice: This email message, including any attachments, is > for the sole use of the intended recipient(s) and may contain confidential > and/or privileged information. If you are not the intended recipient(s), > you are hereby notified that any dissemination, unauthorized review, use, > disclosure or distribution of this email and any materials contained in any > attachments is prohibited. If you receive this message in error, or are not > the intended recipient(s), please immediately notify the sender by email > and destroy all copies of the original message, including attachments. > ___ > 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 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] IronPython
On Fri, Sep 10, 2004 at 08:16:25AM -0400, Dave Aitel wrote: > Has anyone looked at IronPython? I think you could write a pyGTK that > used (wrapped) the GTK# libraries so all our great pyGTK programs could > run on Mono. http://usefulinc.com/edd/blog/contents/2004/08/24-monoadn-ex/read 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/
[pygtk] Lazy tree implementation
Thought I'd share my lazy tree implementation. The idea is that child rows in a tree are not filled in until the user clicks on the expander for that row. Until then, an single unset row is used as a placeholder for the the child rows. http://members.cox.net/davecook/pygtk/LazyTreeStore.py To use it, you need to structure your tree data as nodes with getChildren() and hasChild() methods. An example is show for browsing a filesystem. 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] PyGTK for Mac OS X?
On Thu, Aug 19, 2004 at 11:31:35AM +0400, Mikhail Sobolev wrote: > I looked around for PyGTK port for Mac OS X, and it looks like such a > thing does not exist (at least, as an official release). Is my > impression correct? Pygtk runs fine under Apple's X11 server http://www.apple.com/macosx/features/x11/download/ The quickest way to get the gtk libraries under OS X is to install darwinports http://darwinports.opendarwin.org/ 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] ListStore newbie question
On Wed, Aug 18, 2004 at 10:29:10AM -0600, Cristian Prieto wrote: > Yep, I know already about gtk.CellRendererText(), gtk.CellRendererPixbuf > () and gtk.CellRendererToggle() > I need to insert a gtk.ComboBox and a gtk.CheckBox, I guess I need to > pass a list to the gtk.ComboBox in the model and a bool to the > CheckBox... The checkbox is easy, just use a CellRendererToggle and set the "active" property. 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] Tutorial Question...
On Sun, Aug 08, 2004 at 05:45:38AM -0400, dave wrote: > Are we supposed to be talking about TreeStore's here instead of liststores? > > I'm currently doing a search on a TreeStore: > for row in treestore: > if row[0]==searchedthing: > return row Here's what I came up with when someone asked about this back on 7/7: #untested back-of-the-envelope coding! #Uses the gtk standard of returning False on match. def search_func(model, col, key, iter, user_data): value = model.get_value(iter, col) return value!=key def search(model, col, key, iter, search_func, user_data): if search_func(model, col, key, iter, user_data): for i in range(model.iter_n_children()): child = model.iter_nth_child(i) search(model, col, key, child, search_func, user_data) else: yield iter it = model.get_iter_first() mysearch = search(model, 0, 'foobar', it, search_func) matches = list(mysearch) 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] How to get the text from (new style) ComboBoxEntry
> Nikos Kouremenos wrote: > >but I couldn't understand [sorry I'm new in the GTK world] how to get > >the text from the selection that the user has finally done! I missing some parts of this thread, so don't know if anyone gave this answer: entry = combo_box_entry.get_child() text = entry.get_text() It is in the docs, but it's pretty easy to miss in passing. 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] traversing a TreeView
On Wed, Jul 07, 2004 at 01:13:28AM +, Christian Bird wrote: > I've got a question about the best way to iterate over the items in a > TreeView starting with an arbitrary item in the treeview. I'm trying #untested back-of-the-envelope coding! #Uses the gtk standard of returning False on match. def search_func(model, col, key, iter, user_data): value = model.get_value(iter, col) return value!=key def search(model, col, key, iter, search_func, user_data): if search_func(model, col, key, iter, user_data): for i in range(model.iter_n_children()): child = model.iter_nth_child(i) search(model, col, key, child, search_func, user_data) else: yeild iter mysearch = search(model, 0, 'foobar', it, search_func) matches = list(mysearch) ___ 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] PyGTK2 Tutorial v.2.1
On Tue, Jul 06, 2004 at 12:06:28PM -0700, John Finlay wrote: > In addition to receiving comments about tutorial problems, errors and > enhancements, I'm interested in hearing from poeple who have used the > GenericTreeModel. Specifically, I'm interested in what applications > require a custom tree model instead of the standard ones, and what > issues they encountered developing and using a custom tree model. Same > for the GenericCellRenderer. Attached is a GenericCellRenderer that I used in my Classicollect app (ripped out of context and simplified a bit), but not shown is the important part where you have to take care of sending all the row-insert/changed/deleted etc. signals. Note that it doesn't do the subclassing quite correctly. I could fix this up into a simple working example if anyone is interested. Essentially I implemented this tree (really a forest) the way we were taught in school: each tree node has its cargo, a reference to the parent node, and a list of child nodes. I also keep an index for each node, which is its position its parent's child list, for efficiently finding the path of a node. Since get_path doesn't seem to get called much (by treeviews anyway), this may not be necessary, and it does add some extra bookkeeping if you remove or insert nodes. I originally wrote this because I didn't know about TreeViewColumn.set_cell_data_func, and, well, writing a GTM is kinda fun. Then I went back to it when I found that cell_data_funcs wouldn't work with interactive searches (there was no TreeView.set_search_func in pygtk at the time; when I found out about that it was fixed by gjc within the day!) or with the new ComboBoxes. Now with TreeModelFilter, I don't think I have any need for a generic TreeModel, though I haven't had a chance to really test it with a large data set. And if this works: http://bugzilla.gnome.org/show_bug.cgi?id=144509 you have yet another easy way to write a custom TreeStore. import pygtk; pygtk.require('2.0') import gtk # Schematically, nodes look something like this: class Node: def __init__(self, parent=None, children=None, data=None, index=0, level=None): self.parent = parent if children is None: self.children = [] if data is None: self.data = {} # node cargo self.index = index # index of child self.level = level # provides info about each depth of the tree OUTFILE = sys.stdout def print_debug(*args): for arg in args: print >>OUTFILE, arg, print >>OUTFILE OUTFILE.flush() class PyListTreeModel(gtk.GenericTreeModel): '''A TreeModel using Node objects as its base data structure.''' def __init__(self, root, *column_types): '''constructor for the model. Make sure you call PyTreeModel.__init__''' gtk.GenericTreeModel.__init__(self) self.set_property("leak_references", 0) self.column_types = column_types self.ncolumns = len(self.column_types) self.root = root def on_get_flags(self): '''returns the GtkTreeModelFlags for this particular type of model''' print_debug("on_get_flags") return 0 def on_get_n_columns(self): '''returns the number of columns in the model''' print_debug("on_get_n_columns") return self.ncolumns def on_get_column_type(self, index): '''returns the type of a column in the model''' print_debug("on_get_column_type", index) t = self.column_types[index] return t def on_get_path(self, node): '''returns the tree path (a tuple of indices at the various levels) for a particular node.''' print_debug("on_get_path", node) path = [] while node.parent: path.append(node.index) node = node.parent path.reverse() return tuple(path) def on_get_iter(self, path): '''returns the node corresponding to the given path''' print_debug("on_get_iter:", path) node = self.root try: for i in path: node = node.children[i] except IndexError: node = None return node def on_get_value(self, node, i): '''returns the value stored in a particular column for the node''' print_debug("on_get_value:", node, i) level = node.level try: value = node.data[level.keys[i]] except KeyError: value = level.control_cols[i] return value def on_iter_next(self, node): '''returns the next node at this level of the tree''' print_debug("on_iter_next", node) siblings = node.parent.children try: next = siblings[node.index+1] except IndexError: next = None return next def on_iter_children(self, node): '''returns the first child of this node''' print_debug(
[pygtk] Fun with TreeModelFilter
This class solved a problem that has been bothering me for a long time: how to do interactive searches when your store contains only objects. The TreeView wants to access a column of strings to do this. Also, the new ComboBoxEntry can use a TreeModel, but again it wants to access a column directly to get its text. This is where TMF comes in. Not only can you filter a model, but it also lets you synthesize completely new columns. Jon Finlay's amazing tutorial does a good job covering TMF: http://tinyurl.com/2qjn9 The other solutions I came up with were writing a custom TreeModel (requires keeping track of a lot), and keeping a redundant string column that is kept synchronized with the object column using the Observer pattern. And here's some code showing how TMF can be used in this case: import gtk class Node(object): def __init__(self, name): self.name = name def __str__(self): return self.name def modify_func(model, iter, col): child_iter = model.convert_iter_to_child_iter(iter) child_model = model.get_model() return child_model.get_value(child_iter, 0) def print_nodes(model): it = model.get_iter_first() while it: print model.get_value(it, 0), repr(model.get_value(it, 1)) it = model.iter_next(it) store = gtk.ListStore(object) # ModelFilter synthesizes a string column using the modify func. # This string column can be used for interactive searches and ComboBoxes. filtered = store.filter_new() filtered.set_modify_func((str, object), modify_func) # put objects in the store nodes = map(Node, ['larry', 'bill', 'scott']) for node in nodes: it = store.append() store.set_value(it, 0, node) print_nodes(filtered) # modify the objects for node, name in zip(nodes, ['guido', 'linus', 'james']): node.name = name # does the ModelFilter track our changes? print_nodes(filtered) ___ 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] Progress Cell Renderer
On Fri, Jun 25, 2004 at 04:32:30PM +0200, Lorenzo Gil Sanchez wrote: > I'm not sure what do you mean. There is a bug in GTK+ about having a > CellRendererCombo: > > http://bugzilla.gnome.org/show_bug.cgi?id=139347 > > Wrapping it in pygtk after that would be pretty easy. > > If you mean if we have a bug about full support to subclass gobjects in > pygtk I think there is no such a bug but I may be wrong. There are various bug reports scattered around relating to this, but I think this is the mother of them all: http://bugzilla.gnome.org/show_bug.cgi?id=129843 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] Progress Cell Renderer
On Wed, Jun 23, 2004 at 11:39:21AM -0300, Gustavo Niemeyer wrote: > I haven't found this anywhere, so I thought someone else might > be interested as well. Here is a cell renderer which mimicks > progress bars, based on current gtk+ code. Has anybody done a cell renderer for combo boxes? 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] treeview typeahead
On Wed, Jun 09, 2004 at 08:33:27PM +0200, Danny Milosavljevic wrote: > Can this internal search box be called(shown) per code (i.e. on first > keypress, on toolbutton) ? I don't know, I can't find an API for it. You might want to ask for the feature in bugzilla. 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] Subclassing GtkWidget in PyGTK
On Fri, Jun 04, 2004 at 01:35:37PM +0200, Johan Dahlin wrote: > That demonstrates how to subclass a GtkWidget in PyGTK. What about when constructors require arguments? Is this still an issue? 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] treeview typeahead
On Mon, Jun 07, 2004 at 12:36:27AM +0200, Danny Milosavljevic wrote: > Except dead (f.e. acute) chars which modify the next character. > I wonder how to fix that. The built-in search feature (activated with ctrl-f (or ctrl-s with the emacs keybindings)) should be able to handle special characters like that. 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] MVC and TreeView
On Fri, Jun 04, 2004 at 11:11:28PM +0100, Jonathon McKitrick wrote: > > Hi David, > > the tips you gave me were very helpful. I have a working prototype now that > has helped me understand the basics. But what if I want to still have > multiple columns? I'm still not quite sure where those should be added or > accounted for. When you set the cell_data_func, you can pass in an index, and then in your callback return different object attributes based on the index. 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] MVC and TreeView
On Fri, Jun 04, 2004 at 06:20:04PM +0100, Jonathon McKitrick wrote: > if I have a set of objects and show their properties in a TreeView, is it > better to change the original objects then rebuild the ListStore, or extract the > changes from the ListStore and modify the original objects? Best to avoid redundancy altogether if you can by directly using your objects. You can put the actual objects in the ListStore and then set the cell contents using a callback as described in the FAQ. http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.029.htp This is the easiest way to do it, but you lose interactive searches (which must be on a text column in the TreeModel.) Or you can write a custom TreeModel that returns values from your objects. This is more work since you have to write all the model methods and are responsible for sending out the right signals when the model changes. 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] genericCellRenderer and CellEditable...
On Mon, May 24, 2004 at 11:42:46PM +0200, Lorenzo Gil Sanchez wrote: > I'm sorry at the moment there is no way to create a CellEditable since > it is a GInterface (not a Class) and you can't implement a GInterface in > pygtk so far. I know it because I wanted to do the same thing as you. > See the list archives for more information. Is there a bugzilla entry that I can track? Thanks, 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] what documentation?
On Mon, May 17, 2004 at 08:48:34AM +0200, gabor wrote: > is there a reference like documentation specially for pygtk? Yes, it's linked in the FAQ below: ___ 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] Problem with TreeView.scroll_to_cell()
On Fri, May 07, 2004 at 03:27:33PM +0200, Igor Stroh wrote: > treeview.scroll_to_cell(path, col, gtk.TRUE, 0.5, 0) Try putting the scroll_to_cell in a idle_add call: gtk.idle_add(treeview.scroll_to_cell, path, col, gtk.TRUE, 0.5, 0) 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] how to delete a father without kill the children in a TreeStore ?
On Tue, Apr 13, 2004 at 02:12:12AM +0200, Riccardo Galli wrote: > I can't figure out how can I (in a nice way) delete a row with children without loose the children, in a TreeStore > a working way would be to recursively copy the children before the parent, > and then delete the parent, but it seems to me like a slow and stupid way. This should work fine. It shouldn't be too slow. Remember that for this type of thing you only have to be fast enough for the perception of the user. 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] Storing a TreeView
On Sat, Apr 03, 2004 at 02:12:28PM +0200, Nemesis wrote: > Hmm, I think that the n.1 is the most simple, but however you have to > cicle the list and rebuild the tree, as far I can see. > I'm not sure I understood n.2, The idea is to subclass TreeStore and override TreeStore.set/set_value (and also TreeStore.remove if you are deleting nodes) so that you save data every time set_value is called. But why persist the store, why not just keep it in memory and use TreeView.set_model to change stores? Do you really need to save the headers in between sessions? 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] Storing a TreeView
On Sat, Apr 03, 2004 at 11:00:40AM +0200, Nemesis wrote: > Hi all, >I'm writing a newsreader with python+pygtk. I'm using a TreeView > in order to show the articles (in a threaded fashion). I'd like to > store the model so I don't have to rebuild the threads every time I > select the group. > I've tried pickling the TreeModel, but it isn't picklable. How can > I store this information? Options I can think of: 1. Traverse the tree (TreeModel.foreach and TreeModel.get_value) and save each node. You can use the path as a key, and it's then easy to rebuild the TreeModel. 2. Save nodes in the tree as they are added. It may help to subclass TreeStore. 3. Write you own TreeModel that can be persisted at once. 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] color of selected row in TreeView
On Sun, Mar 28, 2004 at 07:08:07PM -0500, Yann Le Boulanger wrote: > I'd like to change the color of selected row in a treeview. > As CellRenderer and TreeIter are not Widgets, I can't use > style.bg[gtk.STATE_SELECTED] > > Is there a solution ? You can do that for the whole TreeView, but I don't think you can do that on a cell-by-cell basis. 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] treeview. how to "non indent" column ?
On Fri, Mar 26, 2004 at 12:05:57AM +0100, Riccardo Galli wrote: > Is possible not to "indent" a column in a treeview ? > I draw a picture to explain You can add some xpadding using the "xpad" property of the cell renderer (in the same way you might set background color or font on a cell; see the FAQ for examples). The default xpad seems to be 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] Non-homogenous treeview
On Tue, Mar 16, 2004 at 06:19:19AM -0600, David G. Mackay wrote: > That's all very good, but if I want to view a parent with 20 columns, > and then a child with 10 distinct columns, then it's going to get pretty > unwieldy. If each node must have different types in each position, you're going to be using a lot of horizontal space, as in this screenshot: http://classicollect.sourceforge.net/screenshot.png I've since changed the way I represent my nodes so that the same columns are reused for each node. This is possible in the top example because everything is a string, and in the bottom example the node column types at each depth are (str, bool). So I suggest trying to arrange the columns of each node so that the types "line up" or at least overlap. You can then use pixmaps at the beginning of each row to visually distinguish the tree depth (although indentation will help; treeview does not have the connecting lines of the old ctree, though.) I haven't quite decided what to do with column headings, though. 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] Non-homogenous treeview
On Mon, Mar 15, 2004 at 10:26:37PM -0600, David G. Mackay wrote: > Is there any way to implement a treeview (other than deriving a new > class from scratch) with allows child nodes to be differently formatted > from the parent nodes? I would like to use a treeview to view > information from a database with related tables. TreeModels are row oriented, i.e. each node is a row of with a fixed number of columns with fixed types. However, in the TreeView you can control the visibility, editibility, background color, font, and any other properties supported by the renderer(s) for each column on a row by row and cell by cell basis. You can do this by specifying that the renderer properties should be taken from particular columns of the model (example of setting the editable property this way) http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.010.htp or you can specify callback functions to set the properties: http://www.async.com.br/faq/pygtk/index.py?req=all#13.29 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] PyGtk usage question
On Fri, Mar 12, 2004 at 02:00:21PM -0600, Alex Roitman wrote: > pygtk is in Debian since very long ago. Debian has arguably one of the And in Red Hat since they've used it for their installer and admin tools for years (since 6.0 or thereabouts IIRC). 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] How to focos a TreeView's cell?
On Sat, Mar 13, 2004 at 01:45:58AM -0600, Mauricio Téllez wrote: > Hi, I have a ListStore with 3 column of type gobject.TYPE_STRING, the > first and thirth columns are editable, but the second is not. I have an > "Add" button that when I click it append a new row to the model, so I > want that the first cell in the view's new row get selected and ready to > insert text (as if I clicked the cell), and that when I finished with Use TreeView.set_cursor() and TreeView.scroll_to_cell(). I've found that I had to put the scroll_to_cell in an idle callback to make it work right (this may be because of the old gtk in RH9). view.set_cursor(newpath, viewcol, gtk.TRUE) gtk.idle_add(scroll_to_cell, view, newpath, viewcol) def scroll_to_cell(view, path, viewcol): view.scroll_to_cell(path) 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] Selection issues with TreeModelSort
On Thu, Mar 11, 2004 at 04:43:33PM -0700, Don Allingham wrote: > I have created a custom tree model, derived from GenericTreeModel. I use > text strings as iters for the model. This is working well. When I get > the current selection, I get the string that I was using as an iter. > >model = MyModel() >tree.set_model(model) >selection = tree.get_selection() > >return_is_string = selection.get_selected() I don't see how that works, it sounds like a fortuitous bug. In C, a TreeIter is an opaque structure. You should still have to do a get_value to get an actual usable value. 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] Tooltips inside a TreeView
On Mon, Feb 09, 2004 at 11:39:37AM +, Graham Ashton wrote: > I was wondering if it's possible to do row specific tooltips. See http://bugzilla.gnome.org/show_bug.cgi?id=80980 Though this is per cell. Don't know if per row is possible. 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] ComboCellEditor
On Fri, Jan 16, 2004 at 03:52:09PM -0200, Christian Robottom Reis wrote: > Aren't there bugs open on this subject? This has been discussed at > length here, and IIRC there was some consensus that something needs to > be fixed (in PyGTK, IIRC). As to whether you should rewrite the Doesn't gtk 2.3 now have a combobox that implements CellEditable? 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] TreeView, Windows Look & Feel
On Fri, Jan 02, 2004 at 09:40:58AM +0800, Bert Marco Schuldes wrote: > Icons and especially visible lines connecting > the nodes of the tree. I think that's what this RFE is about: http://bugzilla.gnome.org/show_bug.cgi?id=106406 But there seems to be some confusion there between grid lines as in a spreadsheat and connecting lines between tree nodes. I'm pretty sure the lines aren't possible. Depending on the nodes in your tree, using different pixmaps at each level on the tree may help users to figure out where they are in the tree. See the FAQ for some examples. 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] Some gtk-noob TreeStore problems :]
On Tue, Dec 30, 2003 at 10:14:19PM +0100, Daniel Kirkegaard Mouritsen wrote: > Hey everybody, > > I'm having problems with the gtk.CellRendererToggle() renderer, I have a > TreeStore with three column defined like this: > > tree_store = gtk.TreeStore(gobject.GObject, gobject.TYPE_STRING, > gobject.TYPE_STRING) You need a gobject.TYPE_BOOLEAN for the toggle buttons unless you are using TreeViewColumn.set_cell_data_func(). > Ive connected the "toggled" signal to a function, but when i > activate/deactivate the toggle it applies the changes to all the > toggles. What does your callback look like? 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] Unapplied patches
On Wed, Dec 17, 2003 at 03:35:37PM -0700, Don Allingham wrote: > work for more than just trivial cases (proper handling of iters with a > value of None). Oh, I thought this was "just the way it was"! This gave me fits for a day or so. I got around this by using instances of a "Stub" class in place of None. 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] treeview
On Wed, Dec 03, 2003 at 11:43:02PM +0100, asterix wrote: > 1/ in my gtk.treestore, i have a "column" with a value witch can be 'g' > or 'u'. If it's 'g' i'd like the background color of the treeiter to be > blue for example, and another color if it's 'u'. One way is the have an extra color column (as a string) in your store, then set your background to come from this column: cell = GtkCellRendererText() viewcol = gtk.TreeViewColumn(title, cell, text=i, background=j) Where i is the treestore column to take the text from and j is the treestore column to take the color value from. See the properties of GtkCellRendererText for the full list of attributes you can set this way. You could also use a GtkTreeCellDataFunc to do this, but I haven't tried it. There is an example in the FAQ: http://www.async.com.br/faq/pygtk/index.py > 2/ i'd like to define the indentation in the treeview : i'd like the > children of a treeiter to be under it and not shifted, is it possible ? Perhaps the "indent-expanders" property of GtkTreeView? > 3/ i'd like to extract a widget from a treeiter to attach a tooltip to > it. So is there a Hbox or something else in treeiter that can be used ? I don't think it's possible. Doesn't look like we'll have treeview tooltips until gtk+ 2.6. 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] signal on title colum of GtkTreeView
On Thu, Nov 13, 2003 at 12:12:34PM +0100, Harobed wrote: > I would like to show popup window when I click on title column of > TreeView. The TreeViewColumn object has a "clicked" signal: http://tinyurl.com/uuke (scroll to the bottom) So that you know which column was clicked, you can either attach data to the TreeViewColumn or pass user data in when you connect the signal (for example a key or column number). You'll usually do this when adding the columns to the TreeView. 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/
[pygtk] Avoiding extra space in rows without icons in treeview
I have a treeview/treemodel with icons for the first column of each row, using TreeViewColumn.pack_start (works great; thanks guys!). However, I'd like some rows to not have icons. I tried putting None for the pixbuf in my treemodel for those cases, which works, but it leaves quite a bit of space where the icon would have been. Is there a way around this, perhaps by creating an "empty" pixbuf? Thanks, 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] How to remove a row from a GTK.ListStore?
On Sat, Nov 01, 2003 at 12:52:56PM -0500, Hans Deragon wrote: > Newbie here. I tried to figure out how to remove a row from a > GTK.ListStore on the web (documentation and mailing list archives), but I > could not figure it out. The documentation is pretty poor. > > What I want to figure out is how can I get the iter required by > GTK.ListStore.remove()? I have a GTK.TreeView with at GTK.ListStore as a > Model. I want to remove the row that has been selected by the user. How > do I proceed? How do I obtain the iter that points to the currently > selected item? It must be easy, but I cannot find the function that would > return the iter. TreeView contains a selection object that manages user selections. You need to get the selection object, then query it for the selected path with the get_selected() method. For single selection mode: selection = treeview.get_selection() result = selection.get_selected() if result: #result could be None model, iter = result model.remove(iter) For multiple selection mode you need to use a little hack to get the selected paths until get_selected_rows() is implemented (2.2 API): rows = [] selection.selected_foreach(lambda model, path, iter: rows.append(path)) rows will then be a list of selected paths, and you can use model.get_iter(path) to get the iters. Note that this "hack" will work with either selection mode, so I use it everywhere instead of get_selected(). 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] hide certain rows in treeview
On Thu, Oct 09, 2003 at 11:10:09AM -0700, David M. Cook wrote: > On Thu, Oct 09, 2003 at 10:43:54AM -0700, Yang Zheng wrote: > > > Is it possible to not show certain rows in a treeview that is attached > > to a treestore? I know you can display only certain columns, but what > > if there are some rows in a treestore structure that I do not want to be > > displayed? Can I set a flag and have it skipped? > > There's no way to do this currently without copying to another treestore. > gtk 2.4 will have a "FilteredTreeModel" that does this. However, it occurs to me that it may be possible to implement your own FilteredTreeModel as a custom TreeModel. 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] nonstandard widgets in pygtk?
On Tue, Oct 07, 2003 at 11:36:36AM -1000, Tim Newsham wrote: > Hi, I would like to compile some nonstandard gtk extensions > written in C into pygtk. What is involved in this process? > Is there any documentation that covers pygtk internals? Are > interfaces generated or defined manually? This may be helpful: http://www-106.ibm.com/developerworks/linux/library/l-wrap/ 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] hide certain rows in treeview
On Thu, Oct 09, 2003 at 10:43:54AM -0700, Yang Zheng wrote: > Is it possible to not show certain rows in a treeview that is attached > to a treestore? I know you can display only certain columns, but what > if there are some rows in a treestore structure that I do not want to be > displayed? Can I set a flag and have it skipped? There's no way to do this currently without copying to another treestore. gtk 2.4 will have a "FilteredTreeModel" that does this. http://www.gtk.org/plan/2.4/ 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] Several TreeViews with Common Model
On Mon, Sep 29, 2003 at 10:36:40AM +0700, mige wrote: > I'm trying to use a treemodel [store] in both views (showing as a tree > and a list), just like file explorer. > The tree view is working fine. > But, I need to show the direct childrens in the list view if I click the > node. Is there any way not to copy the model ? So, no need creating new > model. May be just passing the node as (sub) treemodel [as list-store] > for the list view ? I don't know a way to do that currently without writing your own treemodels, which is not hard. Then you can have instances of MyTreeStore and MyListStore that reference the same underlying data structure. 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] 'About' strangeness.
On Mon, Sep 01, 2003 at 12:40:11AM -0700, Colin Fox wrote: > In addition to my previous message about the missing yellow star in the > About menu, the "Gnome About" dialog itself is causing me some grief. > > If I show the about box, then dismiss it, then show it again, my program > aborts immediately with a segfault. No traceback stack or anything. I've > tried handling the 'response' and 'close' signals (hiding the dialog & > returning gtk.TRUE), to no avail. You also need to handle the delete_event signal and keep it from propagating by returning gtk.TRUE. 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/