我如何向用户询问文件名?
How do I ask the user for a file name?
正在搜索 FileDialog 的调用
我想向用户询问 Pharo 4.0 中的文件名
通过观察员我发现class
FileDialogWindow
有方法
answerFileName
正在寻找#answerFileName 的发件人,我找到了 class
UITheme
方法中调用的地方
chooseFileNameIn: aThemedMorph
title: title
extensions: exts
path: path preview: preview
然后我从那里来到 class
TEasilyThemed
用方法
chooseFileName: title extensions: exts path: path preview: preview
从那里我终于到达了class
WidgetExamples class >> exampleDialogs
然后我接到电话
WidgetExamples exampleBuilder
chooseFileName: 'Pick a file name'
extensions: nil path: nil preview: nil.
然而,此表达式的 print it
不会 返回文件名。
问题
调用文件对话框的常规方式是什么?
回答后的补充问题
提到有两个 class 提供此服务。
- UI经理
- UI主题
UI经理评论
UIManager 是各种 UI 请求的调度程序。
UI主题评论
Common superclass 用于用户界面主题。提供以标准方式创建新变形的方法、各种“服务”(如文件对话框、消息对话框等)以及用于自定义各种变形外观方面的方法。
尽管在概念上是抽象的,但没有代码是“缺失的”。因此,Subclasses 应该覆盖他们希望更改的方面。
这两种方法有什么区别?
最简单的方法是使用:
UIManager default chooseFileMatching: nil
您可以将模式指定为:
UIManager default chooseFileMatching: #('*.jpg' '*.png')
您还可以为对话框指定标签:
UIManager default
chooseFileMatching: #('*.jpg' '*.png')
label: 'Please select and image to process'
我在我的一个演示应用程序中使用的是
MindmapNode class>>open
|fileName|
fileName := UITheme current chooseFileIn: World title: 'Choose file' extensions: nil path: nil preview:nil.
fileName ifNotNil: [ (FLMaterializer materializationFromFileNamed: fileName)
root openInWorld attachAllSubnodes detachAllSubnodes ]
MindmapNode>>saveMap
|fileName|
fileName := UITheme current fileSaveIn: World title: 'Choose file' extensions: nil path: nil.
fileName ifNotNil: [ FLSerializer serialize: self toFileNamed: fileName].
UIManager 关心的是能够从命令行 运行 无头。然后您希望能够在参数或输入文件中提供文件名。在标准图像情况下,UIManager 默认是委托给当前主题的 MorphicUIManager。
所以使用 UIManager 可能会更好
正在搜索 FileDialog 的调用
我想向用户询问 Pharo 4.0 中的文件名
通过观察员我发现class
FileDialogWindow
有方法
answerFileName
正在寻找#answerFileName 的发件人,我找到了 class
UITheme
方法中调用的地方
chooseFileNameIn: aThemedMorph
title: title
extensions: exts
path: path preview: preview
然后我从那里来到 class
TEasilyThemed
用方法
chooseFileName: title extensions: exts path: path preview: preview
从那里我终于到达了class
WidgetExamples class >> exampleDialogs
然后我接到电话
WidgetExamples exampleBuilder
chooseFileName: 'Pick a file name'
extensions: nil path: nil preview: nil.
然而,此表达式的 print it
不会 返回文件名。
问题
调用文件对话框的常规方式是什么?
回答后的补充问题
提到有两个 class 提供此服务。
- UI经理
- UI主题
UI经理评论
UIManager 是各种 UI 请求的调度程序。
UI主题评论
Common superclass 用于用户界面主题。提供以标准方式创建新变形的方法、各种“服务”(如文件对话框、消息对话框等)以及用于自定义各种变形外观方面的方法。 尽管在概念上是抽象的,但没有代码是“缺失的”。因此,Subclasses 应该覆盖他们希望更改的方面。
这两种方法有什么区别?
最简单的方法是使用:
UIManager default chooseFileMatching: nil
您可以将模式指定为:
UIManager default chooseFileMatching: #('*.jpg' '*.png')
您还可以为对话框指定标签:
UIManager default
chooseFileMatching: #('*.jpg' '*.png')
label: 'Please select and image to process'
我在我的一个演示应用程序中使用的是
MindmapNode class>>open
|fileName|
fileName := UITheme current chooseFileIn: World title: 'Choose file' extensions: nil path: nil preview:nil.
fileName ifNotNil: [ (FLMaterializer materializationFromFileNamed: fileName)
root openInWorld attachAllSubnodes detachAllSubnodes ]
MindmapNode>>saveMap
|fileName|
fileName := UITheme current fileSaveIn: World title: 'Choose file' extensions: nil path: nil.
fileName ifNotNil: [ FLSerializer serialize: self toFileNamed: fileName].
UIManager 关心的是能够从命令行 运行 无头。然后您希望能够在参数或输入文件中提供文件名。在标准图像情况下,UIManager 默认是委托给当前主题的 MorphicUIManager。
所以使用 UIManager 可能会更好