8000 examples: types textinput by illume · Pull Request #3870 · pygame/pygame · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

examples: types textinput #3870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Alrea 8000 dy on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions buildconfig/stubs/pygame/_common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ Coordinate = Union[Tuple[float, float], Sequence[float], Vector2]
# This typehint is used when a function would return an RGBA tuble
RGBAOutput = Tuple[int, int, int, int]
ColorValue = Union[Color, int, str, Tuple[int, int, int], RGBAOutput, Sequence[int]]
from typing import Union

def my_function(my_var: Union[int, float, complex]) -> None:
print(my_var)
_CanBeRect = Union[
Rect,
Tuple[int, int, int, int],
Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int]],
Tuple[Coordinate, Coordinate],
Sequence[int],
Sequence[Union[float, int]],
Sequence[Coordinate],
]

Expand Down
27 changes: 15 additions & 12 deletions examples/textinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
import sys
import os
from typing import List

import pygame
import pygame as pg
Expand All @@ -24,16 +25,19 @@ class TextInput:

# Add font name for each language,
# otherwise some text can't be correctly displayed.
FONT_NAMES = [
"notosanscjktcregular",
"notosansmonocjktcregular",
"notosansregular,",
"microsoftjhengheimicrosoftjhengheiuilight",
"microsoftyaheimicrosoftyaheiuilight",
"msgothicmsuigothicmspgothic",
"msmincho",
"Arial",
]
FONT_NAMES = ",".join(
str(x)
for x in [
"notosanscjktcregular",
"notosansmonocjktcregular",
"notosansregular,",
"microsoftjhengheimicrosoftjhengheiuilight",
"microsoftyaheimicrosoftyaheiuilight",
"msgothicmsuigothicmspgothic",
"msmincho",
"Arial",
]
)

def __init__(
self, prompt: str, pos, screen_dimensions, print_event: bool, text_color="white"
Expand All @@ -50,12 +54,11 @@ def __init__(
self._ime_text_pos = 0
self._ime_editing_text = ""
self._ime_editing_pos = 0
self.chat_list = []
self.chat_list: List[str] = []

# Freetype
# The font name can be a comma separated list
# of font names to search for.
self.FONT_NAMES = ",".join(str(x) for x in self.FONT_NAMES)
self.font = freetype.SysFont(self.FONT_NAMES, 24)
self.font_small = freetype.SysFont(self.FONT_NAMES, 16)
self.text_color = text_color
Expand Down
0