-
Notifications
You must be signed in to change notification settings - Fork 0
/
stroika.py
114 lines (74 loc) · 3.01 KB
/
stroika.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
General file that make move
'''
__author__ = 'r0n9.GOL (http://www.pamparam.net/ email:ron9.gol@gmail.com)'
__version__ = '$Revision: 1.0 $'
__date__ = '$Date: 2009/04/12 11:34:59 $'
__copyright__ = 'Copyright (c) 2009 r0n9.GOL'
import pygtk
pygtk.require('2.0')
import gtk
import sys
import cPickle as pickle
import classes.mysql as mysql
import classes.staff as staff
class Main:
def __init__(self):
self.MySql = mysql.MySql()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title('Стройка')
self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.window.set_icon_from_file(sys.path[0] + '/images/logotip.png')
self.window.connect('destroy', lambda l: gtk.main_quit())
self.go = None
self.loadSession()
self.sender(1)
self.window.show()
gtk.main()
def sender(self, location = None, ID = None):
if location != None and (ID != None or self.ID != None):
if self.ID == None or ID != None: self.ID = ID
self.module = None
self.window.set_size_request(950, 600)
self.go = gtk.VBox()
import modules.Menu as menu
self.menu = menu.Base(self, self.ID)
self.menuGo = self.menu.gO()
self.go.pack_start(self.menuGo, False)
self.senderD(self.menu.active)
self.go.show()
else:
if self.go != None:
self.window.remove(self.go)
f = open(sys.path[0] + '/session.pkl', 'wb')
f.close()
import modules.Login as module
self.go = module.Base().gO(self)
self.window.add(self.go)
def senderD(self, location = None):
if self.module != None:
self.moduleGo.destroy()
if location == 1:
import modules.Customers as module
elif location == 2:
import modules.Projects as module
elif location == 3:
import modules.Staff as module
elif location == 4:
import modules.Accountancy as module
self.module = module.Base(self.MySql, self.window, self.ID)
self.moduleGo = self.module.gO()
self.go.add(self.moduleGo)
def loadSession(self):
try:
f = open(sys.path[0] + '/session.pkl', 'rb')
obj = pickle.load(f)
f.close()
self.ID = int(staff.Staff(self.MySql).getSessId(obj['login'], \
obj['password']))
if self.ID == False: self.ID = None
except: self.ID = None
if __name__ == '__main__':
Main()