(I am using Python and ArchLinux)
I am writing a simple AI in Python as a school project. Because it is a school project, and I would like to visibly demonstrate what it is doing, my intention is to have a different terminal window displaying printed output from each subprocess- one terminal showing how sentences are being parsed, one showing what pyDatalog is doing, one for the actual input-output chat, etc, possibly on two monitors.
From what I know, which is not much, a couple of feasible ways to go about this are threading each subprocess and figuring out display from there, or writing/using a library which allows me to make and configure my own windows.
My question is, then, are those the best ways, or is there an easy way to output to multiple terminals simultaneously. Also, if making my own windows (and I'm sorry if my terminology is wrong when I say 'making my own windows'. I mean building my own output areas in Python) is the best option, I'm looking for which library I should use for that.
So you could go in multiple directions with this. You could create a Tkinter (or GUI library of your choice) output text box and write to that. This option would give you the most control over how to display your data.
Another option is to access multiple terminals via named pipes. This involves spawning an xterm with a pipe and pumping output to it to be written on screen. See this question for and example:
Using Python's Subprocess to Display Output in New Xterm Window
I like #ebarr's answer, but a quick and dirty way to do it is to write to several files. You can then open multiple terminals and tail the files.
Related
I'm reasonably confident this is possible. I have a python script that utilizes tkinter to do various tasks. Is there a way to integrate it into nedit such that it runs in the background? I think I need to edit the shell path, but I'm not entirely sure. Mainly I would like documentation for the nedit editor with respect to adding scripts. What I have found thus far is related to Macros, which I'm pretty sure is not what I want.
I don't have a choice but to use nedit so I want to add some QOL features.
My goal is fairly simple, I have written a python 3 script that runs on an ubuntu server at my workplace. Currently I (and other users) have to SSH into this ubuntu box anytime we want to run the script, which with a growing number of users is getting messy - from a convenience and security standpoint. So my boss would like me to create a nice webpage-based GUI to access this script and some other similar scripts I have written.
This seems like a straight forward thing, but the difficulty is in the details - the script is used for viewing and editing records so it has a lot of back-and-forth communication with the user (using input()) as well as screen clears and code like the following:
sys.stdout.write("\033[F") #back to previous line
sys.stdout.write("\033[K") #clear line
...to keep things clean and within one terminal.
If absolutely needed of course I could modify the script to accept inputs in a different format and output in a more html-friendly method without line and screen clears, but this would be rather tedious to redo for the whole script. SO - my question is what would be the best way to achieve what I'm after with minimal modifications to my written code? Ideally the webpage would just have a container holding a terminal-like graphic that handles all the input and output of the selected script as if it was running through a full fat terminal.
Things I've already looked into include basic python web frameworks such as CGI or mod_wsgi, or a python package like flask, but - correct me if I'm wrong - it seems there isn't a nice way to handle constant inputs within scripts with these let alone the terminal-oriented clearing I do for clearing lines and screens.
I also looked into ways to just host a full terminal on the webpage, and security concerns aside, this seems like the closest solution - using something like ajaxterm (which seems rather outdated now?) or wetty. My main concern with this is it isn't any easier than just using SSH at that point. Unless I could modify the terminal to auto-login and start a specific script automagically with the push of a button on the webpage, this would just be a glorified web-rendition of putty.
Any suggestions on how you would achieve this?
Hi I know this is a pretty basic design question. But I don't realy get it....
I write it in Python with PySide, but I think this is more a language unrelated question.
A simplified example what I want to do:
I Have a Gui with a button that opens a file dialog.
In this one I choose a folder.
The code scans the suffixes of the files in the folder and returns the 3 needed one. lets say .mp3, .txt and .mov and shows them in the gui.
To this point the seperation should be no problem I would have a Gui class that runs the code of the core class, gets the three files as return values and sets up the gui.
What I am wondering about is what happens when there are more then one files matching the .mp3 suffix. I would want to have a pop up with a combobox to select the one I want to use. But I don't realy get how to implement it without adding gui code to the core class.
Well maybe have the function in the Core module return some specifier that such a thing has happened (found multiple) along with the given names, then display the choice to the user and call a function in the Core module that returns relevant information about that file.
Bear in mind you do not have to be dogmatic regarding such restrictions, there are some situations where having code in the GUI is much less of a hassle than having to integrate some way of it to work in between modules.
This is where you make a decision how to go about writing the code, bearing in mind how important this feature is to you, how testable/maintainable you need it to be.
I am working with software that requires only occasional input and that otherwise runs completely in the background.
The input it requires is so simple that I have been able to fully automate it using OpenCV and python. Unfortunately in order to send the input, I need to use mouse events for this, resulting in my mouse being moved around. I tried other ways, such as sending other post_messages directly to the window, but they didn't work unfortunately. So since moving the mouse is the only way to interact, it hinders my productivity, since it will interfere with my daily work. Ideally I would like to use multiple desktops, where the mouse/keyboard inputs are completely separated and where I run all my usual stuff on Desktop 1 and the program & automation on Desktop 2. Doing this seems difficult, however, since there is only one input stream and I would need to have separate input streams which can be controlled individually.
So my question is basically if it is possible to have multiple desktops with independent inputs that can be automated separately?
Please note:
I know there are some solutions that provide input for two mice, but I haven't seen any info on how to interface with them (from python for example), and a lot of them seem to be buggy or discontinued.
I also know that I can use a virtual machine, but unfortunately that is a bit of an overkill, especially given that the underlying program that I want to automate requires quite a bit of resources and those are better used within my primary system.
I've found a Python telnet file, which works fine (at binary tides) but I'm hoping to (learn to) implement control over the input area such that I have shell like history and editing of the input line, uninterrupted by the feed from the telnet server I'm logged into.
I've seen some posts on this, would I be right to think that I need to learn threading so that I can simultaneously watch the server, the input line and handle the division of the console area, to do this? Similar to the discussion of threads/sockets here (SO separate threads for sockets..) except that is for Java and I'm trying to study Python.
Or perhaps SO TKinter is what I should put in my study list..?
EDIT: I should mention that I hope to move to GUI presentation eventually for my small projects but for this one I'm happy to use the console...I figured it might be a smaller step (learning curve).