我正在尝试为 .Net 应用程序运行一个基本的 python。我安装了以下内容:
1) Python 33 for 32-bit
2) pythonnet-py3_beta-py3.3-win32.egg installed with easy_install
但是,每当我使用整数时,我都会收到以下错误。
例如: self.notifyIcon.ShowBalloonTip(1000) 和 timer.Interval = 60000 抛出以下错误
System.EntryPointNotFoundException: Unable to find an entry point named 'PyNumber_Int' in DLL 'python33'
请在下面找到完整的程序:
import win32gui
import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Drawing import Icon
from System.Windows.Forms import (Application, ContextMenu,
MenuItem, NotifyIcon, Timer)
class Main(object):
def __init__(self):
self.initNotifyIcon()
self.onTick(None, None)
# timer = Timer()
# timer.Interval = 60000
# timer.Tick += self.onTick
# timer.Start()
def initNotifyIcon(self):
self.notifyIcon = NotifyIcon()
self.notifyIcon.Icon = Icon("app-icon.ico")
self.notifyIcon.Visible = True
self.notifyIcon.ContextMenu = self.initContextMenu()
def onTick(self, sender, event):
self.notifyIcon.BalloonTipTitle = "Hello, I'm IronPython"
self.notifyIcon.BalloonTipText = "Who are you?"
self.notifyIcon.ShowBalloonTip(1000)
def initContextMenu(self):
contextMenu = ContextMenu()
exitMenuItem = MenuItem("Exit")
exitMenuItem.Click += self.onExit
contextMenu.MenuItems.Add(exitMenuItem)
return contextMenu
def onExit(self, sender, event):
self.notifyIcon.Visible = False
Application.Exit()
if __name__ == "__main__":
main = Main()
Application.Run()