interactive

Running an interactive program from Ruby

不问归期 提交于 2019-12-06 02:31:50
I am trying to run gnuplot from ruby (not using an external gem) and parsing its textual output also. I tried IO.popen , PTY.spawn and Open3.popen3 but whenever I try to get the output it just "hangs" -I guess waiting for more output to come. I feel like its somehow done using Thread.new but I couldn't find the correct way to implement it. Anyone know how it is done? I guess this is what you want: require 'pty' require 'expect' PTY.spawn('gnuplot') do |input, output, pid| str = input.expect(/gnuplot>/) puts str output.puts "mlqksdf" str = input.expect(/gnuplot>/) puts str output.puts "exit"

Sliding through images with Bokeh Slider

有些话、适合烂在心里 提交于 2019-12-06 01:51:20
I am trying to convey a large amount of scientific data seamlessly with the help of sliders. I am beginning with Bokeh and have close to no knowledge in javascript. I tried to setup a first approach to be able to slide through two images, but I cannot get the image to refresh. Suppose I have 1.png and 2.png in my folder. from bokeh.io import vform from bokeh.models import CustomJS, ColumnDataSource, Slider from bokeh.plotting import Figure, output_file, show output_file('image.html') source = ColumnDataSource(data=dict(url=['1.png'])) p = Figure(x_range=(0,1), y_range=(0,1)) callbackimg =

interact and plotting with ipywidgets events produces many graphs

谁说胖子不能爱 提交于 2019-12-05 23:36:45
I am trying to use widget events to make an interactive graph. %matplotlib inline import numpy as np import matplotlib.pyplot as plt import ipywidgets as widgets def myplot(n): x = np.linspace(-5, 5, 30) y = x**n fig, ax = plt.subplots(nrows=1, ncols=1); ax.plot(x, y) ax.set_xlabel('x') ax.set_ylabel('y') plt.show() Interact works as expected (it changes the figure interactively): widgets.interact(myplot, n=(0,5)); However the following snippet creates several figures that appear below as you interact with the slider. n_widget = widgets.IntSlider( value=2, min=0, max=5) def on_value_change

IPython notebook interactive function: how to save the updated function parameters

非 Y 不嫁゛ 提交于 2019-12-05 23:04:57
I wrote the code below in Ipython notebook to generate a sigmoid function controlled by parameters a which defines the position of the sigmoid center, and b which defines its width: %matplotlib inline import numpy as np import matplotlib.pyplot as plt def sigmoid(x,a,b): #sigmoid function with parameters a = center; b = width s= 1/(1+np.exp(-(x-a)/b)) return 100.0*(s-min(s))/(max(s)-min(s)) # normalize sigmoid to 0-100 x = np.linspace(0,10,256) sigm = sigmoid(x, a=5, b=1) fig = plt.figure(figsize=(24,6)) ax1 = fig.add_subplot(2, 1, 1) ax1.set_xticks([]) ax1.set_xticks([]) plt.plot(x,sigm,lw=2

Update mayavi plot in loop

怎甘沉沦 提交于 2019-12-05 22:46:06
What I want to do is to update a mayavi plot in a loop. I want the updating of the plot to be done at a time specified by me (unlike, e.g., the animation decorator). So an example piece of code I would like to get running is: import time import numpy as np from mayavi import mlab V = np.random.randn(20, 20, 20) s = mlab.contour3d(V, contours=[0]) for i in range(5): time.sleep(1) # Here I'll be computing a new V V = np.random.randn(20, 20, 20) # Update the plot with the new information s.mlab_source.set(scalars=V) However, this doesn't display a figure. If I include mlab.show() in the loop,

Using a vb.net application running as SYSTEM, how do I start a detached process for each logged on user?

天大地大妈咪最大 提交于 2019-12-05 18:49:37
After weeks of research on this topic I've finally decided to start a thread of my own in hope there is someone out there with experience that can help. I've scoured the internet trying to understand the various coding examples out there, but I've come up short trying to put a working solution together. Let me start with some background-- Background: I have a vb.net application that is getting delivered to Windows Servers and PCs in my organization using CA IT Client Manager (ITCM). Much like Microsoft SCCM, CA ITCM has an agent service running as SYSTEM on each PC. Hence, when my application

Custom scroll bar behavior in Javascript?

青春壹個敷衍的年華 提交于 2019-12-05 17:26:01
I'd like to reproduce an effect similar to this page: http://artofflightmovie.com/ where the vertical scrollbar controls the progression of the browser "viewport" over a pre-defined path. I am thinking the easiest way of going about this is through the use of javascript to read the scroll bar value and position background elements accordingly. Is it possible to obtain the vertical scroll bar value in Javascript? Am I approaching this design wrong? Is it possible to obtain the vertical scroll bar value in Javascript? var scrollTop = document.documentElement.scrollTop || window.pageYOffset; Am I

Can I use Fabric to perform interactive shell commands?

China☆狼群 提交于 2019-12-05 15:59:49
问题 I`m trying to use fabric to install and deploy a web project during which I need to create a postgresql database and configure a RabbitMQ server. Both these operations are interactive and requires input from the user for creating a database, adding a user, setting password etc ( at least to my knowledge ). Can I use a fabric script to do interative shell operations like these? 回答1: This is in Fabric 1.0. I've tried it and it works for me. Older versions of Fabric (and similar high level SSH

Matplotlib event_handling line picker

血红的双手。 提交于 2019-12-05 15:06:57
This example makes it possible to click a legend and thereby change a plot. I want to do something similar, but then not by clicking the legend, just by clicking the line in the plot. I tried to do it like this: self.ax = self.fig.add_subplot(1,2,1) data = NP.array(2,10) #filled with numbers self.x = NP.arange(2) for line in range(len(data[0,:])): self.ax.plot(self.x, data[:,line], picker=5) In every loop, an extra line is plotted. One line consists of 2 points, so it draws a straight line. But now every loop, the picker is the same, so no matter which line I click, the commands I wrote to

Matplotlib remove patches from figure

风流意气都作罢 提交于 2019-12-05 14:25:21
问题 In my case, I want to remove one of the circle when clicking reset button. However, ax.clear() would clear all circles on the current figure. Can someone tell me how to remove only part of the patches? import matplotlib.patches as patches import matplotlib.pyplot as plt from matplotlib.widgets import Button fig = plt.figure() ax = fig.add_subplot(111) circle1 = patches.Circle((0.3, 0.3), 0.03, fc='r', alpha=0.5) circle2 = patches.Circle((0.4, 0.3), 0.03, fc='r', alpha=0.5) button = Button(plt