How do I make a text box in pygame? [duplicate]

不羁的心 提交于 2019-12-25 08:46:20

问题


So I’m new with pygame and I was wondering how do you make a basic text box

I know you have to create a window as so:

import pygame, sys
pygame.init()

screen= pygame.display.set_mode([800,600]) 
pygame.display.flip

but then I have no idea where to go from there

any help much appreciated :)


回答1:


PyGame is low-level library and it doesn't have widgets.

You can use other modules like PGU, OcempGUI or SGC. Most of them have examples.

Most of them use own event loop so you have to learn how to use it instead of loop while True:.

See more on PyGame page:

  • https://www.pygame.org/wiki/gui
  • https://www.pygame.org/tags/gui

BTW:

SGC doesn't use own event loop and it shows how to use it in own mailoop in Getting Started

PGU uses own event loop but it shows how to use it in own mainloop (only) in example 10



来源:https://stackoverflow.com/questions/47318421/how-do-i-make-a-text-box-in-pygame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!