编程语言
首页 > 编程语言> > python与C互相调用微全

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']))

标签:微全,调用,package,python,self,pywin,pyperclip,import,def
来源: https://www.cnblogs.com/funwithwords/p/15670381.html