[pygtk] gobject.GObject - disconnect v. handler_disconnect?
Is there any difference between GObject.disconnect and GObject.handler_disconnect? The minimal documentation indicates they are identical: http://www.pygtk.org/docs/pygobject/class-gobject.html#method-gobject--handler-disconnect Thx, Skip ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] gobject.timeout_add() won't work after calling gtk.threads_init() on windows xp
Have you tried calling gtk.threads_init() before gobject.timeout_add(...)? On Wed, Jun 26, 2013 at 5:56 AM, Todong Ma wrote: > Hi, everyone > > Following simple code will hang forever on windows XP, and the "check > dialog" text is never outputted to console. The window created in the code > showed but is blocked (when I move mouse into the window area, the mouse > pointer is always a "loading" icon) > > import gtk > import gobject > > def checkDialog(): > print 'check dialog' > return True > > gobject.timeout_add(500, checkDialog) > gtk.threads_init() > w = gtk.Window() > w.show() > gtk.main() > > While same code works well on Windows 7 > > Runtime details: Windows XP SP3, python 2.7.5, pytgtk-2.24-allinone > > > > ___ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] Non-modal dialog?
If I want a dialog to be non-modal, I can't use its run() method, is that true? I have a dialog which is defined in Glade to be non-modal, but calling its run() method sure makes it seem modal to me. Thx, Skip ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Confused about a widget's name
> In a signal callback for a radio button, if I ask for its name > (rb.get_name()) I always get "GtkRadioButton". If I call get_property > with "name" as the argument, I get the empty string. Looking at the > docs for gtk.Builder, I saw this: > > "Objects must be given a name with the "id" attribute, which allows > the application to retrieve them from the builder with get_object(). > An id is also necessary to use the object as property value in other > parts of the UI definition. > > Note: Prior to GTK+ 2.20, gtk.Builder was setting the "name" property > of constructed widgets to the "id" attribute. In GTK+ 2.20 or newer, > you have to use gtk.Buildable.get_name() instead of > gtk.Widget.get_name() to obtain the "id", or set the "name" property > in your UI definition." I am going to answer my own question and report a documentation bug. The gtk.Buildable.get_name() function takes a widget as an argument, but the documentation omits that fact. See: http://www.pygtk.org/docs/pygtk/class-gtkbuildable.html#method-gtkbuildable--set-name More generally, shouldn't the widget's name property be populated by the builder? This change seems like it would cause a lot of needless breakage to existing code ported from libglade to the builder stuff. Skip ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] Confused about a widget's name
I'm returning to PyGTK programming after a long hiatus. When last I visited these waters, I used Gtk 2.12. Now I use 2.22 and this Builder thing, which, I must admit, has me a bit confused. In a signal callback for a radio button, if I ask for its name (rb.get_name()) I always get "GtkRadioButton". If I call get_property with "name" as the argument, I get the empty string. Looking at the docs for gtk.Builder, I saw this: "Objects must be given a name with the "id" attribute, which allows the application to retrieve them from the builder with get_object(). An id is also necessary to use the object as property value in other parts of the UI definition. Note: Prior to GTK+ 2.20, gtk.Builder was setting the "name" property of constructed widgets to the "id" attribute. In GTK+ 2.20 or newer, you have to use gtk.Buildable.get_name() instead of gtk.Widget.get_name() to obtain the "id", or set the "name" property in your UI definition." I can't tell what object gtk.Buildable is supposed to refer to. I have a reference to a widget (in this case, a radio button, but I think the problem is more general than that). How do I retrieve the name I gave it in Glade? Thx, Skip Montanaro ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
[pygtk] gobject.type_register for class hierarchy?
Suppose I have this sort of class relationship: class A(gobject.GObject): def __init__(self): gobject.GObject.__init__(self) ... class B(A): ... A is abstract. Do I need to call gobject.type_register for just A, just B or both? Thanks, -- Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/ "The hippies and the hipsters did some great stuff in the sixties, but the geeks pulled their weight too." -- Billy Bragg ___ 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 use a Tkinter widget inside a PyGtk HMI?
Sebastien> I would like to know if there is a method for using a Tkinter Sebastien> widget inside a PyGtk or wxPython interface. If you're willing to use two separate processes perhaps you can use the gtk.Socket and/or gtk.Plug widgets: http://www.pygtk.org/pygtk2reference/class-gtkplug.html http://www.pygtk.org/pygtk2reference/class-gtksocket.html Here's an example from the PyGtk docs: http://www.pygtk.org/pygtk2tutorial/sec-PlugsAndSockets.html Skip ___ 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] Application responsiveness problem
László> I want to make my application very responsive under high load. ... László> As you can see, I want to pulse a progress bar while a long László> (computationally or I/O intensive) operation is running. I László> started a separate thread for it. I could be wrong (never used threads with gtk), but don't you have some sort of gtk thread initialization function(s) to call? See if something in section 20 of the PyGTK FAQ leads to a solution: http://www.async.com.br/faq/pygtk/index.py?req=index -- Skip Montanaro [EMAIL PROTECTED] ___ 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] I must be missing something - can't get label of a menu item
Christian> One alternative which I use daily is, instead of relying on Christian> the label, doing a set_data() on the menuitems as you put Christian> them into the menu, and then using get_data() to grab it Christian> back. I suppose I can figure it out, but is that an option from a Glade-generated interface? I am not at work so don't have Glade available to try at the moment. Thx, Skip ___ 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] pango markup not working
Chris> you need to add the the text with set_markup not set_text. The Chris> use markup option, in glade only effects the value you give the Chris> label in glade. Muchas gracias, señor. That did the trick. Skip ___ 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] pango markup not working
In glade-2 I defined several labels with the use_markup attribute set to True. In my app I give them values like 12345 None of that markup is converted. It's just displayed as given. Do I need to do more than call the set_text() method of the label widget with the markup text? Thx, -- Skip Montanaro [EMAIL PROTECTED] http://www.mojam.com/ ___ 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] making selected row visible in FileChooser?
Skip> Sure, it's selected, but as far as I can tell the chooser isn't Skip> scrolled if necessary to make the selected file visible. John> Seems to work OK with GTK+ 2.5.4 and GTK+ 2.4.13 and a quick check John> shows this bug: John> http://bugzilla.gnome.org/show_bug.cgi?id=143868 Thanks. I think we are currently stuck at Gtk 2.4.4. I'm not the guy who builds it, but my understanding is that in our environment (Solaris/Intel) there are some problems building more recent versions, at least with Sun's X server software. I'll have to see about prodding the powers-that-be to skip ahead a few more micro versions. Skip ___ 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] making selected row visible in FileChooser?
Tom> With open dialogs, the correct file is selected (I believe -- I'm Tom> not sure I've actually had reason to implement this). Sure, it's selected, but as far as I can tell the chooser isn't scrolled if necessary to make the selected file visible. Skip ___ 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] making selected row visible in FileChooser?
Johan> Have you tried select_filename() ? Yeah. Didn't help as far as I could tell. Skip ___ 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] making selected row visible in FileChooser?
Switching over to the new FileChooser I noticed that if I called set_filename() the indicated file was selected but would not necessarily be visible. Is there a sanctioned way to make it visible? I saw nothing in the FAQ related to the FileChooser, nor did a straightforward Google search pan out. Thx, -- Skip Montanaro [EMAIL PROTECTED] http://www.mojam.com/ ___ 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] how to map modifier keys to bits in modifier masks?
In the docs for gtk.gdk.Event the description of MOD1_MASK reads: gtk.gdk.MOD1_MASK The fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key). How do I determine the mapping at run-time (without human intervention)? I wrote a trivial PyGTK script that picks apart and prints the modifier mask for various events, but I can't have each user run that and build a little database for me. On my particular setup (Solaris Intel running Xi Graphics X server v. 11) NumLock is actually MOD2 while Left Alt is MOD4 and Right Alt appears to be unassigned. Other people here at work run various other combinations of OS and X server software, so there is likely to be some variation. Thanks, -- Skip Montanaro [EMAIL PROTECTED] http://www.mojam.com/ ___ 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] output > gtk.TextView
Marcus> I want to execute some shell commands in my python script. The Marcus> output should be redirected to a gtk.TextView in real-time. How Marcus> can I do this? Use os.popen or one of its cousins, capture the output via reads on the file object returned, then stuff it into the TextBuffer associated with your TextView widget. -- Skip Montanaro [EMAIL PROTECTED] http://www.mojam.com/ ___ 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 must be missing something - can't get label of a menu item
>> I can then march through that [optionmenu] to find the active item, >> but can't find a label property or something similar from which I can >> extract the text. Johan> That's FAQ 16.6: Johan> http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq16.006.htp Johan> The FAQ contains all sorts of gory GtkOptionMenu details. Thanks. I should know better that to just rely on the regular docs. (Still, perhaps this property of OptionMenus should get a bit of elaboration in the documentation.) Johan> Note, if you can require 2.4.0 or higher, please consider Johan> switching to GtkComboBox. Thanks, not quite an "option" at this point. Skip ___ 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 must be missing something - can't get label of a menu item
I have an option menu full of radio menu items defined via Glade. At runtime I'd like to get a string value out of the menu which corresponds to the selected item. The displayed label would be fine (I'll force it to be unique) but I can't figure out how to get at it. I'm trying to avoid enumerating all the menu item objects in my code (e.g. wtree.get_widget("menu-item-N")), preferring instead to leave all those definitions to the glade user. I did get a handle on one item from which I called get_group() to get all the items in the group. I can then march through that to find the active item, but can't find a label property or something similar from which I can extract the text. I've tried item.get_children(), item.get_child(), item.get_property("child") and item.forall(). Nothing yields a label widget. Any clues would be gratefully appreciated. Thx, -- Skip Montanaro [EMAIL PROTECTED] http://www.mojam.com/ ___ 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] Paned widget w/ > 2 panes or Box widget w/ resizers?
I have a UI component laid out as an HBox with three slots. I have a request from a user to be able to resize each slot separately. The HPaned widget would be ideal, except it only takes two children. Is there such a thing as a Paned widget that supports more than two children or a Box widget that allows independent resizing of its children? As a workaround I could nest one HPaned widget inside another, but that doesn't provide for complete independence of the box sizes. Thx, -- Skip Montanaro Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] CList
Christian> You should also grab an updated version of GTK+ -- that's Christian> where the important Treeview speedups would happen, not Christian> inside PyGTK. I made the comment a day or two ago that I find Treeview overkill for simple lists and use a Table instead. I also find Treeview slow (we're still using GTK 2.2). I subclassed the Table widget in Python to operate in a more Pythonic way (address cells using indexing, for example). It also winds up for my application being about 2-3x faster to refresh than using Treeview. I'll see about releasing it so others can use it/poke at it. -- Skip Montanaro Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] listviews
Keir> im trying to use a list view to show a simple two-collumed list, Keir> how ever im finding it extremly difficult to perform this simple Keir> task, throughout the documentation i cannot find a fully worked Keir> example of a listveiw, only a treeview, could someone point me at Keir> an example of give me one please. FWIW, I prefer to use Tables for these simple cases. They are much easier to use. -- Skip Montanaro Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Problem incorporating Python-subclassed widget into Glade
I subclassed gtk.Table, then started trying to integrate it with Glade-2. I realized I needed to set __gproperties__ to add a property to the class, so I added that: __gproperties__ = { 'use_checkboxes' : (gobject.TYPE_BOOLEAN, # type 'use checkboxes for Booleans', # nick name 'use checkboxes for Booleans', # description True, # default value gobject.PARAM_READWRITE|gobject.PARAM_CONSTRUCT # flags ) } I also changed my superclass init call from gtk.GtkTable.__init__(self, rows, cols) to gobject.__gobject_init__() self.set_property("n-rows", rows) self.set_property("n-columns", cols) I have other instance attributes as well: self.widgets = {} self.values = {} self.formats = {} self.default_format = "%s" I will eventually change default_format to a property. If I instantiate my Table widget from Python, it seems to work fine. When it's instantiated via Glade its __init__ method doesn't appear to be called though. A print statement placed in Table.__init__() is not executed, and Python denies that my class has a widgets attribute. I incorporated the class into Glade by adding a regular GtkTable where I wanted my Table, then using the output of print gobject.type_name(Table) I substituted that for "GtkTable" in my Glade file: True 1 6 False 0 0 I must be missing something, but I'm not sure what. Any ideas? Thx, -- Skip Montanaro Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] cleaner module reload?
>> gobject.type_register(foo) >> >> at the module level to register gobject.GObject subclasses. To >> support module reloading I wrap it: Gustavo> No needed for any of these hacks. Since pygtk 2.3.92, pygtk Gustavo> allows registering the same python class with the type system Gustavo> as many times as you like, so module reloading should Just Gustavo> Work. Thanks, but we're far away from that (2.2.0 according to gtk.pygtk_version). Skip ___ 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] cleaner module reload?
>> try: >> gobject.type_register(foo) >> except RuntimeError: >> pass >> >> This works but seems "unclean". (I've been using Python for ten >> years or Johan> I'm not I can see why raising a RuntimeError from a library like Johan> PyGTK is considered unclean. Like I said, I've been using Python for about ten years and never needed to catch RuntimeError. I've just never seen it used in a situation where you might want to recover. We're dealing with types and values. I would expect a TypeError (type that's already registered) or ValueError (a "value" of gobject.GObject that's already registered) to be raised here. Johan> When are RuntimeError exceptions supposed to be raised? Rarely, if ever, in my experience. The libref doc states: Raised when an error is detected that doesn't fall in any of the other categories. There are so many builtin exceptions that RuntimeError just doesn't get used. It's rare that something else doesn't work. If nothing builtin works, the usual route is to define a custom exception of some sort, often as a subclass of Exception, but sometimes as a subclass of another builtin exception. class TypeRegistrationError(TypeError): pass >> if not gobject.is_registered(foo): >> gobject.type_register(foo) Johan> gobject.type_register sets the __gtype__ variable in the class Johan> when it's registered, so this should do it: Johan> if not foo.__dict__['__gtype__']: Johan> ... Johan> but that's even uglier, so what about using g_type_name and it's Johan> python wrapper? Yes, but this is cleaner: if not hasattr(foo, "__gtype__"): gobject.type_register(foo) Johan> if gobject.type_name(foo) != 'GObject': Johan> ... Johan> Seems to work, but it's still not the nicest way to check this, so you Johan> can check if the name is registered: Johan> if not gobject.type_from_name('__main__+foo'): Johan> ... I think hasattr() is the way to go. Thanks for the hint that attributes were added to the class as a side-effect of type registration. While we're discussing adding attributes during type registration, I did notice that __gsignals__ is also removed as a side-effect of type registration. This is a shame, because it's lost as a nice indicator of the signals that are defined by this class. I'm sure there's some way to introspect this, but it's not something that (for example) pydoc could use. It took me awhile to realize pydoc wasn't broken when I tried running it on one of my GObject subclasses. I couldn't figure one why it didn't tell me about __gsignals__. (I should have noticed the addition of __gtype__ there as well.) Skip ___ 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] cleaner module reload?
I use gobject.type_register(foo) at the module level to register gobject.GObject subclasses. To support module reloading I wrap it: try: gobject.type_register(foo) except RuntimeError: pass This works but seems "unclean". (I've been using Python for ten years or so, and I think this is the first occasion I've had to catch a RuntimeError exception.) I didn't see any obvious way to ask "has the foo class been registered?" All the various gobject functions that take a type/class seem to raise exceptions of one sort or another if foo isn't a PyGTK type. I suppose I should let it go at that, but I was hoping for something like: if not gobject.is_registered(foo): gobject.type_register(foo) Thx, -- Skip Montanaro Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] repetitive get_widget() using Glade?
John> Connect to the 'delete_event' signal on the window. Return False John> if you want the default handler to destroy the window and True to John> indicate that you've handled the event and the default handler John> should not be invoked. Thanks a million. Worked like a charm... Skip ___ 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] repetitive get_widget() using Glade?
>> How do I convince Glade to create new Window and TextView widgets on >> subsequent calls to get_widget()? Johan> Two possible solutions: Johan> 1) Don't destroy the window, just hide it. But when the user pokes the "x" won't the underlying X windows be destroyed? Is there a way to catch the destroy signal and avoid the window destruction? I'd happily just hide the window, but that doesn't seem to work either. Johan> 2) Call glade.XML again to reparse (and recreate all widgets) Sounds expensive. :-( Thanks for the ideas... Skip ___ 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] repetitive get_widget() using Glade?
I have a simple popup window that contains a TextView widget. The TV is tied to a Python interpreter (code.InteractiveConsole). The window and TV are defined in Glade. Works great the first time I ask to display it. If I poke the "X" button in the window's title bar to destroy it I delete my objects (the corresponding X windows are going away, after all) in my destroy event handler. I want to create a new instance the next time I select "Interpreter Window" from my debug menu. Unfortunately, when I call .get_widget(...) a second time it returns None instead of a new TextView or Window. How do I convince Glade to create new Window and TextView widgets on subsequent calls to get_widget()? Thx, -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] creating signals outside __init__()?
Gustavo> The code above should work (at least used to work for me), Gustavo> except that you need to call gobject.type_register(SomeClass) Gustavo> right after the class definition. Thanks, I'll give that a whirl. Skip ___ 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] creating signals outside __init__()?
Code that predates my presence on the current project I work on is littered with stuff like this: class SomeClass(gobject.GObject): my_signal = -1 def __init__(self, underlying_symbol): if SomeClass.my_signal < 0: SomeClass.my_signal = gobject.signal_new(...) A couple casual tries on my part to migrate the signal_new() call out of the __init__() method suggested that's not possible (though it's been long enough ago I don't remember the precise error I got). I could have sworn the last time I used PyGTK heavily (a couple years ago) that it was possible to create the signal at the module scope, like so: class SomeClass(gobject.GObject): my_signal = -1 def __init__(self, underlying_symbol): ... SomeClass.my_signal = gobject.signal_new(...) Before I dig deeper into this, am I really stuck waiting to create signals? Thx, -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] GtkDial widget (where is pygtk wrapper or port)?
Randy> Thanks Steve. I've located the C source for (pre-Gtk2.0 version Randy> of) GtkDial, but have not found the PyGtk wrapper. I would like Randy> to get the wrapper (Python/C source?), so I would at least have a Randy> chance of porting the widget to recent versions of Gtk/PyGtk in Randy> the future (and provide hope to my client that analog gauges are Randy> in the works). Any idea where I can find the PyGtk wrapper, even Randy> though it won't work with Gtk2.0? You might try downloading a pre-gtk-2.0 version of PyGTK and checking to see if it's in there. For the most part the current PyGTK wrappers are generated from some lisp-y interface definitions. Take a look at gtk/gtk.defs. For things the .defs files can't handle, you can write a .override file. Look at gtk/gtkwidget.override for an example. I don't recall if the pre-2.0 stuff used the .defs/.override files. If so, you should be able to modify them slightly. If not, they aren't that tough to write. I'd look at the .def file for a functionally similar widget, such as GtkProgressBar or GtkScale. -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] no signals when paned handles dragged...
>> I discovered that some widgets only emit signals when values are >> changed via keyboard action, not mouse action. Christian> It *really* looks like a bug to me, but I'm surprised the Christian> SpinButton would have the same issue. Are you sure this is Christian> reproducible using a simple testcase? I'm just going by the docs... Quoting from http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtkpaned.html we find: The "move-handle" signal is emitted when paned has the focus and one of the following key combinations is pressed to move the separator: Left Arrow Right Arrow Up Arrow Down Arrow Page Up Page Down Home End Quoting from http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtkspinbutton.html we find: The "change-value" signal is emitted when the spinbutton value is changed by keyboard action using the Up Arrow, Down Arrow, Page Up, Page Down, Control+Page Up or Control+Page Down keys. The SpinButton isn't such a problem because (I think) the value-changed signal is emitted even if the change-value signal is emitted. Skip ___ 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] no signals when paned handles dragged...
I realize this is a gtk question, not a pygtk question. The state of the internet's email infrastructure often makes it nearly impossible to post the occasional message to the most appropriate list though. (Most lists allow posts from subscribers only these days.) I went looking for the GTK FAQ, but it appears to be completely empty at the moment. I was hoping for a little "philosophy" lesson. Working with Thomas Hinkle's WidgetSaver module some more I discovered that some widgets only emit signals when values are changed via keyboard action, not mouse action. For instance, the paned widget only emits a move-handle signal when the separator is moved using a handful of keys (page up, etc). It's not emitted when the separator is dragged with the mouse. It's not at all obvious to me why the signal should be emitted in one case but not the other. I think the SpinButton has a similar trait. Is there some logical reason why this stuff is done the way it is or is it just a case of "nobody ever needed it"? Thx, -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Modification to WidgetSaver.py
I like the concept behind the WidgetSaver script Thomas Hinkle posted the other day. We're a Glade shop though, so I fear that adding the boilerplate necessary to hook up each widget of interest to the WidgetSaver would cause a small revolt among the developers. At the very least they'd avoid using it for more than toy applications. So I modified it slightly. ;-) I added a GladeSaverManager class that knows how to set up widget saving for a number of widget classes. The full test program is now if gtk.gtk_version < (2, 4): print >> sys.stderr, "Need gtk >= 2.4 for this demo (uses gtk.Expander)." sys.exit(1) wtree = gtk.glade.XML("widgetsaver-2.4.glade", 'widgetsaver') saver = GladeSaverManager(wtree, ["widgetsaver", "pane", "expander", "check", "tog", "spin", "quit"], "widgetsaver") quit = wtree.get_widget("quit") quit.connect('clicked', saver.exit) gtk.main() sys.exit(0) Full details here: http://www.musi-cal.com/~skip/python/WidgetSaver.py http://www.musi-cal.com/~skip/python/widgetsaver-2.4.glade Feedback is certainly welcome. This is the only "application" I've tried this with so far. I don't think I got the split in functionality between the saver and the main program right. In particular, having the saver also handle exiting the app seems a bit suspicious. Still, if we decide to use it (I'm still investigating the concept) it will save a lot of code duplication and the corresponding potential for errors. -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] user-controllable treeview column suppression
Steve> Kiwi has a nice way of doing it. Its CList object has a popup Steve> menu on the right click where the user can decide which columns Steve> to display. Thanks for the pointer. I installed it but importing Kiwi failed with an ImportError (no module named libglade). We import glade here as gtk.glade. I don't know if that means we're weird or that PyGTK has changed since Kiwi was last released. Skip ___ 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] user-controllable treeview column suppression
>> Is it possible to give users the ability to suppress display of >> certain columns of a treeview? John> Should be able to using gtk.TreeViewColumn.set_visible(): John> http://www.pygtk.org/pygtk2reference/class-gtktreeviewcolumn.html#method-gtktreeviewcolumn--set-visible Thanks. I guess I was really wondering if any sort of point-n-click functionality is exposed to the user by default. I guess I'll have to create some sort of preferences dialog so the user can select which columns to view. Skip ___ 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] user-controllable treeview column suppression
Is it possible to give users the ability to suppress display of certain columns of a treeview? Perhaps I should be using a table widget instead. (Treeview widgets seem way too complex for fairly simple use, which I suspect is what they are used for 90% of the time.) Thx, -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] PyGTK in the standard Library
>> 1- PyGTK wraps GTK+ for Python. Which life-cycle do we follow, GTK's >> or Python's? Matt> Both this point and the one below are best answered by the library Matt> developers, if they are in favour of the idea of course :^) (I Matt> should make it clear I _use_ pyGTK, I'm not a developer) although Matt> to me following the GTK lifecycle then the python 'standard' Matt> version being the stable version at the time of the python release Matt> would make sense... GTK and PyGTK release cycles seem to be much Matt> faster than pythons I haven't used PyGTK enough to know, but is the GTK community's stance on breakage similar to that in the Python community? If not, simply shipping with "the stable version" of PyGTK when Python is released may cause more perceived Python breakage than that community normally expects. Skip ___ 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 in the standard Library
Matt> There have been several discussions on the list in the last few Matt> months about trying to get PyGTK into the standard library, ... Matt> there where however a few buts... Matt> 1. Documentation - ... Matt> 2. Windows - ... Matt> 3.Idle - ... 4. Mac OSX - Is GTK available on Mac OSX without X11? Tkinter does have the advantage that TkAqua is available for non-X environments. -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Refreshing windows
Joe> I have a function that refreshes the content of window (it goes and Joe> grabs some xml data and then updates the window based on that Joe> data). Joe> How can I have this function be called every, say, one second? Check out gtk.timeout_add()/gobject.timeout_add(): http://www.moeraki.com/pygtkreference/pygtk2reference/gobject-functions.html -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] How do I exit?
I wrote: Except it's not working in the context of the larger application... :-( It was just a typo. I'm in business now. Thanks, Skip ___ 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 do I exit?
Skip> Signals... ack! pfft! Thanks for the reminder to check the FAQ, Skip> but I like the solution I posted better. Except it's not working in the context of the larger application... :-( Skip ___ 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 do I exit?
Jan> Or simply take a look at the FAQ: Jan> http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.003.htp Signals... ack! pfft! Thanks for the reminder to check the FAQ, but I like the solution I posted better. Skip ___ 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 do I exit?
>> Why doesn't it exit if I hit Ctl-C? It just sits there. I have to >> hit Ctl-Z then kill %1. My glib_version is (2, 2, 2). I'm running >> on Solaris 9 should that make a difference. ... Johan> So, use gtk.main() or file a bug against GMainLoop.main() Maybe Johan> just installing a timeout handler, say every 100 ms could be Johan> enough YMMV. We have non-GUI applications which I am led to believe shouldn't use gtk.main(). I tried writing a timeout handler: import gobject main_loop = gobject.MainLoop() def timeout(*args): print args try: pass except KeyboardInterrupt: main_loop.quit() sys.exit() return True gobject.timeout_add(100, timeout, priority=100) main_loop.run() but though it gets called frequently it never sees a KeyboardInterrupt. Does gtk/gobject swallow that? I modified my script to call gtk.main() and to raise something other than KeyboardInterrupt or SystemExit: import gobject, gtk main_loop = gobject.MainLoop() i = 0 def timeout(*args): global i i += 1 if i >= 20: 1/0 return True gobject.timeout_add(100, timeout, priority=100) try: gtk.main() except: print "!" A traceback is displayed about the ZeroDivisionError instead of the app printing "!". I don't see that until I later terminate the app with C-c. A bit more fiddling led to this slight extra complication using sys.except_hook without relying on gtk: import sys import traceback import gobject main_loop = gobject.MainLoop() i = 0 def timeout(*args): global i i += 1 if i >= 50: 1/0 return True def exc_handler(exc, val, tb): if exc != KeyboardInterrupt: traceback.print_exception(exc, val, tb) sys.exit() sys.excepthook = exc_handler gobject.timeout_add(100, timeout, priority=100) main_loop.run() In fact, reducing timeout() to def timeout(): return True seems sufficient. Thanks for the suggestions. -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] How do I exit?
Here's a trivial gobject program: import gobject main_loop = gobject.MainLoop() try: main_loop.run() except KeyboardInterrupt: main_loop.quit() Why doesn't it exit if I hit Ctl-C? It just sits there. I have to hit Ctl-Z then kill %1. My glib_version is (2, 2, 2). I'm running on Solaris 9 should that make a difference. Thanks, -- Skip Montanaro Got gigs? http://www.musi-cal.com/submit.html Got spam? http://www.spambayes.org/ [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Gtk/PyGTK on Solaris/Intel
I'm returning to GTK and PyGTK after an absence of a couple years. Unfortunately, my work platform has since morphed into Solaris/Intel (not a real mainstream environment). I am currently running * Python from CVS * glib 2.2.0 * atk 1.2.4 * pango 1.2.5 * gtk 2.2.4 * pygtk 2.0.0 If I create a trivial module which contains this single line: import gtk then run pychecker over it, Python gets a segmentation violation. I whittled that down to >>> import gtk >>> gtk.CList.__gdoc__ Program received signal SIGSEGV, Segmentation fault. 0xdd88f724 in strlen () from /usr/lib/libc.so.1 (gdb) bt #0 0xdd88f724 in strlen () from /usr/lib/libc.so.1 #1 0xdd8c87db in _doprnt () from /usr/lib/libc.so.1 #2 0xdd8cb825 in vsnprintf () from /usr/lib/libc.so.1 #3 0xdd5957b2 in g_printf_string_upper_bound (format=0xdd64dd95 "%s\n", args=0x8045f98 "") at gmessages.c:891 #4 0xdd59d7f9 in g_strdup_vprintf (format=0xdd64dd95 "%s\n", args1=0x8045f98 "") at gstrfuncs.c:199 #5 0xdd5a0eaf in g_string_append_printf_internal (string=0x8252368, fmt=0xdd64dd95 "%s\n", args=0x8045f98 "") at gstring.c:745 #6 0xdd5a0f19 in g_string_append_printf (string=0x8252368, fmt=0xdd64dd95 "%s\n") at gstring.c:772 #7 0xdd648ed3 in object_doc_descr_get (self=0x818a3b8, obj=0x0, type=0xdd4638a0) at pygtype.c:1010 #8 0x0808dad5 in type_getattro (type=0xdd4638a0, name=0x81e69e0) at ../Objects/typeobject.c:2045 #9 0x0807ee4f in PyObject_GetAttr (v=0xdd4638a0, name=0x81e69e0) at ../Objects/object.c:1063 #10 0x080aad72 in eval_frame (f=0x82019c4) at ../Python/ceval.c:1930 #11 0x080abce8 in PyEval_EvalCodeEx (co=0x81e35e0, globals=0x816679c, locals=0x816679c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2678 #12 0x080ae526 in PyEval_EvalCode (co=0x81e35e0, globals=0x816679c, locals=0x816679c) at ../Python/ceval.c:562 #13 0x080d958d in run_node (n=0x814f608, filename=0x8100d8c "", globals=0x816679c, locals=0x816679c, flags=0x8046288) at ../Python/pythonrun.c:1255 #14 0x080d8b1a in PyRun_InteractiveOneFlags (fp=0x814dbc0, filename=0x8100d8c "", flags=0x8046288) at ../Python/pythonrun.c:752 #15 0x080d8917 in PyRun_InteractiveLoopFlags (fp=0x814dbc0, filename=0x8100d8c "", flags=0x8046288) at ../Python/pythonrun.c:685 #16 0x080d9de5 in PyRun_AnyFileExFlags (fp=0x814dbc0, filename=0x8100d8c "", closeit=0, flags=0x8046288) at ../Python/pythonrun.c:648 #17 0x0805cba8 in Py_Main (argc=0, argv=0x80462e8) at ../Modules/main.c:413 #18 0x0805c747 in main (argc=1, argv=0x80462e8) at ../Modules/python.c:23 Just a wild-ass guess, but I sort of suspect whatever represents CList's __gdoc__ attribute is NULL. Adding a couple lines to pychecker to avoid trying to eval an object's __gdoc__ attribute seems to avoid the problem. Has anyone else encountered (and hopefully fixed) this problem? Thanks, Skip Montanaro [EMAIL PROTECTED] ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] Re: gtk radio button
balu> I am new to py-gtk. How do I get which one of the radio buttons balu> are selected in a particular group? Off the top of my head, I'm not sure. I haven't actually used PyGtk in over a year. You'll be better off asking on the pygtk mailing list, to which I've cc'd this note. -- Skip Montanaro - [EMAIL PROTECTED] http://www.mojam.com/ http://www.musi-cal.com/ ___ 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] FAQ work.
Shandy> What software do you use to create the FAQ? I'd be interested Shandy> in adding a stylesheet... Christian> It's called faqwiz.py, included with python distributions. I Christian> dont know how customizable it is, ... The prologue and epilogue for the HTML are contained in faqconf.py. The prologue should be easy enough to modify. A bit more difficult (though still pretty easy) will be modifying the code in faqwiz.py itself to use the style sheets. If you have a Python distribution look in Tools.faqwiz. If not, you can pick up copies from the CVS repository: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Tools/faqwiz/ Christian> By the way, I wrote a script to move faqs from one section to Christian> the other if anybody wants one. I would submit a patch to the Python SourceForge repository. I think this would be welcome. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] PyGTK Faq
>> I think having a 1.2 vs. 1.3 section might be a good idea as well. Christian> Fine by me, but since we don't have subsections, how do you Christian> propose we separate the "namespaces" since we have widgets Christian> with the same name in 1.2 and 1.3? I was thinking more about general 1.2 v. 1.3 questions, like which widgets disappeared, which are new, how has the build process changed, ... Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] PyGTK Faq
Christian> Sounds reasonable. Would you (anybody, really) have a Christian> suggestion of sections for us? Right now I have: Christian> 1. General Information and Availability Christian> 2. Widget Issues Christian> 3. Themes and Styles Christian> 4. Signal handling Christian> 5. Miscellaneous Christian> I understand that Widget Issues is pretty bad naming (I was Christian> aware at the time) but I wanted to get started and these Christian> things (naming..) hamper work. But now I think I am prepared Christian> to change it sooner than later. So what should I do? Christian> a) have a section for each widget? Christian> b) have a section for groups of widgets? Christian> c) have one big section like i do now? I'd go with b, perhaps patterning it after the section breakdown in the Gtk ref manual table of contents. I think having a 1.2 vs. 1.3 section might be a good idea as well. If nothing else, it might get people to realize the API has changed significantly. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] PyGTK Faq
>> Where is the faq ... Christian> I'm working on one in my spare time (which is why it is still Christian> so short) at http://www.async.com.br/faq/pygtk/ Christian, One thing that might help to generate more input and to lessen your load is to add questions without answers when you realize they are faqs (should be a lot lower effort on your part than trying to come up with answers as well). Every now and again (monthly?) post a list of what questions lack answers. I'd be willing to help. Send me the password when you think of it. One thing that's worth noting about the FAQ wizard is that it's relatively difficult to reorganize things if a section grows too large, so it helps to have a reasonable structure set up before questions start flowing in. Otherwise everything will wind up in one section. (Witness the Python FAQ.) Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] newbie - basic question
(Also looks like gtk.override needs updating.) Make that gtk.defs... -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] newbie - basic question
Tomasz> gtk_item_factory_dump_rc() I went looking for this thinking I might add a manual wrapper to gtk.override, but couldn't find it in the Gtk header files and only found a passing comment to GtkPatternSpec in a Gtk header file: localhost:gtk+.cvs% find . -name '*.h' | xargs egrep GtkPatternSpec ./gtk/gtkenums.h:/* GtkPatternSpec match types */ localhost:gtk+.cvs% find . -name '*.h' | xargs egrep dump_rc localhost:gtk+.cvs% Looks like whatever functionality this function provides in Gtk 1.2 is implemented somehow else in 1.3. (Also looks like gtk.override needs updating.) -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] newbie - basic question
Tomasz> I'm new to pyGtk (not to Gtk) and I've got one question. Is it Tomasz> possible to call following functions thru PyGtk bindings ? Tomasz> gtk_item_factory_dump_rc() Tomasz> gdk_window_get_root_origin() For the first, no. The PyGtk wrapper generator doesn't know anything about the GtkPatternSpec* type, so it doesn't currently wrap that function. The second is available once the widget has a window. If w is a realized widget, w.window.get_root_origin() should work. -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GtkSpinButton question
Steve> I wan't to use a GtkSpinButton to display the port of a service Steve> but I want to display the text for know services. e.g. if 79 is Steve> displayed and they increment, display 'http' instead of 80. This isn't quite what you're looking for, but I was able to create a slider that displayed a list of strings instead of numbers. The trick there is to define a handler for the "format-value" signal. In your case, instead of simply displaying a number, you'd look it up in a dict that maps port numbers to service names and display the service name when found: import gtk class PortScale(gtk.HScale): def __init__(self, min, max): adj = gtk.Adjustment(min, min, max, 1.0, 1.0, 0.0) gtk.HScale.__init__(self, adj) self.protocol_map = { 21: "ftp", 23: "telnet", 25: "smtp", 80: "http", # etc - probably should parse /etc/services } self.set_digits(1) self.connect("format-value", self.get_label) def get_label(self, slider, val): val = int(val) return self.protocol_map.get(val, val) w = gtk.Window() w.set_title("port slider") w.connect("destroy", gtk.mainquit) s = PortScale(21, 80) s.set_size_request(150, -1) w.add(s) w.show_all() gtk.mainloop() HTH... -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
Marco> You may also like the tools explained in this article: Marco> http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html Marco> It is about the LazyPython and pythonstartup.py tools that , Marco> among other things, provides autocompletion , like bash: Thanks, yes, I use rlcompleter and readline. They helpful when you know the prefix of the thing you want, but less so when you don't, e.g.: >>> dirpat(gtk, "(?i)right") ['ARROW_RIGHT', 'CORNER_BOTTOM_RIGHT', 'CORNER_TOP_RIGHT', 'DIRECTION_RIGHT', 'DIR_RIGHT', 'JUSTIFY_RIGHT', 'LEFT_RIGHT', 'POS_RIGHT', 'PROGRESS_LEFT_TO_RIGHT', 'PROGRESS_RIGHT_TO_LEFT', 'SCROLL_PAGE_RIGHT', 'SCROLL_STEP_RIGHT', 'SIDE_RIGHT', 'STOCK_JUSTIFY_RIGHT', 'TEXT_WINDOW_RIGHT'] -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Dialogs demo
>> Where are GtkDialogFlags defined? I can find them in gtk-types.defs, >> but I don't know how to access them. Matt> They are: Matt> gtk.DIALOG_MODAL, gtk.DIALOG_DESTROY_WITH_PARENT, etc. There are so many symbols in the gtk and gtk.gdk modules (> 1100 all told), that I added a modified dir() function and a dirpat() function to my PYTHONSTARTUP file: from __builtin__ import dir as _dir def dir(o=globals,showall=0): if not showall and hasattr(o, "__all__"): x = list(o.__all__) x.sort() return x return _dir(o) import re def dirpat(o, pat): """like dir, but only return strings matching re pat""" names = dir(o, showall=1) return [x for x in names if re.search(pat, x) is not None] It produces what I find to be useful output: >>> dirpat(gtk, "(?i)dialog") ['ColorSelectionDialog', 'DIALOG_DESTROY_WITH_PARENT', 'DIALOG_MODAL', 'DIALOG_NO_SEPARATOR', 'Dialog', 'FontSelectionDialog', 'ICON_SIZE_DIALOG', 'InputDialog', 'MessageDialog', 'STOCK_DIALOG_ERROR', 'STOCK_DIALOG_INFO', 'STOCK_DIALOG_QUESTION', 'STOCK_DIALOG_WARNING'] >>> dirpat(gtk, "DIALOG") ['DIALOG_DESTROY_WITH_PARENT', 'DIALOG_MODAL', 'DIALOG_NO_SEPARATOR', 'ICON_SIZE_DIALOG', 'STOCK_DIALOG_ERROR', 'STOCK_DIALOG_INFO', 'STOCK_DIALOG_QUESTION', 'STOCK_DIALOG_WARNING'] >>> dirpat(gtk, "Dialog") ['ColorSelectionDialog', 'Dialog', 'FontSelectionDialog', 'InputDialog', 'MessageDialog'] YMMV... -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] inserting radio buttons into toolbars?
I'm confused about the required value of the type arg to gtk.Toolbar .append_element when trying to insert a radio button into the toolbar. The Gtk docs say If type == GTK_TOOLBAR_CHILD_RADIOBUTTON, widget is used to determine the radio group for the new element. In all other cases, widget must be NULL. I thought passing in a radio button would be okay: import gtk w = gtk.Window () w.connect ("destroy", gtk.mainquit) tb = gtk.Toolbar () w.add (tb) rb = gtk.RadioButton() tb.append_element ( gtk.TOOLBAR_CHILD_RADIOBUTTON, rb, "radio", "tooltip", "verbose tip", None, None, None ) w.show_all () gtk.main () but PyGtk complains Traceback (most recent call last): File "tb2.py", line 14, in ? None, None, None ) TypeError: second argument must be a GtkWidget or None I can't use a literal GtkWidget, since it's abstract and can't be instantiated. Passing None doesn't work either. What am I supposed to use? I can't find any examples in either PyGtk or Gtk proper that insert radio buttons into toolbars. Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] wrapper for gtk_stock_add
If case anyone wants to add new stock images to their applications, I submitted a patch last night to add a wrapper for gtk_stock_add to PyGtk. It's at http://bugzilla.gnome.org/show_bug.cgi?id=68363 The appended script demonstrates its use. -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) #!/usr/bin/env python import gtk # change these to reference a PNG file on your system dir = "/home/skip/src/gtk/gtk+.cvs/demos/gtk-demo" imbase = "gnome-foot" imfile = imbase + ".png" factory = gtk.IconFactory() factory.add_default() pixbuf = gtk.gdk.pixbuf_new_from_file("%s/%s" % (dir, imfile)) transparent = pixbuf.add_alpha(gtk.TRUE, chr(0xff), chr(0xff), chr(0xff)) icon_set = gtk.icon_set_new_from_pixbuf(transparent) factory.add(imbase, icon_set) gtk.rc_parse_string(''' pixmap_path "%s" style "icons" { stock["my-foot"] = { { "%s" } } } class "GtkButton" style "icons" ''' % (dir, imfile)) gtk.stock_add([(imbase, "_New Folder", 0, 0, "")]) w = gtk.Window() w.connect("destroy", gtk.mainquit) my = gtk.Button(stock=imbase) w.add(my) w.show_all() gtk.mainloop() ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] threading support in development pygtk
James> Of course if python were free threaded, it would integrate with James> almost any other library's idea of threading/locking. Greg Stein developed a free threading patch for Python 1.4. Non-threaded apps to about a 50% performance hit because of the extra overhead. That was several years ago. There are now many more places in the interpreter where reliance on the global interpreter lock lets people ignore locking. Finding all those places would be correspondingly more difficult. (Greg's free threading work was a pretty significant undertaking as I recall.) Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] threading support in development pygtk
James> would be nice if the python interpreter lock was recursive :) Somebody recently rewrote most of threading.py in C for Windows. It was suggested that he tackle a number of interpreter lock issues, including recursion. Perhaps it won't be that far off. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] threading support in development pygtk
Mike> To use the locking mechanisms, you'd first intialize the threads Mike> with code like: Mike> gtk.threads_init () Mike> gtk.threads_enter () Mike> gtk.mainloop () Mike> gtk.threads_leave () Mike> #... Now comes other code in another thread Mike> gtk.threads_enter () Mike> # Modify a widget or something Mike> gtk.threads_leave () It seems then that gtk.threads_enter/leave is functionally like the acquire/release methods of a threading.RLock instance, it's just that the gtk C code knows how to manipulate that single lock. I think I'm synchronized now. Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] threading support in development pygtk
Elliot> The point of the patch is to allow you to use gtk from multiple Elliot> python threads without having to worry about locking gtk Elliot> explicitly. So "threading support" in the subject effectively means "widget data locks", right? Now it's a bit more clear. Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] threading support in development pygtk
James> I have added back threading support to pygtk again (mainly based James> on Sopwith's patch, but with some changes to account for gtk api James> changes). I'm still perplexed. I understand the C programmers might find Gtk's thread support better (more portable, at least) than whatever else they might cobble together. However, when it comes to application writing, I'm a a Python programmer, and I have some questions for the literati in this area: * Under what circumstances should I use Gtk's thread system instead of Python's? * To enable Gtk threads should I disable Python threads? * If not, can they both be used in the same application? Under what circumstances? With what caveats? * Can you give some examples where using both might be useful? Inquiring (and confused) minds want to know. Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] GLIb IO Channels
Johannes> Is there a replacement for gtk_input_add_full ? Not that I'm aware of. As of gtk 1.3.12 it's there and present in PyGtk: >>> gtk.gtk_version (1, 3, 12) >>> gtk.input_add_full I see no indication in the reference man page at http://developer.gnome.org/doc/API/2.0/gtk/gtk-general.html#GTK-INPUT-ADD-FULL that it's deprecated either. Johannes> Or is gtk_input_add_full in opposite to the gdk version not Johannes> depricated ? I believe it's safe to use... -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] `GtkDialogFlags' is not an enum type
I've been away from the Gtk 1.3 release cycles for a month or two. Upon returning to it yesterday, I got this new warning: `GtkDialogFlags' is not an enum type Is this something I need to worry about or will it go away on its own as new versions of PyGtk are released that accommodate some new Gtk 1.3 API change? Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] GtkHtml2 wrapped into PyGtk
Jonas, Thanks for the GObject-ified version of HtmlStream. I found the infloop (I had inserted calls to html_stream_close in a couple functions that were registered as close functions to html_stream_new. doh!) I am now able to render entire pages - graphics and all - from Python using Gtk. Next question is - who wants to maintain this? I have a couple minor changes to the GtkHtml2 tree which I will filter back to Jonas. I also have a set of PyGtk wrappers that wrap HtmlStream, HtmlDocument and HtmlView. These are separate from PyGtk proper, so could be maintained by either the GtkHtml2 folks or the PyGtk folks. It doesn't matter to me. I placed a copy of my current pygtkhtml2 wrappers at http://www.musi-cal.com/~skip/python/pygtkhtml.tar.gz A simple example that displays the python.org home page is included. A copy of my CVS diffs against the gtkhtml2 repository at anoncvs.gnome.org is at http://www.musi-cal.com/~skip/python/gtkhtml.diffs This includes Jonas's GObject-ified HtmlStream. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Pygtk 1.99 and threading.
James> Currently threading is not supported at all, which is why James> --enable-thread defaults to no for now. It's not obvious to me why pygtk needs to support the Glib/Gtk thread model if Python's is available already. Other than being able to manipulate the user interface from multiple threads (which is no big win as far as I can tell), what does it buy you? -- Skip Montanaro ([EMAIL PROTECTED] - http://www.mojam.com/) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] adding wrappers for gtkhtml2
Matt> Get the authors to register it as a boxed type. Thanks. Where do I learn about boxed types? Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] adding wrappers for gtkhtml2
James> If you want to see an example of distributing a binding outside James> of the pygtk module, take a look at the gnome-python package. It James> has been set up to build separately. Matt> for example, when I wrapped atk: ... Matt> The generic rule in pygtk cvs will handle the autogenerating. Thanks to Matt & James for the tutorial on wrapping Gtk-related libraries. I can now successfully display an HTML document in Python code using the GtkHtml2 widget. I have so far only wrapped the HtmlDocument and HtmlView classes. I'm onto the next step: displaying embedded images. I'm unsure which route to take to get there. The HtmlDocument class supports a request-url signal. When I connect to it, my signal handler gets three arguments, a document, a url, and an HtmlStream*. The simple example that comes with GtkHtml2 doesn't do anything with it, but I presume I am supposed to write the image data I retrieve to the stream. Since I have yet to wrap this class, I don't actually see an HtmlStream*, but a PyCObject. HtmlStream is not a subclass of GObject, so I'm unclear how I am supposed to wrap it so that it is automagically mapped to the right kind of Python object. Any suggestions? Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] adding wrappers for gtkhtml2
I decided to wrap the gtkhtml2 library today. Seemed easy enough, small gtkhtml2.defs and gtkhtml2.override files did the trick, or so I thought. Then I started wading through the morass known as autoconf/automake/etc and quickly gave up on trying to do it "right". I ended up simply editing pygtk/gtk/Makefile, trying to mimic what was there for gtk and gobject. I eventually got to the point where I had something that compiled, linked and installed. Now I get a segfault during import, which I have trouble stepping up to because it's in a shared library. *sigh* Does anyone have a "recipe" for adding new wrappers to PyGtk2? I believe I have suitable .defs and .override files. I need the rest of the glue. wrapping-other-libraries-was-never-this-hard-ly, y'rs, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Better support for GError**
Matt> I've implemented this a bit differently (sans memory leak, etc) Matt> and checked it in. Much appreciated. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] kwlist mismatches in gtk/gtk.override
I've discovered a few kwlist length mismatches in gtk/gtk.override (in the new stuff). If you call one of them from Python, it complains about "bad args to an internal function". I don't know if this is a recent addition to Python or not, but it's a nice one. Clued me in... I thought I would mention them here. Some I can figure out the correction. Others perhaps not. _wrap_gtk_window_set_geometry_hints - kwlist has length 9, format string passed to PyArg_ParseTupleAndKeywords has length 11. Not sure what should happen here. It's got a substantially different i/f than the bare gtk function. _wrap_gtk_tree_model_get_value - kwlist has length 3, format string has length 2. The last item in kwlist should be deleted. _wrap_gtk_text_iter_backward_search - kwlist has length 3, format string has length 4. Only three output args are passed to Py_ArgParse... Only the mismatch between kwlist and the format that Python catches avoids memory corruption. If ..._forward_search is any indication, one of the "i" format characters should be deleted. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] HTML widgets that work with latest PyGtk?
Are there any HTML rendering widgets that work with the Gtk 1.3/2.0 API? Any that have been wrapped into PyGtk yet? Actually, as long as I'm thinking about this, are there any third-party widgets that have been wrapped for the latest PyGtk? Thanks, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] pygtk and pygnome documentation
John> Thanks for the tips on learning pygtk. It sounds like there is no John> documentation on pygtk or pygnome other than the source code. In reality, I rarely need to look at the PyGtk source, and most of that is when I want to change something. The wrappers are designed to create a more-or-less one-to-one mapping of the Gtk API, so most of the time, the correct place to look is the Gtk documentation. That said, I frequently use dir() to see what methods, functions and data attributes are exposed (some aren't for a variety of reasons). Because the gtk and gtk.gdk modules contain so many symbols, I wrote a dirpat method for interactive use that allows me to filter symbols based upon regular expressions: def dirpat(o, pat): """like dir, but only return strings matching re pat""" import re names = dir(o) pat = re.compile(pat) return [x for x in names if pat.search(x) is not None] You may find this helpful. -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Threading problem
Skip> ... If not, I'd recommend it *sigh* s/not/so/ Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Threading problem
Mike> Hi all. I'm relatively new to GTK and have been encountering Mike> some issues with thread locking and further updating of the Mike> application. Whose threads are you using, Gtk's or Python's? Are you updating the display in more than one thread? Can you easily restructure your application so that only a single thread is messing with the display? If not, I'd recommend it. Also, my guess is that Python's thread stuff is going to be easier to use than Gtk's. If nothing else, it provides some higher level objects (Queue.Queue, for example). -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Better support for GError**
I hacked up some better support for GError** args today. Unfortunately, I'm piling up diffs between what's in CVS and what I have, so it's getting a bit hard to separate different bits of functionality. I just submitted a patch to bugzilla. Interested parties can peruse http://bugzilla.gnome.org/show_bug.cgi?id=63980 -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Wrapping new types?
I need to get at the IconFactory and IconSet types. It looks like all I need to do is add matcher.register_boxed('GtkIconSet', 'G_TYPE_BOXED') to codegen/argtypes.py in order to wrap the GtkIconSet type ("boxed" means "opaque", right). Anything else? -- Skip Montanaro ([EMAIL PROTECTED]) ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] pixmap buttons?
Kwan> I am trying to create buttons with pixmaps (some kind of picture Kwan> on the button) using pygtk. Here's a simple example (I use the 2.0 API). Don't know how *correct* it is, but I'm pretty sure I figured it out from someone else's example. Obviously change the xpmfile to something on your local disk. -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ import gtk xpmfile = "chicago.xpm" class XPMFileButton(gtk.Button): def __init__(self, xpmfile): gtk.Button.__init__(self) self.xpmfile = xpmfile self.eid = self.connect("expose-event", self.addxpmfile) def addxpmfile(self, b, evt): pix, mask = gtk.gdk.pixmap_create_from_xpm(self.window, None, self.xpmfile) pixmap = gtk.Pixmap(pix, mask) self.add(pixmap) self.show_all() self.disconnect(self.eid) del self.eid def main(): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("title") window.connect("destroy", gtk.mainquit) close = XPMFileButton(xpmfile) close.connect("clicked", gtk.mainquit) window.add(close) window.show_all() gtk.mainloop() if __name__ == "__main__": main() ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Re: changing a combo's popdown strings from select-list callback?
John> Hi Skip, I don't know if this is still true for 1.3, but with gtk John> 1.2 you got a core if you removed the item with focus from a popup John> list. I worked around this by doing a gtk_widget_grab_focus() John> somewhere else before doing the delete. FWIW, I wound up subclassing the Combo widget (in Python) and making the set_popdown_strings method a bit smarter. It checks to see if its list widget's toplevel window is visible, and if so, connects to that widget's unmap signal to defer the actual setting: def deferred_popdown_cb(self, *args): self.list_parent.disconnect(self.popdown_id) gtk.Combo.set_popdown_strings(self, self.popdown_strings) def set_popdown_strings(self, strings): self.popdown_strings = strings self.list_parent = self.list.get_toplevel() if self.list_parent and (self.list_parent.flags() & gtk.MAPPED): self.popdown_id = self.list_parent.connect("unmap", self.deferred_popdown_cb) else: gtk.Combo.set_popdown_strings(self, self.popdown_strings) I'm not sure that's the best way to do it, but it worked for me. Perhaps gtk_combo_set_popdown_strings should do something like this by default. Alternatively, it would be nice if the GtkCombo documentation warned about the potential problems of mucking with the list while it's active. -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Re: changing a combo's popdown strings from select-list callback?
John> Hi Skip, I don't know if this is still true for 1.3, but with gtk John> 1.2 you got a core if you removed the item with focus from a popup John> list. I worked around this by doing a gtk_widget_grab_focus() John> somewhere else before doing the delete. That certainly seems suggestive of the problem I'm having. When I've been able to see a stack trace in gdb it's been in a focus-related function. I'll see if I can "work" your workaround into my code. -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] changing a combo's popdown strings from select-list callback?
I can stimulate a segmentation violation if I change the popdown strings of a GtkCombo while it is popped up. This simple Python script is sufficient to generate a core file: #!/usr/bin/env python import gtk recursive = 0 def fill_new(l, item, combo): global recursive if not recursive: recursive = 1 combo.set_popdown_strings(["a","b","c"]) def main(): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("Today's Menu - Pick an Entree") window.connect("destroy", gtk.mainquit) combo = gtk.Combo() combo.set_popdown_strings(["Spam", "Eggs", "Ham"]) combo.entry.set_text("pick an entree") combo.list.connect("select-child", fill_new, combo) window.add(combo) window.show_all() gtk.mainloop() if __name__ == "__main__": main() How do I work around that? Presumably, I need to wait until the Combo has popped down (and no longer has a pointer grab?) to change its popdown strings. (I'm using the CVS version of Gtk+, but I doubt it matters.) Thx, -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] weird gdb/python/gtk/pango interaction?
Folks, I'm no longer able to run PyGtk scripts from gdb under some circumstances. I am using the CVS HEAD of glib, atk, pango, gtk+ and pygtk. The following simple Python script works fine when run from gdb: #!/usr/bin/env python import gtk w = gtk.Window() w.connect("destroy", gtk.mainquit) #lbl = gtk.Label("hi") #w.add(lbl) w.show_all() gtk.mainloop() with the following output: (gdb) r basic.py Starting program: /usr/local/bin/python basic.py [New Thread 1024 (LWP 19044)] Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES. if you don't know why you are getting this, you probably want to use the stable branch which can be retrieved from ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+ Program exited normally. If I uncomment the two lines involving lbl, however, I get this mess: (gdb) r basic.py Starting program: /usr/local/bin/python basic.py [New Thread 1024 (LWP 19127)] Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES. if you don't know why you are getting this, you probably want to use the stable branch which can be retrieved from ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+ basic.py (pid:19127): GRuntime-CRITICAL **: file gparamspecs.c: line 1687 (g_param_spec_float): assertion `default_value >= minimum && default_value <= maximum' failed basic.py (pid:19127): GRuntime-CRITICAL **: file gobject.c: line 270 (g_object_class_install_property): assertion `G_IS_PARAM_SPEC (pspec)' failed basic.py (pid:19127): ** WARNING **: Couldn't load font "Sans -2.09715e+06" falling back to "Sans -2.09715e+06" basic.py (pid:19127): ** WARNING **: Couldn't load font "Sans -2.09715e+06" falling back to "Sans -2.09715e+06" basic.py (pid:19127): ** WARNING **: All font failbacks failed Program exited with code 01. If I change the Label to an EventBox, everything works, presumably because no font rendering is involved. Also when I run the script from the bash prompt it works as expected (no Gtk warnings). The equivalent C program: #include int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *label; gtk_init(&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); gtk_window_set_title (GTK_WINDOW (window), ""); label = gtk_label_new("hi"); gtk_container_add(GTK_CONTAINER(window), label); gtk_widget_show_all (GTK_WIDGET(window)); gtk_main(); return(0); } works as expected, both from the command line and if run from the gdb prompt. This wouldn't be such a big deal, except in a more complex script I get segfaults in some circumstances, and this makes debugging that problem a bit difficult. Any idea what's going on? -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Why do some stock images not display?
I noticed today that some of the stock images seem to be missing when creating widgets in PyGtk2 that use them. At Havoc's suggestion I ran Gtk's stock image demo. Everything worked fine there. On my system at least, the script below fails to display the UP or DOWN stock images. The BACK and FORWARD images display properly. #!/usr/bin/env python import gtk w = gtk.Window() w.connect("destroy", gtk.mainquit) tbl = gtk.Table(4, 2) tbl.set_homogeneous(gtk.TRUE) w.add(tbl) aopt = gtk.EXPAND|gtk.FILL|gtk.SHRINK r = 0 for label,stock in (("GO_UP", "gtk-go-up"), ("GO_DOWN", "gtk-go-down"), ("GO_BACK", "gtk-go-back"), ("GO_FORWARD", "gtk-go-forward")): c = 0 tbl.attach(gtk.Label(label),c,c+1,r,r+1, aopt, aopt, 0, 0) c = 1 tbl.attach(gtk.Button(stock=stock),c,c+1,r,r+1, aopt, aopt, 0, 0) r += 1 w.show_all() gtk.mainloop() This is extremely weird, because the pixbufs are hard-coded into Gtk. There are no files that can be missing. Can someone explain to me what's going on? Thanks, -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] how to sort properly by column and display right-justified text?
I'm building a (not so) little file selector using the latest PyGtk stuff. In list mode I create a list (using the TreeView widget) with four columns: name, size, type and last mod time. I can click the column headers on any of these to sort the list using that column. It works with the following caveats: 1. Python's sort order seems to be different than Gtk's sort order. For example, if my file list is .emacs abc.txt qtpi.doc Python sorts it as displayed, but sorting using the Gtk sort column button sorts it as abc.txt .emacs qtpi.doc I assume this is some sort of locale thing (my locale is en_US). If I set the LC_COLLATE environment variable to "C", both Gtk and Python sort with "." before letters. I guess this is more a question of why default Python list sort doesn't pay attention to LC_COLLATE. 2. It doesn't matter what I fill the size list with (numbers or their string representation), the column header always sorts lexicographically, not numerically. How can I make it sort numerically? Also, the sizes are always displayed centered. Is there a way to make them right-justified? Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Bug crept into gtk-types.c...
Matt> btw, if you want to know how this function works, see: Matt> http://www.python.org/doc/2.2/api/number.html#l2h-229 Thanks, I eventually figured out the coercion stuff. To work around the problem I figured I'd just can float conversion for now. Seems safe enough, since apparently the Gtk folks don't intend GdkAtoms to hold floats. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Bug crept into gtk-types.c...
Compiling gtk-types.c (v. 1.29) from the latest CVS gives several warnings and two errors: gtk-types.c: In function `pygdk_atom_coerce': gtk-types.c:1262: warning: passing arg 1 of `PyInt_FromLong' makes integer from pointer without a cast gtk-types.c:1266: pointer value used where a floating point value was expected gtk-types.c:1270: warning: passing arg 1 of `PyLong_FromUnsignedLong' makes integer from pointer without a cast gtk-types.c: In function `pygdk_atom_int': gtk-types.c:1288: warning: passing arg 1 of `PyInt_FromLong' makes integer from pointer without a cast gtk-types.c: In function `pygdk_atom_long': gtk-types.c:1294: warning: passing arg 1 of `PyLong_FromUnsignedLong' makes integer from pointer without a cast gtk-types.c: In function `pygdk_atom_float': gtk-types.c:1300: incompatible type for argument 1 of `PyFloat_FromDouble' gtk-types.c: In function `pygdk_atom_oct': gtk-types.c:1308: warning: long unsigned int format, GdkAtom arg (arg 4) gtk-types.c: In function `pygdk_atom_hex': gtk-types.c:1316: warning: long unsigned int format, GdkAtom arg (arg 4) gtk-types.c: At top level: pygtk-private.h:38: warning: `PyGtk_FatalExceptions' defined but not used Looking at the code in question, I have to admit I don't understand what's going on (ignoring the errors and warnings for a moment). It sets *self, then Py_INCREFs *other. What's with that? -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Can't build gobjectmodule.o - missing CVS checkin?
>> Actually, I'm now using 2.2b1+... Matt> They changed the PyTypeObject structure in 2.2b1. We haven't Matt> fixed PyGTK for that yet. Go back to 2.2a4 or wait till it's Matt> fixed. Thanks, that was enough to steer me in the right direction. Should I submit a patch to bugzilla once I'm sure I have all the changes nailed down? Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] Can't build gobjectmodule.o - missing CVS checkin?
Skip> I'm trying to build PyGtk from CVS and get this compilation error: Matt> Are you using Python 2.2a4? Actually, I'm now using 2.2b1+... I update both Python and Gtk/PyGtk stuff frequently, at least a few times a week. I had no problems yesterday. I guess I'll take a look and see what the latest PyGtk checkins were. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Can't build gobjectmodule.o - missing CVS checkin?
I'm trying to build PyGtk from CVS and get this compilation error: gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/include/python2.2 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include/pango-1.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -g -O2 -c gobjectmodule.c -MT gobjectmodule.lo -MD -MP -MF .deps/gobjectmodule.TPlo -fPIC -DPIC -o gobjectmodule.o gobjectmodule.c: In function `pygobject_register_class': gobjectmodule.c:262: structure has no member named `tp_defined' gobjectmodule.c: At top level: gobjectmodule.c:446: warning: initialization from incompatible pointer type gobjectmodule.c: In function `pyg_register_boxed': gobjectmodule.c:476: structure has no member named `tp_defined' gobjectmodule.c: At top level: gobjectmodule.c:1687: warning: initialization from incompatible pointer type gobjectmodule.c:1747: warning: initialization from incompatible pointer type gobjectmodule.c: In function `pyg_register_interface': gobjectmodule.c:1767: structure has no member named `tp_defined' gobjectmodule.c: In function `pyg_type_register': gobjectmodule.c:1965: structure has no member named `tp_defined' gobjectmodule.c: In function `initgobject': gobjectmodule.c:2359: structure has no member named `tp_defined' gobjectmodule.c:2368: structure has no member named `tp_defined' Looks like a .h file got checked in but someone forgot about gobjectmodule.c (or the .h file got checked in too soon). -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] What are the restrictions on hanging new signals on the widget tree?
James> class _HEntry(gtk.Entry): James> def __init__(self): James> gobject.GObject.__init__(self) James> self.set_name("_history_") James> gobject.type_register(_HEntry) James> Note the gobject.type_register() call, and chaining to James> GObject.__init__ rather than gtk.Entry.__init__. If you look at James> _HEntry.__gtype__, it should be for This way, the signals will be James> added to your new type rather than GtkEntry. This will also James> change the type name used in the gtkrc file. The type name is James> generated from the full class name (module.class), with dots James> replaced with plus signs (because Tim doesn't want to make dots James> valid in type names). Thanks, I never would have guessed that. How come there is no need to chain through gtk.Entry.__init__? James> Does the above comments help? Yes, thanks. (My other alternative was to hang my new signals off gtk.Widget...) Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] What are the restrictions on hanging new signals on the widget tree?
Using the Gtk 2.0 API, I have a subclass of GtkEntry to which I've attached three new signals: history-prev, history-next, and history-menu: class _HEntry(gtk.Entry): def __init__(self, *args): gtk.Entry.__init__(self, *args) self.set_name("_history_") gobject.signal_new("history-prev", _HEntry, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) gobject.signal_new("history-next", _HEntry, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) gobject.signal_new("history-menu", _HEntry, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) I want to add the same signals to a subclass of GtkSpinButton: class _HSpinButton(gtk.SpinButton): def __init__(self, *args): gtk.SpinButton.__init__(self, *args) self.set_name("_history_") gobject.signal_new("history-prev", _HSpinButton, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) gobject.signal_new("history-next", _HSpinButton, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) gobject.signal_new("history-menu", _HSpinButton, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) When I try this, the signals seem to be defined for my GtkEntry subclass just fine, but I get a Gtk warning and Python RuntimeError exception when trying to attach the signals to the GtkSpinButton subclass: History.py (pid:18736): GRuntime-WARNING **: gsignal.c:1147:g_signal_newv(): signal "history_prev" already exists in the `GtkEntry' class ancestry Traceback (most recent call last): ... File "/home/skip/src/tttech/projects/SW/lib/python/TGW/Spinner.py", line 19, in ? gobject.TYPE_NONE, ()) RuntimeError: could not create signal This is a bit frustrating. I thought the restriction on signal names was that a direct ancestor of the class to which I was adding a signal couldn't already be using this signal name. It seems to me that I need to add these three signals rather high up in the widget hierarchy, which unfortunately will pollute a lot of widgets that have no use for them with these signals. Is there an alternative? Thx, Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] signal emission message/traceback
The attached Python script subclasses gtk.Combo and adds a value-changed signal so the user doesn't have to fiddle directly with the signals emitted by the underlying Entry and List widgets. Before the switch away from ExtensionClass I could have sworn everything worked fine. Now, every time I emit a value-changed signal I get this message and traceback: Combo.py (pid:30657): GRuntime-CRITICAL **: file gvalue.c: line 140 (g_value_unset): assertion `G_IS_VALUE (value)' failed Traceback (most recent call last): File "Combo.py", line 33, in list_select_cb self.emit("value-changed") TypeError: unknown type (null) Any idea what's going on? The script exhibits no other problems, and though this is labelled "critical", it doesn't seem to have had an deliterious effect on the script. The only change I've made to it since early September was to update the Gtk class references (e.g. gtk.GtkCombo -> gtk.Combo). Thanks, Skip #!/usr/bin/env python import gtk import gobject class Combo(gtk.Combo): def __init__(self): gtk.Combo.__init__(self) self.value = "" self.disable_activate() self.entry.connect("activate", self.activate_cb) self.list.connect("select-child", self.list_select_cb) def set_value(self, val): self.value = val self.entry.set_text(val) def activate_cb(self, e): newval = e.get_text() if newval != self.value: self.value = newval self.emit("value-changed") def set_popdown_strings(self, strings): self.popdown_strings = strings gtk.Combo.set_popdown_strings(self, strings) def list_select_cb(self, lst, item): i = lst.child_position(item) newval = self.popdown_strings[i] if newval != self.value: self.value = newval self.emit("value-changed") gobject.signal_new("value-changed", Combo, gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) def value_cb(c): print "new value:", c.value def main(): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("title") window.connect("destroy", gtk.mainquit) combo = Combo() combo.set_popdown_strings(["abc", "spam", "eggs", "ham"]) combo.set_value("abc") combo.connect("value-changed", value_cb) window.add(combo) window.show_all() gtk.mainloop() if __name__ == "__main__": main()
Re: [pygtk] How to delete Gtk objects
(adding python-dev to this conversation because decisions about missing special methods vis a vis PEP 252/253 seem to me to definitely belong in that space.) >> I think that there may be some problems with extended types and >> __del__? Matt> For example: Matt> class myList(type([])): Matt> def __del__(self): Matt> print "list dealloced" Matt> list = myList() Matt> list.append("foo") Matt> list.append("bar") Matt> del list Matt> never prints list delloced. My guess (without examining any code) is that __del__ is not implemented for new-style classes. There is this rather cryptic note at the end of PEP 253: - open issues: ... - do we need __coerce__, __del__? ... which leads me to believe that __del__ would not be called in the current implementation. If people are going to be subclassing more than the traditional builtin types I think __del__ methods will have to be supported. Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] wrapping gtk_tree_selection_selected_foreach - bit of a problem...
me> I'm adding a wrapper for gtk_tree_selection_selected_foreach to me> gtk.overrides. So far, I have this code: ... me> When I run my example script and select an item in a list, it me> segfaults a couple of stackframes down from _ts_select_foreach_func me> trying to make a pygobject out of the GtkTreePath pointer that was me> passed in. I eventually figured out that pygobject_new was not the correct call to wrap a GtkTreePath pointer in a Python object. Now I'm puzzling about what to do with the GtkTreeIter... I'm sure I'll be asking another question or two about this... ;-) Skip ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] pygtk, g_log warnings, and gdb
(I've changed the subject because I take a left turn into gdb-land in the middle of this message.) James> I may as well add that one of the aims is to never (or at least James> hardly ever) spit out these gtk warnings. Many of the type James> checks that might spit out these warnings are already caught as James> exceptions (mainly type checks). It seems to me that even when pygtk is perfect, the programmer will still be able to make mistakes when manipulating Gtk objects, so these warnings are still going to be present, it's just that they will be the programmer's problem, not yours. James> If you can track down where the warning occurs, please file a bug James> report (they generally indicate an error in the program which James> could cause a segfault if assertions were turned off in gtk). I would, but at this point it's difficult to tell if I'm doing something wrong or there is an underlying problem with pygtk or gtk itself. I'm just not familiar enough with everything. I still think it would be useful to be able to turn these things into exceptions. In response to Matt's "it can't be done" response: I will never use Gtk threads in my Python code (preferring Python's threads instead), will generally not use threads anyway (most code doesn't need it), and when I do will only make Gtk calls from one thread, so for me it makes sense to couple Gtk's warning/error messages with Python's exception handling mechanism, even if just to be able to print out a Python traceback for debugging purposes. It seems to me that most people will constrain their Python/Gtk code structure in similar ways. (Skip makes the signal for a left turn.) One thing I do find rather odd, however, is that in some situations I get no warnings, but when running under gdb (same shared libraries, same python executable, same scripts), get several Gtk messages. To wit: % PYTHONPATH=.. python List.py Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES. if you don't know why you are getting this, you probably want to use the stable branch which can be retrieved from ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+ ['__class__', '__cmp__', '__delattr__', '__dict__', '__getattribute__', '__gobject_init__', '__gtype__', '__hash__', '__init__', '__new__', '__reduce__', '__repr__', '__setattr__', '__str__', 'connect', 'connect_after', 'connect_object', 'connect_object_after', 'destroy', 'disconnect', 'emit', 'emit_stop_by_name', 'flags', 'freeze_notify', 'get_data', 'get_property', 'get_selected', 'handler_block', 'handler_disconnect', 'handler_unblock', 'notify', 'ref', 'remove_data', 'remove_no_notify', 'select_all', 'select_iter', 'select_path', 'select_range', 'selected_foreach', 'set_data', 'set_flags', 'set_mode', 'set_property', 'sink', 'stop_emission', 'thaw_notify', 'unref', 'unselect_all', 'unselect_iter', 'unselect_path', 'unset_flags'] Segmentation fault Okay, we have a problem. Suppose I'd like to debug that segfault. Let's try gdb: % type python python is hashed (/usr/local/bin/python) % gdb /usr/local/bin/python GNU gdb 5.0mdk-11mdk Linux-Mandrake 8.0 Copyright 2001 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-mandrake-linux"... (gdb) set env PYTHONPATH .. (gdb) r List.py Starting program: /usr/local/bin/python List.py [New Thread 1024 (LWP 7124)] Gtk-Message: YOU ARE USING THE DEVEL BRANCH 1.3.x OF GTK+ WHICH IS CURRENTLY UNDER HEAVY DEVELOPMENT AND FREQUENTLY INTRODUCES INSTABILITIES. if you don't know why you are getting this, you probably want to use the stable branch which can be retrieved from ftp://ftp.gtk.org/pub/gtk/v1.2/ or via CVS with cvs checkout -r glib-1-2 glib; cvs checkout -r gtk-1-2 gtk+ List.py (pid:7124): GRuntime-CRITICAL **: file gparamspecs.c: line 1521 (g_param_spec_float): assertion `default_value >= minimum && default_value <= maximum' failed List.py (pid:7124): GRuntime-CRITICAL **: file gobject.c: line 270 (g_object_class_install_property): assertion `G_IS_PARAM_SPEC (pspec)' failed List.py (pid:7124): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -2147483648 and height 12 ['__class__', '__cmp__', '__delattr__', '__dict__', '__getattribute__', '__gobject_init__', '__gtype__', '__hash__', '__init__', '__ne
[pygtk] wrapping gtk_tree_selection_selected_foreach - bit of a problem...
I'm adding a wrapper for gtk_tree_selection_selected_foreach to gtk.overrides. So far, I have this code: %% override gtk_tree_selection_selected_foreach static void _ts_select_foreach_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { /* the real Python function we want to call is hidden in the data */ /* extract that function, wrap the various data args and call it */ PyObject *compound = (PyObject *)data; PyObject *foreach_func; PyObject *gdata; PyObject *pymodel; PyObject *pypath; PyObject *pyiter; PyObject *result; foreach_func = PyTuple_GET_ITEM(compound, 0); gdata = PyTuple_GET_ITEM(compound, 1); pymodel = pygobject_new((GObject *)model); if (pymodel == NULL) return; pypath = pygobject_new((GObject *)path); if (pypath == NULL) { Py_DECREF(pypath); return; } pyiter = pygobject_new((GObject *)iter); if (pyiter == NULL) { Py_DECREF(pymodel); Py_DECREF(pypath); return; } result = PyObject_CallFunction(foreach_func, "", pymodel, pypath, pyiter, gdata); Py_XDECREF(result); Py_DECREF(pymodel); Py_DECREF(pypath); Py_DECREF(pyiter); } static PyObject * _wrap_gtk_tree_selection_selected_foreach(PyGObject *self, PyObject *args) { PyObject *foreach_func = NULL; PyObject *data = NULL; PyObject *compound; if (!PyArg_ParseTuple(args, "O|O:GtkTreeSelection.selected_foreach", &foreach_func, &data)) return NULL; if (data == NULL) { data = Py_None; } Py_INCREF(data); compound = Py_BuildValue("(OO)", foreach_func, data); Py_DECREF(data); if (compound == NULL) return NULL; gtk_tree_selection_selected_foreach(GTK_TREE_SELECTION(self->obj), _ts_select_foreach_func, (gpointer)compound); Py_DECREF(compound); if (PyErr_Occurred()) return NULL; Py_INCREF(Py_None); return Py_None; } When I run my example script and select an item in a list, it segfaults a couple of stackframes down from _ts_select_foreach_func trying to make a pygobject out of the GtkTreePath pointer that was passed in. That object looks reasonable when viewed from gdb: (gdb) p *path $2 = { depth = 1, indices = 0x835f1e0 } but that's not a lot to go on. Here's the beginning of the backtrace with the corresponding C source lines: (gdb) bt #0 0x401be364 in g_object_get_qdata (object=0x835f9f8, quark=46) at gobject.c:1328 g_return_val_if_fail (G_IS_OBJECT (object), NULL); #1 0x4019a10f in pygobject_new (obj=0x835f9f8) at gobjectmodule.c:305 if ((self = (PyGObject *)g_object_get_qdata(obj, pygobject_wrapper_key))) { #2 0x40293c01 in _ts_select_foreach_func (model=0x82ec210, path=0x835f9f8, iter=0xbfffdf10, data=0x82e22e4) at gtk.override:1371 pypath = pygobject_new((GObject *)path); #3 0x4046684d in gtk_tree_selection_selected_foreach (selection=0x82e9d80, func=0x40293bb0 <_ts_select_foreach_func>, data=0x82e22e4) at gtktreeselection.c:401 (* func) (selection->tree_view->priv->model, path, &iter, data); #4 0x40293dc1 in _wrap_gtk_tree_selection_selected_foreach (self=0x82f9ebc, args=0x82da1d4) at gtk.override:1415 gtk_tree_selection_selected_foreach(GTK_TREE_SELECTION(self->obj), I'm only operating on a simple single-column list for my initial testing. I'd post the code that that, but it's as complex as the C code, and I think this is more likely a problem with my C code. (The script was working using selection.get_selected instead of selection.selected_foreach.) Any ideas? -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ http://www.musi-cal.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] Turning Gtk warnings into exceptions?
(apologies if you get this twice. i'm having intermittent mail problems.) Gtk occasionally emits semi-useful error messages like (wrapped for reading convenience): draw.py (pid:29047): GRuntime-CRITICAL **: file gvalue.c: line 140 (g_value_unset): assertion `G_IS_VALUE (value)' failed It seems that g_log_set_handler allows you to establish error handlers for different error and warning classes. For PyGtk I think it might be more useful to raise exceptions than to emit these messages. g_log_set_handler looks like the key function. Unfortunately, I can't get to the glib docs at the moment to investigate this capability more. Has anyone investigated this already? - -- Skip Montanaro ([EMAIL PROTECTED]) http://www.mojam.com/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk