Read the statement by Michael Teeuw here.
MM and Custom Python Script
-
@extra my code can be used to display, and fade out would be a css setting
-
@sdetweil So your PythonPrint module will let me run my python script as MM is running, correct?
And how would I get the print statements to appear like the compliments (same font size, transitions. And if I have 2 sentences that need to be displayed it breaks up the words and fades them in/out in order)?
So basically, I press a button(which unmutes my mic), say my command, and have the results displayed to MM.
Here’s a sample of my python script:
#------------------------------------------------------------------------------------- #Search Wikipedia (General Info) #------------------------------------------------------------------------------------- if ('weather' not in command): if ('who is' in command) or ('what is the' in command) or ('what is a' in command) or ("what is" in command): if ('time' not in command): if ('news' not in command): speak('Searching Wikipedia...') command = command.replace("who is","") command = command.replace("what is the","") command = command.replace("what is a","") command = command.replace("what is","") results = wikipedia.summary(command, sentences = 2) #---------------------- #Auto typing animation: print("Baxter: ", end="") for i in results: sys.stdout.write(i) sys.stdout.flush() time.sleep(0.05) print("\n") #---------------------- speak(results) #------------------------------------------------------------------------------------- #Search Wolfram Alpha (Math/Conversions, Definitions) #------------------------------------------------------------------------------------- if ('weather' not in command): if ('news' not in command): if ('calculate' in command) or ("what's" in command) or ('define' in command): speak('Searching Wolfram Alpha...') command = command.replace("calculate","") command = command.replace("what's","") command = command.replace("define","") # Wolframalpha App Id appId = '' # Wolfram Instance client = wolframalpha.Client(appId) res = client.query(''.join(command)) results = next(res.results).text #---------------------- #Auto typing animation: print("Baxter: ", end="") for i in results: sys.stdout.write(i) sys.stdout.flush() time.sleep(0.05) print("\n") #---------------------- speak(results)
-
@extra my code puts the stdout output of the python script onto the page
you just need to specify css classes in custom.css
try the sample… it launches a python script that runs forever and prints output, the node_helper gets it and sends to module
module displays…
wrapper.innerHTML = this.config.message; wrapper.className += "PythonPrint"
so just set the class values in custom.css
.MMM-PythonPrint .PythonPrint { font-size:24px; color: yellow; }
-
@sdetweil Thanks will do. I just got a little confused, thanks for the clarification.
-
@extra u can use my code as the base for what u need, but it does 95%
splitting lines
easy in JavaScript, split()
how to handle the different lines… that’s your design and implementation
my code assumes one blob of text.