forked from rsaxvc/WxContestLogger
/
ui_search.py
117 lines (91 loc) · 3.13 KB
/
ui_search.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
#snagged from the WxPython Tutorial
import wx
from db_manager import db_manager
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title,
size=(790, 350))
self.db = db_manager()
self.filter = self.db.filter()
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
st1 = wx.StaticText(panel, label='Contact Callsign')
st1.SetFont(font)
hbox1.Add(st1, flag=wx.RIGHT, border=8)
self.tc = wx.TextCtrl(panel)
self.tc.Bind(wx.EVT_TEXT, self.OnSearchBoxUpdate)
hbox1.Add(self.tc, proportion=1)
vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
vbox.Add((-1, 10))
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
st2 = wx.StaticText(panel, label='Matching Callsigns')
st2.SetFont(font)
hbox2.Add(st2)
vbox.Add(hbox2, flag=wx.LEFT | wx.TOP, border=10)
vbox.Add((-1, 10))
hbox3 = wx.BoxSizer(wx.HORIZONTAL)
self.lc = wx.ListCtrl(panel, style=wx.BORDER_SUNKEN)
self.lc.InsertColumn(0,"Callsign")
hbox3.Add(self.lc, proportion=1, flag=wx.EXPAND)
vbox.Add(hbox3, proportion=1, flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=10)
vbox.Add((-1, 25))
hbox5 = wx.BoxSizer(wx.HORIZONTAL)
self.bands = [ 'Satellite', '1.25m', '2m', '6m', '10m', '20m', '40m', '80m', '160m' ]
self.bandswitches = []
for band in self.bands:
cb = wx.CheckBox(panel, label=band )
cb.SetFont(font)
cb.SetValue( True )
hbox5.Add(cb, flag=wx.RIGHT, border=8, proportion=1)
self.bandswitches.append( cb )
vbox.Add(hbox5, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
vbox.Add((-1, 10))
hbox6 = wx.BoxSizer(wx.HORIZONTAL)
self.modes = [ 'cw', 'digital', 'phone' ]
self.modeswitches = []
for mode in self.modes:
cb = wx.CheckBox(panel, label=mode)
cb.SetFont(font)
cb.SetValue( True )
hbox6.Add(cb, flag=wx.RIGHT, border=8)
self.modeswitches.append( cb )
close_btn = wx.Button(panel, label='Close', size=(70, 30))
close_btn.Bind(wx.EVT_BUTTON, self.OnCloseButtonClicked)
hbox6.Add(close_btn, flag=wx.LEFT|wx.BOTTOM, border=5)
# vbox.Add(hbox15, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
# vbox.Add((-1, 10))
vbox.Add(hbox6, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)
panel.SetSizer(vbox)
TIMER_ID = 10000
self.timer = wx.Timer(panel, TIMER_ID)
self.timer.Start(10000)
wx.EVT_TIMER(panel, TIMER_ID, self.OnTimer) # call the on_timer function
self.DisplayView()
def DisplayView(self):
self.lc.DeleteAllItems()
j = 0
for i in self.db.search( self.filter ):
self.lc.InsertStringItem( j, i.band + ", " + i.mode + ", " + i.mycall + "->" + i.theircall )
j = j + 1
def OnSearchBoxUpdate(self,evnt):
self.filter.contains = self.tc.GetValue()
self.DisplayView()
def OnCloseButtonClicked(self,evnt):
self.timer.Stop()
self.Destroy()
def OnTimer(self,event):
self.DisplayView()
pass
if __name__ == '__main__':
app = wx.App()
Example(None, title='WxContextLogger - Search Contacts')
app.MainLoop()