4

I'm writing a game using Pygame, and parts of the game require data input that Tk seems to be good at.

I've got some things working, but I'm finding the implementation ugly and it is becoming clear I'm not using Tkinter the way it was intended to be used.

I have various methods that create Tk windows asking for input and then destroy them so that my Pygame program can make decisions about what the next input should be.

Am I missing something? Is there a better way to get form style input?

2
  • What kind of data input do you mean? Commented May 27, 2012 at 21:22
  • Form type things. Selection from a list, text field, and file selection so far. Commented May 27, 2012 at 21:24

1 Answer 1

4

Pygame doesn't have any included form input type stuff, and there's not really a way for Tkinter and Pygame to coexist peacefully in the same window, so you have two options, if you're going to stay within Pygame:

  1. Use a third party library

Phil's Pygame utilities are a pretty good option and provide some good basic functionality like file dialogs, popups, etc. Take a look around the projects on Pygame's website, and see if anyone else's fits your specific needs better.

  1. Code them yourself

Here is a pretty good example of how you'd put together your own input methods. Buttons, lists, and such would be similar as far as event handling is concerned, just check for mouse clicks in each UI element's borders.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.