java - 将参数传递给用 Jython 编写的 javafx 对象
问题描述
我在 Jython 中编写了一个对象来使用 javaFX 加载多个文件。由于结构非常“刚性”,我不知道如何在不破坏它的情况下将参数传递给这个对象。
import sys
from java.io import File
from java.nio.file import Paths
from javafx.application import Application
from javafx.stage import FileChooser, Stage
class fileBrowser(Application):
@classmethod
def main(cls):
fileBrowser.launch(cls)
@staticmethod
def getAbsPath(primaryStage):
fc = FileChooser()
fc.setInitialDirectory(
File(Paths.get(".").toAbsolutePath().normalize().toString())
)
return fc.showOpenMultipleDialog(primaryStage)
def start(self, primaryStage):
self.getAbsPath(primaryStage)
if __name__ == '__main__':
fb = fileBrowser
fb.main()
例如,我希望我可以将参数传递给函数 setInitialDirectory
。
然而,重要的是传递的任何参数都可以在 start 方法下进行。
如果我使用构造函数def __init__(self)
,程序会中断。
所以我想知道...如何将参数传递给在 start 方法中读取的对象?
提前致谢!
解决方案
推荐阅读
- postgresql - postgres 索引表现不清楚
- python - 使用列表理解找到最小数字
- post - 邮递员 - 将用户发布到 BIM 360 错误?
- java - Spring Thymeleaf classappend 不附加类
- mysql - 禁用 Doctrine 自动查询
- css - Vuejs在css中应用循环来放置悬停
- android - Android - RecyclerView StaggeredGridLayoutManager 拉伸最后一行的宽度
- python - 在 python 多处理中从 bash 调用另一个应用程序非常慢
- python - 如何在 PyUsb 中绑定/取消绑定 USB 设备?
- botframework - 如何扩展 MS Health Bot 现有场景?