wx.FileDialog and scripts
Javi Domínguez
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
--
Javi Domínguez
|
|
DaVid
My driver IBMTTS launch a file dialog from the configuration settings,
toggle quoted messageShow quoted text
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.
|
|
Abdel
Hi Javi, import gui Hope this helps. Kind regards, Abdel. Le 21/08/2022 à 11:42, Javi Domínguez a
écrit :
|
|
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
|
|
Javi Domínguez
Hello, Abdel.
Thanks. My code is very similar to this and in the console it works fine. The problem is that if I put that in a script NVDA crashes.
I think DaVid has given me the solution: use
gui.runScriptModalDialog instead of dlg.ShowModal. I will try it and tell you. Greetings
Javi Domínguez
El 21/08/2022 a las 14:16, Abdel
escribió:
|
|
DaVid
See the code I wrote in my previous e-mail, that function is launched
toggle quoted messageShow quoted text
from a script (using a gesture) and works perfectly for me. Try that function and if that function doesn't work for you, please send here the log, because that function is working on my machine. regards, David CM. 2022-08-21 7:07 GMT-06:00, Javi Domínguez <fjavids@...>:
Hello.
|
|