Python Console UI Suggestions - python

I'm currently rewriting a perl console application that was using curses, and planning to implement it in Python. So far I've narrowed my library options to straight curses, urwid, and dialog.
The application is basically an installer for an appliance that will accommodate basic configuration (network options, hostname, etc). Are there any suggestions or advocates for one of these over the other? Any serious limitations with urwid or dialog?

urwid is a very complete UI interface and you can do almost everything. In fact, I'm developing an app using urwid. But, as Paulo Scardine said, dialog is a better choice for a wizard-like app.

Dialog is very easy to use and a good choice for an installer using 'wizard-like' interface.

Related

How to control a Windows application from Python

I have the application installed on my windows PC, I want to launch that application using python and select dropdown options and do some other activities in that application.
I was able to launch the application using the os.system command, but I am not able to proceed further.
I want my program to do things like:
* select from a dropdown menu
* click on a button
How can my application control the user interface of another application?
Normally, an application exposes a user interface (UI) for users, and an application programming interface (API) for programming.
A human being uses keyboard and mouse to work with the user interface (UI)
An application uses programming to work with the application programming interface (API)
The UI is designed for humans, and the API is designed for computers.
It is sometimes possible to use programming to control the user interface of another program -- so your program acts as if it were using the keyboard and mouse. This technique is often called "UI automation", and programs that do it are sometimes called "robots".
It's a big topic, and it can be quite complex. It's almost always better to use an API instead if you can: it's faster, simpler, more reliable.
If you do need to use UI automation, there are a few different tools that can help.
You are asking about Python, so here are a few UI automation tools that work with Python:
AutoIT is a standalone product, but you can use Python to script it.
PyWinAuto is designed for use from Python.
Sikuli uses computer vision to find parts of the screen. I believe it comes with a recording tool as well.
Just to repeat: UI automation is weird and hard. If you can possibly use an API instead, your life will be much easier.
You need to install pywinauto package
Try the following code to run the .exe file
from pywinauto import application
app = application.Application()
app.start("Notepad.exe")
here you are:
(with os ^_-)
import os
os.startfile('your exe file address')

How to control an outside executable application?

I have my own application on python 2.7. I want to control an outside .exe application.
I'm able to launch such an application, klm.exe as:
from win32com.client import *
ExtApp = Dispatch("Wscript.Shell")
ExtApp.Run("E:\XYZ\ABC\klm")
But I want to have full control of this outside .exe application as it has tabs, radio buttons, push buttons, etc.
Is there a way to do so?
But I want to have full control of this outside .exe application as it has tabs, radio buttons, push buttons, etc.
Is there a way to do so?
Yes, multiple ways, depending on the application.
Since you're already using COM (although I'm not sure why you're using it just to launch apps)… does the app have a COM automation (IDispatch) interface? If so, there will probably be documentation showing how to use it from VB# (or VBScript or C# or …), which you can easily adapt to Python and win32com. (For an example of such an application, see the Outlook automation docs.)
If there's no COM automation interface, there may still be a lower-level COM interface, which is almost as easy to use via win32com, but it usually won't provide any access to the GUI controls; instead, you'll be talking to the same lower-level functionality that the GUI uses. (For a good example, see Apple's iTunes COM Interface.)
If there's no COM support at all, the simplest thing to do is to automate it via Windows WM_* events. There are some examples of doing that in the pywin32 documentation, but there are also a lot of higher-level wrappers, like AutoPy and pywinauto/swapy, and so on that will make things a whole lot easier. There are dozens of these, free and commercial, and even more if you're willing to step outside of Python and use a different scripting system, and SO is not a good place to discuss the pros and cons of each.
Finally, you can always ignore the app's windows and just automate the system mouse… but this is almost always a silly thing to do.

How to use Python and HTML to build a desktop software?

Maybe my question is stupid but I still want to ask. I am always wondering whether I can use Python, HTML and Css to develop a desktop software. I know there are alrealy several good GUI frameworks like Qt, Tk and etc. But the various sources of HTML and JS frameworks are still attractive to me. I don't mean a software which is just like a web application where there is a frontend and Python acts as a server side language either. I mean use Python like other GUI frameworks. I can create widgets built by HTML and Css.
Dose there any framework have this function? I know there is app.js for Javascript. Or what I think is wrong.
Look at pyjs.
What is pyjs?
pyjs is a Rich Internet Application (RIA) Development Platform for both Web and Desktop. With pyjs you can write your JavaScript-powered web applications entirely in Python.
CEFPython allows this by embedding the Chromium browser and providing python bindings to it:
https://code.google.com/p/cefpython/
~: python example.py
brings up:

How to load SWF content into a Python application on Linux?

I have an application that uses Flash for the GUI and Python for the core logic. This combination is awesome. Unfortunately my current approach only works on Windows, as it uses the wxPython comtypes library to embed the Flash ActiveX player. Every other aspect of the app is platform-agnostic, so I'm thinking there must be some way on Linux to have Python talk to Flash.
The SWF need not require AVM2/AS3, though ideally I could use the most current Flash player available. I am using wxPython (wxWidgets) and would prefer to keep using it. Worst case I could jerry-rig something that loads the SWF in a separate process and talks over a socket connection to the Python, but I see no simple way to have the Flash display inside my application's window rather than a player window with its own menus and decorations.
Any suggestions appreciated. I'm very open to hacking at a solution if there's reason to believe it will work :)
Flash Professional has support to Adobe Air, so you could use it as front-end, usually a flash project can be released as an AIR application without major changes to its code. The communication could be done using Native Process Api (see links bellow). Then you can run it on Mac, Win e Lin.
http://www.kirupa.com/forum/showthread.php?349728-Air2-NativeProcess-launching-Python-scripts.
http://mykola.bilokonsky.net/2010/11/adobe-air-nativeprocess-and-python-introduction/

Any way to run python TK scripts on web page?

Is there any way to run a python script that utilizes TKinter on a web page such that a user could run the script and interact with the TK windows without having to download the script or have the appropriate python interpreter?
No. There is no way to do this.
The only approach I can think of, is to use some virtual screen protocol such as VNC, run your Tkinter script on a server for that protocol (e.g., a VNC server), and use a viewer browser plug-in for that protocol in the user's browser (e.g., maybe this one -- haven't tried it myself, though). A similar approach could use the NX protocol (e.g., cfr here).
Note that such solutions will most likely not scale well: they're mostly meant to let one user connect to "their desktop" from a browser. Performance, robustness and scalability of web-native approaches will all run rapid circles around any such "compatibility hack"!

Categories