/
CKDB MSDB only combined panel.py
154 lines (118 loc) · 5.81 KB
/
CKDB MSDB only combined panel.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import wx, gVar, pyodbc
from myListCtrl import VirtualList as vListCtrl
#from BetterListCtr import vListCtrl
from wx.lib.pubsub import setupkwargs
from wx.lib.pubsub import pub
import fetchodbc as fetch
class combinedPanel(wx.Panel):
def __init__(self, *args, **kwds):
kwds["style"] = wx.TAB_TRAVERSAL
wx.Panel.__init__(self, *args, **kwds)
self.list = vListCtrl(self, style=wx.LC_HRULES)
# for wxMSW
self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick)
# for wxGTK
self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
self.__set_properties()
self.__do_layout()
self.__do_main()
""" self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list)
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected, self.list)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.list)
self.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnItemDelete, self.list)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)
self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColRightClick, self.list)
self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColBeginDrag, self.list)
self.Bind(wx.EVT_LIST_COL_DRAGGING, self.OnColDragging, self.list)
self.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnColEndDrag, self.list)
self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list)
self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)"""
def OnRightClick(self, event):
self.currentItem = self.list.currentItem
#rint'self.currentItem', self.currentItem
#rint'lodilo... have result, publishing it via pubsub'
pub.sendMessage('change_statusbar', arg1=123, arg2=dict(a='abc', b='def'))
#self.index = self.list.GetFirstSelected()
# only do this part the first time so the events are only bound once
if not hasattr(self, "popupID1"):
self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID3 = wx.NewId()
self.popupID4 = wx.NewId()
self.popupID5 = wx.NewId()
self.popupID6 = wx.NewId()
self.Bind(wx.EVT_MENU, self.OnPopupOne, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.OnPopupTwo, id=self.popupID2)
self.Bind(wx.EVT_MENU, self.OnPopupThree, id=self.popupID3)
self.Bind(wx.EVT_MENU, self.OnPopupFour, id=self.popupID4)
self.Bind(wx.EVT_MENU, self.OnPopupFive, id=self.popupID5)
self.Bind(wx.EVT_MENU, self.OnPopupSix, id=self.popupID6)
# make a menu
menu = wx.Menu()
# add some items
menu.Append(self.popupID1, "?")
menu.Append(self.popupID2, "?")
menu.Append(self.popupID3, "?")
menu.Append(self.popupID4, "?")
menu.Append(self.popupID4, "?")
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.PopupMenu(menu)
menu.Destroy()
def OnPopupOne(self, event):# View Test Results
#rint"Popup one\n"
#rint"FindItem:", self.list.FindItem(-1, "Roxette")
#rint"FindItemData:", self.list.FindItemData(-1, 11)
def OnPopupTwo(self, event): # Receive Payment
#rint"Selected items:\n"
index = self.list.GetFirstSelected()
while index != -1:
#rint" %s: %s\n" % (self.list.GetItemText(index), self.list.GetColumnText(index, 0))
index = self.list.GetNextSelected(index)
def OnPopupThree(self, event): # Update Status
#rint"Popup three\n"
#self.list.ClearAll()
#wx.CallAfter(self.list.PopulateList)
def OnPopupFour(self, event): # View Student Details
item = self.list.GetItem(self.currentItem)
#rintitem.m_text, item.m_itemId, self.list.GetItemData(self.currentItem)
def OnPopupFive(self, event): # Withdraw Application
pass # self.list.DeleteAllItems()
def OnPopupSix(self, event):
self.list.EditLabel(self.currentItem)
def updateData(self):
sql ="SELECT courses FROM courses_by_year WHERE schYr = %s" % 2015
sql ="SELECT course_level, course_name FROM courses ORDER BY course_level, course_name"
results = fetch.getAll_dict(sql)
#rint'courses', results
#for
sql = "SELECT cSiswa.Kode , courses.course_name, cSiswa.Nama , cSiswa.Status \
FROM cSiswa INNER JOIN courses ON cSiswa.Kelas = courses.id \
WHERE cSiswa.TahunAjaran = %s" % gVar.schYr
schoolKode = 0
if gVar.school == "CG": schoolKode = 1
if gVar.school == "SD": schoolKode = 2
if gVar.school == "SMP": schoolKode = 3
if gVar.school == "SMA": schoolKode = 4
#rintgVar.school, schoolKode
if schoolKode:
#rint"School"
#sqlSch = " AND courses.school_id = %d" % schoolKode
#sql = "%s%s" % (sql, sqlSch)
sql = "%s%s" % (sql, " ORDER BY courses.course_level, cSiswa.Nama" )
#sql = "SELECT Kode, Nama, Status FROM cSiswa \
# WHERE TahunAjaran = %s" % gVar.schYr
#sql = "SELECT course_name \
# FROM courses "
#rintsql
results = fetch.getAll_dict(sql)
#rintlen(results), "Results "
print
results = fetch.DATA(sql)
##rint"DATA = " , results
self.list.PopulateList(results)
def __do_layout(self):
sizer_main = wx.BoxSizer( wx.VERTICAL)
sizer_main.Add(self.list, 1, wx.EXPAND | wx.ALL, 0)
self.SetSizer(sizer_main)