GithubHelp home page GithubHelp logo

pygame_textinput's Introduction

Input system support in Pygame

This is a library that supports input using IME and direct input in pygame.
(PygameでIMEや直接入力を支援するライブラリです)
As far as I can tell, you can type in English, Japanese, and Chinese.

install with pip

pip install git+https://github.com/DYGV/pygame_textinput.git

Usage of example

import sys

import pygame
from pygame_textinput.textinput import TextInput


def main():
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    text_box = TextInput(pygame.font.SysFont("yumincho", 30), (255, 0, 0))
    while True:
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit(0)
            if event.type == pygame.USEREVENT:
                # 入力確定したテキスト
                print(event.Text)
        screen.fill((112, 225, 112))
        text_box.update(events)
        screen.blit(text_box.get_surface(), (10, 550))
        pygame.display.update()


if __name__ == "__main__":
    main()

In some environments, you can't use the "yumincho" font . Please refer to this page.

You can also type in Chinese if you set up your IME and specify the font.

↓ Microsoft IME(Japanese) 実行結果_jp

↓ Microsoft pinyin(Chinese) 実行結果_ch

pygame_textinput's People

Contributors

dygv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.