473,699 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

made a eventbox invisible in a transparent window??

1 New Member
hi everyone
im making a transparent window. look pretty cool (python gtk cairo)
i added some buttons and they look very ugly
so add just images instead buttons, look grate again,even the animated and transparent images look ok, but image don't have "clicked" events
then put images into eventbox, work, but a rectangle surround the image, eventbox is not transparent
there is some way to make them transparent?

i lend here an example script and a image. hope some one can help me =3

Expand|Select|Wrap|Line Numbers
  1. import sys
  2. import gobject
  3. import pango
  4. sys.path[:0] = ['/usr/local/lib/python2.4/site-packages/gtk-2.0']
  5. import pygtk
  6. pygtk.require('2.0')
  7. import gtk
  8. from gtk import gdk
  9. import cairo
  10.  
  11. if gtk.pygtk_version < (2,9,0):
  12.     print "PyGtk 2.9.0 or later required"
  13.     raise SystemExit
  14. supports_alpha = False
  15.  
  16. def ejemplo(widget,event,data="....."):
  17.     print data
  18.  
  19. def expose(widget, event):
  20.     global supports_alpha
  21.  
  22.     cr = widget.window.cairo_create()
  23.  
  24.     if supports_alpha == True:
  25.         cr.set_source_rgba(0, 0, 0, 0.6) # Transparent
  26.     else:
  27.         cr.set_source_rgb(1.0, 1.0, 1.0) # Opaque white
  28.  
  29.     # Draw the background
  30.     cr.set_operator(cairo.OPERATOR_SOURCE)
  31.     cr.paint()
  32.  
  33.     cr.fill()
  34.     cr.stroke()
  35.     return False
  36.  
  37. def screen_changed(widget, old_screen=None):
  38.  
  39.     global supports_alpha
  40.  
  41.     # To check if the display supports alpha channels, get the colormap
  42.     screen = widget.get_screen()
  43.     colormap = screen.get_rgba_colormap()
  44.     if colormap == None:
  45.         print 'Your screen does not support alpha channels!'
  46.         colormap = screen.get_rgb_colormap()
  47.         supports_alpha = False
  48.     else:
  49.         print 'Your screen supports alpha channels!'
  50.         supports_alpha = True
  51.  
  52.     # Now we have a colormap appropriate for the screen, use it
  53.     widget.set_colormap(colormap)
  54.  
  55.     return False
  56.  
  57. def main(args):
  58.     win = gtk.Window()
  59.  
  60.     win.set_title('Alpha Demo')
  61.     win.connect('delete-event', gtk.main_quit)
  62.     win.set_app_paintable(True)
  63.     win.connect('expose-event', expose)
  64.     win.connect('screen-changed', screen_changed)
  65.     win.set_decorated(True)
  66.     win.add_events(gdk.BUTTON_PRESS_MASK)
  67.     win.set_default_size(920,460) 
  68.     #win.connect('button-press-event', clicked)    
  69.     screen_changed(win)
  70.     hbox = gtk.HBox(False,0)
  71.     ima = gtk.Image()
  72.     ima.set_from_file("folder_orange_open.png")
  73.     bot = gtk.Button()
  74.     bot.connect("clicked",ejemplo,"folder_orange_open.png")
  75.     bot.add(ima)
  76.     hbox.pack_start(bot,False,False,20)
  77.  
  78.     ima2 = gtk.Image()
  79.     ima2.set_from_file("folder_orange_open.png")
  80.     hbox.pack_start(ima2,False,False,20)
  81.  
  82.     ima3 = gtk.Image()
  83.     ima3.set_from_file("folder_orange_open.png")
  84.     e = gtk.EventBox()
  85.     e.add(ima3)
  86.     e.connect("button_press_event",ejemplo,"eventbox")
  87.     hbox.pack_start(e,False,False,20)
  88.  
  89.  
  90.     vbox = gtk.VBox(False,0)
  91.     vbox.pack_start(hbox,False,True,50)    
  92.     win.add(vbox)
  93.     win.show_all()
  94.     gtk.main()
  95.  
  96.     return True
  97.  
  98. if __name__ == '__main__':
  99.     sys.exit(main(sys.argv))    
  100.  
  101.  
Attached Images
File Type: png folder_orange_open.png (3.2 KB, 151 views)
Aug 26 '12 #1
0 1732

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2681
by: joe | last post by:
I have a 50% transparent window that is on top of the desktop. I want the user to be able to click 'Through the transparent window' onto objects behind it ... my computer. The transparent window does not need force it just needs to be ontop of all the other windows. another example is .. if you press alt-ctrl-del to bring up task manager how can i program the window to pass mouse clicks on it to the window behined it, if task manger...
0
1496
by: Never Best | last post by:
hello, I was curious if someone here could help... I basically want to put a transparent window infront of a fullscreen application and keep drawing text onto the transparent window (basically the transparent window wont affect the fullscreen application in anyway, just use to display information). The fullscreen application is an external program. I've tried using the "setTopMost" but it only puting the window I created above all the...
3
1916
by: Wolfgang | last post by:
Is it possible in C# .NET to create a window that is always on top of all other windows, while at the same time being partially transparent? If not in C# .NET, how about in C++ .NET? As an example that this kind of thing is possible, the splash screen of Adobe Reader (formely Acrobat) seems to be partially transparent. If you have a code snippet of how something like this could be done, that would be great.
0
959
by: Max | last post by:
Hello Everyone, I have written a VB.NET application that uses a transparent panel. I display various forms and one external COM application in my transparent panel (one at a time). When I resize my panel or change its location, then theform or application that fills the transparent panel resizes or moves as needed. However, I have a problem when a user selects another
3
3038
by: Wolfgang | last post by:
Is it possible in VB .NET to create a window that is always on top of all other windows, while at the same time being partially transparent? As example that this kind of thing is possible, the splash screen of Adobe Reader (formely Acrobat) seems to be partially transparent. If you have a code snippet of how something like this could be done, that would be great. Thanks,
1
3133
by: ShurikAg | last post by:
Hi, I have this kind of class: // SplashWnd.cpp : implementation of the CSplashWnd class // /////////////////////////////////////////////////////////////////////////////
1
2524
by: yuban | last post by:
I am trying ( so far in vain ) to display a normal looking ( non-transparent ) control in a transparent window. I am attempting this in C++, on Vista ( argh ), and having no luck at all. Our transparent window has been accomplished with the infamous "DwmExtendFrameIntoClientArea()" call, which of course implies that "composition" is enabled. If someone can tell me how to simply render an icon or bitmap so that it is not see-through, I would...
4
3212
by: TS | last post by:
I am losing my colgroup html element of a table that i toggle back and forth of being visible=true/false. is there any workaround since the rendered html doesn't contain it even though it has not been explicitely been made invisible? note also that even when the table is made visible=true, colgroup still doesn't show up
1
1907
by: Terry | last post by:
Hi again folks, After getting my page (http://theamazing.onlinewebshop.net/spotlight/) to work in Firefox and Safari. I thought I would try to get in working in IE. My attempt is here: http://theamazing.onlinewebshop.net/light/ Unfortunately, the transparent window is not enclosing the mouse
1
1429
by: ranpelt | last post by:
Hi folks, After getting my page (http://theamazing.onlinewebshop.net/spotlight/) to work in Firefox and Safari. I thought I would try to get in working in IE. My attempt is here: http://theamazing.onlinewebshop.net/light/ Unfortunately, the transparent window is not enclosing the mouse position when the mouse is over the image. Also, the transparent window is jumping around.
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8944
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8899
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7786
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2364
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.