import wx
from wx.adv import Animation,AnimationCtrl
from wx import Image as image
class MyFrame(wx.Frame):
def __init__(self):
super().__init__(None, title='桌宠', size=(200, 200))
self.SetWindowStyle(wx.STAY_ON_TOP) # 设置窗口总在最上层
self.Bind(wx.EVT_CLOSE, self.on_close) # 绑定关闭事件
def on_close(self, event):
self.Destroy() # 关闭窗口时销毁
class Trans(wx.Frame):
def __init__(self,parent,title):
super(Trans,self).__init__(parent, title = title,size = (330,380),style = wx.SYSTEM_MENU|wx.CAPTION|wx.TE_MULTILINE | wx.HSCROLL)
self.panel = wx.Panel(self)
self.a = AnimationCtrl(self.panel,-1,Animation("E:/2022/python/test/桌宠动图/sun4.gif"),pos = (0,0),size =(20000,20000))
self.a.SetTransparent(15011111)
self.a.Play()
box_sizer = wx.BoxSizer(wx.VERTICAL)
box_sizer.Add(self.a, 1, wx.EXPAND)
self.panel.SetSizer(box_sizer)
self.box = wx.BoxSizer(wx.VERTICAL)
self.panel.SetSizer(self.box)
self.Show(True)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.panel, 1, wx.EXPAND)
self.SetSizer(sizer)
self.Layout()
frame = wx.Frame(None, style=wx.TRANSPARENT_WINDOW)
self.a.SetTransparent(111111)
self.SetTransparent(40)
self.timer = wx.Timer(self)
self.timer.Start(1) # 每隔1秒更新文本
app = wx.App()
window = Trans(None, '')
app.MainLoop()
谢谢大家