1.消息框

mfcDialog.py

 import win32ui
 import win32con
 from pywin.mfc import dialog
 class MyDialog(dialog.Dialog):
     def OnInitDialog(self):
         dialog.Dialog.OnInitDialog(self)
     def OnOk(self):
         win32ui.MessageBox('Press OK',\
             'Python', win32con.MB_OK)
     def OnCancel(self):
         win32ui.MessageBox('Press Cancel',\
             'Python', win32con.MB_OK)
 style = (win32con.DS_MODALFRAME    |
             win32con.WS_POPUP    |
             win32con.WS_VISIBLE    |
             win32con.WS_CAPTION    |
             win32con.WS_SYSMENU    |
             win32con.DS_SETFONT)
 buttonstyle = win32con.WS_TABSTOP | win32con.WS_CHILD | win32con.WS_VISIBLE
 di = ['Python', (0,0,300,180), style, None, (8, 'MS Sans Serif')]
 ButOk = (['Button', 'OK', win32con.IDOK, (80,150,50,14), buttonstyle|win32con.BS_PUSHBUTTON])
 ButCancel = (['Button', 'Cancel', win32con.IDCANCEL, (160,150,50,14), buttonstyle|win32con.BS_PUSHBUTTON])
 init = []
 init.append(di)
 init.append(ButOk)
 init.append(ButCancel)
 mydialog = MyDialog(init)
 mydialog.DoModal()

2.窗体

mfcGui.py

 import win32ui
 import win32api
 from win32con import *
 from pywin.mfc import window
 class MyWnd(window.Wnd):
     def __init__(self):
         window.Wnd.__init__(self, win32ui.CreateWnd())
         self._obj_.CreateWindowEx(WS_EX_CLIENTEDGE, \
                 win32ui.RegisterWndClass(0, 0, COLOR_WINDOW+1), \
                 'MFC_GUI', WS_OVERLAPPEDWINDOW, \
                 (100,100,400,300), None, 0, None)
     def OnClose(self):
         self.EndModalLoop(0)
     def OnPaint(self):
         dc, ps = self.BeginPaint()
         dc.DrawText('MFC_GUI',
             self.GetClientRect(),
             DT_SINGLELINE | DT_CENTER | DT_VCENTER)
         self.EndPaint(ps)

 w = MyWnd()
 w.ShowWindow()
 w.UpdateWindow()
 w.RunModalLoop(1)

Python -- Gui编程 -- MFC的使用的更多相关文章

  1. Python GUI编程各种实现的对比

    Python GUI编程各种实现的对比 从 Python 语言的诞生之日起,就有许多优秀的 GUI 工具集整合到 Python 当中,这些优秀的 GUI 工具集,使得 Python 也可以在图形界面编 ...

  2. Python gui编程pyQt5安装步骤t

    Python gui编程pyQt5安装步骤         pip install PyQt5 Pip3 install PyQt5               https://riverbankco ...

  3. Python gui编程pyQt5安装步骤

    Python gui编程pyQt5安装步骤 =============================== -m PyQt5.uic.pyuic  $FileName$ -o $FileNameWit ...

  4. Python GUI 编程

    Python GUI编程(Tkinter) Python 提供了多个图形开发界面的库,几个常用 Python GUI 库如下: Tkinter: Tkinter 模块(Tk 接口)是 Python 的 ...

  5. Python GUI编程(Tkinter) windows界面开发

    Python实现GUI简单的来说可以调用Tkinter库,这样一般的需求都可以实现,显示简单的windows窗口代码如下: python_gui.py 1 #!C:\Python27\python.e ...

  6. Python GUI编程--Tkinter

    今天看到了GUI编程,书上推荐用wxPython,去官网上看了看,发现Windows的最高支持到2.7,我用的是3.4版本,咋办,用自带的库--Tkinter呗,它是Python的默认GUI库,几乎是 ...

  7. python GUI编程tkinter示例之目录树遍历工具

    摘录 python核心编程 本节我们将展示一个中级的tkinter应用实例,这个应用是一个目录树遍历工具:它会从当前目录开始,提供一个文件列表,双击列表中任意的其他目录,就会使得工具切换到新目录中,用 ...

  8. Python -- Gui编程 -- Tkinter的使用 -- 基本控件

    1.按钮 tkBtton.py import tkinter root = tkinter.Tk() btn1 = tkinter.Button(root, anchor=tkinter.E,\ te ...

  9. Python GUI编程实践

    看完了<python编程实践>对Python的基本语法有了一定的了解,加上认识到python在图形用户界面和数据库支持方面快捷,遂决定动手实践一番. 因为是刚接触Python,对于基本的数 ...

随机推荐

  1. java 格式化输出 printf 总结

    double d = 345.678; String s = "hello!"; ; //"%"表示进行格式化输出,"%"之后的内容为格式的 ...

  2. Android 将APK文件安装到AVD中并分析其界面结构

    配置环境变量 将android sdk 中的android-sdk\tools .android-sdk\platform-tools 添加到windows环境变量中.用于打开android sdk中 ...

  3. spring获取webapplicationcontext,applicationcontext几种方法详解(转)

    方法一:在初始化时保存ApplicationContext对象 代码: ApplicationContext ac = new FileSystemXmlApplicationContext(&quo ...

  4. 【转】Swig Getting Started

    Installation Via NPM: $ npm install swig --save Basic Usage Swig has multiple ways to compile and re ...

  5. LeetCode144:Binary Tree Preorder Traversal

    题目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given bina ...

  6. linux系统编程之文件与IO(五):stat()系统调用获取文件信息

    一.stat()获取文件元数据 stat系统调用原型: #include <sys/stat.h> int stat(const char *path, struct stat *buf) ...

  7. MVC中使用Hangfire执行定时任务

    需求描述 项目中有一个通知公告的功能,在后台管理员添加公告后需要推送消息给所有注册用户,让其查看消息.消息推送移动端采用极光推送,但是消息在何时发送是个问题,比如说有一个重要的会议通知,可能希望在会议 ...

  8. NGINX部署配置参考.

    请求动态页面 1. uwsgi.ini配置文件.(主从负载uwsgi1.) 2. uwsgi2 的配置文件 3.查看. 4.结构图 5.配置 NGINX服务器  定义上游有哪些服务器. 定义转交给up ...

  9. session 和cookie

    (1)cookie与session---------->>>>>>>>>>>>>>>>>>& ...

  10. Segment Tree-732. My Calendar III

    Implement a MyCalendarThree class to store your events. A new event can always be added. Your class ...