0

I need to attach a GUI to python application. I've seen tkinter and Qt5, but they make too native GUIs. In fact, using the first one I cannot customize my elements with css, and the second one only support a subset of it. That's why I wonder if I can use a fxml file to create a nice interface.

Then, I followed this link and tried to use jython. In one comment, they said: "you can manually add jfxrt.jar to your module search path if you are using a version of Java where it isn't available." This is my case, but I have no idea about how to do it. I downloaded the jfxrt.jar and I put it in the same python script folder, but the same error occurs when I try jython script.py:

WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper$ReflectiveAccess (file:/usr/share/java/jnr-posix.jar) to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper$ReflectiveAccess
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
  File "./test.py", line 10, in <module>
    from javafx.application import Application
ImportError: No module named javafx

What I executed is the code in the page previously linked. What can I do to solve this import error?

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
ma4strong
  • 300
  • 2
  • 8
  • 1
    I don't know how to do this, but I do know that the advice you found "you can manually add jfxrt.jar to your module search path" is not good advice. See [What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?](https://stackoverflow.com/questions/22514310/whats-the-location-of-the-javafx-runtime-jar-file-jfxrt-jar-on-linux). `jfxrt.jar` doesn't even exist in modern JavaFX distributions, which is what you should be using. So the advice around jfxrt.jar no longer even makes any sense. – jewelsea Sep 28 '21 at 16:56
  • There will be precious little if any information or resources available on using jython with JavaFX I expect. My advice is that, if you want to find out if JavaFX and FXML is an appropriate technology for you, create an app *in Java* and use SceneBuilder for the FXML visual design. Then, when you inevitably have some difficulty doing that, you can get a lot more assistance to help resolve your problems. Once you are comfortable with that and if you find that JavaFX is providing the kind of GUI you want and you prefer to code in Jython, you can investigate that integration, but not to start. – jewelsea Sep 28 '21 at 17:00
  • Thanks @jewelsea for the advice, i didnt face that was an old version. I know how to use *scenebuilder*, that's why to make the GUI i want should not be a problem. But i dont want to waste time creating something that i cannot use.. – ma4strong Sep 28 '21 at 17:32
  • Modern JavaFX works around [java modules](https://www.oracle.com/corporate/features/understanding-java-9-modules.html) and should be run off the module path, these are different than packages/python modules/maven modules/etc. (see documentation at openjfx.io for details). So what you will need to do is have your jython runtime work with the Java modules, it may be as simple as adding the JavaFX modules as maven dependencies if you use that tool, or using a distribution like liberica that includes JavaFX modules, but it may be more complex, good luck :-) Self-answer if you get it to work. – jewelsea Sep 28 '21 at 18:41

0 Answers0