GUI in Python

Mike Bray (Quote Loader Author)'s Avatar

Mike Bray (Quote Loader Author)

21 Sep, 2019 01:50 PM

Has anyone used a GUI in the Python extension? If so which GUI library is installed. I have tried Tkinter but it is not found.

  1. Support Staff 1 Posted by Sean Reilly on 21 Sep, 2019 05:19 PM

    Sean Reilly's Avatar

    Hi Mike,
    No GUI library is included specifically in the python layer because nothing would work across platforms. However since the python layer runs on jython you can always use the java swing libraries.


  2. 2 Posted by Mike Bray (Quot... on 22 Sep, 2019 07:18 AM

    Mike Bray (Quote Loader Author)'s Avatar

    Thanks Sean, I will give it go

  3. 3 Posted by sprimost on 22 Sep, 2019 08:10 PM

    sprimost's Avatar

    From: sprimost

    Can I not import from tkinter to use the tinker libraries....just happen
    to be developing something?


  4. Support Staff 4 Posted by Sean Reilly on 22 Sep, 2019 09:07 PM

    Sean Reilly's Avatar

    I wouldn't expect the tkinter libraries to work since I assume they'd have to load native code from a .so. I would love to be proven wrong about that however, and it's certainly worth trying with a quick test!


  5. 5 Posted by Mike Bray (Quot... on 23 Sep, 2019 06:49 AM

    Mike Bray (Quote Loader Author)'s Avatar

    I tried to import tkinter and it came up not found. My research seems to indicate the the various GUI libraries are optional extras hence my original post.

    I have gone through a swing under Jython tutorial which works. There is one odd item. If you create a JFrame and set the defaultCloseOperation to EXIT_ON_CLOSE when you click on the close button the whole of Moneydance closes!!!!!!!, not just the script, or even the Python interface

  6. 6 Posted by hleofxquotes on 23 Sep, 2019 05:22 PM

    hleofxquotes's Avatar

    Mike, on the Swing side. If a JFrame has defaultCloseOperation set to EXIT_ON_CLOSE and all the frames have been disposed, System.exit(0) will be called implicitly which in turn will shutdown the JVM (hence the Moneydance closed).

  7. 7 Posted by Mike Bray (Quot... on 25 Sep, 2019 07:29 AM

    Mike Bray (Quote Loader Author)'s Avatar

    Hi, I understand how Swing works. When this happened I had the main screen of MD open which I assume is a JFrame, the window for the MoneyBot open which again I assume is a JFrame and a window for my script which was a JFrame. When the window for my script is closed all of the windows were closed not just my script window. I suspect that the JFrame in my script does not know about the other frames and as such, as you say, System.exit(0) is called.

  8. Support Staff 8 Posted by Sean Reilly on 25 Sep, 2019 10:51 AM

    Sean Reilly's Avatar

    Yes, that's my understanding of how the exit-on-close behaviour works - System.exit(0) is called when the frame is closed regardless of whether it's the last frame. Definitely don't do that :)

    Sean Reilly
    Developer, The Infinite Kind

  9. Mike Bray (Quote Loader Author) closed this discussion on 24 Nov, 2019 09:14 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac