How to create a GUI [duplicate] - python

This question already has answers here:
How to make a gui in python [closed]
(10 answers)
Closed 7 years ago.
I need to create a Form which accepts some user details and accordingly run a Python script and generate excel files. The code to generate the excel files is ready.
But, I need to create a GUI which asks for the details. I do not want this to be a web application, so I'm not using Django. Is there any other way I can create a standalone exe form (in Python or other languages) that can call my script?

I would recommend using something like TkInter or PyQt. These will allow you to design a user interface in Python and then grab values from them and attach events to them (The UI Objects).
Here is a little TkInter tutorial, and here is a PyQT tutorial on form layouts.
Personally, I would recommend PyQT (4 or 5) as there is a visual designer for the UI, which may speed up development.

Related

interacting with a user created gui dynamically using python

There is a user created GUI which is an .exe that loads a DLL. This GUI has a bunch of sliders, check boxes etc. I would like to move two sliders at the same time using python automatically without me using my mouse to move the sliders. I would like to know the python modules that an be used to achieve this purpose.
You can try using SikuliX.
It can be used to automate mouse or keyboard actions based on pattern matching. It is originally developed for Java I think, but it can be used with Python.
Basically, anything you can do yourself manually can be done with it.
The developer seems to be pretty active, so you can easily seek help from him if you have issues.

Open() in Python - Does a popup window exist? [duplicate]

This question already has an answer here:
How do I allow a user to select a file?
(1 answer)
Closed 4 years ago.
I am starting to look into Python from a learning perspective and I am finding it nice and easy after Java.
I am currently looking at working with files and I am using the 'with open()' command to make use of the open file only whilst the program is running.
However, all the tutorials I seem to come across only ever seem to hard code either a filename or file path into the open() command.
In Python or any of its libraries - does anyone know of a command I can use to allow the user a pop-up window to navigate and select where the file lives?
Kind Regards
Try using tkinter. tkinter is Python's de-facto standard GUI (Graphical User Interface) package. I will show an example
Either you can ask with this:
a_var = input('select directory of the file')
and then use the a_var to use the directory provided by the user
or
Use tkinter to ask the user to browse to the needed location

Porting a Python Shell Program to a Tkinter GUI

I have looked at similar questions that may answer my question but I am still very unclear on how to go about the following:
I can create programs to run in the Python Shell in Idle and I can also set up windows with widgets in Tkinter, but whatever I create in Tkinter is pointless because I cannot figure out how to take my Python Shell code and "wrap" it in the Tkinter GUI.
I have assumed that it cannot be done, and that entirely new code must be written to assist the language that is specific to Tkinter. I am very confused on how to create a well-rounded program without being left with just a GUI "skeleton" with random buttons, labels, entries, etc. and a Python program that is very unappealing and can only run in the ugly little Shell.
What you create with Tkinter is not pointless. It sounds to me like you're trying to compile a stand-alone program in Python, using the Tkinter library to provide the GUI. Once you have a script working, you can use a program to compile into a standalone program. Look into using py2app on a mac, or py2exe on Windows. Google them and see if that's what you're looking for.
Porting an application from command line to GUI might require some rework (depending on degree of interactivity you want to achieve).
Basically, in a GUI application, you build a few widgets (buttons...) at startup, and then perfom all your actions "on reaction" of user input. You typically do this by binding callbacks onto your widgets (button, input field), and then enter a mainloop (or eventloop).
You might read this chapter about events and binding.
If your application is mainly computing oriented, providing a gui with a "launch" button, and an output field is straightforward. If you perform some command line input, you can switch to widget input at low cost. More interactive apps will require to be architectured toward interaction capabilities.

How to continue executing a python script while showing a plot/figure? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a way to detach matplotlib plots so that the computation can continue?
I use python with matplotlib for scientific programming. But whenever I use the command show() to display a plot, the script just stops there. I have to close the figure window for the script to continue executing. Is there a way to keep the script running while the figure window is open, just like in Matlab?
Sounds like there's only one thread running, and so the rest of your script can't continue until the show function returns, which won't happen until the figure is closed. Should be relatively simple to call that show function in a newly created thread, which would allow the rest of your script to keep running. I'd look into the threading python module.

Python interactive CLI application?

I'm not even sure what these would be called? I used to write them in ADA running on VAX-VMS!
I want to make a simple menu-driven application that would let me display menus and use the cursor keys to navigate around them, choose items and navigate around the app. All fully old school text based.
I want to be able to take over the whole terminal window and display stuff in different places.
Is this possible in Python?
Check out the Python HOWTO on Curses Programming with Python and here is the library reference.
Another easy to use library is Urwid - Console User Interface Library.
http://excess.org/urwid/
http://excess.org/urwid/examples.html
Yes, have a look at the different curses implementations.

Categories

Resources