Hi,

I'm just trying the pywin gui examples and I'm wondering why I won't receive any BN_CLICKED notifications in the code attached. Can anyone help?

Christian
from pywin.mfc import dialog, window
import win32ui
import win32con
import win32api

def MakeDlgTemplate():
    style = (win32con.DS_MODALFRAME |
             win32con.WS_POPUP |
             win32con.WS_VISIBLE |
             win32con.WS_CAPTION |
             win32con.WS_SYSMENU |
             win32con.DS_SETFONT)
    cs = (win32con.WS_CHILD |
          win32con.WS_VISIBLE)

    w = 164
    h = 264

    dlg = [["Red box",
            (0, 0, w, h),
            style,
            None,
            (9, "MS Sans Serif")],
           ]

    s = win32con.WS_TABSTOP | cs

    dlg.append([128,
                "Cancel",
                win32con.IDCANCEL,
                (7, h - 18, 50, 14), s | win32con.BS_PUSHBUTTON])

    dlg.append([128,
                "Ok",
                win32con.IDOK,
                (57, h - 18, 50, 14), s | win32con.BS_PUSHBUTTON])

    return dlg

class TestDialog(dialog.Dialog):
        def OnInitDialog(self):
                rc = dialog.Dialog.OnInitDialog(self)
                self.btn = win32ui.CreateButton()
                self.btn.CreateWindow('button', 
win32con.BS_PUSHBUTTON|win32con.WS_CHILD|win32con.WS_VISIBLE, (5, 5, 140, 140), 
self, 1001)

                self.HookNotify(self.OnNotify, win32con.BN_CLICKED)

        def OnNotify(self, *args):
                print args

def demo():
    d = TestDialog (MakeDlgTemplate())
    d.DoModal()

if __name__=='__main__':
    demo()
    
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to