Python Forum
Subprocesses not opening File Select Dialog
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subprocesses not opening File Select Dialog
#1
Hello ,
I am trying to run a command which should open up a File Select Windows widget in Kivy. Kivy has the non-native FileChooser class which is not user friendly in my perspective. My plan is to use a subprocess call to run a powershell script which would open a File Select Dialog.

class UserInfoWidget(BoxLayout): def browse_file(self): p = subprocess.Popen(["powershell.exe", '"' + os.path.join(os.getcwd(), "filebrowser.ps1")+'"'], stdout=sys.stdout) p.communicate()
Clicking the button once the kivy gui is launched gives the default statements in the shell and then when button is clicked gives
C:\Users\Dell\OneDrive\Desktop\New folder\filebrowser.ps1 in the shell.Why is the File Dialog not opening?
It is opening when I run powershell.exe ./filebrowser.ps1 in windows powershell or command prompt.
Img1- https://ibb.co/1G5SKMF
Img2 - https://ibb.co/bR44JqK
Reply
#2
Try to remove the two '"' in the subprocess arguments.
Reply
#3
I fixed it now. And those " " are important because of file paths like "C:/Users/New Folder/...". Observe the space please. I copied this code from StackOverflow

class UserInfoWidget(BoxLayout): def browse_file(self): co_initialize = ctypes.windll.ole32.CoInitialize co_initialize(None) import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import OpenFileDialog file_dialog = OpenFileDialog() print(dir(file_dialog)) file_dialog.Filter = "Excel files|*.xls;*.xlsx" ret = file_dialog.ShowDialog() # if ret != 1: # print("Cancelled") # sys.exit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Hard disk structure like a file selection dialog malonn 2 2,524 Aug-09-2023, 09:14 PM
Last Post: malonn
  select files such as text file RolanRoll 2 2,488 Jun-25-2022, 08:07 PM
Last Post: RolanRoll
  [S0LVED] [Tkinter] Center dialog? Winfried 8 9,881 Mar-01-2022, 07:17 PM
Last Post: Winfried
  Facing Problem while opening a file through command prompt vlearner 4 4,175 Jan-30-2022, 08:10 AM
Last Post: snippsat
  how to view all installed software in a dialog Tyrel 6 4,292 Oct-09-2021, 08:11 PM
Last Post: Tyrel
  Set Text in Open Dialog Box giddyhead 0 2,902 May-21-2021, 06:31 PM
Last Post: giddyhead
  Terminating Subprocesses and Threads while they're calculating lvlanson 4 6,075 Oct-17-2020, 12:33 PM
Last Post: lvlanson
  Opening file and outputting its text content example leodavinci1990 1 3,058 Oct-12-2020, 05:33 AM
Last Post: buran
  File Opening Hitso 10 8,300 Jun-05-2020, 10:35 AM
Last Post: DeaD_EyE
  Test a file for a string without opening it? tester_V 2 3,576 Jun-03-2020, 06:40 PM
Last Post: tester_V

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.