Python -- Gui编程 -- MFC的使用
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的使用的更多相关文章
- Python GUI编程各种实现的对比
Python GUI编程各种实现的对比 从 Python 语言的诞生之日起,就有许多优秀的 GUI 工具集整合到 Python 当中,这些优秀的 GUI 工具集,使得 Python 也可以在图形界面编 ...
- Python gui编程pyQt5安装步骤t
Python gui编程pyQt5安装步骤 pip install PyQt5 Pip3 install PyQt5 https://riverbankco ...
- Python gui编程pyQt5安装步骤
Python gui编程pyQt5安装步骤 =============================== -m PyQt5.uic.pyuic $FileName$ -o $FileNameWit ...
- Python GUI 编程
Python GUI编程(Tkinter) Python 提供了多个图形开发界面的库,几个常用 Python GUI 库如下: Tkinter: Tkinter 模块(Tk 接口)是 Python 的 ...
- Python GUI编程(Tkinter) windows界面开发
Python实现GUI简单的来说可以调用Tkinter库,这样一般的需求都可以实现,显示简单的windows窗口代码如下: python_gui.py 1 #!C:\Python27\python.e ...
- Python GUI编程--Tkinter
今天看到了GUI编程,书上推荐用wxPython,去官网上看了看,发现Windows的最高支持到2.7,我用的是3.4版本,咋办,用自带的库--Tkinter呗,它是Python的默认GUI库,几乎是 ...
- python GUI编程tkinter示例之目录树遍历工具
摘录 python核心编程 本节我们将展示一个中级的tkinter应用实例,这个应用是一个目录树遍历工具:它会从当前目录开始,提供一个文件列表,双击列表中任意的其他目录,就会使得工具切换到新目录中,用 ...
- Python -- Gui编程 -- Tkinter的使用 -- 基本控件
1.按钮 tkBtton.py import tkinter root = tkinter.Tk() btn1 = tkinter.Button(root, anchor=tkinter.E,\ te ...
- Python GUI编程实践
看完了<python编程实践>对Python的基本语法有了一定的了解,加上认识到python在图形用户界面和数据库支持方面快捷,遂决定动手实践一番. 因为是刚接触Python,对于基本的数 ...
随机推荐
- 201709013工作日记--static理解 && abstract
1.关于viewHolder设置成static的讨论 一般情况下是尽量不要使用static关键字,因为static一旦有引用变量指向了变量,使用完毕后而没有设置null,就会造成内存泄露,而且很难排查 ...
- (并查集) Wireless Network --POJ --2236
链接: http://poj.org/problem?id=2236 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82830#probl ...
- Hdu1728 逃离迷宫 2017-01-17 10:56 81人阅读 评论(0) 收藏
逃离迷宫 Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submissi ...
- 2014年誓言:干掉网页设计程序——Dreamweaver!
2014年誓言:干掉网页设计程序——Dreamweaver! 阅读: 评论: 作者:Rybby 日期: 来源:rybby.com 2014年,我写下誓言,用自己设计的在线网页设计工具“拉拉变” ...
- hibernate 一对多,由谁维护性能最优
举例如下 Customer类: public class Customer { private int id; private String name; private Set orders = ne ...
- XCode 7.3.1(dmg) 官方直接下载地址(离线下载)
XCode 7 7.3.1:https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7.3. ...
- paxos ---学习笔记
摘自维基百科:分布式系统中的节点通信存在两种模型:共享内存(Shared memory)和消息传递(Messages passing).基于消息传递通信模型的分布式系统,不可避免的会发生以下错误:进程 ...
- 设计模式之迭代器模式(Iterator Pattern)
一.什么是迭代器模式? 用迭代器来封装集合对象的遍历细节,使调用者能够通过统一的接口来实现对集合的遍历 迭代器也给集合对象提供了一定的保护,想要遍历集合,直接调用迭代器的方法就好了,我们不知道也不必知 ...
- asp.net—自定义轻量级ORM
大型项目中ORM的使用已经是相当的频繁.目前.NET(C#)中比较流行的ORM框架也有很多,比如SqlSugar,Dapper,Entity Framework(EF)等. 相信很多有2年以上工作经验 ...
- OSLab课堂作业1
日期:2019/3/16 作业:实现命令cat, cp, echo. myecho命令 #include <stdio.h> int main(int argc, char *ar ...