Python Forum

Full Version: So help to make a text rpg gui
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi folks.

I just started coding in python, and I had a lot of fun following several "courses" on youtube. However I have now run into a problem. I made a text rpg (a classic one where the player read a description and chooses one of 3 or 4 options) I put a lot of time and effort into the game, and I'm happy with the result. Every scene is defined as function, and the player input simply triggers a new function. The functions are basically print, input and a lot of if, elif and else commands.

The problem is that I would like the game to run in a separate window. Like a tkinter window, and not just in the terminal of PyCharm. But I can't find any tutorials regarding this. I watched several tutorials on tkinter, but can seem to find anything relevant.

So I'm in need to a link or a tutorial or something that can point me in the right direction. I don't mind putting in a lot of hours learning or programming, but I need to know where to look for any relevant courses, tutorials or anything that can put me on the right track.
(Mar-16-2019, 03:27 PM)bondsec Wrote: [ -> ]The functions are basically print, input and a lot of if, elif and else commands.

You might want to look at this tutorial. It will probably simplify your code a lot.

As to the GUI version, you would need to define what you want in more detail. Do you just want to replicate the command line in a GUI, or do you want to provide buttons that the player would click to move and do other things?
Thanks for the til, I'll make sure check out the tutorial as soon as I'm home.

As for the gui, I'm not really sure what will be the best option. I guess clickable buttons would be the coolest option. I already know how to bind buttons so I can (in theory) make buttons that can be clicked using the mouse, and make them run functions. The main problem is displaying the text in the gui. I know the lable command, but not how to run functions that would change the label.

I guess the first task would be to make a part of window display the text, then have some sort of input that will change the text to a new text with new options and so on. The game is really read, chose a, b, or c. Read the new text, she choose again.

Did that make my gui problems clearer?
(Mar-16-2019, 04:55 PM)bondsec Wrote: [ -> ]The game is really read, chose a, b, or c. Read the new text, she choose again.
(Mar-16-2019, 03:27 PM)bondsec Wrote: [ -> ]The problem is that I would like the game to run in a separate window. Like a tkinter window, and not just in the terminal
tkinter would probably be a good first GUI step then. You basically would only need buttons and labels
You can google around for tkinter tutorials if you want to dive in further. You can use python2.x tutorials, just be aware there are some name changes between python3.x and python2.x.
Python 2.x Syntax: tkFont
Python 3.x Syntax: tkinter.font

Python 2.x Syntax: Tkinter
Python 3.x Syntax: tkinter

Python 2.x Syntax: Tkdnd
Python 3.x Syntax: tkinter.dnd

Python 2.x Syntax: tkCommonDialog
Python 3.x Syntax: tkinter.commondialog

Python 2.x Syntax: Tkconstants
Python 3.x Syntax: tkinter.constants

Python 2.x Syntax: Dialog
Python 3.x Syntax: tkinter.dialog

Python 2.x Syntax: tkFileDialog
Python 3.x Syntax: tkinter.filedialog

Python 2.x Syntax: tkMessageBox
Python 3.x Syntax: tkinter.messagebox

Python 2.x Syntax: FileDialog
Python 3.x Syntax: tkinter.FileDialog

Python 2.x Syntax: ScrolledText
Python 3.x Syntax: tkinter.scolledtext

Python 2.x Syntax: tkColorChooser
Python 3.x Syntax: tkinter.colorchooser

Python 2.x Syntax: Tix
Python 3.x Syntax: tkinter.tix

Python 2.x Syntax: tkSimpleDialog
Python 3.x Syntax: tkinter.simpledialog

Python 2.x Syntax: SimpleDialog
Python 3.x Syntax: tkinter.simpledialog
Awesome. Thanks man! I'll start looking for tutorial regarding tkinter:-)