如何创建祝酒通知(带按钮!)使用win32api?

2024-09-19 23:45:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用win10toast library(链接到我试图修改的init文件)有一段时间了,我有一个问题:

如何修改模块,使其具有两个按钮的toast通知,比如win32gui、win32api、win32con libs?在

我一直在使用init代码,试图在第83行的self.hwnd = CreateWindow(...)中添加一个子元素,如下所示:

class ToastNotifier(object):

....

    style = WS_CLIPCHILDREN | WS_VISIBLE | WS_OVERLAPPED | WS_SYSMENU
            styleButton = WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON

            self.hwnd = CreateWindow(self.classAtom, "Taskbar", style,
                                     0, 0, CW_USEDEFAULT,
                                     CW_USEDEFAULT,
                                     0, 0, self.hinst, None)

           """ self.hwndButton = CreateWindow("Button", "OK", styleButton,
                                     0, 0, CW_USEDEFAULT,
                                     CW_USEDEFAULT,
                                     self.hwnd, None, 0, None)"""

            self.hwndButton = CreateWindow("Button",  # Predefined class; Unicode assumed
                                        "OK",      # Button text
                                        styleButton,  # Styles
                                        0,         #// x position
                                        0,         #// y position
                                        35,        #// Button width
                                        35,        #// Button height
                                        self.hwnd,     #// Parent window
                                        None,       #// No menu.
                                        0,
                                        None)

....

但是它不起作用the way I want to(Toast通知的按钮应该是OK,而不是在单独的窗口中显示)。在

我联系了模块的作者,因为他不知道怎么做。我还在努力学习python,我对win32api不太了解。有小费吗?谢谢!在


Tags: 模块selfnonewsinitbuttonok按钮