-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoBookmarker.py
73 lines (57 loc) · 2.1 KB
/
AutoBookmarker.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
import sys
from pathlib import Path
from PyQt6.QtWidgets import QMainWindow, QApplication, QHBoxLayout, QFileDialog
from PyQt6.uic import loadUi
from PyQt6.QtCore import QThread, pyqtSignal
from CdropLabel import CdropLayoutBkMks, CdropLayoutChronology, CdropLayoutHyperlinks
import json
import wx
import frame_main
class MainUI(QMainWindow):
def __init__(self):
super(MainUI, self).__init__()
loadUi('MainWindow.ui', self)
self.settings={'ReferenceFolder':'','Chronology':{},'Hyperlinks':{}, 'Bookmarks':{}}
self.getSettings()
self.labelBookmark = CdropLayoutBkMks(self)
self.labelChrono = CdropLayoutChronology(self)
self.labelHyperlinks=CdropLayoutHyperlinks(self)
self.horizontalLayout.addLayout(self.labelBookmark)
self.horizontalLayout.addLayout(self.labelChrono)
self.horizontalLayout.addLayout(self.labelHyperlinks)
self.setWindowTitle('Autobookmark')
self.actionSet_reference_folder.triggered.connect(self.setRefFolder)
def setRefFolder(self):
dlg=QFileDialog(self)
dlg.setFileMode(QFileDialog.FileMode.Directory)
if dlg.exec():
dir=dlg.selectedFiles()[0]
self.settings['ReferenceFolder']=dir + '/'
self.saveSettings()
def getSettings(self):
try:
f = open('settings.json')
# returns JSON object as
# a dictionary
self.settings = json.load(f)
except:
print('No settings.json file')
def saveSettings(self):
with open('settings.json', 'w', encoding='utf-8') as f:
json.dump(self.settings, f, ensure_ascii=False, indent=4)
class AutoBookMarker(wx.App):
def __init__(self):
super(AutoBookMarker, self).__init__()
self.frame = frame_main.FrameMain(None)
self.SetTopWindow(self.frame)
self.frame.Show()
#if __name__ == '__main__':
# app = AutoBookMarker()
# app.MainLoop()
# sys.exit()
if __name__ == '__main__':
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec()