質問編集履歴
3
いらない部分の削除、元に戻しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,27 +24,6 @@
|
|
24
24
|
frame = tk.Frame(root, bg='black')
|
25
25
|
frame.grid(row=0, column=0, sticky="nsew", pady=20)
|
26
26
|
|
27
|
-
#タイトルウィジェットの作成
|
28
|
-
title_img = tk.PhotoImage(file='title.png')
|
29
|
-
title_img_label = tk.Label(frame, image=title_img, background='black')
|
30
|
-
title_img_label.grid()
|
31
|
-
start_btn = tk.Button(frame, text = 'はじめから', command = lambda:pg.change_app(frame_1))
|
32
|
-
start_btn.place(x = 400, y = 800)
|
33
|
-
continue_btn = tk.Button(frame, text = 'つづきから')
|
34
|
-
continue_btn.place(x = 1420, y = 800)
|
35
|
-
titlemusic = 'titlemusic.mp3'
|
36
|
-
pg.music(titlemusic, -1)
|
37
|
-
|
38
|
-
#タイトルまでウィンドウの作成と設置
|
39
|
-
frame_1 = tk.Frame(root, bg='black')
|
40
|
-
frame_1.grid(row=0, column=0, sticky="nsew", pady=20)
|
41
|
-
talk_label = tk.Label(frame_1, text = tg.first[pg.x])
|
42
|
-
talk_label.place(x=0, y=800, width=1920, height=300)
|
43
|
-
name_txt = tk.Entry(frame_1, width=100, justify='center')
|
44
|
-
decide_btn = tk.Button(frame_1, text = '決定', command = lambda:pg.name_get(name_txt, over_frame, over_label))
|
45
|
-
|
46
|
-
keyboard.on_press_key('enter', lambda _:pg.talk_next(talk_label, frame_1, main_map))
|
47
|
-
|
48
27
|
#マップ画面
|
49
28
|
main_map = tk.Frame(root, bg='black')
|
50
29
|
main_map.grid(row=0, column=0, sticky="nsew", pady=20)
|
@@ -52,15 +31,15 @@
|
|
52
31
|
map_img_label = tk.Label(main_map, image=map_img, background='black')
|
53
32
|
map_img_label.grid()
|
54
33
|
|
55
|
-
map_radio = tk.
|
34
|
+
map_radio = tk.IntVar()
|
56
35
|
map_radio.set(0)
|
57
|
-
map_1 = tk.Radiobutton(map_img_label, value=
|
36
|
+
map_1 = tk.Radiobutton(map_img_label, value=0, variable=map_radio)
|
58
37
|
map_1.place(x=500, y=600)
|
59
|
-
map_2 = tk.Radiobutton(map_img_label, value=
|
38
|
+
map_2 = tk.Radiobutton(map_img_label, value=1, variable=map_radio)
|
60
39
|
map_2.place(x=1000, y=700)
|
61
|
-
map_3 = tk.Radiobutton(map_img_label, value=
|
40
|
+
map_3 = tk.Radiobutton(map_img_label, value=2, variable=map_radio)
|
62
41
|
map_3.place(x=1300, y=500)
|
63
|
-
map_select_button = tk.Button(main_map, text='選択', command=lambda:pg.change_map(map_radio
|
42
|
+
map_select_button = tk.Button(main_map, text='選択', command=lambda:pg.change_map(map_radio))
|
64
43
|
map_select_button.place(x=1800, y=1000)
|
65
44
|
|
66
45
|
#ろとの塔
|
@@ -94,27 +73,11 @@
|
|
94
73
|
import main
|
95
74
|
import pygame
|
96
75
|
|
97
|
-
def change_app(window):
|
98
|
-
window.tkraise()
|
99
|
-
|
76
|
+
map_no = [roto, yuusha, tenku]
|
100
77
|
|
101
78
|
def change_map(var):
|
102
|
-
var.tkraise()
|
103
|
-
pygame.mixer.music.stop()
|
104
|
-
|
105
|
-
def music(mp3,mp3_n):
|
106
|
-
p
|
79
|
+
map_value= var.get()
|
107
|
-
p
|
80
|
+
map_no[map_value].tkraise()
|
108
|
-
pygame.mixer.music.play(mp3_n)
|
109
|
-
|
110
|
-
def talk_next(tl_label, main_frame, nt_frame):
|
111
|
-
global x
|
112
|
-
x = x + 1
|
113
|
-
tl_label = tk.Label(main_frame, text = tg.first[x])
|
114
|
-
tl_label.place(x=0, y=800, width=1920, height=300)
|
115
|
-
if x == 10:
|
116
|
-
change_app(nt_frame
|
117
|
-
)
|
118
81
|
```
|
119
82
|
```error
|
120
83
|
map_no[map_value].tkraise()
|
2
必要部分も修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,35 +20,66 @@
|
|
20
20
|
root.grid_rowconfigure(0, weight=1)
|
21
21
|
root.grid_columnconfigure(0, weight=1)
|
22
22
|
|
23
|
+
#タイトルウィンドウ設置
|
24
|
+
frame = tk.Frame(root, bg='black')
|
25
|
+
frame.grid(row=0, column=0, sticky="nsew", pady=20)
|
26
|
+
|
27
|
+
#タイトルウィジェットの作成
|
28
|
+
title_img = tk.PhotoImage(file='title.png')
|
29
|
+
title_img_label = tk.Label(frame, image=title_img, background='black')
|
30
|
+
title_img_label.grid()
|
31
|
+
start_btn = tk.Button(frame, text = 'はじめから', command = lambda:pg.change_app(frame_1))
|
32
|
+
start_btn.place(x = 400, y = 800)
|
33
|
+
continue_btn = tk.Button(frame, text = 'つづきから')
|
34
|
+
continue_btn.place(x = 1420, y = 800)
|
35
|
+
titlemusic = 'titlemusic.mp3'
|
36
|
+
pg.music(titlemusic, -1)
|
37
|
+
|
38
|
+
#タイトルまでウィンドウの作成と設置
|
39
|
+
frame_1 = tk.Frame(root, bg='black')
|
40
|
+
frame_1.grid(row=0, column=0, sticky="nsew", pady=20)
|
41
|
+
talk_label = tk.Label(frame_1, text = tg.first[pg.x])
|
42
|
+
talk_label.place(x=0, y=800, width=1920, height=300)
|
43
|
+
name_txt = tk.Entry(frame_1, width=100, justify='center')
|
44
|
+
decide_btn = tk.Button(frame_1, text = '決定', command = lambda:pg.name_get(name_txt, over_frame, over_label))
|
45
|
+
|
46
|
+
keyboard.on_press_key('enter', lambda _:pg.talk_next(talk_label, frame_1, main_map))
|
47
|
+
|
23
48
|
#マップ画面
|
24
49
|
main_map = tk.Frame(root, bg='black')
|
25
50
|
main_map.grid(row=0, column=0, sticky="nsew", pady=20)
|
26
51
|
map_img = tk.PhotoImage(file='map.png')
|
27
|
-
map_img_label = tk.Label(main_map, image=map_img)
|
52
|
+
map_img_label = tk.Label(main_map, image=map_img, background='black')
|
28
53
|
map_img_label.grid()
|
29
54
|
|
30
|
-
map_radio = tk.
|
55
|
+
map_radio = tk.StringVar()
|
31
56
|
map_radio.set(0)
|
32
|
-
map_1 = tk.Radiobutton(map_img_label,
|
57
|
+
map_1 = tk.Radiobutton(map_img_label, value='roto', variable=map_radio)
|
33
58
|
map_1.place(x=500, y=600)
|
34
|
-
map_2 = tk.Radiobutton(map_img_label,
|
59
|
+
map_2 = tk.Radiobutton(map_img_label, value='yuusha', variable=map_radio)
|
35
60
|
map_2.place(x=1000, y=700)
|
36
|
-
map_3 = tk.Radiobutton(map_img_label,
|
61
|
+
map_3 = tk.Radiobutton(map_img_label, value='tenku', variable=map_radio)
|
37
62
|
map_3.place(x=1300, y=500)
|
38
|
-
map_select_button = tk.Button(main_map, text='選択', command=lambda:pg.change_map(map_radio))
|
63
|
+
map_select_button = tk.Button(main_map, text='選択', command=lambda:pg.change_map(map_radio.get()))
|
39
64
|
map_select_button.place(x=1800, y=1000)
|
40
65
|
|
41
|
-
#
|
66
|
+
#ろとの塔
|
42
67
|
roto = tk.Frame(root, bg='black')
|
43
68
|
roto.grid(row=0, column=0, sticky="nsew", pady=20)
|
69
|
+
talk_label = tk.Label(roto, text = tg.roto_tell[pg.roto_x])
|
70
|
+
talk_label.place(x=0, y=800, width=1920, height=300)
|
44
71
|
|
45
|
-
#
|
72
|
+
#勇者の集落
|
46
73
|
yuusha = tk.Frame(root, bg='black')
|
47
74
|
yuusha.grid(row=0, column=0, sticky="nsew", pady=20)
|
75
|
+
talk_label = tk.Label(yuusha, text = tg.yuusha_tell[pg.yuusha_x])
|
76
|
+
talk_label.place(x=0, y=800, width=1920, height=300)
|
48
77
|
|
49
|
-
#
|
78
|
+
#天空の洞窟
|
50
79
|
tenku = tk.Frame(root, bg='black')
|
51
80
|
tenku.grid(row=0, column=0, sticky="nsew", pady=20)
|
81
|
+
talk_label = tk.Label(tenku, text = tg.tenku_tell[pg.tenku_x])
|
82
|
+
talk_label.place(x=0, y=800, width=1920, height=300)
|
52
83
|
|
53
84
|
# frameを前面にする
|
54
85
|
frame.tkraise()
|
@@ -60,13 +91,30 @@
|
|
60
91
|
import time
|
61
92
|
import tkinter as tk
|
62
93
|
import tkinter.ttk as ttk
|
63
|
-
import i
|
94
|
+
import main
|
64
95
|
import pygame
|
65
96
|
|
97
|
+
def change_app(window):
|
98
|
+
window.tkraise()
|
99
|
+
pygame.mixer.music.stop()
|
100
|
+
|
66
101
|
def change_map(var):
|
67
|
-
map_value = var.get()
|
68
|
-
|
102
|
+
var.tkraise()
|
69
103
|
pygame.mixer.music.stop()
|
104
|
+
|
105
|
+
def music(mp3,mp3_n):
|
106
|
+
pygame.mixer.init()
|
107
|
+
pygame.mixer.music.load(mp3)
|
108
|
+
pygame.mixer.music.play(mp3_n)
|
109
|
+
|
110
|
+
def talk_next(tl_label, main_frame, nt_frame):
|
111
|
+
global x
|
112
|
+
x = x + 1
|
113
|
+
tl_label = tk.Label(main_frame, text = tg.first[x])
|
114
|
+
tl_label.place(x=0, y=800, width=1920, height=300)
|
115
|
+
if x == 10:
|
116
|
+
change_app(nt_frame
|
117
|
+
)
|
70
118
|
```
|
71
119
|
```error
|
72
120
|
map_no[map_value].tkraise()
|
1
エラーの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
root.bind('<Escape>', lambda e: root.destroy())
|
18
18
|
root.geometry("1920x1200")
|
19
19
|
root.configure(bg='black')
|
20
|
-
root.title("いっくんクエスト")
|
21
20
|
root.grid_rowconfigure(0, weight=1)
|
22
21
|
root.grid_columnconfigure(0, weight=1)
|
23
22
|
|
@@ -70,5 +69,6 @@
|
|
70
69
|
pygame.mixer.music.stop()
|
71
70
|
```
|
72
71
|
```error
|
72
|
+
map_no[map_value].tkraise()
|
73
73
|
AttributeError: 'str' object has no attribute 'tkraise'
|
74
74
|
```
|