Launch and External Application

Post your Gambas programming questions here.
Post Reply
User avatar
sarpomira
Posts: 20
Joined: Monday 28th December 2020 4:15pm

Launch and External Application

Post by sarpomira »

Hi All,

I am having trouble finding the method to launch an external python application.
In the attempt below, I get a "File or directory does not exist " error.
The App.py resides on my Desktop and is definitely in the path I provided.
I wish to launch it in the linux teminal shell.

BUTTON:
Public Sub cmdExec_Click()

  Exec ["home/robert/Desktop/App.py"]

End
Any guidance would be appreciated.

Cheers
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Launch and External Application

Post by Quincunxian »

Hi sarpomira,

You may be able to get xdg-open to work for this.

xdg-open will find the correct application to open the file appended to the command.
I use the subroutine below in a module to globally open things like text, html, {office documents} ect.
If you have the appropriate applications installed and registered correctly then it should open any associated file.
Public Sub OpenDocument(InPath As String)
  
  Exec ["xdg-open", InPath]
  
End

The xdg family of utilities are quite good and are on 'most' linux installs.
Cheers - Quin.
I code therefore I am
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Launch and External Application

Post by BruceSteers »

sarpomira wrote: Thursday 15th July 2021 4:04am Hi All,

I am having trouble finding the method to launch an external python application.
In the attempt below, I get a "File or directory does not exist " error.
The App.py resides on my Desktop and is definitely in the path I provided.
I wish to launch it in the linux teminal shell.

BUTTON:
Public Sub cmdExec_Click()

  Exec ["home/robert/Desktop/App.py"]

End
Any guidance would be appreciated.

Cheers
you have no / at the beginning of the path...

try this..

Public Sub cmdExec_Click()
 
  Exec ["/home/robert/Desktop/App.py"]
 
End
If at first you don't succeed , try doing something differently.
BruceS
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Launch and External Application

Post by cogier »

Gambas has the tools to do this. You need to add the gb.desktop component for this solution.
''Requires the gb.desktop component

Public Sub cmdExec_Click()
  
  Desktop.Open(User.Home &/ "Desktop/App.py", True)
  
End
See the help HERE.
User avatar
sarpomira
Posts: 20
Joined: Monday 28th December 2020 4:15pm

Re: Launch and External Application

Post by sarpomira »

Thank you all !

This worked for me.
''Requires the gb.desktop component
 
Public Sub cmdExec_Click()
   
  Desktop.Open(User.Home &/ "Desktop/App.py", True)
   
End
Cheers !
Post Reply