1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
import tkinter as tk |
3
|
|
|
import tkinter.ttk as ttk |
4
|
|
|
import customtkinter |
5
|
|
|
import matplotlib.pyplot as plt |
6
|
|
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg |
7
|
|
|
from pycirclize import Circos |
8
|
|
|
import pandas as pd |
9
|
|
|
|
10
|
|
|
from . import ProcessingMenu |
11
|
|
|
from . import Definition |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class CreateWindowClass(Definition.DefinitionClass): |
15
|
|
|
"""画面の描画のクラス. |
16
|
|
|
|
17
|
|
|
・画面描画にあるプログラム群 |
18
|
|
|
|
19
|
|
|
Args: |
20
|
|
|
app (instance): MainProcessingClass のインスタンス |
21
|
|
|
locale_var (str): ロケーション |
22
|
|
|
master (instance): toplevel のインスタンス |
23
|
|
|
""" |
24
|
|
|
|
25
|
|
|
def __init__(self, app, locale_var, master=None): |
26
|
|
|
super().__init__(locale_var, master) |
27
|
|
|
self.app = app |
28
|
|
|
self.app.my_font = customtkinter.CTkFont(family="Meiryo", size=14) |
29
|
|
|
|
30
|
|
|
def create_widgets(self): |
31
|
|
|
"""画面の描画. |
32
|
|
|
|
33
|
|
|
・メインウインドウにウェジットを配置する。 |
34
|
|
|
""" |
35
|
|
|
# メニューの配置 |
36
|
|
|
File_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
37
|
|
|
Edit_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
38
|
|
|
List_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
39
|
|
|
Processing_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
40
|
|
|
Help_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
41
|
|
|
# ファイルメニュー |
42
|
|
|
File_menu.add_command( |
43
|
|
|
label=self.app.dic.get_dict("Newfile"), |
44
|
|
|
under=5, |
45
|
|
|
accelerator="Ctrl+N", |
46
|
|
|
command=self.app.fmc.new_open, |
47
|
|
|
) |
48
|
|
|
File_menu.add_command( |
49
|
|
|
label=self.app.dic.get_dict("FileOpen"), |
50
|
|
|
under=3, |
51
|
|
|
accelerator="Ctrl+E", |
52
|
|
|
command=self.app.fmc.open_file, |
53
|
|
|
) |
54
|
|
|
File_menu.add_separator() |
55
|
|
|
File_menu.add_command( |
56
|
|
|
label=self.app.dic.get_dict("Save"), |
57
|
|
|
under=3, |
58
|
|
|
accelerator="Ctrl+S", |
59
|
|
|
command=self.app.fmc.overwrite_save_file, |
60
|
|
|
) |
61
|
|
|
File_menu.add_command( |
62
|
|
|
label=self.app.dic.get_dict("Save as"), |
63
|
|
|
under=9, |
64
|
|
|
accelerator="Ctrl+W", |
65
|
|
|
command=self.app.fmc.save_file, |
66
|
|
|
) |
67
|
|
|
File_menu.add_separator() |
68
|
|
|
File_menu.add_command( |
69
|
|
|
label=self.app.dic.get_dict("Close"), |
70
|
|
|
under=4, |
71
|
|
|
accelerator="Ctrl+C", |
72
|
|
|
command=self.app.fmc.on_closing, |
73
|
|
|
) |
74
|
|
|
self.app.menu_bar.add_cascade( |
75
|
|
|
label=self.app.dic.get_dict("File"), under=5, menu=File_menu |
76
|
|
|
) |
77
|
|
|
# 編集メニュー |
78
|
|
|
Edit_menu.add_command( |
79
|
|
|
label=self.app.dic.get_dict("Redo"), |
80
|
|
|
under=5, |
81
|
|
|
accelerator="Ctrl+Shift+Z", |
82
|
|
|
command=self.app.emc.redo, |
83
|
|
|
) |
84
|
|
|
Edit_menu.add_command( |
85
|
|
|
label=self.app.dic.get_dict("Undo"), |
86
|
|
|
under=3, |
87
|
|
|
accelerator="Ctrl+Z", |
88
|
|
|
command=self.app.emc.undo, |
89
|
|
|
) |
90
|
|
|
Edit_menu.add_separator() |
91
|
|
|
Edit_menu.add_command( |
92
|
|
|
label=self.app.dic.get_dict("Cut"), |
93
|
|
|
under=5, |
94
|
|
|
accelerator="Ctrl+X", |
95
|
|
|
command=self.app.emc.cut, |
96
|
|
|
) |
97
|
|
|
Edit_menu.add_command( |
98
|
|
|
label=self.app.dic.get_dict("Copy"), |
99
|
|
|
under=4, |
100
|
|
|
accelerator="Ctrl+C", |
101
|
|
|
command=self.app.emc.copy, |
102
|
|
|
) |
103
|
|
|
Edit_menu.add_command( |
104
|
|
|
label=self.app.dic.get_dict("Paste"), |
105
|
|
|
under=5, |
106
|
|
|
accelerator="Ctrl+V", |
107
|
|
|
command=self.app.emc.paste, |
108
|
|
|
) |
109
|
|
|
Edit_menu.add_separator() |
110
|
|
|
Edit_menu.add_command( |
111
|
|
|
label=self.app.dic.get_dict("Find"), |
112
|
|
|
under=3, |
113
|
|
|
accelerator="Ctrl+F", |
114
|
|
|
command=self.app.fpc.find_dialog, |
115
|
|
|
) |
116
|
|
|
Edit_menu.add_command( |
117
|
|
|
label=self.app.dic.get_dict("Replacement"), |
118
|
|
|
under=3, |
119
|
|
|
accelerator="Ctrl+L", |
120
|
|
|
command=self.app.fpc.replacement_dialog, |
121
|
|
|
) |
122
|
|
|
self.app.menu_bar.add_cascade( |
123
|
|
|
label=self.app.dic.get_dict("Edit"), under=3, menu=Edit_menu |
124
|
|
|
) |
125
|
|
|
# 処理メニュー |
126
|
|
|
Processing_menu.add_command( |
127
|
|
|
label=self.app.dic.get_dict("Ruby"), |
128
|
|
|
under=6, |
129
|
|
|
accelerator="Ctrl+R", |
130
|
|
|
command=self.app.pmc.ruby_huri, |
131
|
|
|
) |
132
|
|
|
Processing_menu.add_command( |
133
|
|
|
label=self.app.dic.get_dict("Count charactors"), |
134
|
|
|
under=9, |
135
|
|
|
accelerator="Ctrl+Shift+C", |
136
|
|
|
command=self.app.pmc.count_moji, |
137
|
|
|
) |
138
|
|
|
Processing_menu.add_command( |
139
|
|
|
label=self.app.dic.get_dict("Meaning of selected characters"), |
140
|
|
|
under=8, |
141
|
|
|
accelerator="Ctrl+Shift+F", |
142
|
|
|
command=self.app.pmc.find_wikipedia, |
143
|
|
|
) |
144
|
|
|
Processing_menu.add_command( |
145
|
|
|
label=self.app.dic.get_dict("Read aloud"), |
146
|
|
|
under=8, |
147
|
|
|
accelerator="Ctrl+Shift+R", |
148
|
|
|
command=self.app.pmc.read_text, |
149
|
|
|
) |
150
|
|
|
Processing_menu.add_command( |
151
|
|
|
label=self.app.dic.get_dict("Sentence structure"), |
152
|
|
|
under=5, |
153
|
|
|
accelerator="Ctrl+Y", |
154
|
|
|
command=self.app.pmc.yahoo, |
155
|
|
|
) |
156
|
|
|
Processing_menu.add_separator() |
157
|
|
|
Processing_menu.add_command( |
158
|
|
|
label=self.app.dic.get_dict("Font size"), |
159
|
|
|
under=11, |
160
|
|
|
accelerator="Ctrl+Shift+F", |
161
|
|
|
command=self.app.pmc.font_dialog, |
162
|
|
|
) |
163
|
|
|
Processing_menu.add_separator() |
164
|
|
|
Processing_menu.add_command( |
165
|
|
|
label=self.app.dic.get_dict("Open [Become a Novelist]"), |
166
|
|
|
under=17, |
167
|
|
|
accelerator="Ctrl+U", |
168
|
|
|
command=self.app.pmc.open_becoming_novelist_page, |
169
|
|
|
) |
170
|
|
|
self.app.menu_bar.add_cascade( |
171
|
|
|
label=self.app.dic.get_dict("Processing"), under=3, menu=Processing_menu |
172
|
|
|
) |
173
|
|
|
# リストメニュー |
174
|
|
|
List_menu.add_command( |
175
|
|
|
label=self.app.dic.get_dict("Increase item"), |
176
|
|
|
under=7, |
177
|
|
|
accelerator=self.app.dic.get_dict("Select and right click"), |
178
|
|
|
command=self.app.lmc.message_window, |
179
|
|
|
) |
180
|
|
|
List_menu.add_command( |
181
|
|
|
label=self.app.dic.get_dict("Delete item"), |
182
|
|
|
under=6, |
183
|
|
|
accelerator=self.app.dic.get_dict("Select and right click"), |
184
|
|
|
command=self.app.lmc.message_window, |
185
|
|
|
) |
186
|
|
|
List_menu.add_command( |
187
|
|
|
label=self.app.dic.get_dict("Rename item"), |
188
|
|
|
under=9, |
189
|
|
|
accelerator="Ctrl+G", |
190
|
|
|
command=self.app.lmc.on_name_click, |
191
|
|
|
) |
192
|
|
|
self.app.menu_bar.add_cascade( |
193
|
|
|
label=self.app.dic.get_dict("Item"), under=4, menu=List_menu |
194
|
|
|
) |
195
|
|
|
# ヘルプメニュー |
196
|
|
|
Help_menu.add_command( |
197
|
|
|
label=self.app.dic.get_dict("Help"), |
198
|
|
|
under=4, |
199
|
|
|
accelerator="Ctrl+H", |
200
|
|
|
command=self.app.hmc.help, |
201
|
|
|
) |
202
|
|
|
Help_menu.add_command( |
203
|
|
|
label=self.app.dic.get_dict("Version"), |
204
|
|
|
under=8, |
205
|
|
|
accelerator="Ctrl+Shift+V", |
206
|
|
|
command=self.app.hmc.version, |
207
|
|
|
) |
208
|
|
|
self.app.menu_bar.add_cascade( |
209
|
|
|
label=self.app.dic.get_dict("Help"), under=4, menu=Help_menu |
210
|
|
|
) |
211
|
|
|
# ツリーコントロール、入力欄、行番号欄、スクロール部分を作成 |
212
|
|
|
self.app.tree = ttk.Treeview(self.app, show="tree") |
213
|
|
|
self.app.tree.grid(row=0, column=0, sticky=(tk.N, tk.S)) |
214
|
|
|
self.frame() |
215
|
|
|
self.app.fmc.tree_get_loop() |
216
|
|
|
|
217
|
|
|
def frame(self): |
218
|
|
|
"""フレーム内にテキストボックスを表示. |
219
|
|
|
|
220
|
|
|
・メインウインドウの右側に行番号、テキストボックス、スクロールバー |
221
|
|
|
を表示する。 |
222
|
|
|
""" |
223
|
|
|
# FrameNovelフレームにテキストエディタを表示 |
224
|
|
|
self.app.FrameNovel = customtkinter.CTkFrame(self.app) |
225
|
|
|
self.app.NovelEditor = CustomText( |
226
|
|
|
self.app.FrameNovel, font=self.app.my_font, undo=True |
227
|
|
|
) |
228
|
|
|
self.app.CanvasLineNumbers = tk.Canvas(self.app.FrameNovel, width=30) |
229
|
|
|
self.app.ScrollbarVerticalForNovelEditor = customtkinter.CTkScrollbar( |
230
|
|
|
self.app.FrameNovel, |
231
|
|
|
orientation="vertical", |
232
|
|
|
command=self.app.NovelEditor.yview, |
233
|
|
|
) |
234
|
|
|
# 入力欄にスクロールを紐付け |
235
|
|
|
self.app.NovelEditor.configure( |
236
|
|
|
yscrollcommand=self.app.ScrollbarVerticalForNovelEditor.set |
237
|
|
|
) |
238
|
|
|
# 左から行番号、入力欄、スクロールウィジェット |
239
|
|
|
self.app.CanvasLineNumbers.grid(row=0, column=0, sticky=(tk.N + tk.S)) |
240
|
|
|
self.app.NovelEditor.grid(row=0, column=1, sticky=(tk.NSEW)) |
241
|
|
|
self.app.ScrollbarVerticalForNovelEditor.grid( |
242
|
|
|
row=0, column=2, sticky=(tk.N + tk.S) |
243
|
|
|
) |
244
|
|
|
self.app.FrameNovel.columnconfigure(1, weight=1) |
245
|
|
|
self.app.FrameNovel.rowconfigure(0, weight=1) |
246
|
|
|
self.app.FrameNovel.grid(row=0, column=1, sticky=(tk.NSEW)) |
247
|
|
|
# テキスト入力欄のみ拡大されるように |
248
|
|
|
self.app.columnconfigure(1, weight=1) |
249
|
|
|
self.app.rowconfigure(0, weight=1) |
250
|
|
|
# テキストを読み取り専用にする |
251
|
|
|
self.app.NovelEditor.configure(state="disabled") |
252
|
|
|
# テキストにフォーカスを当てる |
253
|
|
|
self.app.NovelEditor.focus() |
254
|
|
|
self.app.epc.create_event_text() |
255
|
|
|
|
256
|
|
|
def frame_image(self): |
257
|
|
|
"""フレーム内にイメージフレーム表示. |
258
|
|
|
|
259
|
|
|
・メインウインドウの右側にイメージキャンバス、スクロールバーを表示する。 |
260
|
|
|
""" |
261
|
|
|
self.app.FrameImage = customtkinter.CTkFrame(self.app) |
262
|
|
|
self.app.CanvasImage = tk.Canvas(self.app.FrameImage, bg="black", width=30) |
263
|
|
|
self.app.ScrollbarVerticalForCanvasImage = customtkinter.CTkScrollbar( |
264
|
|
|
self.app.FrameImage, |
265
|
|
|
orientation="vertical", |
266
|
|
|
command=self.app.CanvasImage.yview, |
267
|
|
|
) |
268
|
|
|
self.app.ScrollbarHorizontalForCanvasImage = customtkinter.CTkScrollbar( |
269
|
|
|
self.app.FrameImage, |
270
|
|
|
orientation="horizontal", |
271
|
|
|
command=self.app.CanvasImage.xview, |
272
|
|
|
) |
273
|
|
|
self.app.CanvasImage.configure( |
274
|
|
|
xscrollcommand=self.app.ScrollbarHorizontalForCanvasImage.set |
275
|
|
|
) |
276
|
|
|
self.app.CanvasImage.configure( |
277
|
|
|
yscrollcommand=self.app.ScrollbarVerticalForCanvasImage.set |
278
|
|
|
) |
279
|
|
|
self.app.CanvasImage.grid(row=0, column=1, sticky=(tk.NSEW)) |
280
|
|
|
self.app.ScrollbarVerticalForCanvasImage.grid( |
281
|
|
|
row=0, column=2, sticky=(tk.N + tk.S) |
282
|
|
|
) |
283
|
|
|
self.app.ScrollbarHorizontalForCanvasImage.grid( |
284
|
|
|
row=1, column=1, sticky=(tk.W + tk.E) |
285
|
|
|
) |
286
|
|
|
self.app.FrameImage.grid(row=0, column=1, sticky=(tk.NSEW)) |
287
|
|
|
self.app.FrameImage.columnconfigure(1, weight=1) |
288
|
|
|
self.app.FrameImage.rowconfigure(0, weight=1) |
289
|
|
|
self.app.FrameImage.grid(row=0, column=1, sticky=(tk.NSEW)) |
290
|
|
|
# デフォルトの画像を設定する |
291
|
|
|
self.app.CanvasImage.photo = tk.PhotoImage(data=self.BLANK_IMAGE) |
292
|
|
|
self.app.ImageOnImage = self.app.CanvasImage.create_image( |
293
|
|
|
0, 0, anchor="nw", image=self.app.CanvasImage.photo |
294
|
|
|
) |
295
|
|
|
self.app.epc.create_event_image() |
296
|
|
|
|
297
|
|
|
def frame_character(self): |
298
|
|
|
"""フレーム内にキャラクターフレーム表示. |
299
|
|
|
|
300
|
|
|
・メインウインドウの右側に呼び名、似顔絵、名前、誕生日、略歴を表示する。 |
301
|
|
|
""" |
302
|
|
|
# チェック有無変数 |
303
|
|
|
self.app.var = tk.IntVar() |
304
|
|
|
# value=0のラジオボタンにチェックを入れる |
305
|
|
|
self.app.var.set(0) |
306
|
|
|
# キャラクター名フレーム |
307
|
|
|
self.app.FrameCharacter = customtkinter.CTkFrame(self.app) |
308
|
|
|
self.app.FrameCallName = customtkinter.CTkFrame(self.app.FrameCharacter) |
309
|
|
|
self.app.LabelCallName = customtkinter.CTkLabel( |
310
|
|
|
self.app.FrameCallName, |
311
|
|
|
text=self.app.dic.get_dict("Call name"), |
312
|
|
|
font=self.app.my_font, |
313
|
|
|
) |
314
|
|
|
self.app.EntryCallName = customtkinter.CTkEntry( |
315
|
|
|
self.app.FrameCallName, |
316
|
|
|
width=400, |
317
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size), |
318
|
|
|
) |
319
|
|
|
self.app.LabelCallName.grid(row=0, column=0) |
320
|
|
|
self.app.EntryCallName.grid(row=1, column=0) |
321
|
|
|
# キャラクターフルネームフレーム |
322
|
|
|
self.app.FrameName = customtkinter.CTkFrame(self.app.FrameCharacter) |
323
|
|
|
self.app.LabelName = customtkinter.CTkLabel( |
324
|
|
|
self.app.FrameName, |
325
|
|
|
text=self.app.dic.get_dict("Name"), |
326
|
|
|
font=self.app.my_font, |
327
|
|
|
) |
328
|
|
|
self.app.EntryName = customtkinter.CTkEntry( |
329
|
|
|
self.app.FrameName, |
330
|
|
|
width=400, |
331
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size), |
332
|
|
|
) |
333
|
|
|
self.app.LabelName.grid(row=0, column=0) |
334
|
|
|
self.app.EntryName.grid(row=1, column=0) |
335
|
|
|
# 性別フレーム |
336
|
|
|
self.app.FrameSex = customtkinter.CTkFrame(self.app.FrameCharacter) |
337
|
|
|
self.app.LabelSex = customtkinter.CTkLabel( |
338
|
|
|
self.app.FrameSex, text=self.app.dic.get_dict("Sex"), font=self.app.my_font |
339
|
|
|
) |
340
|
|
|
self.app.RadioButtonMan = customtkinter.CTkRadioButton( |
341
|
|
|
self.app.FrameSex, |
342
|
|
|
value=0, |
343
|
|
|
variable=self.app.var, |
344
|
|
|
text=self.app.dic.get_dict("Man"), |
345
|
|
|
font=self.app.my_font, |
346
|
|
|
) |
347
|
|
|
self.app.RadioButtonWoman = customtkinter.CTkRadioButton( |
348
|
|
|
self.app.FrameSex, |
349
|
|
|
value=1, |
350
|
|
|
variable=self.app.var, |
351
|
|
|
text=self.app.dic.get_dict("Woman"), |
352
|
|
|
font=self.app.my_font, |
353
|
|
|
) |
354
|
|
|
self.app.RadioButtonOther = customtkinter.CTkRadioButton( |
355
|
|
|
self.app.FrameSex, |
356
|
|
|
value=2, |
357
|
|
|
variable=self.app.var, |
358
|
|
|
text=self.app.dic.get_dict("Other"), |
359
|
|
|
font=self.app.my_font, |
360
|
|
|
) |
361
|
|
|
self.app.LabelSex.grid(row=0, column=1) |
362
|
|
|
self.app.RadioButtonMan.grid(row=1, column=1) |
363
|
|
|
self.app.RadioButtonWoman.grid(row=2, column=1) |
364
|
|
|
self.app.RadioButtonOther.grid(row=3, column=1) |
365
|
|
|
# ポートレートフレーム |
366
|
|
|
self.app.FramePortrait = customtkinter.CTkFrame(self.app.FrameCharacter) |
367
|
|
|
self.app.LabelPortrait = customtkinter.CTkLabel( |
368
|
|
|
self.app.FramePortrait, |
369
|
|
|
text=self.app.dic.get_dict("Portrait"), |
370
|
|
|
font=self.app.my_font, |
371
|
|
|
) |
372
|
|
|
self.app.CanvasPortrait = tk.Canvas( |
373
|
|
|
self.app.FramePortrait, bg="black", width=149, height=199 |
374
|
|
|
) |
375
|
|
|
self.app.FramePortraitButtons = customtkinter.CTkFrame(self.app.FramePortrait) |
376
|
|
|
self.app.ButtonPortraitInsert = customtkinter.CTkButton( |
377
|
|
|
self.app.FramePortraitButtons, |
378
|
|
|
text=self.app.dic.get_dict("Insert"), |
379
|
|
|
width=len(self.app.dic.get_dict("Insert")) * 12, |
380
|
|
|
command=self.app.spc.btn_click, |
381
|
|
|
font=self.app.my_font, |
382
|
|
|
) |
383
|
|
|
self.app.ButtonPortraitDelete = customtkinter.CTkButton( |
384
|
|
|
self.app.FramePortraitButtons, |
385
|
|
|
width=len(self.app.dic.get_dict("Delete")) * 12, |
386
|
|
|
text=self.app.dic.get_dict("Delete"), |
387
|
|
|
command=self.app.spc.clear_btn_click, |
388
|
|
|
font=self.app.my_font, |
389
|
|
|
) |
390
|
|
|
self.app.ButtonPortraitInsert.grid(row=0, column=1) |
391
|
|
|
self.app.ButtonPortraitDelete.grid(row=1, column=1) |
392
|
|
|
|
393
|
|
|
self.app.LabelPortrait.grid(row=0, column=0, columnspan=2) |
394
|
|
|
self.app.FramePortraitButtons.grid(row=1, column=0, sticky=(tk.S)) |
395
|
|
|
self.app.CanvasPortrait.grid(row=1, column=1) |
396
|
|
|
# 誕生日フレーム |
397
|
|
|
self.app.FrameBirthday = customtkinter.CTkFrame(self.app.FrameCharacter) |
398
|
|
|
self.app.LabelBirthday = customtkinter.CTkLabel( |
399
|
|
|
self.app.FrameBirthday, |
400
|
|
|
text=self.app.dic.get_dict("Birthday"), |
401
|
|
|
font=self.app.my_font, |
402
|
|
|
) |
403
|
|
|
self.app.EntryBirthday = customtkinter.CTkEntry( |
404
|
|
|
self.app.FrameBirthday, |
405
|
|
|
width=400, |
406
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size), |
407
|
|
|
) |
408
|
|
|
self.app.LabelBirthday.grid(row=0, column=1) |
409
|
|
|
self.app.EntryBirthday.grid(row=1, column=1) |
410
|
|
|
# 性格フレーム |
411
|
|
|
self.app.FrameCharacterChart = customtkinter.CTkFrame(self.app.FrameCharacter) |
412
|
|
|
self.app.LabelCharacterChart = customtkinter.CTkLabel( |
413
|
|
|
self.app.FrameCharacterChart, |
414
|
|
|
text=self.app.dic.get_dict("CharacterChart"), |
415
|
|
|
justify="center", |
416
|
|
|
font=self.app.my_font, |
417
|
|
|
) |
418
|
|
|
self.app.LabelExtraversion = customtkinter.CTkLabel( |
419
|
|
|
self.app.FrameCharacterChart, |
420
|
|
|
text=self.app.dic.get_dict("Extraversion"), |
421
|
|
|
font=self.app.my_font, |
422
|
|
|
) |
423
|
|
|
self.app.LabelExtraverted = customtkinter.CTkLabel( |
424
|
|
|
self.app.FrameCharacterChart, |
425
|
|
|
text=self.app.dic.get_dict("Extraverted"), |
426
|
|
|
font=self.app.my_font, |
427
|
|
|
) |
428
|
|
|
self.app.LabelIntroverted = customtkinter.CTkLabel( |
429
|
|
|
self.app.FrameCharacterChart, |
430
|
|
|
text=self.app.dic.get_dict("Introverted"), |
431
|
|
|
font=self.app.my_font, |
432
|
|
|
) |
433
|
|
|
self.app.SliderExtraversion = customtkinter.CTkSlider( |
434
|
|
|
self.app.FrameCharacterChart, |
435
|
|
|
from_=0, |
436
|
|
|
to=6, |
437
|
|
|
number_of_steps=6, |
438
|
|
|
command=self.app.spc.update_character_chart, |
439
|
|
|
) |
440
|
|
|
self.app.LabelAgreeableness = customtkinter.CTkLabel( |
441
|
|
|
self.app.FrameCharacterChart, |
442
|
|
|
text=self.app.dic.get_dict("Agreeableness"), |
443
|
|
|
font=self.app.my_font, |
444
|
|
|
) |
445
|
|
|
self.app.LabelAgreeable = customtkinter.CTkLabel( |
446
|
|
|
self.app.FrameCharacterChart, |
447
|
|
|
text=self.app.dic.get_dict("Agreeable"), |
448
|
|
|
font=self.app.my_font, |
449
|
|
|
) |
450
|
|
|
self.app.LabelHostile = customtkinter.CTkLabel( |
451
|
|
|
self.app.FrameCharacterChart, |
452
|
|
|
text=self.app.dic.get_dict("Hostile"), |
453
|
|
|
font=self.app.my_font, |
454
|
|
|
) |
455
|
|
|
self.app.SliderAgreeableness = customtkinter.CTkSlider( |
456
|
|
|
self.app.FrameCharacterChart, |
457
|
|
|
from_=0, |
458
|
|
|
to=6, |
459
|
|
|
number_of_steps=6, |
460
|
|
|
command=self.app.spc.update_character_chart, |
461
|
|
|
) |
462
|
|
|
self.app.LabelConscientiousness = customtkinter.CTkLabel( |
463
|
|
|
self.app.FrameCharacterChart, |
464
|
|
|
text=self.app.dic.get_dict("Conscientiousness"), |
465
|
|
|
font=self.app.my_font, |
466
|
|
|
) |
467
|
|
|
self.app.LabelConscientious = customtkinter.CTkLabel( |
468
|
|
|
self.app.FrameCharacterChart, |
469
|
|
|
text=self.app.dic.get_dict("Conscientious"), |
470
|
|
|
font=self.app.my_font, |
471
|
|
|
) |
472
|
|
|
self.app.LabelSpontaneous = customtkinter.CTkLabel( |
473
|
|
|
self.app.FrameCharacterChart, |
474
|
|
|
text=self.app.dic.get_dict("Spontaneous"), |
475
|
|
|
font=self.app.my_font, |
476
|
|
|
) |
477
|
|
|
self.app.SliderConscientiousness = customtkinter.CTkSlider( |
478
|
|
|
self.app.FrameCharacterChart, |
479
|
|
|
from_=0, |
480
|
|
|
to=6, |
481
|
|
|
number_of_steps=6, |
482
|
|
|
command=self.app.spc.update_character_chart, |
483
|
|
|
) |
484
|
|
|
self.app.LabelNeuroticism = customtkinter.CTkLabel( |
485
|
|
|
self.app.FrameCharacterChart, |
486
|
|
|
text=self.app.dic.get_dict("Neuroticism"), |
487
|
|
|
font=self.app.my_font, |
488
|
|
|
) |
489
|
|
|
self.app.LabelNeurotic = customtkinter.CTkLabel( |
490
|
|
|
self.app.FrameCharacterChart, |
491
|
|
|
text=self.app.dic.get_dict("Neurotic"), |
492
|
|
|
font=self.app.my_font, |
493
|
|
|
) |
494
|
|
|
self.app.LabelStable = customtkinter.CTkLabel( |
495
|
|
|
self.app.FrameCharacterChart, |
496
|
|
|
text=self.app.dic.get_dict("Stable"), |
497
|
|
|
font=self.app.my_font, |
498
|
|
|
) |
499
|
|
|
self.app.SliderNeuroticism = customtkinter.CTkSlider( |
500
|
|
|
self.app.FrameCharacterChart, |
501
|
|
|
from_=0, |
502
|
|
|
to=6, |
503
|
|
|
number_of_steps=6, |
504
|
|
|
command=self.app.spc.update_character_chart, |
505
|
|
|
) |
506
|
|
|
self.app.LabelOpenness = customtkinter.CTkLabel( |
507
|
|
|
self.app.FrameCharacterChart, |
508
|
|
|
text=self.app.dic.get_dict("Openness"), |
509
|
|
|
font=self.app.my_font, |
510
|
|
|
) |
511
|
|
|
self.app.LabelOpen = customtkinter.CTkLabel( |
512
|
|
|
self.app.FrameCharacterChart, |
513
|
|
|
text=self.app.dic.get_dict("Open"), |
514
|
|
|
font=self.app.my_font, |
515
|
|
|
) |
516
|
|
|
self.app.LabelClosed = customtkinter.CTkLabel( |
517
|
|
|
self.app.FrameCharacterChart, |
518
|
|
|
text=self.app.dic.get_dict("Closed"), |
519
|
|
|
font=self.app.my_font, |
520
|
|
|
) |
521
|
|
|
self.app.SliderOpenness = customtkinter.CTkSlider( |
522
|
|
|
self.app.FrameCharacterChart, |
523
|
|
|
from_=0, |
524
|
|
|
to=6, |
525
|
|
|
number_of_steps=6, |
526
|
|
|
command=self.app.spc.update_character_chart, |
527
|
|
|
) |
528
|
|
|
self.app.LabelCharacterChart.grid( |
529
|
|
|
row=0, column=1, columnspa=3, sticky=(tk.E + tk.W) |
530
|
|
|
) |
531
|
|
|
self.app.LabelExtraversion.grid(row=1, column=1, columnspa=3) |
532
|
|
|
self.app.LabelExtraverted.grid(row=2, column=3) |
533
|
|
|
self.app.SliderExtraversion.grid(row=2, column=2) |
534
|
|
|
self.app.LabelIntroverted.grid(row=2, column=1) |
535
|
|
|
self.app.LabelAgreeableness.grid(row=3, column=1, columnspa=3) |
536
|
|
|
self.app.LabelAgreeable.grid(row=4, column=3) |
537
|
|
|
self.app.SliderAgreeableness.grid(row=4, column=2) |
538
|
|
|
self.app.LabelHostile.grid(row=4, column=1) |
539
|
|
|
self.app.LabelConscientiousness.grid(row=5, column=1, columnspa=3) |
540
|
|
|
self.app.LabelConscientious.grid(row=6, column=3) |
541
|
|
|
self.app.SliderConscientiousness.grid(row=6, column=2) |
542
|
|
|
self.app.LabelSpontaneous.grid(row=6, column=1) |
543
|
|
|
self.app.LabelNeuroticism.grid(row=7, column=1, columnspa=3) |
544
|
|
|
self.app.LabelNeurotic.grid(row=8, column=3) |
545
|
|
|
self.app.SliderNeuroticism.grid(row=8, column=2) |
546
|
|
|
self.app.LabelStable.grid(row=8, column=1) |
547
|
|
|
self.app.LabelOpenness.grid(row=9, column=1, columnspa=3) |
548
|
|
|
self.app.LabelOpen.grid(row=10, column=3) |
549
|
|
|
self.app.SliderOpenness.grid(row=10, column=2) |
550
|
|
|
self.app.LabelClosed.grid(row=10, column=1) |
551
|
|
|
|
552
|
|
|
df = pd.DataFrame( |
553
|
|
|
data=[[3, 3, 3, 3, 3]], |
554
|
|
|
index=["Hero"], |
555
|
|
|
columns=[ |
556
|
|
|
self.app.dic.get_dict("Extraversion"), |
557
|
|
|
self.app.dic.get_dict("Agreeableness"), |
558
|
|
|
self.app.dic.get_dict("Conscientiousness"), |
559
|
|
|
self.app.dic.get_dict("Neuroticism"), |
560
|
|
|
self.app.dic.get_dict("Openness"), |
561
|
|
|
], |
562
|
|
|
) |
563
|
|
|
circos = Circos.radar_chart( |
564
|
|
|
df, |
565
|
|
|
vmax=6, |
566
|
|
|
grid_interval_ratio=0.166666666666666, |
567
|
|
|
grid_label_kws=dict(size=20), |
568
|
|
|
label_kws_handler=lambda v: dict(size=20), |
569
|
|
|
) |
570
|
|
|
plt.rcParams["font.family"] = "Meiryo" |
571
|
|
|
fig = circos.plotfig(dpi=50) |
572
|
|
|
plt.close() |
573
|
|
|
self.app.FrameCharacterChartMap = customtkinter.CTkFrame( |
574
|
|
|
self.app.FrameCharacterChart |
575
|
|
|
) |
576
|
|
|
self.app.canvasCharacterChart = FigureCanvasTkAgg( |
577
|
|
|
fig, master=self.app.FrameCharacterChartMap |
578
|
|
|
) |
579
|
|
|
self.app.canvasCharacterChart.draw() |
580
|
|
|
self.app.canvasCharacterChart.get_tk_widget().pack() |
581
|
|
|
self.app.FrameCharacterChartMap.grid(row=1, column=4, rowspan=10) |
582
|
|
|
# 略歴フレーム |
583
|
|
|
self.app.LabelBiography = customtkinter.CTkLabel( |
584
|
|
|
self.app.FrameCharacter, text=self.app.dic.get_dict("Biography") |
585
|
|
|
) |
586
|
|
|
self.app.TextboxBiography = customtkinter.CTkTextbox( |
587
|
|
|
self.app.FrameCharacter, |
588
|
|
|
width=800, |
589
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size), |
590
|
|
|
) |
591
|
|
|
self.app.FrameCallName.grid(row=0, column=1, columnspa=2) |
592
|
|
|
self.app.FrameSex.grid(row=1, column=1, rowspan=2) |
593
|
|
|
self.app.FramePortrait.grid(row=0, column=3, rowspan=3) |
594
|
|
|
self.app.FrameName.grid(row=0, column=4) |
595
|
|
|
self.app.FrameBirthday.grid(row=1, column=4) |
596
|
|
|
self.app.FrameCharacterChart.grid( |
597
|
|
|
row=3, column=1, columnspa=4, sticky=(tk.E + tk.W) |
598
|
|
|
) |
599
|
|
|
self.app.LabelBiography.grid(row=4, column=1, columnspa=4) |
600
|
|
|
self.app.TextboxBiography.grid(row=5, column=1, columnspa=4, sticky=(tk.NSEW)) |
601
|
|
|
self.app.FrameCharacter.columnconfigure(1, weight=1) |
602
|
|
|
self.app.FrameCharacter.columnconfigure(4, weight=1) |
603
|
|
|
self.app.FrameCharacter.rowconfigure(5, weight=1) |
604
|
|
|
|
605
|
|
|
self.app.FrameCharacter.grid(row=0, column=1, sticky=(tk.NSEW)) |
606
|
|
|
self.app.columnconfigure(1, weight=1) |
607
|
|
|
self.app.rowconfigure(0, weight=1) |
608
|
|
|
# デフォルトの画像を設定する |
609
|
|
|
self.app.CanvasPortrait.photo = tk.PhotoImage(data=self.BLANK_IMAGE) |
610
|
|
|
self.app.ImageOnPortrait = self.app.CanvasPortrait.create_image( |
611
|
|
|
0, 0, anchor="nw", image=self.app.CanvasPortrait.photo |
612
|
|
|
) |
613
|
|
|
|
614
|
|
|
# キャラクターイベントを追加 |
615
|
|
|
self.app.epc.create_event_character() |
616
|
|
|
|
617
|
|
|
|
618
|
|
|
class CustomText(tk.Text): |
619
|
|
|
"""Textのイベントを拡張したウィジェット. |
620
|
|
|
|
621
|
|
|
・TCl/TKを使って、textに<<Scroll>>イベントと、<<Change>>イベントを追加する。 |
622
|
|
|
|
623
|
|
|
Args: |
624
|
|
|
master (instance): toplevel のインスタンス |
625
|
|
|
""" |
626
|
|
|
|
627
|
|
|
def __init__(self, master, **kwargs): |
628
|
|
|
super().__init__(master, **kwargs) |
629
|
|
|
self.tk.eval( |
630
|
|
|
""" |
631
|
|
|
proc widget_proxy {widget widget_command args} { |
632
|
|
|
# 引数を使用してtkウィジェットコマンドを呼び出す |
633
|
|
|
set result [uplevel [linsert $args 0 $widget_command]] |
634
|
|
|
# ビューが移動した場合、バインドできるイベントを生成する |
635
|
|
|
if {([lrange $args 0 1] == {xview moveto}) || |
636
|
|
|
([lrange $args 0 1] == {xview scroll}) || |
637
|
|
|
([lrange $args 0 1] == {yview moveto}) || |
638
|
|
|
([lrange $args 0 1] == {yview scroll})} { |
639
|
|
|
event generate $widget <<Scroll>> -when tail |
640
|
|
|
} |
641
|
|
|
# 内容が変更された場合、バインドできるイベントを生成する |
642
|
|
|
if {([lindex $args 0] in {insert replace delete})} { |
643
|
|
|
event generate $widget <<Change>> -when tail |
644
|
|
|
} |
645
|
|
|
# ウィジェットコマンドから結果を返す |
646
|
|
|
return $result |
647
|
|
|
} |
648
|
|
|
""" |
649
|
|
|
) |
650
|
|
|
self.tk.eval( |
651
|
|
|
""" |
652
|
|
|
# コマンドをリネームする |
653
|
|
|
rename {widget} _{widget} |
654
|
|
|
# コマンドを置き換える |
655
|
|
|
interp alias {{}} ::{widget} {{}} widget_proxy {widget} _{widget} |
656
|
|
|
""".format( |
657
|
|
|
widget=str(self) |
658
|
|
|
) |
659
|
|
|
) |
660
|
|
|
|