1
2
3
4
5
6
7
8
9
10 "Deals with Google Calendar (gCalendar) import stuff"
11
12
13 from __future__ import with_statement
14 import urllib2
15
16
17 import wx
18
19
20 import common_calendar
21 import database
22 import guihelper
23 import ical_calendar as ical
24 import vcal_calendar as vcal
25
26 module_debug=False
27
28
30
31 message_str='Select a Google Calendar iCal URL'
32
33 - def browse(self, parent=None):
43
44
45 URLDictKey='URLs'
46 URLDictName='gCalURL'
54 urlobjectfactory=database.dataobjectfactory(URLDataObject)
55
56
58
60 return urllib2.urlopen(name)
61
62
63 parentclass=ical.iCalendarImportData
71
72
86
87
89 - def __init__(self, parent, message, database):
90 super(SelectURLDialog, self).__init__(parent, -1, 'URL Selection')
91 self._db=database
92 self._data=[]
93 vbs=wx.BoxSizer(wx.VERTICAL)
94 vbs.Add(wx.StaticText(self, -1, message), 0, wx.EXPAND|wx.ALL, 5)
95 self._choices=wx.ListBox(self, -1,
96 style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB)
97 wx.EVT_LISTBOX_DCLICK(self, self._choices.GetId(), self.OnOK)
98 vbs.Add(self._choices, 0, wx.EXPAND|wx.ALL, 5)
99 vbs.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)
100 hbs=self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL)
101 _btn=wx.Button(self, -1, 'New')
102 wx.EVT_BUTTON(self, _btn.GetId(), self.OnNew)
103 hbs.Add(_btn, 0, wx.EXPAND|wx.ALL, 5)
104 _btn=wx.Button(self, -1, 'Delete')
105 wx.EVT_BUTTON(self, _btn.GetId(), self.OnDel)
106 hbs.Add(_btn, 0, wx.EXPAND|wx.ALL, 5)
107 vbs.Add(hbs, 0, wx.EXPAND|wx.ALL, 5)
108
109 self._get_from_fs()
110 self.SetSizer(vbs)
111 self.SetAutoLayout(True)
112 vbs.Fit(self)
113
122 - def set(self, data):
123 self._data=data
124 self._choices.Clear()
125 for _item in self._data:
126 self._choices.Append(_item['name'], _item['url'])
135 with guihelper.WXDialogWrapper(NewURLDialog(self),
136 True) as (_dlg, retcode):
137 if retcode==wx.ID_OK:
138 _name, _url=_dlg.get()
139 self._choices.Append(_name, _url)
140 self._data.append({ 'name': _name,
141 'url': _url })
142 self._save_to_fs(self._data)
143 - def OnOK(self, evt):
144 self.EndModal(wx.ID_OK)
150
151
154 super(NewURLDialog, self).__init__(parent, -1, 'New URL Entry')
155 vbs=wx.BoxSizer(wx.VERTICAL)
156 vbs.Add(wx.StaticText(self, -1, 'URL:'), 0, wx.EXPAND|wx.ALL, 5)
157 self._url=wx.TextCtrl(self, -1, '')
158 vbs.Add(self._url, 0, wx.EXPAND|wx.ALL, 5)
159 vbs.Add(wx.StaticText(self, -1, 'Name:'), 0, wx.EXPAND|wx.ALL, 5)
160 self._name=wx.TextCtrl(self, -1, '')
161 vbs.Add(self._name, 0, wx.EXPAND|wx.ALL, 5)
162 vbs.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)
163 vbs.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),
164 0, wx.EXPAND|wx.ALL, 5)
165
166 self.SetSizer(vbs)
167 self.SetAutoLayout(True)
168 vbs.Fit(self)
169
172