Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am having an issue with my GUI disconnecting from my python code.
The structure is essentially a minimal entry point script with:
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
_ = config_settings(ui)
then another script that has config_settings has a try block:
cmdDef = ui.commandDefinitions.itemById(commandId)
if not cmdDef:
cmdDef = ui.commandDefinitions.addButtonDefinition(commandId, commandName, commandDescription)
handlers = []
onCommandCreated = MyCreatedHandler(ui, handlers)
cmdDef.commandCreated.add(onCommandCreated)
handlers.append(onCommandCreated)
cmdDef.execute()
adsk.autoTerminate(False)
return True
Without making this a massive code explanation, the remainder is basically a GUI that has a few dropdowns and some buttons. The problem is, the dropdowns all work consistently and will change some setting. However, if I press one of the buttons, it works the first time, but then won't work again (but sometimes does). It _seems_ like the way I can get it to usually work is by adding a breakpoint in the debug mode of the calculation parts of the code. When there is no breakpoint, it just ends up disconnecting the the gui, and nothing I press calls any of the python functions. I.e. even if I put a breakpoint inside the class inheriting the event handler, nothing is printed and breakpoint is not hit.
class MyInputChangedHandler(adsk.core.InputChangedEventHandler):
def __init__(self, ui):
self.ui = ui
super().__init__()
def notify(self, args):
print("Entered Notify")
So the closest thing I can understand it to be is like the API is losing its reference to the GUI callbacks and the program has ended, but it was dereferenced properly so the GUI still remains. But this is a wild guess.
Has anyone experienced this or has an idea what causes it?
Solved! Go to Solution.