Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxPython中的面板不透明_Python_Python 2.7_Wxpython_Panel - Fatal编程技术网

wxPython中的面板不透明

wxPython中的面板不透明,python,python-2.7,wxpython,panel,Python,Python 2.7,Wxpython,Panel,我试图使panel1和panel2透明,即背景图像应可见。但这是失败的吗?我正在使用panel1.SetTransparent,但它仍然不起作用。有人能说出原因吗。谢谢 import wx class MainPanel(wx.Panel): """""" #---------------------------------------------------------------------- def __init__(self, parent,size): """Construc

我试图使panel1和panel2透明,即背景图像应可见。但这是失败的吗?我正在使用panel1.SetTransparent,但它仍然不起作用。有人能说出原因吗。谢谢

import wx
class MainPanel(wx.Panel):
""""""

#----------------------------------------------------------------------
def __init__(self, parent,size):
    """Constructor"""
    wx.Panel.__init__(self, parent=parent,size=size)
    self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
    self.frame = parent

    #sizer = wx.BoxSizer(wx.VERTICAL)
    #hSizer = wx.BoxSizer(wx.HORIZONTAL)


    self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)

#----------------------------------------------------------------------
def OnEraseBackground(self, evt):
    """
    Add a picture to the background
    """
    # yanked from ColourDB.py
    dc = evt.GetDC()

    if not dc:
        dc = wx.ClientDC(self)
        rect = self.GetUpdateRegion().GetBox()
        dc.SetClippingRect(rect)
    dc.Clear()
    bmp = wx.Bitmap("v:/IMAG0081.jpg")
    dc.DrawBitmap(bmp, 0, 0)


  ########################################################################
class MainFrame(wx.Frame):
  """"""

#----------------------------------------------------------------------
def __init__(self):
    """Constructor"""
    wx.Frame.__init__(self, None, size=(600,450))
    panel1 = MainPanel(self,size=(600,450))
    panel2 = wx.Panel(panel1, -1,size=(600,200),style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)
    panel2.SetTransparent(100)
    panel3 = wx.Panel(panel1, -1,pos=(0,200),size=(600,200),style=wx.BORDER_SUNKEN)
    panel3.SetTransparent(200)
   # panel4 = MainPanel(panel1,size=(600,200))
    #panel2 =MainPanel(panel, -1,size=(600,200),style=wx.BORDER_SUNKEN)

    self.Center()
class Main(wx.App):
""""""

#----------------------------------------------------------------------
def __init__(self, redirect=False, filename=None):
    """Constructor"""
    wx.App.__init__(self, redirect, filename)
    dlg = MainFrame()
    dlg.Show()

#----------------------------------------------------------------------  
if __name__ == "__main__":
app = Main()
app.MainLoop()