我有一个简单的功能“复制”,复制和粘贴与win32com。它运行几次没有问题。使用win32com复制粘贴错误(Glade GTK Python)
但是如果我使用按钮(GUI GTK Glade)来触发函数“Copy()”,它只运行一次。第二次我得到以下错误:
Gdk-CRITICAL (recursed) **: inner_clipboard_window_procedure:
assertion `success' failed
aborting...
你能帮我吗?
CopyPaste:
import os, sys
import win32com.client
def Copy():
# Pfad zum Template
path_to_temp = r"C:\004_Python_Workspace\Persek\Template.xls"
# Pfad zum Testpaket
xlsPath = r"C:\004_Python_Workspace\Testfolder\Testanweisung_LK_ASL.xls"
# Blattname im Template und im Testpaket
Sheet = 'ECU_Config'
excel_app = win32com.client.dynamic.Dispatch('Excel.Application')
###### Kopiere ECU_Config aus Template #####
excel_workbook1 = excel_app.Workbooks.Open(path_to_temp)
excel_workbook1.Worksheets(Sheet).UsedRange.Copy()
###### Fuege in das neue Testpaket ein #####
excel_workbook2 = excel_app.Workbooks.Open(xlsPath)
excel_workbook2.Worksheets(Sheet).Range('A1').PasteSpecial()
excel_workbook2.worksheets(Sheet).Columns('A:B').AutoFit()
excel_workbook2.Close(SaveChanges=True)
del excel_workbook2
excel_workbook1.Close()
del excel_workbook1
excel_app.Quit()
Glade的GTK触发与按钮:
def on_debug_clicked(self, object, data=None):
CopyPaste_Error.Copy()
更新1A: 直到 “UsedRange.Copy()” 行是全部相同。
excel_workbook1.Worksheets(Sheet).UsedRange.Copy()
excel_app.Quit()
这是类似于http://stackoverflow.com/questions/15690277/gtk-error-when-copy-paste-performed-outside-of-application – WombatPM
你好WombatPM,也许它相同但没有解决方案。我必须做什么? – user3231222