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. 伪共享(False Sharing)

    原文地址:http://ifeve.com/false-sharing/ 作者:Martin Thompson  译者:丁一 缓存系统中是以缓存行(cache line)为单位存储的.缓存行是2的整数 ...

  2. hdu1002 A + B Problem II(高精度加法) 2016-05-19 12:00 106人阅读 评论(0) 收藏

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. genymotion无法连接相机问题

    genymotion模拟器即时打开了相机的开关,也无法连接到相机.这是因为其他进程占用了相机,虚拟设备无法获得,可以尝试: 1.不关闭模拟器,重启adt的Eclipse 2.重启ADB,adb kil ...

  4. javascript 奇技淫巧45招

    教程:http://chensd.com/2015-01/45-useful-javascript-tips-tricks-and-best-practices.html 1.上线前检查和压缩代码:用 ...

  5. [Ubuntu]管理开机启动项的软件

    sudo apt-get install sysv-rc-conf

  6. LeetCode139:Word Break

    题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-se ...

  7. MYsql 之多表查询.

    http://www.cnblogs.com/wangfengming/articles/8067220.html

  8. Day 43数据库(Day1)

    创建表. create table student( id int not null auto_increment PRIMARY key, name archar() not null, age i ...

  9. keepalive 原理讲解

    keepalive 我们说到keepalive的时候,需要先明确一点,这个keepalive说的是tcp的还是http的. tcp的keepalive是侧重在保持客户端和服务端的连接,一方会不定期发送 ...

  10. XCode - vmware虚拟机安装XCode进行iPhone真机调试

    1.vmware安装黑苹果,然后在appStore安装XCode http://blog.csdn.net/forgot2015/article/details/51104329 2.真机调试证书等申 ...