python與C互相呼叫微全
阿新 • • 發佈:2021-12-10
# 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']))