Search code examples
user-interfacetkinterabaqus

importing tkinter in Abaqus error


I have a problem durring abaqus scripting. I am trying to use tkinter in an abaqus scipt. When I run my code for the first time the program runs fine but when I run my program the second time, then the abaqus quits with the following error: "Unexpected LoadlibraryA error 193 ipc_CONNECTION_BROKEN"

I'm using abaqus 6.14 with python 2.7 running with Intel Paralllal Stuido XE 2015 Composer Edition 64 bit Update 2

My plugin class looks like this:

from abaqusGui import getAFXApp, Activator
from abaqusConstants import ALL
import os
thisPath = os.path.abspath(__file__)
thisDir = os.path.dirname(thisPath)
toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerGuiMenuButton(
    buttonText='Pilot GUI', 
    object= Activator(os.path.join(thisDir, 'pilotDB.py')),
    kernelInitString=''
)

my pilotDB class looks like this:

class pilotDB:     
import Tkinter
root = Tkinter.Tk()
app = pilotDB(root)
root.mainloop()
root.quit()

Solution

  • I have found the solution: The problem was when I first closed the TK window with the X on the upper right corner, the application cannot destroyed the window properly so when I started app the second time, it crashed. Solution: Add the following code to my pilotDB class:

    def shutdown_ttk_repeat(self):
         self.mainroot.eval('::ttk::CancelRepeat')
         self.mainroot.destroy()
    

    and then add the destroying protokol to the start of "init" function in pilotDB class

    def __init__(self, parent):
         self.mainroot=parent
         self.mainroot.protocol("WM_DELETE_WINDOW", self.shutdown_ttk_repeat):