Re: [pygtk] Displaying jpg files
On Mon, May 13, 2002 at 10:59:25PM +0200, Thomas Guettler wrote: > Hi! > > I am new to pygtk, how can I display a jpg file? > > BTW, I tried to read the FAQ, but async.com.br is unavailable. The FAQ is available again, I found the answer how to display a jpeg. Maybe the FAQ should contain how to scale an image, too. I do like this: #start img=GdkImlib.Image("foo.jpg") size=600 width=img.rgb_width height=img.rgb_height print width, height if width>height: height=(size*height)/width width=size else: width=(size*width)/height height=size print width, height img.render(width, height) pixmap=img.make_pixmap() self.vbox.pack_start(pixmap, gtk.TRUE, gtk.TRUE, 0) pixmap.show() #end Is this the right way? thomas -- Thomas Guettler <[EMAIL PROTECTED]> http://www.thomas-guettler.de ___ 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] Displaying jpg files
Hi! I am new to pygtk, how can I display a jpg file? BTW, I tried to read the FAQ, but async.com.br is unavailable. thomas -- Thomas Guettler <[EMAIL PROTECTED]> http://www.thomas-guettler.de ___ 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] Typo in FAQ
At 2:06 PM -0400 5/14/02, Shandy Brown wrote: > > """ >> 1.7. Where are the reference manuals? >> However, the Python mapping is quite straightforward *wrt* the C >>API, so it is quite useful in general >> """ > >WRT stands for With Respect To. > >Maybe this should be capitalized in the FAQ. > > > """ In other words, you can attach any number of references to any > > GtkObject and, with the string you set() them *with, retrieve them*. >> """ > >Sounds like correct grammar to me. > >Would this make it clearer? > > GtkObject and, *using* the string you set() them with, retrieve them. It is correct, but bad grammar. IMO something like this would be better: "In other words, you can attach any number of references to any GtkObject and retrieve them using the string you set() them with." -Ben -- http://homepage.mac.com/bhines/ ___ 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] canvas item callbacks
Hmmm, I've run across this also. It turned out that I needed to create a shared library. If the original file is foo.c, compile it to foo.o then create a shared object called foo.so with ld -shared foo.o -o foo.so. Then it won't mind the undefined symbol (which gets loaded at run time) Mathew > I have a feeling that I'm still doing something wrong, because calling > the macros from pygtk.h was harder than it ought to be. I'm > including pygtk.h like this: > >#define NO_IMPORT_PYGTK >#include >#undef NO_IMPORT_PYGTK > > That works as long as I don't use any macros. If I call > PyGtk_BlockThreads, then python complains that _PyGtk_API is > undefined and won't load my module's .so file. So I declared my own > copy of _PyGtk_API, which feels like the wrong thing to do, but seems > to work. Then I initialize it by duplicating the init_pygtk macro. > (The reason that I can't just call init_pygtk directly is that it > won't compile with g++. g++ says that the line > _PyGtk_API = PyCObject_AsVoidPtr(cobject); > requires an explicit cast.) > > Thanks again. > > -- Steve > > > -- > /* EMail: [EMAIL PROTECTED] -- Phone: (301) 975-5423 -- > -- WWW: http://math.nist.gov/~SLanger/ Fax: (301) 990-4127 -- > -- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, MD 20899-8910 */ ___ 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] canvas item callbacks
On Tue, May 14, 2002 at 04:10:14PM -0700, Mathew Yeates wrote: > > I'm going to make a wild ass guess here. Have you tried inserting > the macros to block threads? Can't remember exactly what they are > but I've seen tons of examples in the pygtk code. > > Mathew For a wild ass guess, that was pretty good! I had to jump through a few hoops to make the macro calls within C++, but after I did that the python callbacks from the gtk canvas callbacks work. I have a feeling that I'm still doing something wrong, because calling the macros from pygtk.h was harder than it ought to be. I'm including pygtk.h like this: #define NO_IMPORT_PYGTK #include #undef NO_IMPORT_PYGTK That works as long as I don't use any macros. If I call PyGtk_BlockThreads, then python complains that _PyGtk_API is undefined and won't load my module's .so file. So I declared my own copy of _PyGtk_API, which feels like the wrong thing to do, but seems to work. Then I initialize it by duplicating the init_pygtk macro. (The reason that I can't just call init_pygtk directly is that it won't compile with g++. g++ says that the line _PyGtk_API = PyCObject_AsVoidPtr(cobject); requires an explicit cast.) Thanks again. -- Steve -- /* EMail: [EMAIL PROTECTED] -- Phone: (301) 975-5423 -- -- WWW: http://math.nist.gov/~SLanger/ Fax: (301) 990-4127 -- -- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, MD 20899-8910 */ ___ 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] regenerated documentation
I regenerated the documentation found at: http://www.gnome.org/~james/pygtk-docs/ The script hasn't changed yet (so it still doesn't list functions, interfaces, boxed types or pointer types), but the defs files in pygtk are now up to date with the 2.0 API, and more of gtk has been documented. It contains combined documentation for the pango, atk, gtk, gtk.gdk and gtk.glade modules. James. -- Email: [EMAIL PROTECTED] | Linux.conf.au 2003 Call for Papers out WWW: http://www.daa.com.au/~james/ | http://conf.linux.org.au/cfp.html ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] pygtk2 DND
Tom Morton wrote: >Hi, > >Does anyone know how to get drag-n-drop working in pygtk2? I've looked at >the C docs and the API doesn't appear to have changed much, but >drag_data_received is never called. The DnD demo in the pygtk2 examples >seems to be broken in the same way. > This is probably related to the following bug: http://bugzilla.gnome.org/show_bug.cgi?id=67813 I have to get round to addressing that one ... > >Eek.. and something else entirely: I can't figure out how to change the >text attributes of one row in a GtkTreeView. It is a CellRendererText >and i'd like some rows to be in bold (it is an emailer. bold marks unread >messages or whatever).. > Simply add an int column to your model that is set to either pango.WEIGHT_NORMAL or pango.WEIGHT_BOLD. Then map the "weight" attribute of the text cell renderer to this column, the same way you would map the "text" attribute. James. -- Email: [EMAIL PROTECTED] | Linux.conf.au 2003 Call for Papers out WWW: http://www.daa.com.au/~james/ | http://conf.linux.org.au/cfp.html ___ 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] pygtk2 DND
Hi, Does anyone know how to get drag-n-drop working in pygtk2? I've looked at the C docs and the API doesn't appear to have changed much, but drag_data_received is never called. The DnD demo in the pygtk2 examples seems to be broken in the same way. Eek.. and something else entirely: I can't figure out how to change the text attributes of one row in a GtkTreeView. It is a CellRendererText and i'd like some rows to be in bold (it is an emailer. bold marks unread messages or whatever).. Thanks, -- Tom "Moretom" Morton (www.moretom.net) ___ 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] canvas item callbacks
I'm going to make a wild ass guess here. Have you tried inserting the macros to block threads? Can't remember exactly what they are but I've seen tons of examples in the pygtk code. Mathew > > I'm encountering some strange behavior and hope someone on this list > can provide some insight. We're using pygtk 0.6.8 with python 2.1, > and gtk-canvas 0.1. We're using the gtk-canvas instead of > gnome-canvas so that our users don't have to install all of gnome. A > disadvantage of that is that we have to create our own python wrappers > for the canvas functions. Everything was fine until I tried to > extract mouse click coordinates. > > Here's what happens. There's a C++ class, OOFCanvas, that wraps the > gtk-canvas. It has a set_callback() function which looks like this: > > void OOFCanvas::set_callback(PyObject *callback) { > pycallback = callback; // pycallback is OOFCanvas instance data > Py_XINCREF(callback); > gtk_signal_connect(GTK_OBJECT(root), // root is the gtk_canvas_root > "event", >GTK_SIGNAL_FUNC(OOFCanvas::mouse_event), > this); > } > > set_callback() is SWIGged, and I know that its argument is being > handled correctly, since I can call the callback under other > circumstances. (The SWIG typemap uses PyCallable_Check to verify that > the argument is sane.) > > When the canvas gets an event, it calls the static function > OOFCanvas::mouse_event, which just calls a non-static function: > > gint OOFCanvas::mouse_event(GtkCanvasItem *item, GdkEvent *event, gpointer data) > { > OOFCanvas *oofcanvas = (OOFCanvas*)(data); > oofcanvas->mouse_eventCB(item, event); > return TRUE; > } > > That non-static function invokes the Python callback: > > void OOFCanvas::mouse_eventCB(GtkCanvasItem *item, GdkEvent *event) { > PyObject *args = 0; > switch(event->type) { > case GDK_MOTION_NOTIFY: > args = Py_BuildValue("(sdd)", "motion_notify", >event->motion.x, event->motion.y); > break; > // [ several other event types omitted ] > } > if(args) { > PyObject *result = PyEval_CallObject(pycallback, args); // dumps core! > Py_XDECREF(args); > Py_XDECREF(result); > } > } > > The call to PyEval_CallObject() dumps core. I know that the argument > is being constructed correctly, since I can print it with > PyString_AsString(PyObject_Repr(args)). I know that the callback is > set correctly, since I can examine it in the same way. I can even > call the callback function successfully (but not usefully) if I call > it from set_callback(). It just doesn't work when I call it from > within a GtkCanvasItem signal callback! > > Is there something special that I have to do to when calling Python > from C within a C gtk signal callback? I can call the same Python > function successfully, with the same C++ code, as long as I don't call > it from within the signal handler. > > Any advice would be much appreciated. > >-- Steve > > > > > -- > /* EMail: [EMAIL PROTECTED] -- Phone: (301) 975-5423 -- > -- WWW: http://math.nist.gov/~SLanger/ Fax: (301) 990-4127 -- > -- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, MD 20899-8910 */ > ___ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] GtkTreeView Woes (again)
First a bribe -- in return for help/fixes here I'll write up my experiences with gtk.GenericTreeModel... I have a custom model which inherits from gtk.GenericTreeModel. My code calls view.get_selection().selected_foreach(worker) which iterates over every selected row and calls worker() with a path and an iterator. However, this iterator is not an iterator in the GenericTreeModel way of thinking -- it is a real GtkTreeIter. This seems fine but when I call my method in the custom model it cannot do anything with it! I have lost the "wrapped" GtkTreeIter (a simple Python object, which I was using as an integer index into a internal list). I cannot convert the given path into an iterator as I get a real GtkTreeIter again, and the method I want to call needs an index which is stored in the user data. Argh! I can post code samples if my poor explanation is not good enough (it will force me to clean up the poor code :) Thanks, Ross -- Ross Burton mail: [EMAIL PROTECTED] jabber: [EMAIL PROTECTED] diary: http://advogato.org/person/RossBurton PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF ___ 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] canvas item callbacks
I'm encountering some strange behavior and hope someone on this list can provide some insight. We're using pygtk 0.6.8 with python 2.1, and gtk-canvas 0.1. We're using the gtk-canvas instead of gnome-canvas so that our users don't have to install all of gnome. A disadvantage of that is that we have to create our own python wrappers for the canvas functions. Everything was fine until I tried to extract mouse click coordinates. Here's what happens. There's a C++ class, OOFCanvas, that wraps the gtk-canvas. It has a set_callback() function which looks like this: void OOFCanvas::set_callback(PyObject *callback) { pycallback = callback; // pycallback is OOFCanvas instance data Py_XINCREF(callback); gtk_signal_connect(GTK_OBJECT(root), // root is the gtk_canvas_root "event", GTK_SIGNAL_FUNC(OOFCanvas::mouse_event), this); } set_callback() is SWIGged, and I know that its argument is being handled correctly, since I can call the callback under other circumstances. (The SWIG typemap uses PyCallable_Check to verify that the argument is sane.) When the canvas gets an event, it calls the static function OOFCanvas::mouse_event, which just calls a non-static function: gint OOFCanvas::mouse_event(GtkCanvasItem *item, GdkEvent *event, gpointer data) { OOFCanvas *oofcanvas = (OOFCanvas*)(data); oofcanvas->mouse_eventCB(item, event); return TRUE; } That non-static function invokes the Python callback: void OOFCanvas::mouse_eventCB(GtkCanvasItem *item, GdkEvent *event) { PyObject *args = 0; switch(event->type) { case GDK_MOTION_NOTIFY: args = Py_BuildValue("(sdd)", "motion_notify", event->motion.x, event->motion.y); break; // [ several other event types omitted ] } if(args) { PyObject *result = PyEval_CallObject(pycallback, args); // dumps core! Py_XDECREF(args); Py_XDECREF(result); } } The call to PyEval_CallObject() dumps core. I know that the argument is being constructed correctly, since I can print it with PyString_AsString(PyObject_Repr(args)). I know that the callback is set correctly, since I can examine it in the same way. I can even call the callback function successfully (but not usefully) if I call it from set_callback(). It just doesn't work when I call it from within a GtkCanvasItem signal callback! Is there something special that I have to do to when calling Python from C within a C gtk signal callback? I can call the same Python function successfully, with the same C++ code, as long as I don't call it from within the signal handler. Any advice would be much appreciated. -- Steve -- /* EMail: [EMAIL PROTECTED] -- Phone: (301) 975-5423 -- -- WWW: http://math.nist.gov/~SLanger/ Fax: (301) 990-4127 -- -- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, MD 20899-8910 */ ___ 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] Re: FAQ Question: Snooping keystrokes
On Tue, 2002-05-14 at 16:08, Christian Reis wrote: > On Sun, May 12, 2002 at 02:56:30AM -0400, Evan Hughes wrote: > > > > How can I detect whenever the user hits a key or moves the mouse? > > Added FAQ questions 3.2, 3.3 and 3.4: > > http://www.async.com.br/faq/pygtk/index.py?req=index Very nice, thanks. Is it okay for anybody (who's confident of the answer) to update the FAQ with the wizard, or are there a few people who take responsibility for keeping it current? I ask because there is a bug in the example code in 3.2; the print statement in wakeup() has bad variable substitution formats in it. This would do nicely (for PyGTK 0.6.x): def wakeup( widget, event, *args ): print "Event %d woke me up" % event.type I think that question 3.3 might benefit from a link to the GtkEventBox widget too, incase people are trying to bind events to a widget that doesn't have it's own X window. I notice that to capture a key press you don't specify GDK.KEY_PRESS_MASK, yet you can still connect the window to the key_press_event. Why does this work? My reading of the docs lead me to believe that you need to do this: w.add_events(GDK.KEY_PRESS_MASK) in order to get w.connect("key_press_event", wakeup) to work at all (but I've tested your example, and it works -- mine doesn't, see below). There's a more explicit example here (the fact that nobody replied made me wonder if it was just me that was confused): http://www.daa.com.au/pipermail/pygtk/2002-May/002757.html While we're on the subject of key snooping, why doesn't PyGTK have a binding to the GTK+ global key snooper, which would surely be a better way to do all this? Is it just that nobody needed it? -- Graham Ashton <[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] Typo in FAQ
Just my opinion, but it doesn't take that many keystrokes to type "with respect to", especially in a document like a FAQ. The reader shouldn't need to read the geek-speak FAQ first, IMHO... :) Ralph Walden Shandy Brown wrote: > > > """ > > 1.7. Where are the reference manuals? > > However, the Python mapping is quite straightforward *wrt* the C API, so it is >quite useful in general > > """ > > WRT stands for With Respect To. > > Maybe this should be capitalized in the FAQ. > > > """ In other words, you can attach any number of references to any > > GtkObject and, with the string you set() them *with, retrieve them*. > > """ > > Sounds like correct grammar to me. > > Would this make it clearer? > > GtkObject and, *using* the string you set() them with, retrieve them. > > ___ > pygtk mailing list [EMAIL PROTECTED] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ -- Ralph E. Walden Tripos, Inc. [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] Typo in FAQ
> """ > 1.7. Where are the reference manuals? > However, the Python mapping is quite straightforward *wrt* the C API, so it is quite >useful in general > """ WRT stands for With Respect To. Maybe this should be capitalized in the FAQ. > """ In other words, you can attach any number of references to any > GtkObject and, with the string you set() them *with, retrieve them*. > """ Sounds like correct grammar to me. Would this make it clearer? GtkObject and, *using* the string you set() them with, retrieve them. ___ 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] Typo in FAQ II
Found an other typo: """ In other words, you can attach any number of references to any GtkObject and, with the string you set() them *with, retrieve them*. """ I am not an native speaker, but I think this is wrong. thomas -- Thomas Guettler <[EMAIL PROTECTED]> http://www.thomas-guettler.de ___ 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] Typo in FAQ
Quote: """ 1.7. Where are the reference manuals? However, the Python mapping is quite straightforward *wrt* the C API, so it is quite useful in general """ Thank you for this FAQ und pygtk, thomas -- Thomas Guettler <[EMAIL PROTECTED]> http://www.thomas-guettler.de ___ 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: FAQ Question: Snooping keystrokes
On Sun, May 12, 2002 at 02:56:30AM -0400, Evan Hughes wrote: > > I'm interested in writing a program similar to an x screen saver. It > watches for user keystrokes, every time it receives one, it restarts a > timer. > > How can I detect whenever the user hits a key or moves the mouse? Added FAQ questions 3.2, 3.3 and 3.4: http://www.async.com.br/faq/pygtk/index.py?req=index Take care, -- Christian Reis, Senior Engineer, Async Open Source, Brazil. http://async.com.br/~kiko/ | [+55 16] 272 3330 | NMFL ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/