-1

I'm creating a game with pygame. Then and again I want to let the player type something - multiple lines, with the option to click anywhere into the text and edit from there.

You can think of it pretty much like the post/comment input window here on stackoverflow.

So far the only thing I have found are other modules, and most of the modules dont have the functionality, that I can click with my mouse between any two letters and edit/type from there.

The only thing I have found, that is able to do that is Tkinter widgets, but I cannot get them working inside my pygame window.

I found something where pygame was blitting onto a Tkinter frame, but since my entire game is based on pygame, I would not like to change everything in order to implement the textbox.

Does anyone know of a input textbox tool/module with the described functionalities, which works with pygame?

Cribber
  • 2,513
  • 2
  • 21
  • 60
  • The question is off-topic, but you can check out some of the GUI libraries that are available for pygame: https://www.pygame.org/wiki/gui , [SGC](http://www.pygame.org/project-SGC-2089-4505.html), [ThorPy](http://pygame.org/project-ThorPy-2979-.html). SGC is pretty easy to use. Here's a [text input module](https://github.com/Nearoo/pygame-text-input). – skrx Jan 10 '18 at 14:32
  • none of those GUIs supported input textboxes with asci character and clicking inbetween letters to edit them... or they didn't work with pygame. In the end I just programmed a TextEditor in pygame myself from scratch - including all the functionality I needed :) [however, i don't know how to "close" my question here. ] – Cribber Jan 10 '18 at 22:10
  • You can use https://github.com/ddorn/GUI that has a one line input box, that support cursor if you have any questions about it, just ask me ;) – Diego Jan 11 '18 at 06:21
  • SGC has an input box with movable cursor as well. Or do you want a text window with multiple lines? – skrx Jan 11 '18 at 07:01
  • I needed multiple lines :) If anyone comes up with a solution for multiple lines, cursor support, arrow-keys support, etc, then I will gladly accept it as a solution for future people who look for an answer. However, I coded a text editor from scratch now, so i'm done here ;) – Cribber Jan 11 '18 at 16:35
  • Possible duplicate of [Embedding a Pygame window into a Tkinter or WxPython frame](https://stackoverflow.com/questions/23319059/embedding-a-pygame-window-into-a-tkinter-or-wxpython-frame) – Artemis Apr 10 '18 at 17:33
  • I know it's about the opposite, but it doesn't require 'changing everything'. – Artemis Apr 10 '18 at 17:35

1 Answers1

1

I ended up writing and publishing a package for this problem as there didn't exist any solution yet: https://pypi.org/project/pygame-texteditor/

Cribber
  • 2,513
  • 2
  • 21
  • 60