How to open a exe file with RenPy?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
slenderman64
Newbie
Posts: 9
Joined: Tue Feb 27, 2018 6:21 am
Contact:

How to open a exe file with RenPy?

#1 Post by slenderman64 »

Hello, i try this on Renpy but it not works (he does nothing) :

Code: Select all

label OPENFILE:
     python:
         import os
         os.popen("app.exe")
There is a way to open a exe file on RenPy?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How to open a exe file with RenPy?

#2 Post by PyTom »

You can use subprocess.Popen. I'd suggest doing the import from an init python block, or else in a python hide block. You'll also need to give the full path to the executable.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

slenderman64
Newbie
Posts: 9
Joined: Tue Feb 27, 2018 6:21 am
Contact:

Re: How to open a exe file with RenPy?

#3 Post by slenderman64 »

Now my code is:

Code: Select all

label OPENFILE:
     init python:
              import subprocess
              subprocess.popen("C:/app/app.exe")
but i have this error:

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script-example.rpy", line 509, in script
init python:
File "game/script-example.rpy", line 511, in <module>
subprocess.popen("C:/app/app.exe")
AttributeError: 'module' object has no attribute 'popen'

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/script-example.rpy", line 509, in script
init python:
File "C:\Users\UTILISATEUR\Desktop\renpy-6.99.14.1-sdk\renpy\ast.py", line 848, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\UTILISATEUR\Desktop\renpy-6.99.14.1-sdk\renpy\python.py", line 1812, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script-example.rpy", line 511, in <module>
subprocess.popen("C:/app/app.exe")
AttributeError: 'module' object has no attribute 'popen'

Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
test 0.1.0
Sat Mar 03 01:50:31 2018


line 509 is init python:
line 511 is subprocess.popen("C:/app/app.exe")

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to open a exe file with RenPy?

#4 Post by trooper6 »

I noticed that PyTom wrote subprocess.Popen while you wrote subprocess.popen
That capital P might make a difference.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

slenderman64
Newbie
Posts: 9
Joined: Tue Feb 27, 2018 6:21 am
Contact:

Re: How to open a exe file with RenPy?

#5 Post by slenderman64 »

It works!

now my code is:

Code: Select all

label OPENFILE:
     init python:
              import subprocess
              subprocess.Popen("C:/app/app.exe")

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: How to open a exe file with RenPy?

#6 Post by xavimat »

But, don't put "init python" inside a label.
"init" is the phase where renpy loads,and labels are executed when the game reaches them:

Code: Select all

init python:
    import subprocess
label OPENFILE:
    python:
        subprocess.Popen("C:/app/app.exe")
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Bing [Bot]