[pygtk] Catching gobject.GError..
How should I catch gobject.GError, or where is it? I couldn't find where to take this class from :-( Thanks, dave -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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[2]: [pygtk] High CPU problem example
Hi! I'm not sure what's your problem but I had have one of your problems: The create_pango_layout is not supposed to be called all the time.. For that, my class caches the layout: class Message: def __init__(self, msg): We are expecting unicode message strings self.msg = msg.encode('utf-8') # create a font description self.font_desc = pango.FontDescription('Serif 8') def _make_layout (self, widget): global wrapmode, wrapwidth # create a layout for your drawing area self.layout = widget.create_pango_layout(self.msg) self.layout.set_wrap(wrapmode) self.layout.set_width(wrapwidth) # tell the layout which font description to use self.layout.set_font_description(self.font_desc) def _make_cache(self, gc): This method doesn't seems to be fundamental, but.. global depth #self.image = string.join(self.mx*3*self.my*['\0'],) #self.image = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, self.mx, self.my) self.image = gtk.gdk.Pixmap(None, self.mx, self.my, depth) self.gc = gc colormap = gc.get_colormap() white = colormap.alloc_color('white') yellow = colormap.alloc_color('yellow') black = colormap.alloc_color('black') gc.set_rgb_fg_color (yellow) self.image.draw_rectangle(gc, gtk.TRUE, 0,0, self.mx-1, self.my-1) gc.set_rgb_fg_color (black) self.image.draw_rectangle(gc, gtk.FALSE,0,0, self.mx-1, self.my-1) gc.set_rgb_fg_color (black) # draw the text with the draw_layout method self.image.draw_layout(self.gc, Message.BORDER_SIZE, Message.BORDER_SIZE, self.layout) def drawon(self, atx, aty, widget=None, gc=None): if not self.widget: if not widget or not gc: return else: self._make_layout(widget) self.widget = widget self._make_cache(gc) # draw the text with the draw_layout method #widget.window.draw_layout(gc, atx, aty, self.layout) #self.image.render_to_drawable (widget.window, gc, 0, 0, atx,aty, self.mx, self.my, gtk.gdk.RGB_DITHER_MAX, 0, 0) widget.window.draw_drawable(self.gc, self.image, 0, 0, atx, aty, self.mx, self.my) This creates the layout and dumps it, with a frame into a pixmap that's later used to be draw anytime. I removed some code, but that should be enough. It's from the class Message of IMFish(.sourceforge.net) :-) Also, i think that you should setup what font do you want to use, in other place, than the expose-cb! Seeya! -Original Message- From: Jean-Baptiste Cazier [EMAIL PROTECTED] To: Gustavo J. A. M. Carneiro [EMAIL PROTECTED] Date: Fri, 12 Dec 2003 17:38:46 + Subject: Re: [pygtk] High CPU problem example Hello Gustavo ! Thanks for your answer. Your solution works fine for my simplified problem. It also pin-point the source of my troubles. But in order to solve my original problem I need a further tip: Indeed If I actually draw something based on the modified font by adding the line area.window.draw_layout(self.gc, 10, 10, self.area.create_pango_layout(TEXT)) Nothing is drawn at all if moved to the area_realize_cb routine. In my real area_expose_cb routine I draw many things with various fonts that are set-up in other windows For example I call draw_axes_s which uses 2 types of fonts. def draw_axes_s(self, xo, yo, xs, ys ): Draw axis and write down the labels on the screen win=self.area.window mini=self.Cld.mini maxi=self.Cld.maxi mindist=self.Cld.mindist markers=self.Cld.markers location=self.Cld.location f_mrkX=markers[0][0] l_mrkX=markers[0][len(markers[0])-1] f_mrkY=markers[1][0] l_mrkY=markers[1][len(markers[1])-1] xsize=min(max(float(xs)/(maxi[0]-mini[0])*mindist[0]*.9,self.min_size),self.max_size) ysize=min(max(float(ys)/(maxi[1]-mini[1])*mindist[1]*.9,self.min_size),self.max_size) # Draw the lines self.gc.foreground =self.area.get_colormap().alloc_color(black) win.draw_line(self.gc, xo, yo, xo+xs, yo) win.draw_line(self.gc, xo, yo, xo, yo-ys) #Draw ticks for m in markers[0]: col=(location[0][m]-mini[0])/(maxi[0]-mini[0]) win.draw_line(self.gc, xsize/2+xo+col*(xs-xsize), yo,xsize/2+xo+col*(xs-xsize),yo+3 ) for m in markers[1]: col=(location[1][m]-mini[1])/(maxi[1]-mini[1]) win.draw_line(self.gc, xo,-ysize/2+yo-col*(ys-ysize), xo-3,
[pygtk] Someone have used gtk.IMContext ?
Is there some example? I'm doing: im = gtk.IMContextSimple() im.set_client_window(some_gtk_window) im.filter_keypress(a_keypress_event) and then: im.get_preedit_string() returns : ('', PangoAttrList at 0x833d3f0, 0) (after passing a few keypress) I don't know if I shoould call something more, to initialize them, or if I should connect something.. or what.. And I can't found information on this gtk functions. Also, note, that it says that I shoould pass (**string,*attrs,*pos), but, after tryng that, it says that it requires no arguments, and, doing in that way, it returns the 3-upla above. Thanks in advance, for anything! david -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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] help: how to build text from keypress and dead/compose keys ?
Hi! I hooked key_press event.. and all was ok until I wanted to 'handle' deadkeys .. well actually.. the deadkey event comes as a keypress. But I can't handle it, I could save it for later use.. but still don't know how can I use that when other key comes. When a keypress comes I do: 1. check it's a keypress event 2. check if keyval 0xff00 == 0xff00, if it's that, - contrrol key 3. if not control key: 4. oldstr = oldstr + unichar(gtk.gdk.keyval_to_unicode( keyval )) Well I must check that keyval_to_unicode doesn't return 0L. But, is keyval_to_unicode the function that I should call? I saw that there are some gtk_im_context methods/classes.. are them for this kind of things? (i don't found information about that functions).. Is there some kind of value that I can keep, to process next keypress with, in order to apply the char modification? Thanks in advance! -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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 librsvg bindings..
On Tue October 14 2003 22:11, Malcolm Tredinnick wrote: On Tue, 2003-10-14 at 18:07, alejandro david weil wrote: I mean classes. Only thing I want from librsvg is a function, that reads a .svg file an returns a Pixbuf, and I want the Pixbuf created to be of the same class that python-gtk2 uses for Pixbufs. Oh, I see what you want now. The method mentioned in the FAQ about including other .def files is really the recommended way to do this. Look at something like the gnome-python/gnome bindings from CVS or a source tarball (e.g nautilus.override or something similar) to see how it includes classes from other modules. The required header files will be installed somewhere under ${prefix}/include/ is you have the appropriate *-devel packages installed (depends on your distribution). second: where should I take the pygtk's codegen from? I used the one from my debian's python-gtk2 source packages, but have had lots of problems (for example, doesn't have autoget.sh, to automake/confs problems..).. so i wanted to checkout, if there exists some stable version? Whatever comes with the pygtk sources is really the official version and it works well for its purpose (generating the gnome-python bindings). Periodically I think that it may not be crazy to release it as a separate package, since the .defs format is good for many language bindings (it is used by a couple of others) and is relatively simple to create for extra packages. I have an unreleased thing at the moment I am working on where I used the .defs format to create the Python bindings. But I have the same problem you do -- it creates an implicit pygtk dependency for a package that doesn't use pygtk. Mmmh.. the module I made, doesn't seems to import pygtk, is this enough?: I don't think you are responding to the comment I wrote. :-) Mmh.. I answered that, because, i think that you were talking about a runtime reference :-). Maybe because, I saw, in one of the faqs, that for using the module created, one should import pygtk before importing the module created. Talking about packages, I also think that it's not crazy to release python-gtk's-gen separated! :-) Related question, is the def files's format one known or standard format? Well, at least, binary packages from debian: ii python2.3-gnom 2.0.0-5Python bindings for GNOME 2 ii python2.3-gtk2 2.0.0-2Python bindings for the GTK+ widget set Seems to doesn't have codegen installed :-( You possibly need the development package for pygtk as well. I am not familiar enough with Debian's packaging scheme to know for sure. Ok, and, as Charles said, it's on python-gtk2-dev has pygtk-codegen! Thanks for the answers! alejandro -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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 librsvg bindings..
On Tue October 14 2003 00:05, Malcolm Tredinnick wrote: On Tue, 2003-10-14 at 10:45, alejandro david weil wrote: first: if i want to reuse objects returned by it, then, I should use the .defs and .override definitions that pygtk's codegen builds? Is there another, more.. manual way to do? I don't understand this question. Where do you want to reuse the objects (and what objects are you talking about)? Maybe an example would be good. I mean classes. Only thing I want from librsvg is a function, that reads a .svg file an returns a Pixbuf, and I want the Pixbuf created to be of the same class that python-gtk2 uses for Pixbufs. second: where should I take the pygtk's codegen from? I used the one from my debian's python-gtk2 source packages, but have had lots of problems (for example, doesn't have autoget.sh, to automake/confs problems..).. so i wanted to checkout, if there exists some stable version? Whatever comes with the pygtk sources is really the official version and it works well for its purpose (generating the gnome-python bindings). Periodically I think that it may not be crazy to release it as a separate package, since the .defs format is good for many language bindings (it is used by a couple of others) and is relatively simple to create for extra packages. I have an unreleased thing at the moment I am working on where I used the .defs format to create the Python bindings. But I have the same problem you do -- it creates an implicit pygtk dependency for a package that doesn't use pygtk. Mmmh.. the module I made, doesn't seems to import pygtk, is this enough?: Python 2.3.1 (#2, Sep 30 2003, 00:50:40) [GCC 3.3.2 20030908 (Debian prerelease)] on linux2 Type help, copyright, credits or license for more information. dir() ['__builtins__', '__doc__', '__name__'] import rsvg dir() ['__builtins__', '__doc__', '__name__', 'rsvg'] dir(rsvg) ['__doc__', '__file__', '__name__', 'rsvg_pixbuf_from_file', 'rsvg_pixbuf_from_file_at_max_size', 'rsvg_pixbuf_from_file_at_size', 'rsvg_pixbuf_from_file_at_zoom', 'rsvg_pixbuf_from_file_at_zoom_with_max', 'rsvg_set_default_dpi'] ..and it works fine, I used to create a Pixbuf, and then, the pixbuf is used in pygtk functions without problem. I asked for the package alone, because, I couldn't get it to work for these bindings in, about, some hours, and wanted to check documentation or new releases. I'm very new with python, and more, with its bindings, and wanted to know, if, for wrapping a lib. of about 6 functions, without extra data types, and, requiring only one function to be exported, it has sense to do all that process. (Anyway, it's possible that the process turned heavy because I'm newbie in this) third: is something like that avaible? where? CVS or a released pygtk tarball. Well, at least, binary packages from debian: ii python2.3-gnom 2.0.0-5Python bindings for GNOME 2 ii python2.3-gtk2 2.0.0-2Python bindings for the GTK+ widget set Seems to doesn't have codegen installed :-( Thanks for your answer! -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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 librsvg bindings..
Hi! Today I were trying to make these bindings. Finally, with a coctail of good luck, faqs and faqs, some other packages etc.. .. I made them work.. Well I have a couple of questions: first: if i want to reuse objects returned by it, then, I should use the .defs and .override definitions that pygtk's codegen builds? Is there another, more.. manual way to do? second: where should I take the pygtk's codegen from? I used the one from my debian's python-gtk2 source packages, but have had lots of problems (for example, doesn't have autoget.sh, to automake/confs problems..).. so i wanted to checkout, if there exists some stable version? third: is something like that avaible? where? Well.. finally i couldn't have working with the 1.11. faq section.. i did all but.. i couldn't finnish that cause i didn't have autogen.sh, i tried running autoconf aclocal automake.. finally taked an autogen.sh frrom python-gnome, but when it runs automake said: can't find Makefile.am (the file was there..) .. well .. lots of problems.. :-( Then i checked the faq on ibm's site, referenced in 1.11, and handled to get it working.. Well.. if someone, needs it, i can send it. See ya! david -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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] Question about idle_add() and refreshing some widget..
Hi! I'm making a program that has only a widget that's a GtkDrawingArea. In that widget I draw my own objects. Well, I want it to be refreshed as fast to produce some smooth efect in the objects that are moving inside. For drawing the objects inside i've put a expose callback function. And, until yesterday, I was using a timeout callback to queue a draw event. Timeout set to 30 ms. It was very cpu consuming. So I changed it, to queue draw events on a idle callback, if an update flag is set, and I set that flag from a timeout callback. Why? Because the idle loop was executed too many times, so I have this restricted to a timeout.. Well, at this point, the problem is that it keeps using too much cpu! :-) so, i don't know what should I do. I've seen that there are some gtk's idle_add_priority function, but I don't have that one in python-gtk2 2.0.0-1, debian's module. And also I'm not sure if using that is the right way to do the things. Maybe this question is more gtk-related than pygtk. Well, anyway, I think that with idletimeout implementation that I did, the cpu wasting I have is constant when I draw more objects on the DrawableArea.. Well, that's all, thanks in advance! alejandro -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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] ANNOUNCE: PyGTK 2.0.0
Nice to see this release! One question: Does pygtk works in M$ Windows? If not, what should be done to get that? Thanks! ___ 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] Can't get key-press-events..
Hi. I'm using python-gtk21.99.17-3 on debian. The problem is that i can't get keypress events, and, i'm getting the button-press-events in right way. I'm tryng to get them, on a subclass of gtk.DrawingArea. The code is this: self.connect(expose-event, self.area_expose_cb) self.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.add_events(gtk.gdk.KEY_PRESS) self.connect(button_press_event,self.someevent) self.connect(key_press_event,self.someevent) #self.connect(key-press-event,self.keyevent) I'm not too familiar with python-gtk, i make all the tests that could help. the first: button-press-event works correctly. I tried without the button_press.. Also i tried wrapping my DA subclass on a gtk.EventBox.. but keeps failing. Well.. any help would be appreciated. Now i'm going to check te value of gtk.gdk.KEY_PRESS. Thanks a lot. david -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ 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] Can't get key-press events..
Well.. main window seems to get the events.. so it should be some focus-related issue, i mean, i only have that widget, but never setup the focus.. so .. that should be.. david -- + There is no dark side of the moon really. Matter of fact it's all dark. ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/