Conditions | 1 |
Total Lines | 146 |
Code Lines | 112 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | #!/usr/bin/env python3 |
||
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 | |||
481 |