GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Aug 31, 2014 6:17 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 5:56 pm 
Offline
Familiar Face

Joined: Mon Feb 25, 2013 12:50 am
Posts: 5
Hi,

I see that gtk.STOCK_* images often have a flipped, "RTL" variant. I want to use the RTL variant of STOCK_MEDIA_PLAY here:
http://python-gtk-3-tutorial.readthedoc ... stock.html

After much searching, I can't figure out how to to use the RTL variant. Anyone know how to do this, or to simply horizontally flip STOCK_MEDIA_PLAY so the triangle points left instead of right?

Thanks!

Jeremy.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 6:35 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Hi,

The RTL (Right To Left) variants are automatically used when the language used is written Right To Left such as Arabic. It is therefore best not to force the use of a locale dependent stock icon. Also the icon can vary depending on the theme and icon set installed.

If you really need to have a specific icon it may be best to design it yourself and use it where needed.

_________________
E.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 6:50 pm 
Offline
Familiar Face

Joined: Mon Feb 25, 2013 12:50 am
Posts: 5
Thanks for the quick reply! Then is there a quick way to manually flip the image? I tried using img.get_pixbuf() but I get "ValueError: image should be a GdkPixbuf or empty".

Jeremy.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 7:31 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
No, don't flip a stock icon as this is not good practice and you may not always get what you expect. It also means that your application will not translate properly.

If you want the arrows to point in a particular direction design or obtain your own icons and use these instead. This way you are not changing the meaning of the stock icons.

_________________
E.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 8:33 pm 
Offline
Familiar Face

Joined: Mon Feb 25, 2013 12:50 am
Posts: 5
I don't want to permanently change the meaning of STOCK_MEDIA_PLAY, I just want to flip it for one button - something like:

img = gtk.Image()
img.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_LARGE_TOOLBAR)

##
##...some manipulation to flip the image...
##

playReverseButton.set_image(img)


I would much rather not to have to package a single separate image file along with my application, which is otherwise just one .py file, especially since the image needed is a simple reverse of a stock image. So if there's any way to do some on-the-fly manipulation of the pre-existing STOCK_MEDIA_PLAY image that would be ideal, perhaps by extracting a GdkPixbuf from the image.

Sorry to be so picky, it just feels like there should be some relatively simple way to accomplish this, especially since the RTL feature means the exact image I want is hidden somewhere within the functionality of gtk. Then again, I'm certainly no expert.

Jeremy.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Mon Feb 25, 2013 10:03 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Yes it is possible to extract the GdkPixbuf and manipulate it. Just be warned it will very likely not be what you want if your application was to run on another system where the default text writing system is RTL (Right To Left). It may be that the icons are completely different and possibly not even be an arrow!!! even on a system with LTR (Left To Right) writing systems.

So if you were to flip a stock icon what you may be doing is taking something that has some meaning and turning it into a flipped version which may not have any meaning any more. For example the icon for STOCK_MEDIA_PLAY could possibly be the letter "P" for "Play" or a kanji character. And flipping these would make no sense at all.

Even the stock icons installed on my system is different from the examples given in the documentation.

My advise is if you need a set of arrows that point in a particular direction then create them yourself. And basic triangles can be created with code if needed.

_________________
E.


Top
 Profile  
 
 Post subject: Re: How to use RTL (flipped) version of a button image.
PostPosted: Tue Feb 26, 2013 4:21 am 
Offline
Familiar Face

Joined: Mon Feb 25, 2013 12:50 am
Posts: 5
Great! I managed to get a pixbuf out of the stock image and flip it. I'm not too concerned about portability - this app will have limited distribution to say the least, and even if it ends up being a backwards P or whatever, the fact that it's the reverse of the "play" icon should be communicative enough, and more consistent with whatever stock image scheme is being used than a custom icon built by me.

Thanks very much for your help!

Jeremy.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group