-3

I'm a starting programmer looking to make a simple text based RPG from scratch. I know there might be an easy tool to do this but I want as little handed to me as possible to use this project as a sort of learning possible. I've been using Python and so far I really like it (I'm willing to use Java or Javascript if absolutely necessary.)

My problem though is that right now I'm using the console to run the game but I'd prefer to run it as a standalone application (also so I can distribute it in like an .exe or similar). Is there some simple way I can do this? Everything is in Unicode, so it just needs to be able to display Unicode text (in-line preferably) and have some way to check for key presses (to type commands).

I've looked into Kivy, but it seems far beyond what I need and the text it displays is not in-line and must be displayed line by line. Plus it doesn't seem to be able to be exported to a single file.

Thanks for the help and remember I'm very much a newbie.

W. Miles
  • 113
  • 6
  • By "standalone application" do you mean not in the console? A graphics interface? A web-based application? – rassar Dec 05 '16 at 21:16
  • @rassar Like a graphics interface, that can be run from a file like an .exe. Sorry should have been more clear. – W. Miles Dec 05 '16 at 21:17
  • have you looked into `tkinter` https://docs.python.org/3/library/tk.html ? also what version of python are you using? – rassar Dec 05 '16 at 21:20
  • I'll look into that, seems like it might be what I'm looking for. I'm currently using 2.7.0 – W. Miles Dec 05 '16 at 21:22

2 Answers2

1

If you want a GUI in Python, you can use TkInter, which is fairly easy to learn (https://wiki.python.org/moin/TkInter).

However, if you want to make it an executable so you can share it then you have to use something like the following:

cx_freeze (http://cx-freeze.sourceforge.net/)

py2exe(http://www.py2exe.org)

PyInstaller(http://www.pyinstaller.org)

These will 'freeze' your Python scripts by including the interpreter and libraries in the .exe file. There's a lot of information in this previously asked question; How do i convert a Python program to a runnable .exe Windows program?

Community
  • 1
  • 1
  • 1
    This seems like what I need. I'm investigating TkInter, and it seems like what I want. I have looked into some of those before and once i get to that point I'm sure I'll look closer. Thanks. – W. Miles Dec 05 '16 at 21:32
0

Here's a basic example of a text thing in tkinter:

from tkinter import *

root = Tk()
playerEntry = Entry(root)
textLabel = Label(root, justify=LEFT)
playerEntry.pack()
textLabel.pack()

def changeText(addText):
    textLabel.config(text = textLabel["text"] + addText + "\n")   

def get(event):
    changeText(">>> %s" % playerEntry.get())
    do_stuff()
    playerEntry.delete(0, END)

def do_stuff():
    changeText("Stuff is happening")

playerEntry.bind("<Return>", get)

root.mainloop()
rassar
  • 5,412
  • 3
  • 25
  • 41