python - wxpython: Transparent panel in wxpython -


it possible make whole frame transparent using settransparent(val) in wxpython. can make single panel in transparent?

i tried using panelobj.settransparent(val) didnt work.

import wx  class myframe(wx.frame):     def __init__(self, parent, id, title):         wx.frame.__init__(self, parent, id, title,size=(250, 250))          toppanel = wx.panel(self)          panel1 = wx.panel(toppanel, -1)         panel1.settransparent(100)         panel2 = wx.panel(toppanel, -1)         panel2.setbackgroundcolour('gray')          sizer = wx.boxsizer(wx.vertical)         sizer.add(panel1,1,flag = wx.expand|wx.all)         sizer.add(panel2,1,flag = wx.expand|wx.all)          toppanel.setsizer(sizer)    class myapp(wx.app):      def oninit(self):          frame = myframe(none, -1, 'frame')          frame.show(true)          return true  app = myapp(0) app.mainloop() 

supposing want set transparency panel1.

it's platform-specific windows can , can't made transparent.

the cansettransparent method allows check whether window's transparency can toggled @ runtime. if returns false, settransparent (usually) nothing, , shouldn't call it.

off top of head (but don't quote me on this—it must documented somewhere, can't find it…):

  • mac os x cocoa build: can transparent.
  • mac os x carbon build (which nobody uses anymore): top-level windows can transparent.
  • windows: top-level windows can transparent.
  • x11 compositor: can transparent.
  • x11 without compositor: nothing can transparent.
  • wayland (which still experimental): can transparent.

however, windows special case. while can't toggle sub-window's transparency, or set percentage, can make transparent @ creation time, shown in ρss's answer.

so, if that's you're looking for, , want portably possible, you'll want this:

style = wx.transparent_window if sys.platform.lower() == 'win32' else 0 panel1 = wx.panel(toppanel, -1, style=style) if panel1.cansettransparent:     panel1.settransparent(100) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -