Simplecv & shell input - shell

I'm developing an app using SimpleCV and I want to use shell while this application runs, to input commands. I'm using Python and since this SimpleCV is a running thread, how am I gonna wait for key events?

You may want to look at some of the examples using GTK(https://github.com/ingenuitas/SimpleCV/tree/develop/SimpleCV/examples). We don't have the shell setup to handle async events. You can look at the Display class and see how we extended pygame to try and build your own version of it.
It would very well be possible because we are using ipython and they use kernels, you can attach multiple shells/processes to a single kernel. My recommendation would be to do it this way and have your GUI application talk to the same kernel that way variables/objects share the same namespace.

Related

Extract state from non-interactive LLDB session?

Is it possible to extract the current state of a C/C++ program using LLDB, without starting an interactive session? I've seen some information about the LLDB API but I haven't seen much info about how to use it, and if it can even accomplish what I'm looking for.
Ideally, I would write some code in Python or something, that is external the code I am debugging, where I use the LLDB API to get information about the current program, such as current variables and values, and can start and stop execution. Is this (or a subset of this) possible? Is there some alternative?
Here is some pseudocode for what I would like to do:
state = program.getState()
print state.values
program.next()
newState = state.set("newVariable", 10)
program.setState(newState)
program.continue()
The Xcode debugger is implemented using lldb's API's. Xcode happens to offer an lldb command console as well, but all the UI commands are implemented using the public SB API's directly.
So it is certainly possible to do what you want.
Here's an example of driving a program with the SB API's:
https://github.com/llvm/llvm-project/blob/master/lldb/examples/python/process_events.py
Here's an example of fetching all the global variables and their values:
https://github.com/llvm/llvm-project/blob/master/lldb/examples/python/globals.py
There are a bunch of other examples in that directory that do parts of what you might be interested in. If there's anything (within reason) you want to do with the SB API's but can't find a way to do, please file a bug with http://bugs.llvm.org. The intent is that the SB API's provide a complete interface to LLDB, orthogonal to the command interpreter.
Of course, you can also use the command interpreter in non-interactive mode if you prefer (through the SBCommandInterpreter class), though I don't suggest that for programming the debugger since that ends up tying your code to the specifics of the output of the various lldb commands, and we don't guarantee that output as API...

Is there a recommended way to repeatedly call matlab from an external program?

I am repeatedly calling a matlab script MyMatlabScript from another program (written in Erlang). I am doing this using a batch file containing the following:
matlab -nodesktop -nosplash -wait -r "addpath('C:/...'); MyMatlabScript; %quit;"
This means that Matlab has to launch everytime I run the batch file script. It works but is slow*.
To improve performance I would like to be able to launch Matlab once and then somehow, using Erlang or a batch script, repeatedly initiate my Matlab script using that one instance of Matlab.
Can this be done?
Note, I am using Matlab 7.8.0 (R2009a) on Windows7.
*Extra slow due to issue outlined here!
It is not simple. But you can try using COM automation server interface in MATLAB. You need to have Erlang library for interfacing with COM automation servers. With this interface you can create an automation server and then keep sending commands to it. The documentation is available at http://www.mathworks.com/help/matlab/call-matlab-com-automation-server.html. In the documentation there are examples which use Visual Basic code.
I do not know whether passing messages into Matlab is a viable option, but I would like to propose an alternative. Matlab has a "timer" object, which lets you specify a call-back-function. In regular intervals, the Matlab call-back-function could check a file, which is changed by your Erlang program. A changed file triggers the desired Matlab routine. Well, it is not "haute cuisine" in terms of programming style, but it should do the job.
I have experience in just this. There are three predominant options:
Erlang command line calls to Matlab using os:cmd()
Writing a protocol that will require the two applications to be separate and communicate over tcpip. Benefit is the now Erlang is a server or vice-versa, however you code it. Challenge is the protocol code in Matlab, Erlang is particularly built for it.
Make a system pipe. If you're sticking to windows (NamedSystemPipe) then you really shouldn't have a problem finding docs around on how to do it.
I prefer Method 3 for local only comm and 2 for anything network based. Using 1 gives you the absolute least flexibility. There are more but since you're asking, this is what I recommend.
And best of all is that 'slow' problem is gone by not using 1.

Attaching a plugins gui to the hosts gui

I'm writing an application with plugin support. I use C++ and JUCE for that stuff and I want my application to run on windows and MAC OSX (and maybe linux some day).
My plugins have their own GUI. The usual way to display a GUI from a shared library seems to be :
create a new window
get the native handle for it
pass it on to the library
let the library attach its GUI to that handle.
AFAIK that always requires to create a new window for the plugins GUI. My problem is: I would like to have the GUI of the plugins to appear inside the GUI of my host application (= not as a separate window).
I think this is a common thing to do, but I just can't find any concepts for that. How would you solve such a problem?
Thank you very much for ideas and hints!

Console widget wxpython

I have forked an interpreter written in C (Picoc), and I want to create a GUI for that interpreter.
The GUI should have a textarea (TextView in pygtk) and a console in the bottom, that will show the output of the script that you just written, and also prompt the input if its needed.
I do create a PyGTK GUI that has VTE Console widget, but the problem is that i want to make PyGTK cross-platform, i'm using GTKSourceView and as i was looking on Google, its no so easy to port GTK to windows, so, i research about WxPython (which is the same window Manager of Code::Blocks), but the question is:
It DO exists a Console Widget on wxPython?
and most important, how portable it is? can i port it to windows easier than GTK?
It was my understanding that PyGTK is cross-platform. It just doesn't use native widgets. I've certainly used an application written in it on Windows anyway. Admittedly, I've never had much luck actually using it on Windows.
As for wxPython, no it doesn't have a console widget. You would have to use Python's subprocess to launch a console window and communicate with it. On the other hand, wxPython is quite portable. I've seen screenshots of apps on all 3 major platforms and I've written a couple of mine to work on Windows and Ubuntu.

Creating GUI for linux CLI

I am a final year computer engineering student. As my final year project, I have decided to create a multimedia encoder for linux, possibly cross platform.
My question is: How can I create a GUI for ffmpeg (i.e. how can I pass command line arguments from the GUI)?
I am trying to use QT for cross platform development.
Tcl/Tk was designed to embed scripting into C programs and is probably the easiest of any language to do this with. It has several mechanisms for doing this embedding. The API makes it very easy to retrofit it to command-line C programs using argv as it has calls for converting native Tcl data structures to and from char**. It also has GUI toolkit called Tk that is somewhat basic but very easy to use and substantially more flexible than you might think.
In your case, the two mechanisms you would probably use in Tcl are the embedding where you just call main with the arguments passed from your Tcl program. The other is to fork the process with appropriate command line args and wait for it to complete. Both are fairly easy to accomplish with Tcl.
I'm not aware of any QT bindings for Tcl but it is very portable and Tk can be themed thesedays so it doesn't look like a 1990 vintage Motif app.
Se this posting for a more in-depth discussion of the topic.
Do you want to call ffmpeg from within your application? If so, look at QProcess. You can even capture the stdout and stderr streams from the ffmpeg process and use that information to (for example) drive a progress bar or display errors.
If you actually want to embed one GUI application inside another, that's a lot harder, especially to do in a platform independent manner.
The Red Hat folks use Python and pyGTK to write their CLI GUI's.
Blog posting: http://www.oreillynet.com/onlamp/blog/2008/02/red_hats_emerging_technology_g.html

Resources