test #7
This commit is contained in:
parent
de6849e860
commit
1ac3dee97e
4 changed files with 81 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//ActiveX\u7A97\u53E3/AxWidget.py=utf-8
|
||||
encoding//PyQtChart\u7EC3\u4E60/ChartView/ChartView.py=utf-8
|
||||
encoding//PyQtChart\u7EC3\u4E60/ChartView/ChatWidget.py=utf-8
|
||||
encoding//PyQtChart\u7EC3\u4E60/charts/bar/BarStack.py=utf-8
|
||||
|
|
74
ActiveX窗口/AxWidget.py
Normal file
74
ActiveX窗口/AxWidget.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Created on 2017年4月6日
|
||||
@author: Irony."[讽刺]
|
||||
@site: alyl.vip, orzorz.vip, irony.coding.me , irony.iask.in , mzone.iask.in
|
||||
@email: 892768447@qq.com
|
||||
@file: TableView
|
||||
@description:
|
||||
'''
|
||||
from PyQt5.QAxContainer import QAxWidget
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QFileDialog,\
|
||||
QMessageBox
|
||||
|
||||
|
||||
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: 892768447@qq.com"
|
||||
__Copyright__ = "Copyright (c) 2017 Irony.\"[讽刺]"
|
||||
__Version__ = "Version 1.0"
|
||||
|
||||
|
||||
class AxWidget(QWidget):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AxWidget, self).__init__(*args, **kwargs)
|
||||
self.resize(800, 600)
|
||||
layout = QVBoxLayout(self)
|
||||
self.axWidget = QAxWidget(self)
|
||||
layout.addWidget(self.axWidget)
|
||||
layout.addWidget(QPushButton('选择excel,word,pdf文件',
|
||||
self, clicked=self.onOpenFile))
|
||||
|
||||
def onOpenFile(self):
|
||||
path, _ = QFileDialog.getOpenFileName(
|
||||
self, '请选择文件', '', 'excel(*.xlsx *.xls);;word(*.docx *.doc);;pdf(*.pdf)')
|
||||
if not path:
|
||||
return
|
||||
if _.find('*.doc'):
|
||||
return self.openOffice(path, 'Word.Application')
|
||||
if _.find('*.xls'):
|
||||
return self.openOffice(path, 'Excel.Application')
|
||||
if _.find('*.pdf'):
|
||||
return self.openPdf(path)
|
||||
|
||||
def openOffice(self, path, app):
|
||||
self.axWidget.clear()
|
||||
if not self.axWidget.setControl(app):
|
||||
return QMessageBox.critical(self, '错误', '没有安装 %s' % app)
|
||||
self.axWidget.dynamicCall(
|
||||
'SetVisible (bool Visible)', 'false') # 不显示窗体
|
||||
self.axWidget.setProperty('DisplayAlerts', False)
|
||||
self.axWidget.setControl(path)
|
||||
|
||||
def openPdf(self, path):
|
||||
self.axWidget.clear()
|
||||
if not self.axWidget.setControl('Adobe PDF Reader'):
|
||||
return QMessageBox.critical(self, '错误', '没有安装 Adobe PDF Reader')
|
||||
self.axWidget.dynamicCall('LoadFile(const QString&)', path)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.axWidget.close()
|
||||
self.axWidget.clear()
|
||||
self.layout().removeWidget(self.axWidget)
|
||||
del self.axWidget
|
||||
super(AxWidget, self).closeEvent(event)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
app = QApplication(sys.argv)
|
||||
w = AxWidget()
|
||||
w.show()
|
||||
sys.exit(app.exec_())
|
6
ActiveX窗口/README.md
Normal file
6
ActiveX窗口/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# 嗯嗯,就是简单的测试ActiveX控件
|
||||
|
||||
### [Python3.4.4 or Python3.5][PyQt5]
|
||||
|
||||
# 截图
|
||||
![截图1](ScreenShot/excel.png)
|
BIN
ActiveX窗口/ScreenShot/excel.png
Normal file
BIN
ActiveX窗口/ScreenShot/excel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Loading…
Reference in a new issue