-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.py
51 lines (37 loc) · 1.67 KB
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gi
gi.require_version('Gtk', '3.0')
import epub_highlighter
import util
from gi.repository import Gtk
class InfoHolder:
def __init__(self):
self.epub_file_address = "None"
self.epub_word_list_address = "None"
def __str__(self):
return "epub_file: {} epub_word: {} ".format(self.epub_file_address, self.epub_word_list_address)
class Handler:
def __init__(self, info_holder: InfoHolder, builder):
self.info_holder = info_holder
def on_delete_window(self, *args):
Gtk.main_quit(*args)
def epub_file_chosen(self, *args):
self.info_holder.epub_file_address = args[0].get_filename()
def list_file_chosen(self, *args):
self.info_holder.epub_word_list_address = args[0].get_filename()
def button_convert(self, *args):
check_meaning = builder.get_object("check_with_meaning")
status_bar = builder.get_object("status_bar")
if util.check_if_path_exists(self.info_holder.epub_file_address) and util.check_if_path_exists(self.info_holder.epub_word_list_address) and util.check_if_epub(self.info_holder.epub_file_address):
progress_bar = builder.get_object("epub_progress")
# print("got epub_progress")
epub_highlighter.main(
self.info_holder.epub_file_address, self.info_holder.epub_word_list_address, progress_bar, status_bar, check_meaning.get_active())
else:
status_bar.push(1, "Error: Please check files.")
builder = Gtk.Builder()
builder.add_from_file("second.glade")
window = builder.get_object("epub_window")
info_holder = InfoHolder()
builder.connect_signals(Handler(info_holder, builder))
window.show_all()
Gtk.main()