我正在使用文本编辑器,我希望菜单具有菜单选项以使窗口透明,例如this.,这是我的文本编辑器:
import wx
import wx.stc as stc
class Window(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500, 500))
self.control = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
def main():
app = wx.App()
frame = Window(None, "Text Editor")
frame.Show()
app.MainLoop()
if __name__ == '__main__':
main()
谢谢:)
答案 0 :(得分:0)
wx.Window
具有SetTransparent
函数和CanSetTransparent
函数以测试可用性。
0(零)是完全透明的-255是完全不透明
import wx
import wx.stc as stc
class Window(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500, 500))
self.control = wx.stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
self.Trans = wx.Button(self, -1,"Transparent")
self.Trans.Bind(wx.EVT_BUTTON, self.OnTrans)
self.t_state = False
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.control,1,wx.EXPAND,0)
sizer.Add(self.Trans,0,0,0)
self.SetSizerAndFit(sizer)
self.Layout()
self.Show()
#self.OnTrans(None) #Initial Start-up in transparent mode
def OnTrans(self, event):
if not self.t_state:
self.SetTransparent(200)
else:
self.SetTransparent(255)
self.t_state = not self.t_state
def main():
app = wx.App()
frame = Window(None, "Text Editor")
app.MainLoop()
if __name__ == '__main__':
main()