I'm following the the tutorial on PyGTK socket where you embed a xterm window to another application.
I downloaded the file from here: http://www.pygtk.org/pygtk2tutorial/examples/socket.py
When I run it following this: http://faq.pygtk.org/index.py?req=show&file=faq19.015.htp I get two different results:
On Ubuntu Karmic Koala (GTK 2.16) the xterm appears detached from the socket window and it not usable.
On Lucid Lynx (GTK 2.17) the xterm window disappears, and the socket window seems to get the background from the xterm, but nothing happens and of course, it's not usable.
I've modified the script to look like this:
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
from subprocess import Popen
def plugged_event(widget):
print "Inserted a widget"
window = gtk.Window()
window.connect("destroy", gtk.main_quit)
window.show()
socket = gtk.Socket()
window.add(socket)
socket.connect("plug-added", plugged_event)
sock_id = str(socket.get_id())
cmd = ["xterm", "-into", sock_id]
Popen(cmd)
socket.show()
gtk.main()
Everything seems to work fine, the xterm is embedded to the socket window, but I can't use the keyboard on it and the cursor appears empty. This is the same in either versions of GTK. So, does any one know if this can be fixed or if this is a Bug?
On first glance that seems like a bug in the xterm plug/socketing. I can reproduce on Lucid. If you have vim-gtk installed, replace your cmd with:
cmd = ["gvim", "--socketid", sock_id]
And your script runs fine to embed vim.
Related
When running ipython 5 and 6 in a gnu-screen session, pasting multiple lines does not work.
If I run ipython in a normal terminal session, I see the following when I paste 3 import lines separated by newlines:
In [1]: import datetime
...: import os
...: import glob
...:
...:
In [2]:
If I do the same into a gnu-screen session, I see:
In [1]: import datetime
In [2]:
i.e., the results are truncated at the first newline.
Is there any ipython or screen configuration item that can be used to work around this and achieve the same paste behavior in both terminals?
EDIT: This issue has apparently been reported somewhere on the ipython mailing list, as referenced on this issue.
I ran into this problem as well with Gnu screen. The workaround I'm using is that I switched to Tmux. Tmux seems to have similar functionality to screen, and has a handy status bar that lists open virtual windows at the bottom. The default prefix key is CTRL-b.
More importantly for this question, pasting into an ipython terminal within a Tmux session works as expected for me.
I'm exploring to use Scala REPL bridge to shell.It is mainly achieved by import sys.process._ package and I can use "ls" ! to execute shell.
Now, I want to use "vi" ! to open a interactive vi editor, it is really crazy but very exciting. After entering the cmd in REPL, the terminal opens a init vi canvas. Unfortunately, the terminal is not reading any input from my keyboard.
Is it possible to open a vi in REPL?
from https://stackoverflow.com/a/29972867/1573825 (java solution):
import java.lang.{Process, ProcessBuilder}
System.out.println("STARTING VI");
val processBuilder = new ProcessBuilder("/usr/bin/vi")
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT)
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT)
processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT)
val p = processBuilder.start()
// wait for termination.
p.waitFor()
System.out.println("Exiting VI")
it doesn't even corrupt readline.
I wana use the pyoo.py package to control libreOffice via Python.
There are good tutorials available. First step is to open a socket with following command.
soffice --nologo --norestore --nodefault --accept="socket,host=localhost,port=2002;urp;"
But it does not work, it stucks.(Stucks means I enter the command in the cmd but no response)
If I kill the sOffice Process in the Task-Manger it will continue.
It worked once and than never again.
I use Win7 64bit and LibreOffice 5
First be sure that all instances and processes of soffice are closed, because if office is already open, it will not start listening on a socket.
Well there is something wrong with your command; it isn't working for me. What I normally use is:
chdir "%ProgramFiles(x86)%\LibreOffice 5\program\"
start soffice -accept=socket,host=0,port=2002;urp;
On Linux I use the following command, and the same arguments work on Windows:
loffice "--accept=socket,host=localhost,port=2002;urp;" --writer
EDIT:
From your comment, it sounds like you were able to get it to work by removing various arguments to see which one was causing the problem.
I have been struggling to get emacs CUA-mode working in the console where it works fine in X (in an xterm using emacs -nw).
The main features I want are shift-movement selection and ^C,^V,^X but any more would be helpful. So far I am using a local keyboard and monitor but ultimate goal is to get all this working over ssh using something like putty.
So far I have been working on getting my terminal to output the same control sequences that emacs expects to see for shift-movement (specifically S-<down> or <S-down>) and this works in the console when shift-select-mode is set in .emacs. So far so good, so I can shift select text from any emacs invocation type: X-windows, terminal ($TERM=linux or $TERM=xterm). This site has been very useful.
Shift-<down> displays as follows using cat -v and emacs happily maps <S-down> to this control sequence.
cat -v (then type shift-down)
^[O2B
Here's the problem, switch on cua-mode and the shift-selection stops working but ^C,^V and ^X starts working !? So I can either have shift-selection or ^C,^V,^X but not both at the same time.
-------
Setup:
emacs 23
Raspberry Pi
Raspian (similar to Debian)
You might like to try a more recent version of Emacs, since cua-mode has been slowly changed to use the same code as shift-select-mode. In Emacs-24.4, cua-mode actually uses shift-select-mode directly.
I'm interested in implementing a behavior in IPython that would be like a combination of ! and !!. I'm trying to use an IPython terminal as an adjunct to my (Windows) shell. For a long running command (e.g., a build script) I would like to be able to watch the output as it streams by as ! does. I would also like to capture the output of the command into the output history as !! does, but this defers printing anything until all output is available.
Does anyone have any suggestions as to how to implement something like this? I'm guessing that a IPython.utils.io.Tee() object would be useful here, but I don't know enough about IPython to hook this up properly.
Here is a snippet of code I just tried in iPython notebook v2.3, which seems to do what was requested:
import sys
import IPython.utils.io
outputstream = IPython.utils.io.Tee("outputfile.log", "w", channel="stdout")
outputstream.write("Hello worlds!\n")
outputstream.close()
logstream=open("outputfile.log", "r")
sys.stdout.write("Read back from log file:\n")
sys.stdout.write(logstream.read())
The log file is created in the same directory as the iPython notebook file, and the output from running this cell is displayed thus:
Hello worlds!
Read back from log file:
Hello worlds!
I haven't tried this in the iPython terminal, but see no reason it wouldn't work as well there.
(Researched and answered as part of the Oxford participation in http://aaronswartzhackathon.org)