1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
import os |
3
|
|
|
import shutil |
4
|
|
|
import platform |
5
|
|
|
import tkinter as tk |
6
|
|
|
import tkinter.ttk as ttk |
7
|
|
|
|
8
|
|
|
import CW |
9
|
|
|
import EP |
10
|
|
|
import SP |
11
|
|
|
import HP |
12
|
|
|
import FP |
13
|
|
|
import CP |
14
|
|
|
import FM |
15
|
|
|
import EM |
16
|
|
|
import HM |
17
|
|
|
import PM |
18
|
|
|
import LM |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
class MainProcessingClass(ttk.Frame): |
22
|
|
|
"""メインフレーム処理のクラス. |
23
|
|
|
|
24
|
|
|
・初期設定をするプログラム群 |
25
|
|
|
|
26
|
|
|
Args: |
27
|
|
|
tree_folder (str): ツリーフォルダの配列 |
28
|
|
|
tokenizer (instance): Tokenizerインスタンス |
29
|
|
|
wiki_wiki (instance): wikipediaapi.Wikipediaインスタンス |
30
|
|
|
title_binary (str): タイトルイメージファイルバイナリ |
31
|
|
|
master (instance): toplevelインスタンス |
32
|
|
|
|
33
|
|
|
""" |
34
|
|
|
|
35
|
|
|
def __init__( |
36
|
|
|
self, |
37
|
|
|
tree_folder, |
38
|
|
|
tokenizer, |
39
|
|
|
wiki_wiki, |
40
|
|
|
title_binary, |
41
|
|
|
master=None |
42
|
|
|
): |
43
|
|
|
super().__init__(master) |
44
|
|
|
self.TREE_FOLDER = tree_folder |
45
|
|
|
# 自作クラスの読み込み |
46
|
|
|
self.cwc = CW.CreateWindowClass(self) |
47
|
|
|
self.epc = EP.EventProcessingClass(self) |
48
|
|
|
self.sfc = SP.SubfunctionProcessingClass(self, self.TREE_FOLDER) |
49
|
|
|
self.hpc = HP.HighlightProcessingClass(self, tokenizer) |
50
|
|
|
self.fpc = FP.FindProcessingClass(self) |
51
|
|
|
self.cpc = CP.ComplementProcessingClass(self, tokenizer) |
52
|
|
|
self.fmc = FM.FileMenuClass(self, master, self.TREE_FOLDER) |
53
|
|
|
self.emc = EM.EditMenuClass(self) |
54
|
|
|
self.pmc = PM.ProcessingMenuClass(self, wiki_wiki, tokenizer) |
55
|
|
|
self.lmc = LM.ListMenuClass(self, master, self.TREE_FOLDER) |
56
|
|
|
self.hmc = HM.HelpMenuClass(self, title_binary) |
57
|
|
|
# メニューバーの作成 |
58
|
|
|
self.menu_bar = tk.Menu(self.master) |
59
|
|
|
self.master.config(menu=self.menu_bar) |
60
|
|
|
# 初期化処理 |
61
|
|
|
self.initialize() |
62
|
|
|
self.cwc.create_widgets() |
63
|
|
|
self.epc.create_event() |
64
|
|
|
|
65
|
|
|
def initialize(self): |
66
|
|
|
"""初期化処理. |
67
|
|
|
|
68
|
|
|
・変数の初期化及び起動準備をする。 |
69
|
|
|
|
70
|
|
|
""" |
71
|
|
|
# 今の処理ししているファイルのパス |
72
|
|
|
self.fmc.now_path = "" |
73
|
|
|
# 現在開いているファイル |
74
|
|
|
self.fmc.file_path = "" |
75
|
|
|
# 検索文字列 |
76
|
|
|
self.fpc.find_text = "" |
77
|
|
|
# 現在入力中の初期テキスト |
78
|
|
|
self.lmc.text_text = "" |
79
|
|
|
self.lmc.select_list_item = "" |
80
|
|
|
# 文字の大きさ |
81
|
|
|
self.pmc.font_size = 16 |
82
|
|
|
self.APPID = "" |
83
|
|
|
if os.path.isfile("./appid.txt"): |
84
|
|
|
f = open("./appid.txt", "r", encoding="utf-8") |
85
|
|
|
self.APPID = f.read() |
86
|
|
|
f.close() |
87
|
|
|
if u"ここを消して、" in self.APPID: |
88
|
|
|
self.APPID = "" |
89
|
|
|
# フォントをOSごとに変える |
90
|
|
|
pf = platform.system() |
91
|
|
|
if pf == 'Windows': |
92
|
|
|
self.font = "メイリオ" |
93
|
|
|
elif pf == 'Darwin': # MacOS |
94
|
|
|
self.font = "Osaka-等幅" |
95
|
|
|
elif pf == 'Linux': |
96
|
|
|
self.font = "IPAゴシック" |
97
|
|
|
# dataフォルダがあるときは、削除する |
98
|
|
|
if os.path.isdir('./data'): |
99
|
|
|
shutil.rmtree('./data') |
100
|
|
|
# 新しくdataフォルダを作成する |
101
|
|
|
for val in self.TREE_FOLDER: |
102
|
|
|
os.makedirs('./{0}'.format(val[0])) |
103
|
|
|
|