0
I am creating a virtual assistant that communicates with the user through notification messages. I researched a lot on the internet about and found the win10toast
.
So far the program is working perfectly, however today, I was implementing a function for the user to define directories for the wizard perform searches of programs and others on the computer.
Code to select a directory:
from tkinter import Tk
from tkinter.filedialog import askdirectory,askopenfilename
def getDirectory():
Tk().withdraw()
path = askdirectory()
return path
The problem is that it does not work. It does not open a window to select a directory. I have tested remove from the code the part that uses the win10toast
and worked the function getDirectory()
.
Code to display wizard message:
from win10toast import ToastNotifier
class MessageBox(object):
def __init__(self,icon=None):
self.__icon = icon
self.__toastNotifier = ToastNotifier()
def send(self,title,message,duration=5,threaded=True):
# Se eu retirar este método a função getDirectory funciona.
self.__toastNotifier.show_toast(
title,
message,
icon_path=self.__icon,
duration=duration,
threaded=threaded
)
Example of execution:
messageBox = MessageBox() #Inicializar um objeto de ToastNotifier não gera problemas para o getDirectory.
# Se eu retirar essa linha, o getDirectory funciona.
messageBox.send("Jarvis","Aperte Windows + S para falar.",threaded=False) #Envia mensagem
command = assistant.listen() #Retorna uma string
if command.lower() == "adicione caminho":
path = getDirectory()
if path and not path in paths:
paths.append(path)
What could be generating this problem and how can I solve it ? I know there are similar problems this and that there is a solution, but in my case this solution does not work.
the above codex does not have the aao call "win10toast", and therefore "works perfectly". I don’t see how anyone can help you unless you set a minimum example with code that present the problem (in other words: including initialization and call to win10toast, the way you are doing)
– jsbueno
Ok I’ll put the question, but I don’t think it’s very necessary because win10toast has only one class with 3 methods being one to appear the notification, another to check if the notification is still active and another to perform something while destroying the notification.
– JeanExtreme002
like I said - without it, the code works, so there’s nothing to answer
– jsbueno
Searching, I found similar problems that had solution as for example this: https://github.com/pywinauto/pywinauto/issues/517. However in my case this solution did not work, so I wondered if someone who understands in depth about how the filedialog works can answer me.
– JeanExtreme002