interactive

How do I push a string to stdin? Provide input via stdin on startup, then read stdin input interactively

谁说胖子不能爱 提交于 2019-12-04 13:36:21
Is there a way to "push" a string to the stdin stream of a program when calling it? So that we would have the effect of echo "something" | ./my_program but instead of reading EOF after "something" , my_program would read its further input from the original stdin (e.g., the keyboard). Example: Say we want to start a bash shell, but the first thing we would like to do inside it is to call date . echo date | bash would not do the job, as the shell would terminate after running date . Jonathan Leffler This might work: (echo "something"; cat -) | ./my_program It creates a sub-shell where the first

Matplotlib interactive graph embedded in PyQt

大城市里の小女人 提交于 2019-12-04 09:45:20
问题 I've created a simple python script that when run should display an embedded matplotlib graph inside a PyQT window. I've used this tutorial for embedding and running the graph. Aside from some differences in the naming conventions and in the overall UI my graph is generated exactly as the one in the tutorial mentioned. My problem is that I would like to make this an interactive graph that allows for zooming and dragging, but I would like to do this with only the mouse (clicking and dragging,

How can I start an interactive console for VBS?

微笑、不失礼 提交于 2019-12-04 09:00:50
Very similar to this question: How can I start an interactive console for Perl? I just want to be able to start entering VBS statements, one at a time, and have them evaluated straight away, like Python's IDLE. Ansgar Wiechers I wrote this a couple years ago. It's based on this blog post (archived here ), but with a couple enhancements. Essentially it's a REPL (Read, Execute, Print, Loop) using the Execute statement: Do While True WScript.StdOut.Write(">>> ") line = Trim(WScript.StdIn.ReadLine) If LCase(line) = "exit" Then Exit Do On Error Resume Next Execute line If Err.Number <> 0 Then

Does an updated 'vimtutor' exist? [closed]

十年热恋 提交于 2019-12-04 07:35:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . vim comes with a nice built-in interactive tutorial. You can access this tutorial by just running: $ vimtutor It is very easy to use because it creates working cases for basic commands. Is there a more advanced tutorial? Has any one thought to build one to help uses take their VIM skills to the next level? Most

How to make an interactive program?

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:44:56
问题 I'm learning Ocaml and I need to create a program that can interact with the user in the following way: Program: "Welcome!" User: command1 arg1 arg2 program: "The answer is..." User: command2 arg program: "The answer is..." User: exit I need a scheme of the loop that make something like that 回答1: Here's a loop that will read lines of input until it reaches end of file, or sees a line that says "exit". let rec loop () = match read_line () with | "exit" -> () | s -> Printf.printf "I saw %s\n%!"

How do Ruby and Python implement their interactive consoles?

眉间皱痕 提交于 2019-12-04 03:44:54
When implementing the interpreter for my programming language I first thought of a simple console window which allows the user to enter some code which is then executed as a standalone program as a shell. But there are severe problems: If every line of code the user enters is handled as a standalone program, it has to go through the tokenizer and parser and is then just executed by the interpreter - what about functions then? How can the Python/Ruby interactive consoles (IDLE, irb) "share" the code? How is the code entered handled? Example: >> def x: >> print("Blah") >> >> x() Where is the

Get point information after dragging

随声附和 提交于 2019-12-04 03:42:02
问题 There is the amazing mpld3 for interactive matplotlib-plots in IPython Notebooks. mpld3 also features plugins. One is especially interesting for me: You can pick a point in the plot and drag it around - it is presented here: http://mpld3.github.io/examples/drag_points.html. The source code in the link generates the plot below. I would like to have the information back from the plugin where I have dragged my points to. But I really get lost in the javascript part and how I could get

bash: choose default from case when enter is pressed in a “select” prompt

你。 提交于 2019-12-04 02:04:00
I'm prompting questions in a bash script like this: optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;; 2) includeAudits=false; break ;; "\n") echo "You pressed enter"; break ;; # <--- doesn't work *) echo "What's that?"; exit;; esac done How can I select a default option when enter is pressed? The "\n" case does not catch the enter key. mklement0 To complement Aserre's helpful answer , which explains the problem with your code and offers an effective workaround, with background information and a generic,

Can I use Fabric to perform interactive shell commands?

回眸只為那壹抹淺笑 提交于 2019-12-04 01:22:46
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? This is in Fabric 1.0. I've tried it and it works for me. Older versions of Fabric (and similar high level SSH libraries) run remote programs in limbo, unable to be touched from the local end. This is problematic when

Matplotlib remove patches from figure

落花浮王杯 提交于 2019-12-04 00:34:13
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.axes([0.8, 0.025, 0.1, 0.04]), 'Reset', color='g', hovercolor='0.975') ax.add_patch(circle1) ax.add