Is there a way to add python games to renpy?

328 Views Asked by At

I'm coding a visual novel for a school project and I want to incorporate a mini-game made with python and tkinter. How can I do this?

I copied the code into renpy but renpy says "statement expected", and I don't think I'm doing it the right way. Thank you in advance!

label start:
"Welcome!"


from tkinter import *
window=Tk()
window.title('Hello Python')
window.geometry("300x200+10+20")
window.mainloop()
return

What I get: "from tkinter import-->* expected statement"...

1

There are 1 best solutions below

2
Alderven On BEST ANSWER

There is a way to launch other application (any application not only Python code) from RenPy code. Let's say this is your RenPy code:

$import os

label start:

    "Welcome!"
    $os.system(r"c:\renpy_test\game.py")

And here is your Tkinter game stored in c:\renpy_test\game.py:

import tkinter as tk
window = tk.Tk()
window.title('Hello Python')
window.geometry("300x200+10+20")
window.mainloop()

When you launch your RenPy game it then launches your Tkinter app:

enter image description here