Re: [pygtk] Is there a known bug in iter_children?
Johan Dahlin <[EMAIL PROTECTED]>: > tor 2003-03-13 klockan 06.29 skrev Eric S. Raymond: > > Code: > > > > def load_record(self, parent, value): > > "Load a record with a specified value." > > # This conditional works around an apparent bug. > > # iter_children doesn't accept None as a synonym for the root. > > sibling = None > > if parent != None: > > print "Looking at: ", parent > > sibling = self.gtk_model.iter_children(parent) > > while sibling: > > if cmp(self.gtk_model.get_value(sibling, OakumGUI.payload_column), > > value) > 0: > > break > > sibling = self.gtk_model.iter_next(sibling) > > recordlevel = self.gtk_model.insert_before(parent, sibling) > > > > > > Error trace: > > > > Looking at: > > Traceback (most recent call last): > > File "./oakum.py", line 1047, in on_data_field_accept > > self.add_item_post(here) > > File "./oakum.py", line 980, in add_item_post > > newrow = self.load_name(zc,text,dnsrecord) > > File "./oakum.py", line 781, in load_name > > namelevel = self.load_record(zone_cursor, dns_name) > > File "./oakum.py", line 767, in load_record > > sibling = self.gtk_model.iter_children(parent) > > TypeError: parent should be a GtkTreeIter > > Is parent really a GtkTreeIter, are you sure it's not invalidated? > http://doc/gtk/gtk/2.0/gtktreemodel.html#GTK-TREE-MODEL-ITER-CHILDREN I'm not sure. I ended up coding this in a different way that avoided the problem. I can tell you what I *suspect* went wrong -- it looks like throwing iters as the value associated with an exception invalidates them. > If you're using a GtkTreeStore model, there should only be one way of > getting iters invalidated (According to GtkTreeView hacker kris): > > there the iter only gets invalidated when it's poiting to the > last row being removed An iter becomes invalid when its row is removed. OK, that makes sense. Are there any other known circumstances that can invalidate an iter? > > I had previously noted that iter_children doesn't accept a None > > argument as an iter object meaning the model root. > > This could easily be added, so if None is specified the iter is fetch by > calling get_iter_root() That should be fixed, yes. Also, the diagnostic emitted when a function chokes on an invalid but nonzero iterator should *not* be a TypeError -- this is misleading, because actually the type is right but the payload is invalid. It's more like a Python ValueError. I suggest that throwing a value error with a message like "iterator invalid" would be better. -- http://www.catb.org/~esr/";>Eric S. Raymond ___ 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] I can't add a widget to another one
On Sun, Mar 16, 2003 at 07:57:37PM +0100, David Gil wrote: > editor=f.get_widget("DobEditor") > win.add(editor) [...] > Traceback (most recent call last): > File "gladetest1.py", line 10, in ? > win.add(editor) > File "/usr/lib/python2.1/site-packages/gtk.py", line 514, in add > _gtk.gtk_container_add(self._o, child._o) > AtributeError: 'None' object has no attribute '_o' > > Could you please tell me what should I do to insert a widget into the > other one or what should I read to learn how to do it? get_widget() up there is returning None, which is why, when trying to add() it to the window, an exception is raised. The error message is confusing, since it exposes an implementation detail (who cares if widgets have underlying _o attributes). Two problems can be happenning: a) There is no widget named "DobEditor" in your gladefile. b) The GladeXML() parse is failing and you're getting back an empty widget tree (f). Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL ___ 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 2 Tutorial update
Kai Weber wrote: distribution to use as an example in the tutorial. Please let me know if you have suggestions or find errors in the tutorial. I try learning pygtk with your nice tutorial. I have a question regarding the helloworld.py example. What is the reason to connect the "clicked" event on the button directly to the window's destroy function? self.button.connect("clicked", lambda wid,win: win.destroy(), self.window) There is already an defined destroy-callback function which can be used easy self.button.connect("clicked", self.destroy) Or is this just there for learning purposes? Besides that I do not understand your explanation why we need a lambda function there. This illustrates connection to two different types of signal handlers: one user defined, the other a Window method. The button callback passes two args to the callback function but the Window destroy() method only takes one; the lambda function mediates between these. A better way to do this is to use the connect_object() method: self.button.connect("clicked", gtk.Widget.destroy, self.window) which replaces the Button object in the callback with the Window object. Thanks for the feedback Kai. I'll change the tutorial to use the connect_object() method. John ___ 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] I can't add a widget to another one
Hi! I don't know if this is the right place to ask it. If not, please tell me where should I ask. I'm making a program with Glade+pygtk. I attach the Glade file. A piece of the program follows: from gtk import * from libglade import * f= GladeXML("DobEditor.glade", "MainWindow") win=f.get_widget("MainWindow") editor=f.get_widget("DobEditor") win.add(editor) mainloop() As you can see, what I try to do is to insert a widget into another, but python says: Traceback (most recent call last): File "gladetest1.py", line 10, in ? win.add(editor) File "/usr/lib/python2.1/site-packages/gtk.py", line 514, in add _gtk.gtk_container_add(self._o, child._o) AtributeError: 'None' object has no attribute '_o' Could you please tell me what should I do to insert a widget into the other one or what should I read to learn how to do it? Thank you very much! Dàvik DobEditor.glade Description: Binary data ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
GTK+ signals and arguments, was Re: [pygtk] Any way to retrieve thetitle of a dialog?
On Sun, Mar 16, 2003 at 10:19:37AM -0500, Steve McClure wrote: > > >Would anybody find it convenient if I posted a list of all the args for > > >Gtk widgets? I had to fish it out of the source code so it might at > > >least save you trying to write a custom script. > > Which source did you find it in? It's spread all over the GTK+ source code, which makes it quite hard to find if you don't whip up a script. Since it seems that many people don't have such a list, I've compiled one and attached it to FAQ 5.14. I've also added a list of signals for each widget. James comment for GTK+ 2.x is also there. Since the files aren't too long, I'm also attaching them to the message. > > For GTK 2.0, run "help(gtk.Window)" and you will get a list of all the ^^^ > > signals and properties for that class. (It will only work correctly in > > Python >= 2.2.2 though. For previous releases, try "print > > gtk.Window.__gdoc__"). > > print gtk.Window.__gdoc__: AttributeError: Window > print gtk.GtkWindow.__gdoc__: AttributeError: __gdoc__ > print gtk.GtkWindow.__doc__: None Did you miss James' 2.0 statement up there? You *know* gtk doesn't have a Window class in 0.6.x ;) Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL GtkAccelLabel accel_widget GtkAlignment xalign yalign xscale yscale GtkArrow arrow_type shadow_type GtkAspectFrame xalign yalign ratio obey_child GtkBox spacing homogeneous GtkButton label relief GtkCList n_columns shadow_type selection_mode row_height reorderable titles_active use_drag_icons sort_type GtkColorSelection policy use_opacity GtkContainer border_width resize_mode child reallocate_redraws GtkCTree n_columns tree_column indent spacing show_stub line_style expander_style curve_type GtkCurve min_x max_x min_y max_y GtkEditable text_position editable GtkEntry max_length visibility GtkFrame label label_xalign label_yalign shadow GtkHandleBox shadow handle_position snap_edge GtkHScale adjustment GtkHScrollbar adjustment GtkLabel label pattern justify wrap GtkList selection_mode GtkMenuBar shadow GtkMisc xalign yalign xpad ypad GtkNotebook page tab_pos tab_border tab_hborder tab_vborder show_tabs show_border scrollable enable_popup homogeneous GtkObject user_data signal signal_after object_signal object_signal_after GtkPacker spacing default_border_width default_pad_x default_pad_y default_ipad_x default_ipad_y GtkPaned handle_size gutter_size GtkPreview expand GtkProgress activity_mode show_text text_xalign text_yalign GtkProgressBar adjustment orientation bar_style activity_step activity_blocks discrete_blocks GtkRadioButton group GtkRange update_policy GtkRuler lower upper position max_size GtkScale digits draw_value value_pos GtkScrolledWindow hadjustment vadjustment hscrollbar_policy vscrollbar_policy window_placement GtkSpinButton adjustment climb_rate digits snap_to_ticks numeric wrap update_policy shadow_type value GtkTable n_rows n_columns row_spacing column_spacing homogeneous GtkText hadjustment vadjustment line_wrap word_wrap GtkTipsQuery emit_always caller label_inactive label_no_tip GtkToggleButton active draw_indicator GtkToolbar orientation toolbar_style space_size space_style relief GtkViewport hadjustment vadjustment shadow_type GtkVScale adjustment GtkVScrollbar adjustment GtkWidget name parent x y width height visible sensitive app_paintable can_focus has_focus can_default has_default receives_default composite_child style events extension_events GtkWindow type title auto_shrink allow_shrink allow_grow modal window_position default_width default_height GtkAccelgroup add-accelerator ['GTK_TYPE_UINT', 'GTK_TYPE_ACCEL_GROUP', 'GTK_TYPE_UINT', 'GTK_TYPE_GDK_MODIFIER_TYPE', 'GTK_TYPE_ACCEL_FLAGS'] remove-accelerator ['GTK_TYPE_ACCEL_GROUP', 'GTK_TYPE_UINT', 'GTK_TYPE_GDK_MODIFIER_TYPE'] GtkAdjustment changed [] value_changed [] GtkButton pressed [] released [] clicked [] enter [] leave [] GtkCalendar month_changed [] day_selected [] day_selected_double_click [] prev_month [] next_month [] prev_year [] next_year [] GtkCheckmenuitem toggled [] GtkClist
Re: [pygtk] Any way to retrieve the title of a dialog?
On Sat, 2003-03-15 at 14:41, Andreas Kostyrka wrote: > On Wed, Mar 12, 2003 at 06:55:18PM -0500, Steve McClure wrote: > > I need to augment titles, at runtime, of dialogs created with Glade. I > > don't see anything in the API to do a get_title, but there is a > > GtkWindow.title attribute in the GTK docs. I can't even get to > > GtkWindow attributes in my code though, I keep getting attribute errors > > when I do a dialog.window_position where dialog is a GtkDialog instance. > > > > I'm using 0.6.8 > Upgrade to pygtk2: Thanks, but that isn't really an option right now. > [EMAIL PROTECTED]:~$ python > Python 2.2.2 (#1, Jan 18 2003, 10:18:59) > [GCC 3.2.2 20030109 (Debian prerelease)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import pygtk > >>> pygtk.require("2.0") > >>> import gtk > >>> gtk.Window().title > >>> w=gtk.Window() > >>> w.set_title("TEST") > >>> w.title > 'TEST' > > Andreas > > __ > > ___ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ -- Steve McClure <[EMAIL PROTECTED]> Racemi, Inc. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Any way to retrieve the title of a dialog?
On Sat, 2003-03-15 at 21:39, James Henstridge wrote: > Christian Reis wrote: > > >On Wed, Mar 12, 2003 at 06:55:18PM -0500, Steve McClure wrote: > > > > > >>I need to augment titles, at runtime, of dialogs created with Glade. I > >>don't see anything in the API to do a get_title, but there is a > >>GtkWindow.title attribute in the GTK docs. I can't even get to > >>GtkWindow attributes in my code though, I keep getting attribute errors > >>when I do a dialog.window_position where dialog is a GtkDialog instance. > >> > >> > > > >Use window['title']. It's a property. (Added FAQ 10.8) Thanks. > > > >Would anybody find it convenient if I posted a list of all the args for > >Gtk widgets? I had to fish it out of the source code so it might at > >least save you trying to write a custom script. Which source did you find it in? > > > > > For GTK 2.0, run "help(gtk.Window)" and you will get a list of all the > signals and properties for that class. (It will only work correctly in > Python >= 2.2.2 though. For previous releases, try "print > gtk.Window.__gdoc__"). print gtk.Window.__gdoc__: AttributeError: Window print gtk.GtkWindow.__gdoc__: AttributeError: __gdoc__ print gtk.GtkWindow.__doc__: None Thanks again folks, I really appreciate the help. > > James. -- Steve McClure <[EMAIL PROTECTED]> Racemi, Inc. signature.asc Description: This is a digitally signed message part ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] handling mainloop exceptions (by calling a callback)
Hello, I would like to popup a dialog message if an (otherwise) unhandled exception occurs. I've read in an old message (http://www.daa.com.au/pipermail/pygtk/2000-July/000159.html) that someone wrote a patch which calls a callback in case of an error. Is that patch by any chance include in pygtk-1.99.15? Is there another way to handle exceptions in the mainloop? What I know is that setting PYGTK_FATAL_EXCEPTIONS = 1 would probably quit the program in case of a raised exception but how would I handle/catch these excpetions? Any help appreciated on this topic. Cheers, Marc -- The first time Microsoft makes something that doesn't suck is when they start making vacuum cleaners. ___ 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] handling mainloop exceptions (by calling a callback)
Hello, I would like to popup a dialog message if an (otherwise) unhandled exception occurs. I've read in an old message (http://www.daa.com.au/pipermail/pygtk/2000-July/000159.html) that someone wrote a patch which calls a callback in case of an error. Is that patch by any chance include in pygtk-1.99.15? Is there another way to handle exceptions in the mainloop? What I know is that setting PYGTK_FATAL_EXCEPTIONS = 1 would probably quit the program in case of a raised exception but how would I handle/catch these excpetions? Any help appreciated on this topic. Cheers, Marc -- The first time Microsoft makes something that doesn't suck is when they start making vacuum cleaners. ___ 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 2 Tutorial update
> distribution to use as an example in the tutorial. Please let me know if > you have suggestions or find errors in the tutorial. I try learning pygtk with your nice tutorial. I have a question regarding the helloworld.py example. What is the reason to connect the "clicked" event on the button directly to the window's destroy function? self.button.connect("clicked", lambda wid,win: win.destroy(), self.window) There is already an defined destroy-callback function which can be used easy self.button.connect("clicked", self.destroy) Or is this just there for learning purposes? Besides that I do not understand your explanation why we need a lambda function there. Nice tutorial. Helps a lot. *Kai ___ 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] Is there a guide how to program with pygtk?
David M. Cook wrote: On Tue, Dec 21, 2004 at 10:29:17PM -0200, Michel wrote: Hi Guys! I want to program in pygtk but I didn't find a guide, I read the faq and some examples but I want a reference guide... See FAQ item 1.7. Tell me if the pygtk is very unlike tkinter... I used tkinter to make guis and I think it's easy to work, is the pygtk so easy? pygtk is not as easy as tkinter... This is quite subjective :) PyGTK is about as easy as Tkinter for many simple tasks. For many moderate tasks, PyGTK can be a lot easier, as it contains more widgets (which in Tkinter you may need to reimplement). In my opinion, it is also better for difficult tasks :) James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/