⑴ python如何调用ui文件
ui文件是Qt生成xml格式的文件,python要使用就得用pyside 或pyqt这其中一个库才能将ui文件转化为py文件,安装pyside库后,在命令行打这一句 : pyside-uic XXX.ui -o XXX_ui.py
⑵ Python下Pywin32的使用教程
你可以直接到lib的site-packages下面的win32目录下,有一个demos。另外几个win32开头的目录里也有demos子目录。进去看他们写好的例子。
⑶ python怎么操作windows服务
你可以使用pythoncom 库,它包含ActivePython 或者可以安装pywin32 (Python for Windows extensions).
下面是一个简单操作服务的例子:
importpythoncom
importwin32serviceutil
importwin32service
importwin32event
importservicemanager
importsocketclassAppServerSvc(win32serviceutil.ServiceFramework):
_svc_name_="TestService"
_svc_display_name_="TestService"
def__init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop=win32event.CreateEvent(None,0,0,None)
socket.setdefaulttimeout(60)
defSvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
defSvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.main()
defmain(self):
pass
if__name__=='__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)
你的代码需要放在mian()方法里面,通常会有一些情况通过检查你在 SvcStop 方法中设置的标志,然后中断循环
⑷ python怎么用win32ui
用python的sendkeys直接模拟键盘,用ctype扩展来点鼠标。你需要做的就是用python打开浏览器,然后输入网站,在找到按钮的坐标(固定到程序里),然后点击就行了。不过简单的可以,复杂点的就要考虑很多问题了,程序截图如下:
⑸ 不可以使用Python进行DDE连接.win32ui出现不工作问题,怎么解决
I had a similar problem. I had to:
uninstall Python 2.7 64-bit
install Python 2.7 32-bit
use the pywin32 version 214
Run cmd.exe as administrator so that the c.ConnectTo() connects successfully
However, I am still having the weird problem that I must have Excel open at the same time with a cell holding the value =MTX|DATA!EURUSD.SON for the python script to return a valid quote. Otherwise, I just get "N/A" as the return value.
⑹ python pywin32 里面操作窗体,获取窗体里面的数据,在函数GetDlgItem函数中,怎么获取第二个参数的值
不知道你解决了没,最近正好研究python。
hwnd=win32gui.FindWindow()这个获取窗体句柄,大概都会用;
ctrl=win32gui.FindWindowEx(hwnd,None,'窗口类名',‘标题文本’)已知控件类名或控件名时获取控件句柄,这个标题文本不一定存在,所以使用None默认值获取的是该窗口类名中第一个顺位的控件句柄。
你使用b=win32gui.GetDlgItem(edit,资源ID)最终结果是获取的是句柄,这里的资源ID其实是spy++中的窗口ID,句柄是可变的,窗口ID是不可变的。这里似乎错了,你这样子大概获取的是控件中的子项(控件有子项的话,比如Combox中的edit框),我猜的,没试过。b=win32gui.GetDlgItem(hwnd,窗口ID)是已知ID下获取某控件句柄
如果你想获取某个控件的ID则ctrlid=win32gui.GetDlgCtrlID(ctrl)这是一只某控件句柄的情况下获取该控件在应用程序中的窗口ID。
如果不知控件句柄的情况下大概可以试试spy++获取窗口ID,把窗口ID(这个是16进制的)转化成10进制带进b=win32gui.GetDlgItem(hwnd,窗口ID)大概也可以得到控件句柄。
其实就是三个函数之间的转化
ctrl=win32gui.FindWindowEx(hwnd,None,'edit',None)控件句柄
ctrlid=win32gui.GetDlgCtrlID(ctrl)控件的窗口id
ctrl2=win32gui.GetDlgItem(hwnd,ctrlid)控件句柄
print "%x" %ctrllist
print "%x" %ctrlid
print "%x" %ctrl
输出,看一下数据与spy++是否一致。然后ctrl=ctrl2
⑺ python pywin32模块中的makepy.py使用问题(急用)
个人的经验是,makepy会生成一个中间层,上层的python code是通过中间层访问下层的DLL,所以,
你的DLL文件和转换的py文件需要同时存在
你的DLL文件需要注册