【发布时间】:2019-08-18 05:55:07
【问题描述】:
我正在尝试在系统托盘中显示动态文本(这将是 2 个数字(从 1 到 100)每 2 分钟更改一次)。
我发现这个script 是一个起点(但我没有承诺!)。
但我收到此错误:
TypeError: Image.SetData(): arguments did not match any overloaded call:
overload 1: argument 1 has unexpected type 'str'
overload 2: argument 1 has unexpected type 'str'
OnInit returned false, exiting...
代码的相关部分是:
def Get(self,l,r):
s=""+self.s_line
for i in range(5):
if i<(5-l):
sl = self.sl_off
else:
sl = self.sl_on
if i<(5-r):
sr = self.sr_off
else:
sr = self.sr_on
s+=self.s_border+sl+self.s_point+sr+self.s_point
s+=self.s_border+sl+self.s_point+sr+self.s_point
s+=self.s_line
image = wx.EmptyImage(16,16)
image.SetData(s)
bmp = image.ConvertToBitmap()
bmp.SetMask(wx.Mask(bmp, wx.WHITE)) #sets the transparency colour to white
icon = wx.EmptyIcon()
icon.CopyFromBitmap(bmp)
return icon
我通过添加 import wx.adv 并将 2 wx.TaskBarIcon 替换为 wx.adv.TaskBarIcon 来添加更新脚本。
我在 Windows 10 上使用 Python 3.6
【问题讨论】:
标签: python python-3.x wxpython system-tray