Re: wx.FileDialog and scripts
Javi Domínguez
Hello.
I know how launch a file dialog from the configuration settings and there it works fine for me but when i try to launch it from a script it crashes. I think the solution is in gui.runScriptModalDialog; I was trying to launch it via result = dlg.ShowModal(). Thanks.
Javi Domínguez
El 21/08/2022 a las 14:12, DaVid
escribió:
My driver IBMTTS launch a file dialog from the configuration settings, it shows a category in the NVDA settings dialog. You can use that add-on as reference. But I have a personal add-on that launch a file dialog from a script, I did not publish the add-on because is just for personal purposes, but see the code I used here. This is the function called by the script: def setFile(self): d = wx.FileDialog(gui.mainFrame, message= _("Select the text to show in the document loader"), # Translators: the label for the text document extension (txt) file type wildcard=(_("text files (*.{ext})")+"|*.{ext}").format(ext="txt")) def callback(result): if result == wx.ID_OK: text = open(d.GetPath(),encoding="utf-8").read() self.document = SimpleTextResult(text) self.documentUi = CustomTextUi(result = self.document) self.documentUi.setFocus() gui.runScriptModalDialog(d, callback) Regards, David CM. 2022-08-21 3:42 GMT-06:00, Javi Domínguez <fjavids@...>:Hello. Does anyone know why I can't use a wx.FileDialog in a globalPlugin script? NVDA crashes. However, elsewhere, for example calling it from the NVDA menu it works perfectly. Thanks |
|