Primstar on the Mac

gaia.clary's picture

Hi.

We found a partial solution for the tkinter problems on the Mac. Actually the problem is that after the tkinter popup closes, blender is left behiond in a somewhat undefined state. It is the frontmost windowm, but it is not the active window and furthermore in that state NO WINDOW IS ACTIVE on your machine. There are 2 ways to reactivate blender:

  1. You can click somewhere outside of blender, then click into the blender window again and it becomes active.
  2. You can click on the top row of the blender window. It becomes active, but the just created sculpted prim becomes temporarily invisible. As soon as you click into the blender main window, everything turns back to normal and you can proceed.

Both solutions above are ugly and not very convenient. There is one proposal from Domino here: www.dominodesigns.info/node/157#comment-417 But that solution does not work as well as expected. In fact on Snow Leopard it does nothing at allexcept consuming a bit of runtime. So we tried hard to find a better solution. The goal was to let primstar behave just like it does in Windows. Sadly we failed to reach that goal, but we found a way to get very close to the ideal. Here is what you need to do:

in add_mesh_sculpt_mesh.py:

locate the main() method at the bottom of the file and add the 2 lines around "### add this ###"  and "### end addition ###" below. Take care on the indentation !!!

def main():
    root = None
    start_time = Blender.sys.time()
    gui.debug(1, "started", SCRIPT)
    try:
        root = gui.ModalRoot()
        app = GuiApp(root)
        app.redraw()
        root.mainloop()
        root.destroy()
    except:
        if root:
            root.grab_release()
            root.quit()
            root.destroy()
        raise
    #### add this ####
    if gui.platform == "darwin":
        os.system('''/usr/bin/osascript -e 'tell app "System Events" to activate process "Blender"' ''')
    #### end addition ####
    gui.debug(1, "ended in %.4f sec." % (
            Blender.sys.time() - start_time), SCRIPT)

 Do the exact same in render_sculptie.py:

def main():
    root = None
    start_time = Blender.sys.time()
    gui.debug(1, "started", SCRIPT)
    try:
        root = gui.ModalRoot()
        app = GuiApp(root)
        app.redraw()
        root.mainloop()
        root.destroy()
        #### add this ####
        if gui.platform == "darwin":
            os.system('''/usr/bin/osascript -e 'tell app "System Events" to activate process "Blender"' ''')
        #### end addition ####

    except:
        if root:
            root.grab_release()
            root.quit()
            root.destroy()
        raise
    gui.debug(1, "ended in %.4f sec." % \
            (Blender.sys.time() - start_time), SCRIPT)

Now primstar behaves much smoother: You just need to click somewhere into the 3D view to reactivate blender. You no longer need to click outside of blender first. It is still one extra click (instead of 2), but at least it does no longer feel like a nasty trick.

BTW we tried to get even further with osascript and added some code to fake a click on the blender window. But that did not work because the blender window is not seen by applescript while it is in that zombie state (frontmost but not active). So we suspect that there is a bug in blender itself which does not cleanly integrate into the OSX-windowing system or it is a bug in OSX ... We don't know for sure.

I hope that helps a bit.

 

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p> <pre>
  • Lines and paragraphs break automatically.
  • Project issue numbers (ex. [#12345]) turn into links automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options