| Conditions | 1 |
| Total Lines | 196 |
| Code Lines | 156 |
| 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 |
||
| 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 | |||
| 481 |