python与C互相调用微全

Posted _

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python与C互相调用微全相关的知识,希望对你有一定的参考价值。

# C调用python. search(Calling Python Functions From C PyObject Py_XDECREF Py_XINCREF).
# 
# SetWindowsHookEx,回调函数用Python写: https://www.cnblogs.com/funwithwords/p/15669613.html ctypes
# 用SetConsoleTextAttribute设置文本颜色: https://www.cnblogs.com/funwithwords/p/15670028.html ctypes
# 
# pip install pywin32
# import win32clipboard as w
# import win32con
# def get_text(): w.OpenClipboard(); s=w.GetClipboardData(win32con.CF_UNICODETEXT); w.CloseClipboard()
# win32api.MessageBox(0,"msgbox", "title")
# 
# pip install pyperclip 还有个wheel叫clipboard.
# import pyperclip
# pyperclip.copy(\'The text to be copied to the clipboard.\')
# pyperclip.paste()
# 
# D:\\Python39\\Lib\\site-packages\\pythonwin\\Pythonwin.exe 默认没有加入PATH.
# D:\\Python39\\Lib\\site-packages\\pythonwin\\pywin\\Demos\\*.py 大部分需要先运行pywin,再在pywin里运行.py
# 
# >>> help(pywin)
# PACKAGE CONTENTS
#     debugger (package)
#     dialogs (package)
#     docking (package)
#     framework (package)
#     idle (package)
#     mfc (package)
#     scintilla (package)
#     tools (package)
#
# First demo - use the built-in to Pythonwin "Tab Stop" dialog, but
# customise it heavily.
class TestDialog(dialog.Dialog):
    def __init__(self, modal=1):
        dialog.Dialog.__init__(self, IDD_SET_TABSTOPS)
        self.counter = 0
        if modal:
            self.DoModal()
        else:
            self.CreateWindow() # 菜鸟MFC程序员都不知道无模式对话框呢
    def OnInitDialog(self):
        self.SetWindowText("Used to be Tab Stops!")
        self.edit = self.GetDlgItem(IDC_EDIT_TABS)  # the text box.
        self.edit.SetWindowText("Test")
    def OnDestroy(self, msg):
        del self.edit
        del self.counter
        
import pywin.dialogs.list
print(pywin.dialogs.list.SelectFromList(\'Select fruit\', [\'apple\', \'grape\', \'orange\']))

以上是关于python与C互相调用微全的主要内容,如果未能解决你的问题,请参考以下文章

怎样让Python脚本与C++程序互相调用

Python摄氏度与华氏度互相转化

Dart 与 C 的互相调用

Python Pytest自动化测试 fixture与fixture互相调用

Lua与C语言的互相调用

Android NDK开发----- Java与C互相调用实例详解