Re: [python-win32] Using win32com.shell to browse iphone photos | problem with pywebview

2022-05-11 Thread Tim Roberts

Bastian Schnitzler wrote:

I want to use win32com to transfer photos from my iphone to my
computer (I found a code snippet here, that worked for me:
https://gitlab.com/lassi.niemisto/iphone-photo-dump/).
In addition I would like to use pywebview to build a GUI.
...
It is the same, except that the folder for Apple iPhone is missing on
the second go.

Why is the shell behaving differently here? Is this a bug in win32com
or is pywebview influencing it somehow? What can I do to make it work?


Have you tried configuring your app to use a local web server? If you 
don't run your own server, then your pywebview app runs inside the 
browser's process, and that is a highly protected sandbox.  That's 
probably why you don't see external devices.


--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



smime.p7s
Description: S/MIME Cryptographic Signature
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Using win32com.shell to browse iphone photos | problem with pywebview

2022-05-11 Thread Bastian Schnitzler
Hello,

I want to use win32com to transfer photos from my iphone to my
computer (I found a code snippet here, that worked for me:
https://gitlab.com/lassi.niemisto/iphone-photo-dump/).
In addition I would like to use pywebview to build a GUI.

Behaviour of the shell listing the resource "My computer" is
unexpected when I access the win32com functions through pywebview as
it is not showing my iphone then.

Here is a minimal working example (you may have to replace the String
== "Dieser PC" according to the language of your windows):

from win32com.shell import shell, shellcon
from webview import create_window, start, windows

class Api():
def listFoldersDieserPC(self):

folder = shell.SHGetDesktopFolder()
for item in folder:
print("loop: ", folder.GetDisplayNameOf(item,
shellcon.SHGDN_NORMAL))
if folder.GetDisplayNameOf(item, shellcon.SHGDN_NORMAL) ==
"Dieser PC":
new_folder = folder.BindToObject(item, None,
shell.IID_IShellFolder)
break

# list folders in Dieser PC/This Computer
for item in new_folder:
print("loop: ", new_folder.GetDisplayNameOf(item,
shellcon.SHGDN_NORMAL))


api = Api()
window = create_window('Test', 'index.html', js_api=api, min_size=(600, 450))
api.listFoldersDieserPC()
print("now from the browser")
start()

With index.html:
List
Folders

The first time I call the function api.listFoldersDieserPC directly
from python, the second time through the button in the pywebview
browser window.

This is the output:

loop: Dieser PC
loop: Downloads
loop: Bilder
loop: Musik
loop: Desktop
loop: Dokumente
loop: Videos
loop: Apple iPhone
loop: Local Disk (C:)

now from the browser

loop: Dieser PC
loop: Downloads
loop: Bilder
loop: Musik
loop: Desktop
loop: Dokumente
loop: Videos
loop: Local Disk (C:)

Process finished with exit code 0

It is the same, except that the folder for Apple iPhone is missing on
the second go.

Why is the shell behaving differently here? Is this a bug in win32com
or is pywebview influencing it somehow? What can I do to make it work?

Kind regards
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32