質問編集履歴
2
情報の追加
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
【Python】漢字変換
|
1
|
+
【Python】Pygame日本語入力&漢字変換をしたい
|
body
CHANGED
@@ -13,4 +13,51 @@
|
|
13
13
|
実は最終的に、Pygameでテキスト入力ボックスを作りたいと考えています。
|
14
14
|
https://code.i-harness.com/ja-jp/q/2c3dbd7を試してみたのですが、日本語入力はできないようです。
|
15
15
|
Pygameで日本語に対応したテキスト入力ボックスの作るためにどうすればいいか分かりません。
|
16
|
-
再度よろしくお願いします。
|
16
|
+
再度よろしくお願いします。
|
17
|
+
###補足3
|
18
|
+
Pygameのテキスト入力ボックスのコマンドをhttps://code.i-harness.com/ja-jp/q/2c3dbd7を参考に作りました。
|
19
|
+
```
|
20
|
+
import pygame,sys
|
21
|
+
|
22
|
+
|
23
|
+
def main():
|
24
|
+
pygame.init()
|
25
|
+
screen = pygame.display.set_mode((640, 480))
|
26
|
+
font = pygame.font.SysFont("meiryomeiryoboldmeiryouiboldmeiryouibolditalic", 32)
|
27
|
+
clock = pygame.time.Clock()
|
28
|
+
input_box = pygame.Rect(100, 50, 140, 32)
|
29
|
+
active = False
|
30
|
+
text = ''
|
31
|
+
while True:
|
32
|
+
for event in pygame.event.get():
|
33
|
+
if event.type == pygame.QUIT:
|
34
|
+
pygame.quit()
|
35
|
+
sys.exit()
|
36
|
+
if event.type == pygame.MOUSEBUTTONDOWN:
|
37
|
+
if input_box.collidepoint(event.pos):
|
38
|
+
active = True
|
39
|
+
else:
|
40
|
+
active = False
|
41
|
+
if event.type == pygame.KEYDOWN:
|
42
|
+
if active:
|
43
|
+
if event.key == pygame.K_RETURN:
|
44
|
+
print(text)
|
45
|
+
text = ''
|
46
|
+
elif event.key == pygame.K_BACKSPACE:
|
47
|
+
text = text[:-1]
|
48
|
+
else:
|
49
|
+
text += event.unicode
|
50
|
+
|
51
|
+
screen.fill((255,255,255))
|
52
|
+
txt_surface = font.render(text, True, (0,0,0))
|
53
|
+
width = max(200, txt_surface.get_width()+10)
|
54
|
+
input_box.w = width
|
55
|
+
screen.blit(txt_surface, (input_box.x+5, input_box.y+5))
|
56
|
+
pygame.draw.rect(screen, (0,0,0), input_box, 2)
|
57
|
+
pygame.display.update()
|
58
|
+
|
59
|
+
|
60
|
+
if __name__ == '__main__':main()
|
61
|
+
```
|
62
|
+
fontを日本語にしているにも関わらず、日本語書式で表示されません。
|
63
|
+
何が問題でしょうか。よろしくお願いします。
|
1
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,9 @@
|
|
8
8
|
ご教授お願いします。
|
9
9
|
###補足
|
10
10
|
できれば、PyPIやgithub以外のサイトが提供しているものを使いたくないです。
|
11
|
-
そのような方法を教えて頂ければ光栄です。
|
11
|
+
そのような方法を教えて頂ければ光栄です。
|
12
|
+
###補足2
|
13
|
+
実は最終的に、Pygameでテキスト入力ボックスを作りたいと考えています。
|
14
|
+
https://code.i-harness.com/ja-jp/q/2c3dbd7を試してみたのですが、日本語入力はできないようです。
|
15
|
+
Pygameで日本語に対応したテキスト入力ボックスの作るためにどうすればいいか分かりません。
|
16
|
+
再度よろしくお願いします。
|