⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myext.c

📁 征服PYTHON--语言基础与典型应用光盘 实例源码
💻 C
字号:
#include <python.h>
#include <windows.h>
/* 定义C扩展中的函数 */
PyObject *show(PyObject *self, PyObject *args)
{
	char *message;
	const char *title = NULL;
	HWND hwnd = NULL;
	int r;
	/* 使用PyArg_ParseTuple处理参数 */
	if (!PyArg_ParseTuple(args, "iss", &hwnd, &message, &title))
		return NULL;
	r = MessageBox(hwnd,message, title, MB_OK);
	return Py_BuildValue("i", r);
}
/* 模块的方法列表 */
static PyMethodDef myextMethods[] = 
{
	{"show", show, METH_VARARGS,"show a messagebox"},
	{NULL,NULL}
};
/* 模块的初始化函数 */
PyMODINIT_FUNC initmyext()
{
	PyObject *mod;
	/* 使用Py_InitModule初始化模块*/
	mod = Py_InitModule("myext",myextMethods);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -