Conditions | 2 |
Total Lines | 319 |
Code Lines | 255 |
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 |
||
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 | |||
660 |