【发布时间】:2021-09-09 15:27:06
【问题描述】:
我在 Windows 上制作了一个 PyQt5 应用程序,现在我想在 Mac 上使用该应用程序。该应用程序会提示用户选择几个不同的文件。我使用 QFileDialog 窗口的标题来让用户知道哪些文件是这样的:
instrument_file_raw=QFileDialog().getOpenFileName(self, "Select Instrument File","","Excel (*.xlsx)")
instrument_file_raw=str(instrument_file_raw[0])
if instrument_file_raw=="":
error_dialog = QErrorMessage(self)
error_dialog.showMessage('No filename entered')
return
run_list_file=QFileDialog().getOpenFileName(self, "Select Run List File","","Excel (*.xlsx)")
run_list_file=str(run_list_file[0])
if run_list_file=="":
error_dialog = QErrorMessage(self)
error_dialog.showMessage('No filename entered')
return
但是,当我在 Mac 上运行相同的代码时,文件资源管理器打开时没有显示窗口标题。即使我手动设置窗口标题
instrument_file_window=QFileDialog()
instrument_file_window.setWindowTitle("Select Instrument File")
instrument_file_raw=instrument_file_window.getOpenFileName(self,"Select Instrument File","","Excel (*.xlsx)")
有没有办法在 Mac 上显示窗口标题?如何向用户指示要输入的内容?
【问题讨论】:
-
您可能使用的是高于 10.11 的 macOS 版本,对吧?
-
是的,它的 10.15.5