Launch and External Application

Post

Posted
Rating:
#1 (In Topic #703)
Avatar
Regular
sarpomira is in the usergroup ‘Regular’
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:

Code (gambas)

  1. Public Sub cmdExec_Click()
  2.  
  3.   Exec ["home/robert/Desktop/App.py"]
  4.  

Any guidance would be appreciated.

Cheers
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
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.
  

Code (gambas)

  1. Public Sub OpenDocument(InPath As String)
  2.  
  3.   Exec ["xdg-open", InPath]
  4.  
  5.  
  6.  

The xdg family of utilities are quite good and are on 'most' linux installs.

Cheers - Quin.
I code therefore I am
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’

sarpomira said

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:

Code (gambas)

  1. Public Sub cmdExec_Click()
  2.  
  3.   Exec ["home/robert/Desktop/App.py"]
  4.  

Any guidance would be appreciated.

Cheers

you have no / at the beginning of the path…

try this..

Code (gambas)

  1.  
  2. Public Sub cmdExec_Click()
  3.  
  4.   Exec ["/home/robert/Desktop/App.py"]
  5.  
  6.  
Online now: Yes Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
Gambas has the tools to do this. You need to add the gb.desktop component for this solution.

Code (gambas)

  1. ''Requires the gb.desktop component
  2.  
  3. Public Sub cmdExec_Click()
  4.  
  5.   Desktop.Open(User.Home &/ "Desktop/App.py", True)
  6.  

See the help HERE.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
sarpomira is in the usergroup ‘Regular’
Thank you all !

This worked for me.

Code (gambas)

  1. ''Requires the gb.desktop component
  2.  
  3. Public Sub cmdExec_Click()
  4.    
  5.   Desktop.Open(User.Home &/ "Desktop/App.py", True)
  6.    

Cheers !
Online now: No Back to the top
1 guest and 0 members have just viewed this.