interactive

Play multiple sounds at the same time in python

主宰稳场 提交于 2019-11-29 07:15:28
I have been looking into a way to play sounds from a list of samples, and I found some modules that can do this. I am using AudioLazy module to play the sound using the following script: from audiolazy import AudioIO sound = Somelist with AudioIO(True) as player: player.play(sound, rate=44100) The problem with this code is that it stop the whole application till the sound stop playing and I can't play multiple sound at the same time. My program is interactive so what I want is to be able to play multiple sound at the same time,So for instance I can run this script which will play a 5 second

How to convert string to integer in UNIX

孤街醉人 提交于 2019-11-29 01:50:33
问题 I have d1="11" and d2="07" . I want to convert d1 and d2 to integers and perform d1-d2 . How do I do this in UNIX? d1 - d2 currently returns "11-07" as result for me. 回答1: The standard solution: expr $d1 - $d2 You can also do: echo $(( d1 - d2 )) but beware that this will treat 07 as an octal number! (so 07 is the same as 7 , but 010 is different than 10 ). 回答2: Any of these will work from the shell command line. bc is probably your most straight forward solution though. Using bc: $ echo "$d1

Interactive(?) plotting in Spyder with matplotlib

陌路散爱 提交于 2019-11-29 01:41:28
I am trying to migrate over to Python from Matlab and can't figure out how to get interactive(?) plotting working within the Spyder IDE. My test code is shown below. With the .ion() nothing happens, I get a quick flash of a figure being drawn then the window instantly closes and spits out my Hello. Without the .ion() the figure is drawn correctly but the script hangs and doesn't spit out Hello until I manually close the figure window. I would like the script to run like a matlab script would and plot the various figures I ask it to while chugging along any computations and putting the output

Having a console in a single-threaded Python script

亡梦爱人 提交于 2019-11-29 00:38:47
I would like to have an interactive console in a single-threaded script that has several TCP connections open. This means I can't just have a standard input blocking the thread. Is there an easy way to do this? Or should I just put the console in its own thread and be done with it? You can subclass InteractiveConsole (from the builtin 'code' module) and override the push() method with a wrapper that redirects stdout/stderr to a StringIO instance before forwarding to the base InteractiveConsole's push() method. Your wrapper can return a 2-tuple (more, result) where 'more' indicates whether

Detect empty command

泪湿孤枕 提交于 2019-11-28 23:06:08
Consider this PS1 PS1='\n${_:+$? }$ ' Here is the result of a few commands $ [ 2 = 2 ] 0 $ [ 2 = 3 ] 1 $ 1 $ The first line shows no status as expected, and the next two lines show the correct exit code. However on line 3 only Enter was pressed, so I would like the status to go away, like line 1. How can I do this? Here's a funny, very simple possibility: it uses the \# escape sequence of PS1 together with parameter expansions (and the way Bash expands its prompt). The escape sequence \# expands to the command number of the command to be executed. This is incremented each time a command has

code manipulation via interactive tree for Mathematica

橙三吉。 提交于 2019-11-28 21:52:15
This question caused me to ponder an interactive method for editing code. I wonder if it is possible to implement something like this given the dynamic capabilities of Mathematica. Consider an expression: Text[Row[{PaddedForm[currentTime, {6, 3}, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"}]}]] And its TreeForm : I would like to be able to edit that tree directly, and then have the result translated back into Mathematica code. One should at least be able to: rename nodes, replacing symbols delete nodes, reverting their leaves to the node above reorder nodes and leaves (the order of

Interactive console using Pydev in Eclipse?

随声附和 提交于 2019-11-28 17:05:10
问题 I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint. For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a

Including JavaScript in SVG

只愿长相守 提交于 2019-11-28 17:03:41
I am trying to create an interactive SVG code with JavaScript, by embedding the JavaScript in the SVG. I don't know if this is the right way to do this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" onkeypress="move()"> <script type="text/javascript"> <![CDATA[ var x; var y; function move() { x = new Number(svg.getElementsByTagName("circle")[0].getAttribute("cx")); y = new Number (svg.getElementsByTagName(

Are there good Java libraries that facilitate building command-line applications? [closed]

妖精的绣舞 提交于 2019-11-28 16:31:16
I need to write a simple command-line application in Java. It would be nice to use a library that takes care of parsing commands and takes care of things like flags and optional/mandatory parameters... UPDATE Something that has built-in TAB completion would be particularly great. Kevin ORourke I've used the Apache Commons CLI library for command-line argument parsing. It's fairly easy to use and has reasonably good documentation . Which library you choose probably comes down to which style of options you prefer ("--gnu-style" or "-javac-style"). Michael Myers JLine looks helpful. JLine is a

Interactive web pages in Go

半城伤御伤魂 提交于 2019-11-28 11:51:58
Do you know if it's possible to create interactive web pages in Go? For example, having one or multiple buttons, or a combo box that refreshes the page with the data being filtered according to the choice? I've tried to look for it but didn't find anything relevant. Thanks in advance. Browsers are not capable of running Go code directly. Interactive web pages at the client side use different technologies, such as HTML, Javascript and CSS. However, it is a viable technology stack to use the above mentioned languages at the client side, and do everything in Go at the server side. That being said