-
Notifications
You must be signed in to change notification settings - Fork 4
/
mainwindow.py
83 lines (67 loc) · 2.66 KB
/
mainwindow.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
74
75
76
77
78
79
80
81
82
83
import gtk
import logging
from activity import KSEActivityView
from interface import KSEToolBar
from undo import UndoableActionLog
from startupwizard import StartUpWizard
WINDOWTITLE="Kerious Ressources Editor"
WINWIDTH=1024
WINHEIGHT=768
BORDERWIDTH=2
class KSEWindow:
def __init__(self, fileName = None, debug = False):
self.action_log = UndoableActionLog()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_size_request(WINWIDTH, WINHEIGHT)
self.window.set_title(WINDOWTITLE)
self.window.set_border_width(BORDERWIDTH)
self._initLogging(debug)
self.settings = None
self.mainbox = gtk.VBox(False, 0)
self.mainbox.show()
self.window.add(self.mainbox)
self.window.set_icon_from_file("assets/kselogo.png")
self.activityView = KSEActivityView(fileName, self)
accelGroup = gtk.AccelGroup()
self.window.add_accel_group(accelGroup)
self.toolbar = KSEToolBar(self.activityView, accelGroup)
actionGroup = gtk.ActionGroup("Main window actions")
actionGroup.add_actions([("MainWindow", None, "Save Project",
"<control>s", "Saves the project",
self._saveProjectCb)])
self.mainbox.pack_start(self.toolbar, False, False, 2)
self.mainbox.pack_start(self.activityView, True, True, 0)
self.window.connect("delete_event", self.stop)
self.window.maximize()
self.window.show()
if fileName == None:
self.wizard = StartUpWizard(self)
self.wizard.show()
def start(self):
gtk.main()
def stop(self, event, data = None):
gtk.main_quit()
#INTERNAL
def _initLogging(self, debug):
self.logger = logging.getLogger("KRFEditor")
hdlr = logging.FileHandler('KRFEditor.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
self.logger.addHandler(hdlr)
hdlr.setLevel(logging.WARNING)
if debug:
shdlr = logging.StreamHandler()
self.logger.addHandler(shdlr)
if debug == "debug":
shdlr.setLevel(logging.DEBUG)
elif debug == "info":
shdlr.setLevel(logging.INFO)
elif debug == "warning":
shdlr.setLevel(logging.WARNING)
elif debug == "error":
shdlr.setLevel(logging.ERROR)
elif debug == "critical":
shdlr.setLevel(logging.CRITICAL)
self.logger.setLevel(logging.INFO)
def _saveProjectCb(self, widget):
print "saved"