Drag and Drop Files into Folders via Python GUI? - python

Problem
I'm trying to make a gui in python that displays two directories in two side-by-side panels and their contents (via tree, thumbnails, list, etc), which then allows the user to either:
drag files between both panels
select files to transfer (manually and via script), and transfer after user input
The point is to automate as much of the process as possible, but allow the user to verify each file's final transfer.
Is this possible? Which python gui library would be ideal for this? I'm just looking for a general direction, since I really don't know where to begin looking.
Current workaround
I have a python script that will sort mail into subfolders based on client, and then iterates through each client, simultaneously opening mail\<client> and the client's main file directory in explorer. I drag each file to its appropriate <main>\<client\<subfolder>, close the two windows, press 'enter' in IDLE, and it moves on to the next client. Tedious, but it's a rough implementation.
System info
Windows XP, Python 2.7

Well, you could implement a custom drag-and-drop with any GUI framework, so you might consider using Tkinter, since it's built-in to the standard Python library.
If you need to be able to drag-and-drop between applications, it's a bit more complicated, but supposedly can be achieved with Tkinter, although you might prefer to use wxPython, for which there's an example on the wiki.

For anything file related I would use the Python os module, http://docs.python.org/2/library/os.html

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.

python 3 create a GUI to set directory in a program

I would like to create a GUI that pops up asking where to download a file using python. I would like it to be similar to the interface that Google Chrome uses when downloading a file as that looks pretty standard. Is there a default module or add on that I can use to create thus GUI? or will I have to create myself? any help would be appreciated.
If You mean the dialog window, in which You chose where to put file, it's tkinter.filedialog (https://docs.python.org/3/library/tkinter.html), which would give the most native look and feel.
But if You mean the dialog, in which You chose whether to save file in default location or specify another one, there's no such widget, but You may build it on Your own. For that case You probably should dig into Chromium sources, to determine how exactly it acts(https://chromium.googlesource.com/)
There are a number of GUI toolkits you could use, including:
Kivy (modern touch-enabled)
Tkinter (bundled with Python)
These have file chooser widgets, which you could use that would provide standard-looking interfaces to your file system.
How do you want to run this program?

How to read/edit a GUI/MFC application in Python?

I want to automate one of my tasks, by changing a third-party GUI/MFC application's properties as per my requirements. Every time I need to carry out any testing, I need to change the properties of the application to test my software.
I tried to automate it by using Python and IronPython. After Googling a lot I found IronPython, because the GUI is written C# and VB.NET.
Suppose when opening the GUI in its editor it gives me the option to edit the properties, MFC contains lots of controls.. e.g.:
Enter Time |__| //Need to enter the value in the box
Enter the dealy |__| //Need to enter the value in the box
Want to display |_| //Check box , check or uncheck
some Radio buttons.
Some more controls.
....
....
I want to control all the changes from my Python script. I will just enter the value from my script and it will update them in the GUI.
I wrote a script in IronPython to read the GUI:
fw = open("MyFile.vnb", 'r')
for line in fw.readlines():
print (line)
I found plenty of encrypted/encoded characters along with some of the C#/VB.NET codes in the console. So, I am completely stuck here.
I would like to know can we edit a third-party GUI with Python/IronPython or not? Do I need to use some special tools from Python to edit the GUI?
If you need classic GUI automation you can control MFC application by pywinauto library. You can send keyboard events, mouse clicks, moves etc. pywinauto has also limited support for .NET controls (simple automation like buttons, text boxes etc. is available). I guess this is realistic task (see sample video by the link above).
But if you need some binary instrumentation to change the GUI executable permanently (it sounds strange), this is completely another topic. Read about PIN tool. It's used for profilers development, for example. Collecting stack samples, unwinding call stacks and other tricky reverse engineering things. :)

Drag drop file onto Python script

I'm looking for a cross-platform way of making my Python script process a file's path by implementing a drag n drop method. At the moment I manually go to the terminal and use the sys.argv method:
python myscript.py /Python/myfile.xls
However this is slow and "techy". Ideally I would a quick and interactive way of allowing a file be processed by my Python script. I primarily need this to work for Mac but cross-platform would be better.
If you want to use Tkinter, have a look at the Tkinter DnD binding from here http://klappnase.bubble.org/TkinterDnD/index.html
When run, the binding shows an example with a listbox that allows you to drag a file on to it.
Do you want to drag and drop the myfile.xls onto your python script within your file navigator ? Say Finder or whatever on Mac, Explorer on Win, Nautilus etc. ? In that case there will not be a simple cross-platform solution, given that you will have to hook into different software on different systems.
For a Mac specific solution try AppleScript - here is a sample
And for something Pythonic there is http://appscript.sourceforge.net/ , http://docs.python.org/library/macosa.html
Otherwise the solution is in the answer above. Use a custom GUI built in Tk, or wx or QT. You can look up their respective documentation for drag and drop, they do have cross-platform ways of doing it.
It'd be easiest to just write a small GUI with Tkinter or something similar and have the user select a file from within the GUI. Something along these lines:
import tkFileDialog
f = tkFileDialog.askopenfilename()
# Go on from there; f is a handle to the file that the user picked
I'm not aware of any cross platform methods to get a script to work with drag and drop, however. This is probably easier, though.

Detect Areas of Text in Screenshot

I'm working on a project to increase the ability for wine to automatically test software packages. What I'm looking to do now is detect text in the screen capture of the current window. I can then parse all of the text and use autohotkey to give a mouse click on the coordinates of the text I want.
For example, in firefox, I might want to test different things, the first open being opening preferences. I would then need to parse the screenshot of firefox, detect all of the separate locations of text. I can then run these separate images of text into tesseract-ocr and detect which one, says "Edit". I then redo this again for "preferences".
I've tried to find a solution but so far can't find anything. I'd prefer a solution that uses python or has python binds as thats what I've been programing in so far.
A possible starting point is Project SIKULI. It is a tool to automate GUI testing. It is written in Java, nonetheless it includes a scripting environment based on Jython, hence modifying it to support python script may be not too difficult.

Categories

Resources