Draw text over image

View: New views
5 Messages — Rating Filter:   Alert me  

Draw text over image

by Rafael Ferreira Silva :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm new to pygtk and gtk and have been doing some tests and most of them are very successful (thanks for the excelent tutorial and api documentation)!

I have a question, and hope you could help me. I have a gtk.Image within a eventbox. The image is resized when the containter is resized. I want to write some text over this image and resize the text (proportional). My text is a pango layout.

I've made most part of it, but there are 2 problems: sometimes, when the eventbox is resized the text simply disapear and allways there's a flash when the text is refreshed.

Ok, probably that isn't the correct way to do this task, and that's why I'm here. Could anybody help me find the best way to write a text over an image (that's all I need for now)?

I've been looking on google and list archive but I didn't found anything about draw a text over an image.

Thank you in advance!
_______________________________________________
pygtk mailing list   pygtk@...
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Re: Draw text over image

by A.T.Hofkamp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[Sorry Rafael, I pressed the 'send' button instead of cancel]

Rafael wrote:
> Hi,
>
> I have a question, and hope you could help me. I have a gtk.Image within a
> eventbox. The image is resized when the containter is resized. I want to
> write some text over this image and resize the text (proportional). My text
> is a pango layout.

Why don't you use a DrawingArea, and render the image and the text yourself?



Albert
_______________________________________________
pygtk mailing list   pygtk@...
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Re: Draw text over image

by Rafael Ferreira Silva :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Aug 5, 2008 at 7:34 AM, A.T.Hofkamp <a.t.hofkamp@...> wrote:
[Sorry Rafael, I pressed the 'send' button instead of cancel]

Rafael wrote:
Hi,


I have a question, and hope you could help me. I have a gtk.Image within a
eventbox. The image is resized when the containter is resized. I want to
write some text over this image and resize the text (proportional). My text
is a pango layout.

Why don't you use a DrawingArea, and render the image and the text yourself?



Albert

Hi Albert,

Thank you for your help. I've been playing with the drawingarea and finally now I can do what I want. My problem, besides the wrong component, was on using wrong events.
Thank you again.

--
Rafael Ferreira Silva - Web Developer
http://rafaelsilva.net
http://drupal-br.org

_______________________________________________
pygtk mailing list   pygtk@...
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Re: Draw text over image

by ilius :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I need to draw a text on a pixbuf (and use in tray icon). I found a way that alraedy WORKS on GNU/Linux (varoius disto's with PyGTK >= 2.10.x) and windows-xp (with PyGTK 2.12.1). But that was very hard to find this way by too many searching an too many experimentation. Then I put my code here maybe help other programmers (that will google on their problem)
My code looks like this:

pixbuf = gtk.gdk.pixbuf_new_from_file('bx-green.png')
drawable = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0]
textLay = self.dialog.create_pango_layout(numLocal(ddate[2]))
(w, h) = textLay.get_pixel_size()
drawable.draw_layout(drawable.new_gc(), (22-w)/2.0, 5+(19-h)/2.0, textLay, None, None)
self.trayPix.get_from_drawable(drawable, self.dialog.get_screen().get_system_colormap(), 0, 0, 0, 0, -1, -1)
self.statusIcon.set_from_pixbuf(self.trayPix)

Re: Draw text over image

by HDA :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,
I am struggling for display button with image on GTK.treeview.
I can display button with text label.
here is the sample code attached treecall.py which will display button on tree view.
suggestions will be appreciated.

treecall.py