-1

I have run into a problem durring abaqus programming with phyton 2.7. I'm using Tkinter and making a window with a lot of controls on it. My main problem is that durring my plugin window is opened, the user needs to click on abaqus menuitems, browse modells, etc. So using the main program while my plugin still works on screen. If I do create my Tk window without thread, than when the user clicks on abaqus main windo functions while my plugin is opened, then abaqus will not respond or crash with "LoadlibraryA error 193" (example: while plugin runs and user clicks on Viewvport menü/ViewPort Annotation Options then he/she wont be able to change tabs)

If i do create my Tk window inside a thread, then the al the Tk window controls will only responds the mouse events after I leave the Tk window with my cursor. (example: I make 2 notebook page and after start i click on the not selected one. then nothing happens until my mous inside the Tk window, but as soon as i move it out, the click takes effect and the tab changes...)

The threaded version of my code:

import threading

class pilotDB(threading.Thread):
def shutdown_ttk_repeat(self): self.root.eval('::ttk::CancelRepeat') self.root.destroy()

def __init__(self):
    import threading
    threading.Thread.__init__(self)

def refresh(self):
    self.root.after(50, self.refresh)

def tabpage(self):
    import ttk
    import sys
    self.notebook = ttk.Notebook(self.root)
    self.tabpage_tab1 = ttk.Frame(self.notebook,width=400,height=500)
    self.tabpage_tab2 = ttk.Frame(self.notebook,width=400,height=500)
    self.notebook.add(self.tabpage_tab1, text='Tab1')
    self.notebook.add(self.tabpage_tab2, text='Tab2')
    self.notebook.place(x=30, y=40)

def run(self):
    import Tkinter
    self.root = Tkinter.Tk()
    self.root.protocol("WM_DELETE_WINDOW", self.shutdown_ttk_repeat)
    self.tabpage()
    self.root.after(1000, self.refresh())  
    self.root.mainloop()

app = pilotDB() app.start()

user3219009
  • 19
  • 1
  • 6

1 Answers1

0

app/pilotDB has no function named "start" (last line of the code posted). If I put a call to self.run() in init, and delete threading, then the program works as expected, i.e. opens a window and displays 2 tabs and the user can switch between tabs, all the time the mouse is in the window as is normal. Note also that the refresh() function does nothing but call itself repeatedly. You should try to find the offending code by first commenting the lines for the "WM_DELETE_WINDOW", shutdown_ttk_repeat and the call to execute the function tabpage() which leaves a basic window. Then uncomment one and run it, and repeat until you find the error.

  • If I simply call the run() function then the program will run as intended AS LONG AS I'm not using abaqus durring the program. As I described, the problem with this option is that while running my plugin window... click on abaqus menu named "ViewPort/ViewPort Annotation Oprtions..." then try to change to any tabpage on that.... you cannot. The tabpage will be selected, but the content won't refresh until the plugin window is open.Yes you are right, my plugin does not have a start(), but the threading class have this function that starts running the predefinied class when I call this function – user3219009 May 30 '16 at 10:48
  • If I run the threaded version, then the abaqus inside function will work durring my plugin window still on screen,Tthe only problem is that the plugin window itself only reacts to mouse, etc. controls after my mouse left the plugin window. The refresh function is there because I tried to forcing refresh my plugins window. But it did not resolved my problem. So you are right, that its unneccessary for now. – user3219009 May 30 '16 at 10:57
  • WM_DELETE_WINDOW was needed in the NO thread version because if I close my pluging window and reopen it then abaqus will crash bacause the controls are still present, but not destroyed in abaqus. I don't know if threaded version will destroy the controls on close so i would not remove this if not needed... – user3219009 May 30 '16 at 10:59