Re: Anti-Aliased 2D drawing
Not exactly what you asked for (and no use at all if you're not using python), but matplotlib: http://matplotlib.sourceforge.net/ is great for this sort of thing. John Scott Robert Ladd wrote: Anti-Aliased 2D drawing I'm working on a program that draws relatively simple diagrams -- involving lines of different styles and a few arcs -- on top of a base PNG image. Doing this using the standard GTK facilities isn't difficult, but the result is... well, rather rough (jagged, actually). As I understand it, Gtk+ does not support anti-aliasing natively. I've been experimenting with GtkDrawingArea and GtkImage, but I'd appreciate any advice on drawing high-quality simple figures in a GtkWidget. While I want to keep dependencies to a minimum, it looks like I need to use an external library. I've found Cairo (http://cairographics.org) and, of course, libart. My interest is in finding the simplest and most universal solution. Cairo looks interesting, but seems to still be in early beta. And, of course, there's libart. I've heard that Cairo might be integrated into Gtk at some point. Thank you in advance for helpful comments. ..Scott ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: TreeView: Multiple selection inefficient?
Andrew is suggesting you insert a small delay in between getting the signal the 'selection_changed' signal and actually doing something about it. By adding the delay you allow time for then next signal to come along + if you get a second signal you should reset the timer to zero, to allow for yet another user event. By tuning the size of the delay you'll cut down the number of signals for which you actually do something and performance should be good. You need to check-out gobject.timeout_add() and gobject.source_remove(), which will allow you to set your processing to be triggered after the delay. source_remove is needed so that you can cancel an earlier timeout_add when you get a second 'selection_changed' event. Hope that helps. John Matthias Kaeppler wrote: Re: TreeView: Multiple selection inefficient? Andrew E. Makeev wrote: I think, it is not GTK+ neither GTKMM issue. You have to delay signal handler just until user keep send events to your application. Set timer callback where you will call "selection_changed" handler, and reset it after each user event that changes selection. Regards, -andrew Hm, I'm not sure what you mean, can you elaborate on that? Sorry for my ignorance, I'm fairly new to the whole Gtk thing. -- Matthias Kaeppler ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: context menu when right clicking on a TreeViewColumn header
See: http://bugzilla.gnome.org/show_bug.cgi?id=148558 http://bugzilla.gnome.org/show_bug.cgi?id=141937 Short answer: can't really be done at present without probing around in stuff you probably shouldn't. Bug 148558 has some good discussion of how to do it. Funny you should mention Evolution -- it has its own custom Treeview I believe, I looked at that when I ran into the problem, only to discover it had its own widget. John Lorenzo Gil Sanchez wrote: context menu when right clicking on a TreeViewColumn header Hi, I wonder how can I detect right click mouse button events on the header of a TreeView so I can display a context popup menu (like Evolution does). Button events on the rest of the TreeView are ok, it just I don't get them when clicking on the button headers. Regards Lorenzo Gil Sanchez ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
TreeModelFilter performance with large models
I've been experiencing poor performance with a TreeModelFilter as the number of rows in my model grows. Attached is a short Pygtk script which demonstrates the problem. The app loads 1 rows into a ListStore. Buttons on the bottom of the app allow you to filter to show either: All entries Those which are non-zero Those which are zero A fast version of filtering to show just zero The performance is poor when going from all (or all non-zero) entries to just-zero. See figures below. 1.85 1 just zero 4.08 15000 just zero 8.37 2 just zero 15.59 25000 just zero 23.55 3 just zero 36.62 35000 just zero 53.42 4 just zero Note that performance is only poor when a large number of rows are being filtered out of the view. Looking at the code for gtktreemodelfilter.c it becomes clear why things degenerate as the store size increases. Each time a row in the child store is changed a row_changed signal is sent to the TreeFilterModel. When the change is such that a row switches from visible to invisible gtk_tree_model_filter_remove_node is called to remove the node. This function ends up doing a binary search to find the data to remove. It then runs the following code to fix up pointers for children of all the elements in the array beyond the one that just got removed. for (i = MAX (--i, 0); i level-array-len; i++) { /* NOTE: here we do *not* decrease offsets, because the node was * not removed from the child model */ elt = g_array_index (level-array, FilterElt, i); if (elt-children) elt-children-parent_elt = elt; } I think this means that the algorithm is O(n^2). My 'fast-just-zero' simply copies the child store to a new store, gets rid of the original child store, modifies all the elements in the new store and then creates a new TreeModelFilter from the new store and attaches it to the view. This approach is very much faster, since adding entries to a new TreeModelFilter is very much faster than removing a lot of entries from an existing one. Note I have to create a new store and copy the data over, since I can't find anyway of removing a filter from a store once it has been created. I'm not sure what the best way to fix this performance issue is. A more efficient gtk_tree_model_filter_remove_node is probably the way to go, but I think this would need a fair bit of re-working of the data-structures that are being used. Another (simpler?) option would be to provide an API to allow row-changed signals to be blocked + a method to simply throw away the current data and refresh completely from the child. John treefilter.py Description: application/python ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: TreeFilterModel and sorting
I've just run into this problem (using pygtk). I'd like to have a liststore that is both sortable and filterable. In fact, I had such a beast, but I was using my own nasty hacks to implement the filtering. I've had on my to-do list to switch to the TreeModelFilter + I've just tried that -- unfortunately it seems I can either have filtering or sorting, but not both. Am I missing some trick? John bernd wrote: TreeFilterModel and sorting Hi, we use GtkTreeModelFilter to filter a modell to diff. views. Ok it works. But we can't sorting the view because the model in dthe view is not a SORTABLE. In function: gboolean gtk_tree_sortable_get_sort_column_id (GtkTreeSortable *sortable, gint *sort_column_id, GtkSortType *order) { GtkTreeSortableIface *iface; g_return_val_if_fail (GTK_IS_TREE_SORTABLE (sortable), FALSE); from gtk_tree_column_sort: has_sort_column = gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column-tree_view)-priv-model), sort_column_id, order); we get the error message: Gtk-CRITICAL **: file gtktreesortable.c: line 108 (gtk_tree_sortable_get_sort_column_id): assertion `GTK_IS_TREE_SORTABLE (sortable)' failed Is it not possible to sort a view with FilterModel? Or have me make a failure in bilding the view? MfG Bernd ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: TreeFilterModel and sorting
[EMAIL PROTECTED] wrote: I've just run into this problem (using pygtk). I'd like to have a liststore that is both sortable and filterable. In fact, I had such a beast, but I was using my own nasty hacks to implement the filtering. I've had on my to-do list to switch to the TreeModelFilter + I've just tried that -- unfortunately it seems I can either have filtering or sorting, but not both. Am I missing some trick? You can stack models GtkListStore GtkFilterStore GtkSortStore And use the Store are the model in the GtkTreeview Stian Many thanks for this -- I'd just discovered the same as your e-mail came in. My (pygtk) code now looks like this and is working pretty well. # Get a ListStore self.store = gtk.ListStore(*self.col_types) # Add filtering filtered_model = self.store.filter_new() filtered_model.set_visible_column(self.store.get_n_columns()-1self) # And now add sorting self.filtered_model = gtk.TreeModelSort(filtered_model) self.view.set_model(self.filtered_model) ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: gtk Treeview tutorial
A really good way to learn gtk is to work with the python bindings, pygtk. There is a good pygtk tutorial for the treeview here: http://liw.iki.fi/liw/texts/gtktreeview-tutorial.html There are also a whole section on the treeview in the pygtk faq: http://www.async.com.br/faq/pygtk/index.py?req=index Even if you are not using python, this tutorial and faq can be very useful to learn how to do stuff in GTK. John weo wu wrote: gtk Treeview tutorial HI guys: I'm a newbie in gtk+ , I have many questions about the GtkTreeView .Somebody ever told me that the Gtk+ 2.0 Tree View tutorial is usefull,but I could not visit the websit scentric.net/tutorial/treeview-tutorial. pdf which contains the tutorial (is this url is invalid?). I ever used the google to search for it,but no result. Could anybody who has one send me a copy ? thanks so much ! (My English is so bad ,hope this could be understanded!) Thank you so much . Mail: [EMAIL PROTECTED] _ Do You Yahoo!? 150MP3 http://music.yisou.com/ http://image.yisou.com 1G1000 http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Gtk::TreeView performance
Thanks very much indeed for this pointer, armed with this info I've speeded up the loading of my grids by a factor of 5. I had been trying: TreeViewColumn::set_fixed_width() and TreeViewColumn::set_sizing(TREE_VIEW_COLUMN_FIXED) but hadn't noticed CellRenderer::set_fixed_size(width, height) or tree-view property "fixed-height-mode". The "fixed-height-mode" is the key for me -- I had been working with gtk2.2 which doesn't have that property. With: TreeViewColumn::set_sizing(TREE_VIEW_COLUMN_FIXED) tree-view property "fixed-height-mode" TreeViewColumn::set_fixed_width() I get dramatic improvements. CellRenderer::set_fixed_size(width, height) doesn't seem to make any difference, once the other three are set. Many thanks, this has really made my day. John It might be faster if it's not having to recalculate sizes all the time. You can set everything to some form of fixed-size mode using: - CellRenderer::set_fixed_size(width, height) - TreeViewColumn::set_sizing(TREE_VIEW_COLUMN_FIXED) - setting the tree-view property "fixed-height-mode" to true This is based on the gtkmm API docs, I haven't actually tried it, or even used gtkmm before. I think that some of this may not be present in older versions of GTK. -- Tim Evans Applied Research Associates NZ http://www.aranz.com/ ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Gtk::TreeView performance
I've been running into similar performance issues with the TreeView, using a liststore containing thousands of rows. For example, with about 40K rows with 10 columns the data loads into the store quickly and then the cpu races for around 30-40 seconds. I think what is going on is the treeview is doing calculations to decide how much space and padding each column needs. I had hoped that having fixed widths would mean no calculations needed to be done, but I still get the same cpu racing. If I watch the treeview carefully while this goes on I see a small shift in the layout of data within each column, moving from left to right (presumably as the code loops through the columns). My suspicion is that the treeview is calculating the layout of the renderers within the the fixed width of each column. I'm guessing if there was an option to stop it doing this (since its initial layout is more than good enough for me) that we would see a dramatic speed improvement. When I get time I was intending to take a look at this, but if there is someone out there more familiar with the treeview code -- that means anyone who has actually looked at it :) then a few pointers would be most welcome. John Igor Gorbounov wrote: Gtk::TreeView performance Hi, All! My application uses a TreeView (using ListStore model) table to present measured data once per second. This table has about 20 rows and about 40 columns. The problem is in consuming too much CPU resources (about 14% when the table is switched on, and near 3% when it is switched off). The cells af this tables display text, and the color of this text foreground and background is changed depending on values in invisible cells. So is there any way to optimize this whole structure? Igor Gorbounov ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Gtk::TreeView performance
Igor Gorbounov wrote: John Gill wrote: [] My suspicion is that the treeview is calculating the layout of the renderers within the the fixed width of each column. I'm guessing if there was an option to stop it doing this (since its initial layout is more than good enough for me) that we would see a dramatic speed improvement. Yes, if it could be possible to freeze the treeview while updating data and only then unfreeze it, then it would be a performance increase, I suppose. Igor Gorbounov I believe this can be done, but doesn't actually help in this case :( Eg gtk faqs advise you to disconnect the model from the view whilst loading the model. Whilst this works around some performance issues, it does not solve the one I described. As soon as the model is re-attached the view seems to scan the new contents to re-calculate its size information. Another option which might work very nicely is only to use the visible rows for size calculations -- this might lead to some jumpiness as you scroll through data, but ought to improve performance dramatically. Yet another option would be to be able to specify a set of rows to be used for sizing purposes, default would be to use the lot. This together with not recalculating all the layout stuff every time the store is changed would probably solve both our problems. John ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: How do i connect C callbacks to Python scripts ?
I'd be inclined to use pygtk for your gui -- this will allow you to have all your code in python (if i understand correctly the only C code you have is the stuff from glade). There is an excellent pygtk faq here: http://www.async.com.br/faq/pygtk/index.py?req=index There is an excellent reference to pygtk here: http://www.pygtk.org/pygtk2reference/ The best (only?) way to work with glade and pygtk is to use libglade to use the glade xml to create a gui directly. All you have to do for that is: class App(object): def __init__(self) import gtk glade='the_xml_file_you_build_with_glade.glade') xml = gtk.glade.XML(glade) xml.signal_autoconnect() gtk.main() and just make your callbacks methods for the App object. The signal_autoconnect thing is smart --- looks for methods which match the ones you defined via glade. You will also find that writing pygtk code directly (and leaving out glade altogether) is very easy once you get going. John saurabh wagh wrote: How do i connect C callbacks to Python scripts ? Hey there... I m a newbie in linux... and am designing an interface for my project ... I ve used Glade for the same and the code generated is in C... I ve got some python scripts which i have to use as callbacks...The callback functions are all in the C code... and I gotta link those to my python script actions... Is there any way i can do that ?? Please reply Saurabh Wagh _ Seized by wanderlust? http://www.msn.co.in/Travel/ Have the best vacation ever. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Submenu inside popup menu problems
I recently encountered what I thought was flaky behaviour with gtk menus, but in the end it turned out to be a feature. What I found was that I was bringint the original menu up with the right mouse button and then selecting a sub-menu entry with the left button. Now it appears that whatever button is passed into the call to gtk_menu_popup() has to be the same one that is used to select an entry from a submenu. Any other button just dismisses the menu. This behaviour can be quite useful once you know it works that way (although for some reason you can use any button to select items from the top-level menu). Anyway, I changed my code to pass in 0 as the button and now I can use any mouse button to select from subitems. I'm guessing you are running into the same issue. John Miroslav Rajcic wrote: Submenu inside popup menu problems I've created popup menu with its submenu using code like below. Submenu is displayed ok, but the problem is no handler functions are called when submenu item gets clicked (all other popup menu items work ok). Can anyone spot the error ? Thanks, Miroslav Rajcic GtkWidget *menu, *submenu; GtkWidget *menu_item, *move_item; int button, event_time; menu = gtk_menu_new (); //add menu items menu_item = gtk_menu_item_new_with_label("Insert Node\tIns"); g_signal_connect(GTK_OBJECT (menu_item), "activate", G_CALLBACK (on_menu_insert_node), NULL); gtk_menu_append(menu, menu_item); gtk_widget_show (menu_item); // Show the widget move_item = gtk_menu_item_new_with_label("Move Node"); gtk_menu_append(menu, move_item); gtk_widget_show (move_item); // Show the widget submenu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_label("Up \tShift+Up"); gtk_menu_append(submenu, menu_item); g_signal_connect(GTK_OBJECT (menu_item), "activate", G_CALLBACK (on_menu_move_up), NULL); gtk_widget_show (menu_item); // Show the widget gtk_menu_item_set_submenu (GTK_MENU_ITEM (move_item), submenu); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, event_time); ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: TreeViewColumn and right-click
Thanks very much for the suggestions. For now I've gone with 2) + I've just submitted a bug request as suggested. http://bugzilla.gnome.org/show_bug.cgi?id=148558 Thanks again for the help, much appreciated. John Suggestions: 1) You can access column-button directly and connect to ::event or ::button-press-event on that. But that is *not* public API and if it breaks in GTK+-2.6 you and your users get both pieces. 2) Do something else in your interface, submit a bug asking for a ::popup-menu signal to be added to GtkTreeViewColumn. I would suggest 2). Regards, Owen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
TreeViewColumn and right-click
I'm using the TreeView and a ListStore to display tables of data. Users often want to sort on a particular column or filter to see a subset of the values in a particular column. The TreeView has excellent support for the former -- I just need to make the column headers clickable and I pretty much get the sorting for free. For the latter I'd like to have it so that right-click on a column label will pop up a simple dialog which allows the user to select which values they want to see. (as an aside, kudos for the latest gtk which has support for a filtered model, very handy for the filtering part). Unfortunately, it seems that the TreeViewColumn code catches all the events on the column headers and suppresses all button events apart from the left click, which gets turned into a 'clicked' event and activates the sorting. Is there any way to get my hands on the other button events on column headers? John ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Win32 modal dialog problem.
I've been having problems with modal dialogs on win32. Specifically, if I have a modal dialog which in turn pops up a modal dialog then I find that the second dialog comes up behind the first dialog -- it gets the focus correctly and is indeed modal, but it is concealed by the original window. Under linux everything works as expected :) I can get the win32 version to work a little better by setting the original window to be non-modal before popping up the second modal dialog. See attached pygtk code for a demonstration of the problem. Is this a bug in the win32 version of gtk or am I doing something wrong? John Test windows modal stuff. import gtk class App(gtk.Window): def __init__(self): gtk.Window.__init__(self) self.set_size_request(400, 250) vbox = gtk.VBox() self.add(vbox) button = gtk.Button('Press Me') button.connect('clicked', self.on_button) vbox.pack_start(button) quit = gtk.Button('Quit') quit.connect('clicked', self.on_quit) vbox.pack_start(quit) self.show_all() self.connect('destroy', gtk.mainquit) self.set_modal(True) def on_quit(self, *args): self.destroy() gtk.mainquit() def on_button(self, *args): NestedDialog(self) class NestedDialog(gtk.Dialog): # Set to false to see buggy behaviour on windows Kludge = True def __init__(self, parent): Dialog to let user chose values to filter. # Initialise Dialog base class gtk.Dialog.__init__( self, 'Filter', parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) self.set_size_request(400, 250) self.vbox.pack_start(gtk.Label('Simple nesting test'), expand=True, fill=True) self.show_all() # Tell parent it is not modal if self.Kludge: pmodal = parent.get_modal() parent.set_modal(False) response = self.run() # Re-set modality of parent if self.Kludge: parent.set_modal(pmodal) self.process_response(response) def process_response(self, response): Process dialog response if response == gtk.RESPONSE_OK: NestedDialog(self) self.destroy() if __name__ == '__main__': import sys sys.path.insert(0, 'E:\work\python') app = App() gtk.main() ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list