1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
import tkinter as tk |
3
|
|
|
import tkinter.ttk as ttk |
4
|
|
|
import customtkinter |
5
|
|
|
|
6
|
|
|
from . import ProcessingMenu |
7
|
|
|
from . import Definition |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class CreateWindowClass(Definition.DefinitionClass): |
11
|
|
|
"""画面の描画のクラス. |
12
|
|
|
|
13
|
|
|
・画面描画にあるプログラム群 |
14
|
|
|
|
15
|
|
|
Args: |
16
|
|
|
app (instance): MainProcessingClass のインスタンス |
17
|
|
|
locale_var (str): ロケーション |
18
|
|
|
master (instance): toplevel のインスタンス |
19
|
|
|
""" |
20
|
|
|
def __init__(self, app, locale_var, master=None): |
21
|
|
|
super().__init__(locale_var, master) |
22
|
|
|
self.app = app |
23
|
|
|
|
24
|
|
|
def create_widgets(self): |
25
|
|
|
"""画面の描画. |
26
|
|
|
|
27
|
|
|
・メインウインドウにウェジットを配置する。 |
28
|
|
|
""" |
29
|
|
|
# メニューの配置 |
30
|
|
|
File_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
31
|
|
|
Edit_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
32
|
|
|
List_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
33
|
|
|
Processing_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
34
|
|
|
Help_menu = tk.Menu(self.app.menu_bar, tearoff=0) |
35
|
|
|
# ファイルメニュー |
36
|
|
|
File_menu.add_command( |
37
|
|
|
label=self.app.dic.get_dict("Newfile"), |
38
|
|
|
under=5, |
39
|
|
|
accelerator='Ctrl+N', |
40
|
|
|
command=self.app.fmc.new_open |
41
|
|
|
) |
42
|
|
|
File_menu.add_command( |
43
|
|
|
label=self.app.dic.get_dict("Open"), |
44
|
|
|
under=3, |
45
|
|
|
accelerator='Ctrl+E', |
46
|
|
|
command=self.app.fmc.open_file |
47
|
|
|
) |
48
|
|
|
File_menu.add_separator() |
49
|
|
|
File_menu.add_command( |
50
|
|
|
label=self.app.dic.get_dict("Save"), |
51
|
|
|
under=3, |
52
|
|
|
accelerator='Ctrl+S', |
53
|
|
|
command=self.app.fmc.overwrite_save_file |
54
|
|
|
) |
55
|
|
|
File_menu.add_command( |
56
|
|
|
label=self.app.dic.get_dict("Save as"), |
57
|
|
|
under=9, |
58
|
|
|
accelerator='Ctrl+W', |
59
|
|
|
command=self.app.fmc.save_file |
60
|
|
|
) |
61
|
|
|
File_menu.add_separator() |
62
|
|
|
File_menu.add_command( |
63
|
|
|
label=self.app.dic.get_dict("Close"), |
64
|
|
|
under=4, |
65
|
|
|
accelerator='Ctrl+C', |
66
|
|
|
command=self.app.fmc.on_closing |
67
|
|
|
) |
68
|
|
|
self.app.menu_bar.add_cascade( |
69
|
|
|
label=self.app.dic.get_dict("File"), |
70
|
|
|
under=5, |
71
|
|
|
menu=File_menu |
72
|
|
|
) |
73
|
|
|
# 編集メニュー |
74
|
|
|
Edit_menu.add_command( |
75
|
|
|
label=self.app.dic.get_dict("Redo"), |
76
|
|
|
under=5, |
77
|
|
|
accelerator='Ctrl+Shift+Z', |
78
|
|
|
command=self.app.emc.redo |
79
|
|
|
) |
80
|
|
|
Edit_menu.add_command( |
81
|
|
|
label=self.app.dic.get_dict("Undo"), |
82
|
|
|
under=3, |
83
|
|
|
accelerator='Ctrl+Z', |
84
|
|
|
command=self.app.emc.undo |
85
|
|
|
) |
86
|
|
|
Edit_menu.add_separator() |
87
|
|
|
Edit_menu.add_command( |
88
|
|
|
label=self.app.dic.get_dict("Cut"), |
89
|
|
|
under=5, |
90
|
|
|
accelerator='Ctrl+X', |
91
|
|
|
command=self.app.emc.cut |
92
|
|
|
) |
93
|
|
|
Edit_menu.add_command( |
94
|
|
|
label=self.app.dic.get_dict("Copy"), |
95
|
|
|
under=4, |
96
|
|
|
accelerator='Ctrl+C', |
97
|
|
|
command=self.app.emc.copy |
98
|
|
|
) |
99
|
|
|
Edit_menu.add_command( |
100
|
|
|
label=self.app.dic.get_dict("Paste"), |
101
|
|
|
under=5, |
102
|
|
|
accelerator='Ctrl+V', |
103
|
|
|
command=self.app.emc.paste |
104
|
|
|
) |
105
|
|
|
Edit_menu.add_separator() |
106
|
|
|
Edit_menu.add_command( |
107
|
|
|
label=self.app.dic.get_dict("Find"), |
108
|
|
|
under=3, |
109
|
|
|
accelerator='Ctrl+F', |
110
|
|
|
command=self.app.fpc.find_dialog |
111
|
|
|
) |
112
|
|
|
Edit_menu.add_command( |
113
|
|
|
label=self.app.dic.get_dict("Replacement"), |
114
|
|
|
under=3, |
115
|
|
|
accelerator='Ctrl+L', |
116
|
|
|
command=self.app.fpc.replacement_dialog |
117
|
|
|
) |
118
|
|
|
self.app.menu_bar.add_cascade( |
119
|
|
|
label=self.app.dic.get_dict("Edit"), |
120
|
|
|
under=3, |
121
|
|
|
menu=Edit_menu |
122
|
|
|
) |
123
|
|
|
# 処理メニュー |
124
|
|
|
Processing_menu.add_command( |
125
|
|
|
label=self.app.dic.get_dict("Ruby"), |
126
|
|
|
under=6, |
127
|
|
|
accelerator='Ctrl+R', |
128
|
|
|
command=self.app.pmc.ruby_huri |
129
|
|
|
) |
130
|
|
|
Processing_menu.add_command( |
131
|
|
|
label=self.app.dic.get_dict("Count charactors"), |
132
|
|
|
under=9, |
133
|
|
|
accelerator='Ctrl+Shift+C', |
134
|
|
|
command=self.app.pmc.count_moji |
135
|
|
|
) |
136
|
|
|
Processing_menu.add_command( |
137
|
|
|
label=self.app.dic.get_dict("Meaning of selected characters"), |
138
|
|
|
under=8, |
139
|
|
|
accelerator='Ctrl+Shift+F', |
140
|
|
|
command=self.app.pmc.find_wikipedia |
141
|
|
|
) |
142
|
|
|
Processing_menu.add_command( |
143
|
|
|
label=self.app.dic.get_dict("Read aloud"), |
144
|
|
|
under=8, |
145
|
|
|
accelerator='Ctrl+Shift+R', |
146
|
|
|
command=self.app.pmc.read_text |
147
|
|
|
) |
148
|
|
|
Processing_menu.add_command( |
149
|
|
|
label=self.app.dic.get_dict("Sentence structure"), |
150
|
|
|
under=5, |
151
|
|
|
accelerator='Ctrl+Y', |
152
|
|
|
command=self.app.pmc.yahoo |
153
|
|
|
) |
154
|
|
|
Processing_menu.add_separator() |
155
|
|
|
Processing_menu.add_command( |
156
|
|
|
label=self.app.dic.get_dict("Font size"), |
157
|
|
|
under=11, |
158
|
|
|
accelerator='Ctrl+Shift+F', |
159
|
|
|
command=self.app.pmc.font_dialog |
160
|
|
|
) |
161
|
|
|
Processing_menu.add_separator() |
162
|
|
|
Processing_menu.add_command( |
163
|
|
|
label=self.app.dic.get_dict("Open [Become a Novelist]"), |
164
|
|
|
under=17, |
165
|
|
|
accelerator='Ctrl+U', |
166
|
|
|
command=self.app.pmc.open_becoming_novelist_page |
167
|
|
|
) |
168
|
|
|
self.app.menu_bar.add_cascade( |
169
|
|
|
label=self.app.dic.get_dict("Processing"), |
170
|
|
|
under=3, |
171
|
|
|
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"), |
194
|
|
|
under=4, |
195
|
|
|
menu=List_menu |
196
|
|
|
) |
197
|
|
|
# ヘルプメニュー |
198
|
|
|
Help_menu.add_command( |
199
|
|
|
label=self.app.dic.get_dict("Help"), |
200
|
|
|
under=4, |
201
|
|
|
accelerator='Ctrl+H', |
202
|
|
|
command=self.app.hmc.help |
203
|
|
|
) |
204
|
|
|
Help_menu.add_command( |
205
|
|
|
label=self.app.dic.get_dict("Version"), |
206
|
|
|
under=8, |
207
|
|
|
accelerator='Ctrl+Shift+V', |
208
|
|
|
command=self.app.hmc.version |
209
|
|
|
) |
210
|
|
|
self.app.menu_bar.add_cascade( |
211
|
|
|
label=self.app.dic.get_dict("Help"), |
212
|
|
|
under=4, |
213
|
|
|
menu=Help_menu |
214
|
|
|
) |
215
|
|
|
# ツリーコントロール、入力欄、行番号欄、スクロール部分を作成 |
216
|
|
|
self.app.tree = ttk.Treeview(self.app, show="tree") |
217
|
|
|
self.app.tree.grid(row=0, column=0, sticky=(tk.N, tk.S)) |
218
|
|
|
self.frame() |
219
|
|
|
self.app.fmc.tree_get_loop() |
220
|
|
|
|
221
|
|
|
def frame(self): |
222
|
|
|
"""フレーム内にテキストボックスを表示. |
223
|
|
|
|
224
|
|
|
・メインウインドウの右側に行番号、テキストボックス、スクロールバー |
225
|
|
|
を表示する。 |
226
|
|
|
""" |
227
|
|
|
# FrameNovelフレームにテキストエディタを表示 |
228
|
|
|
self.app.FrameNovel = customtkinter.CTkFrame(self.app) |
229
|
|
|
self.app.NovelEditor = CustomText( |
230
|
|
|
self.app.FrameNovel, |
231
|
|
|
font=(self.app.font, self.app.pmc.font_size), |
232
|
|
|
undo=True |
233
|
|
|
) |
234
|
|
|
self.app.CanvasLineNumbers = tk.Canvas(self.app.FrameNovel, width=30) |
235
|
|
|
self.app.ScrollbarVerticalForNovelEditor = customtkinter.CTkScrollbar( |
236
|
|
|
self.app.FrameNovel, |
237
|
|
|
orientation="vertical", |
238
|
|
|
command=self.app.NovelEditor.yview |
239
|
|
|
) |
240
|
|
|
# 入力欄にスクロールを紐付け |
241
|
|
|
self.app.NovelEditor.configure(yscrollcommand=self.app.ScrollbarVerticalForNovelEditor.set) |
242
|
|
|
# 左から行番号、入力欄、スクロールウィジェット |
243
|
|
|
self.app.CanvasLineNumbers.grid(row=0, column=0, sticky=(tk.N + tk.S)) |
244
|
|
|
self.app.NovelEditor.grid(row=0, column=1, sticky=(tk.NSEW)) |
245
|
|
|
self.app.ScrollbarVerticalForNovelEditor.grid(row=0, column=2, sticky=(tk.N + tk.S)) |
246
|
|
|
self.app.FrameNovel.columnconfigure(1, weight=1) |
247
|
|
|
self.app.FrameNovel.rowconfigure(0, weight=1) |
248
|
|
|
self.app.FrameNovel.grid(row=0, column=1, sticky=(tk.NSEW)) |
249
|
|
|
# テキスト入力欄のみ拡大されるように |
250
|
|
|
self.app.columnconfigure(1, weight=1) |
251
|
|
|
self.app.rowconfigure(0, weight=1) |
252
|
|
|
# テキストを読み取り専用にする |
253
|
|
|
self.app.NovelEditor.configure(state='disabled') |
254
|
|
|
# テキストにフォーカスを当てる |
255
|
|
|
self.app.NovelEditor.focus() |
256
|
|
|
self.app.epc.create_event_text() |
257
|
|
|
|
258
|
|
|
def frame_image(self): |
259
|
|
|
"""フレーム内にイメージフレーム表示. |
260
|
|
|
|
261
|
|
|
・メインウインドウの右側にイメージキャンバス、スクロールバーを表示する。 |
262
|
|
|
""" |
263
|
|
|
self.app.FrameImage = customtkinter.CTkFrame(self.app) |
264
|
|
|
self.app.CanvasImage = tk.Canvas(self.app.FrameImage, bg="black", width=30) |
265
|
|
|
self.app.ScrollbarVerticalForCanvasImage = customtkinter.CTkScrollbar( |
266
|
|
|
self.app.FrameImage, |
267
|
|
|
orientation="vertical", |
268
|
|
|
command=self.app.CanvasImage.yview |
269
|
|
|
) |
270
|
|
|
self.app.ScrollbarHorizontalForCanvasImage = customtkinter.CTkScrollbar( |
271
|
|
|
self.app.FrameImage, |
272
|
|
|
orientation="horizontal", |
273
|
|
|
command=self.app.CanvasImage.xview |
274
|
|
|
) |
275
|
|
|
self.app.CanvasImage.configure(xscrollcommand=self.app.ScrollbarHorizontalForCanvasImage.set) |
276
|
|
|
self.app.CanvasImage.configure(yscrollcommand=self.app.ScrollbarVerticalForCanvasImage.set) |
277
|
|
|
self.app.CanvasImage.grid( |
278
|
|
|
row=0, |
279
|
|
|
column=1, |
280
|
|
|
sticky=(tk.NSEW) |
281
|
|
|
) |
282
|
|
|
self.app.ScrollbarVerticalForCanvasImage.grid(row=0, column=2, sticky=(tk.N + tk.S)) |
283
|
|
|
self.app.ScrollbarHorizontalForCanvasImage.grid(row=1, column=1, sticky=(tk.W + tk.E)) |
284
|
|
|
self.app.FrameImage.grid(row=0, column=1, sticky=(tk.NSEW)) |
285
|
|
|
self.app.FrameImage.columnconfigure(1, weight=1) |
286
|
|
|
self.app.FrameImage.rowconfigure(0, weight=1) |
287
|
|
|
self.app.FrameImage.grid(row=0, column=1, sticky=(tk.NSEW)) |
288
|
|
|
# デフォルトの画像を設定する |
289
|
|
|
self.app.CanvasImage.photo = tk.PhotoImage(data=self.BLANK_IMAGE) |
290
|
|
|
self.app.ImageOnImage = self.app.CanvasImage.create_image( |
291
|
|
|
0, |
292
|
|
|
0, |
293
|
|
|
anchor='nw', |
294
|
|
|
image=self.app.CanvasImage.photo |
295
|
|
|
) |
296
|
|
|
self.app.epc.create_event_image() |
297
|
|
|
|
298
|
|
|
def frame_character(self): |
299
|
|
|
"""フレーム内にイメージフレーム表示. |
300
|
|
|
|
301
|
|
|
・メインウインドウの右側に呼び名、似顔絵、名前、誕生日、略歴を表示する。 |
302
|
|
|
""" |
303
|
|
|
# チェック有無変数 |
304
|
|
|
self.app.var = tk.IntVar() |
305
|
|
|
# value=0のラジオボタンにチェックを入れる |
306
|
|
|
self.app.var.set(0) |
307
|
|
|
self.app.FrameCharacter = customtkinter.CTkFrame(self.app) |
308
|
|
|
self.app.FrameCallName = customtkinter.CTkFrame( |
309
|
|
|
self.app.FrameCharacter |
310
|
|
|
) |
311
|
|
|
self.app.LabelCallName = customtkinter.CTkLabel( |
312
|
|
|
self.app.FrameCallName, |
313
|
|
|
text=self.app.dic.get_dict("Call name") |
314
|
|
|
) |
315
|
|
|
self.app.EntryCallName = customtkinter.CTkEntry( |
316
|
|
|
self.app.FrameCallName, 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
|
|
|
self.app.FrameName = customtkinter.CTkFrame( |
322
|
|
|
self.app.FrameCharacter |
323
|
|
|
) |
324
|
|
|
self.app.LabelName = customtkinter.CTkLabel( |
325
|
|
|
self.app.FrameName, |
326
|
|
|
text=self.app.dic.get_dict("Name") |
327
|
|
|
) |
328
|
|
|
self.app.EntryName = customtkinter.CTkEntry( |
329
|
|
|
self.app.FrameName, width=400, |
330
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size) |
331
|
|
|
) |
332
|
|
|
self.app.LabelName.grid(row=0, column=0) |
333
|
|
|
self.app.EntryName.grid(row=1, column=0) |
334
|
|
|
self.app.FrameSex = customtkinter.CTkFrame( |
335
|
|
|
self.app.FrameCharacter |
336
|
|
|
) |
337
|
|
|
self.app.LabelSex = customtkinter.CTkLabel( |
338
|
|
|
self.app.FrameSex, |
339
|
|
|
text=self.app.dic.get_dict("Sex") |
340
|
|
|
) |
341
|
|
|
self.app.RadioButtonMan = customtkinter.CTkRadioButton( |
342
|
|
|
self.app.FrameSex, value=0, |
343
|
|
|
variable=self.app.var, |
344
|
|
|
text=self.app.dic.get_dict("Man") |
345
|
|
|
) |
346
|
|
|
self.app.RadioButtonWoman = customtkinter.CTkRadioButton( |
347
|
|
|
self.app.FrameSex, value=1, |
348
|
|
|
variable=self.app.var, |
349
|
|
|
text=self.app.dic.get_dict("Woman") |
350
|
|
|
) |
351
|
|
|
self.app.RadioButtonOther = customtkinter.CTkRadioButton( |
352
|
|
|
self.app.FrameSex, value=2, |
353
|
|
|
variable=self.app.var, |
354
|
|
|
text=self.app.dic.get_dict("Other") |
355
|
|
|
) |
356
|
|
|
self.app.LabelSex.grid(row=0, column=1) |
357
|
|
|
self.app.RadioButtonMan.grid(row=1, column=1) |
358
|
|
|
self.app.RadioButtonWoman.grid(row=2, column=1) |
359
|
|
|
self.app.RadioButtonOther.grid(row=3, column=1) |
360
|
|
|
self.app.FramePortrait = customtkinter.CTkFrame( |
361
|
|
|
self.app.FrameCharacter |
362
|
|
|
) |
363
|
|
|
self.app.LabelPortrait = customtkinter.CTkLabel( |
364
|
|
|
self.app.FramePortrait, |
365
|
|
|
text=self.app.dic.get_dict("Portrait") |
366
|
|
|
) |
367
|
|
|
self.app.CanvasPortrait = tk.Canvas( |
368
|
|
|
self.app.FramePortrait, |
369
|
|
|
bg="black", |
370
|
|
|
width=149, |
371
|
|
|
height=199 |
372
|
|
|
) |
373
|
|
|
self.app.FramePortraitButtons = customtkinter.CTkFrame(self.app.FramePortrait) |
374
|
|
|
self.app.ButtonPortraitInsert = customtkinter.CTkButton( |
375
|
|
|
self.app.FramePortraitButtons, |
376
|
|
|
text=self.app.dic.get_dict("Insert"), |
377
|
|
|
width=len(self.app.dic.get_dict("Insert"))*12, |
378
|
|
|
command=self.app.spc.btn_click |
379
|
|
|
) |
380
|
|
|
self.app.ButtonPortraitDelete = customtkinter.CTkButton( |
381
|
|
|
self.app.FramePortraitButtons, |
382
|
|
|
width=len(self.app.dic.get_dict("Delete"))*12, |
383
|
|
|
text=self.app.dic.get_dict("Delete"), |
384
|
|
|
command=self.app.spc.clear_btn_click |
385
|
|
|
) |
386
|
|
|
self.app.ButtonPortraitInsert.grid(row=0, column=1) |
387
|
|
|
self.app.ButtonPortraitDelete.grid(row=1, column=1) |
388
|
|
|
|
389
|
|
|
self.app.LabelPortrait.grid(row=0, column=0, columnspan=2) |
390
|
|
|
self.app.FramePortraitButtons.grid(row=1,column=0, sticky=(tk.S)) |
391
|
|
|
self.app.CanvasPortrait.grid(row=1, column=1) |
392
|
|
|
self.app.FrameBirthday = customtkinter.CTkFrame( |
393
|
|
|
self.app.FrameCharacter |
394
|
|
|
) |
395
|
|
|
self.app.LabelBirthday = customtkinter.CTkLabel( |
396
|
|
|
self.app.FrameBirthday, |
397
|
|
|
text=self.app.dic.get_dict("Birthday") |
398
|
|
|
) |
399
|
|
|
self.app.EntryBirthday = customtkinter.CTkEntry( |
400
|
|
|
self.app.FrameBirthday, width=400, |
401
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size) |
402
|
|
|
) |
403
|
|
|
self.app.LabelBirthday.grid(row=0, column=1) |
404
|
|
|
self.app.EntryBirthday.grid(row=1, column=1) |
405
|
|
|
self.app.LabelBiography = customtkinter.CTkLabel( |
406
|
|
|
self.app.FrameCharacter, |
407
|
|
|
text=self.app.dic.get_dict("Biography") |
408
|
|
|
) |
409
|
|
|
self.app.TextboxBiography = customtkinter.CTkTextbox( |
410
|
|
|
self.app.FrameCharacter, |
411
|
|
|
width=800, |
412
|
|
|
font=(self.app.font, ProcessingMenu.ProcessingMenuClass.font_size) |
413
|
|
|
) |
414
|
|
|
self.app.FrameCallName.grid(row=0, column=1, columnspa=2) |
415
|
|
|
self.app.FrameSex.grid(row=2, column=1, rowspan=2) |
416
|
|
|
self.app.FramePortrait.grid(row=0, column=3, rowspan=4) |
417
|
|
|
self.app.FrameName.grid(row=0, column=4) |
418
|
|
|
self.app.FrameBirthday.grid(row=2, column=4) |
419
|
|
|
self.app.LabelBiography.grid(row=4, column=1, columnspa=4) |
420
|
|
|
self.app.TextboxBiography.grid( |
421
|
|
|
row=5, |
422
|
|
|
column=1, |
423
|
|
|
columnspa=4, |
424
|
|
|
sticky=(tk.NSEW) |
425
|
|
|
) |
426
|
|
|
self.app.FrameCharacter.columnconfigure(1, weight=1) |
427
|
|
|
self.app.FrameCharacter.columnconfigure(4, weight=1) |
428
|
|
|
self.app.FrameCharacter.rowconfigure(5, weight=1) |
429
|
|
|
|
430
|
|
|
self.app.FrameCharacter.grid(row=0, column=1, sticky=(tk.NSEW)) |
431
|
|
|
self.app.columnconfigure(1, weight=1) |
432
|
|
|
self.app.rowconfigure(0, weight=1) |
433
|
|
|
# デフォルトの画像を設定する |
434
|
|
|
self.app.CanvasPortrait.photo = tk.PhotoImage(data=self.BLANK_IMAGE) |
435
|
|
|
self.app.ImageOnPortrait = self.app.CanvasPortrait.create_image( |
436
|
|
|
0, |
437
|
|
|
0, |
438
|
|
|
anchor='nw', |
439
|
|
|
image=self.app.CanvasPortrait.photo |
440
|
|
|
) |
441
|
|
|
|
442
|
|
|
# キャラクターイベントを追加 |
443
|
|
|
self.app.epc.create_event_character() |
444
|
|
|
|
445
|
|
|
|
446
|
|
|
class CustomText(tk.Text): |
447
|
|
|
"""Textのイベントを拡張したウィジェット. |
448
|
|
|
|
449
|
|
|
・TCl/TKを使って、textに<<Scroll>>イベントと、<<Change>>イベントを追加する。 |
450
|
|
|
|
451
|
|
|
Args: |
452
|
|
|
master (instance): toplevel のインスタンス |
453
|
|
|
""" |
454
|
|
|
def __init__(self, master, **kwargs): |
455
|
|
|
super().__init__(master, **kwargs) |
456
|
|
|
self.tk.eval(''' |
457
|
|
|
proc widget_proxy {widget widget_command args} { |
458
|
|
|
# 引数を使用してtkウィジェットコマンドを呼び出す |
459
|
|
|
set result [uplevel [linsert $args 0 $widget_command]] |
460
|
|
|
# ビューが移動した場合、バインドできるイベントを生成する |
461
|
|
|
if {([lrange $args 0 1] == {xview moveto}) || |
462
|
|
|
([lrange $args 0 1] == {xview scroll}) || |
463
|
|
|
([lrange $args 0 1] == {yview moveto}) || |
464
|
|
|
([lrange $args 0 1] == {yview scroll})} { |
465
|
|
|
event generate $widget <<Scroll>> -when tail |
466
|
|
|
} |
467
|
|
|
# 内容が変更された場合、バインドできるイベントを生成する |
468
|
|
|
if {([lindex $args 0] in {insert replace delete})} { |
469
|
|
|
event generate $widget <<Change>> -when tail |
470
|
|
|
} |
471
|
|
|
# ウィジェットコマンドから結果を返す |
472
|
|
|
return $result |
473
|
|
|
} |
474
|
|
|
''') |
475
|
|
|
self.tk.eval(''' |
476
|
|
|
# コマンドをリネームする |
477
|
|
|
rename {widget} _{widget} |
478
|
|
|
# コマンドを置き換える |
479
|
|
|
interp alias {{}} ::{widget} {{}} widget_proxy {widget} _{widget} |
480
|
|
|
'''.format(widget=str(self))) |
481
|
|
|
|