xlwings work in pyqt5 Qthread APP Object cannot be created

0
import xlwings as xw
from PyQt5.QtCore  import  QObject,QThread

class workThread(QThread):
  def __init__(self,b,c):
    super(workThread,self).__init__()
    self.b=b
    self.c=c
  def run(self):
    print("run")
    self.csv = xw.App(visible=True, add_book=False)
    print(self.csv)

I want put xlwings work in Qthread child thread run funciton,but the results

E:\python\python.exe "G:/Python Project/excelxlwing/test.py"
run

Process finished with exit code -1073740791 (0xC0000409)enter code here

and then GUI collapse,same code if put them in main thread Working properly,I try to let xw.app() work in main thread ,then pass arguments to child thread .still collapse,I do not konw why workthread object's csv attribute add failed

class workThread(QThread):
  def __init__(self,csv):
    super(workThread,self).__init__()
    self.csv=csv

  def run(self):
    print(self.csv)
class myWin(QMainWindow,mainWin.Ui_MainWindow):

  def __init__(self):
    super().__init__()
    self.setupUi(self)

    self.tablecontent=[]
    self.initUI()     
  def workStart(self):
    self.csv = xw.App(add_book=False)
    self.myThreat = workThread(self.csv)
    self.myThreat.start()

result:

E:\python\python.exe "G:/Python Project/excelxlwing/test.py"

Process finished with exit code -1073740791 (0xC0000409)
python
pyqt5
xlwings
asked on Stack Overflow Dec 30, 2019 by smvwvp

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0