How can I control the finder from vscode - python

Background:
Programming in Python (vscode)
on Mac
Story:
I am using selenium to automate a process and at some point throughout that process I have to upload a picture. I can click on the "from Computer" button that pops up but this opens the finder with all my files/documents. I do not know how I could tell python here to navigate to a given folder and klick "submit" (or upload).
Question:
Does anyone know a way to "control" the finder similarly to what selenium does for the web browser?
Thank you!
I have tried:
Selenium but it can not handle this (to my knowledge) since I am no longer in the browser.
I have also tried the package pyautogui but because I would like to be able to run the same program from several computers (the path will be the same) but they display the finder differently so I dont think that will do the trick.

Related

(Python, Windows) How to add a new folder to PATH without going to advanced settings? From command line?

I'm practicing python coding in my free time at work and am currently working on a little web scraping script. However, I kept running into an issue where the selenium webdriver wasn't in the PATH, and so last time I was online I found a way to go to the command line, type
echo %PATH%
which showed me all my directories. Then, I was able to add a new one which was where my webdriver exes were located. I realize now I could have just plopped the chrome webdriver into one of the directories shown, but I really want to figure out how I was able to do that. Unfortunately, all the guides I find online discuss going into Advanced System Settings, which unfortunately I'm locked out of due to work computer permissions. However, I'd love to be able to keep messing around with it. Any help would be greatly appreciated!
Thanks!
If you wish to set an environment variable from Windows Command Prompt, you can do so using the setx command:
setx PATH "%PATH%;<your-new-path>"
You won't see the new value when you echo %PATH% just after setting it this way, you need to close cmd and open it again.

pywin installed, but PythonWin cannot open

I installed pywin from this site. I used version pywin32-220.win-amd64-py3.6.exe, and it installed without any error.
I am trying to automate use of a software. To do this, I am following a tutorial that says I need to select something from the Tools Menu in pywin. So I expected to find a program with a GUI that I could open from the Windows Start Menu.
However, although I see pywin in Control Panel's Add or Remove Programs, it is not in the start menu, and I don't know where to find it or how to open.
If my description is too vague to suggest a solution, a useful answer to my query would be diagnostic questions I should be asking.
Thank you.
Additional information:
- I am using windows 10.
PythonWin is what I want, yes. It is not in the start menu. (I understand now that pywin32 would not show in the start menu.)
There is a pywin folder on my desktop. One of the subfolders is called Pythonwin. Inside that folder, there is no .exe file. There is a file called start_pythonwin.pyw, but clicking it does not open anything. Based on this webpage, PythonWin needs to be installed separately. Perhaps that is my situation. But there is no .exe file in this folder. I do not know how to install a program from a folder of files--if that is what I need to do, please provide a reference.
Before I can automate use of the softare, the tutorial mentioned above provides the following instructions (sorry, it's on the software site and you have to login, so I can't link). I need to open the GUI to do step 1, but I can't open it.
Instructions:
Open PythonWin and start the COM Makepy utility from the Tools menu. Locate DesktopController Library in the list of COM interfaces and click OK. This produces the following result.
">>> Generating to C:\Python25\lib\site-packages\win32com\gen_py\62401B69-06B2-4C4F-992E-B7A57EFBF059x0x1x0.py
Building definitions from type library...
Generating...
Importing module
Press return and then import the COM support module by typing...(at this point, the tutorial explains how to write code to automate the software...)
I need to select something from the Tools Menu in pywin
I think you mean PythonWin (it comes with pywin32 installer). PythonWin comes with a few tools to use with Pywin32 (it's a GUI program, a Python editor actually and it has a Tools menu). Check your tutorial again and make sure what it is that you're looking for. I could have checked it out, but you didn't provide a link or a quote so it's hard to help you.
Anyway, if it is PythonWin what you are looking for (and I think it is), it should be located along side Python in your start menu.
Hope this helps.
Ok, now that you have updated your question I can help a bit more.
I don't understand how the installer didn't install PythonWin on your Python Start Menu but ok. Since what you want to do is execute makepy, there is another way to do it besides the PythonWin program.
Go to your site-packages folder, then win32com and then into the client directory. So the path will be something like C:\Python36\Lib\site-packages\win32com\client\. There you will find a file called makepy.py and another called makepy.pyc. Either one of those can be used to launch the makepy tool.
Once you have used the makepy tool to create the wrapper to your COM object you can find it in the gen_py directory.
You can comment to this answer if you have any questions.

Clickable links in terminal output

My python program outputs a set of url links. When I run this on pycharm, I can directly click on the links and that will open them up in the browser. However, when I run the python file by double clicking on the .py file, the links are not clickable. I want the links to be clickable so it takes me to the browser directly.
Please support solutions with explanations as I am still learning. Thanks!
As outlined above, you need to use a terminal that supports clicking of URL's.
On linux, most terminals do this. Ex Gnome-terminal, terminator etc..
On Mac, try iterm2.

How to change icon on .exe using resource hacker when no icon option is available?

I've written a program and then used py2exe to convert it to a .exe file. Now im trying to use Resource Hacker to change the icon but when i right click the .exe and use resource hacker all i see is the following:
A folder named PYTHONSCRIPT
and a folder named 24 and thats it.
does anyone know what the issue is here and how to solve it? I've read all the other questions about this and none of them have been a lot of help.
EDIT- Also any alternative way to change the icon on my python script .exe file is also appreciated so by all means if you know an alternative way show me the path!

Create a desktop icon for a Tkinter script

I have written a python script with a Tkinter GUI. I would like to create a desktop icon that will execute this script so that the end-user (not myself) will be able to double-click the icon and have the GUI load, rather than 'run' the script from the terminal or python shell and then have to F5 from there.
Is there a way to do this? I have googled many arrangements of my question but most answers seem to be normal python scripts, not ones which are Tkinter based.
I am using a Raspberry Pi with Wheezy and Python 2.7
Thanks in advance.
I create executables(icons that I click to start the programs I write) using 'py2exe'. I use windows 7 and I am not sure if it would work for you with Raspberry Pi, but a google search may clear that up for you. I will provide the link below. Basically you end up with a folder with the executable(icon) and also some files, without which the executable won't work. It's unfortunate that you get this extra 'baggage', but it's still handy and the best solution I have come across. I don't think there is a much better way, but I am not 100% on that. Interestingly, I found that you could delete most of these baggage files and the executable would still work, it was trial and error, but it didn't take long. If I want to send the folder to someone, I zip it first.
py2exe is here
If you need a 64 bit binary you can get it here, along with, actually, pretty much every other version. get py2exe here also
Besides creating executable file other option is create simple .bat file:
Open notepad
Enter "C:\ProgramData\Anaconda3\python.exe" "C:\Users\Your ID\script.py"
First part is path to python.exe, second to your python script
save file as .bat file, ex. "open_program.bat"
Now simply double click on saved .bat file icon should open your script.
I like using cx-freeze to convert python scripts to exe.
There is very easy to follow documentation to do this. In short, you create a setup.py script that specifies what libraries and packages you want to include or exclude in your application.
You can then run the build in the console and it will create a build folder, in which will be an Application File. You can create a Desktop short cut using send to and selecting desktop.
Documentation link
You can save the script as a .pyw file so the user can click on the file and the GUi would open

Categories