English 中文(简体)
如何在 Pygame 中用 Tkinter 获得表格输入?
原标题:How to get a form input using Tkinter in Pygame?

我用 Pygame 来撰写游戏,游戏的某些部分需要数据输入,而 Tk 似乎很好。

我有些东西有用, 但我发现执行过程很丑, 并且越来越清楚, 我不使用Tkinter的方式,

我有各种方法可以创建 Tk 窗口, 请求输入, 然后销毁它们, 这样我的 < code> Pygame 程序就可以决定下一个输入应该是什么 。

我是不是漏掉了什么?是否有更好的方法获得窗体样式输入?

问题回答

Pygame 没有任何包含窗体输入类型的东西, 而且没有办法让 Tkinter 和 Pygame 在同一窗口中和平共处, 所以如果您要留在 Pygame 内, 您有两个选项 :

  1. Use a third party library

"http://www.pygame.org/project-PGU+-+Phil s+pyGame+Uvilits-108-471.html" rel=“不跟随无悔者”>>Phil s Pygame 公用事业 是一个相当不错的选择,它提供了一些良好的基本功能,如files对话框 , popups 等。 在 Pygame s 网站上查看各个项目,看看是否有其他人更好地满足你的具体需求。

  1. Code them yourself

< a href=> "http://www.pygame.org/pcr/inputbox/index.php" rel=“nofollow noreferrer>>这里 是一个很好的例子,说明如何组合自己的输入方法。按钮、列表和类似的例子,就事件处理而言,请在每个用户界面元素的边框中检查鼠标点击情况。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签