1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20 import wx.lib.newevent
21
22 from timelinelib.canvas.data.exceptions import TimelineIOError
23 from timelinelib.wxgui.dialogs.editcontainer.view import EditContainerDialog
24 import timelinelib.wxgui.utils as gui_utils
25
26
28
29 ContainerChangedEvent, EVT_CONTAINER_CHANGED = wx.lib.newevent.NewEvent()
30
31 - def __init__(self, parent, db, **kwargs):
32 wx.Choice.__init__(self, parent, **kwargs)
33 self.db = db
34 self._clear()
35 self.Bind(wx.EVT_CHOICE, self._on_choice)
36
37 - def Fill(self, select_container):
40
47
49 new_selection_index = event.GetSelection()
50 if new_selection_index > self.last_real_container_index:
51 self.SetSelection(self.current_container_selection)
52 if new_selection_index == self.add_container_item_index:
53 self._add_container()
54 else:
55 self.current_container_selection = new_selection_index
56 wx.PostEvent(self, self.ContainerChangedEvent())
57
63
65 self.last_real_container_index = None
66 self.add_container_item_index = None
67 self.current_container_selection = None
68 self.Clear()
69
70 - def _fill(self, containers, select_container):
71 self.Append("", None)
72 selection_set = False
73 current_item_index = 1
74 if select_container is not None and select_container not in containers:
75 self.Append(select_container.text, select_container)
76 self._select(current_item_index)
77 current_item_index += 1
78 selection_set = True
79 for container in containers:
80 self.Append(container.text, container)
81 if not selection_set:
82 if container == select_container:
83 self._select(current_item_index)
84 selection_set = True
85 current_item_index += 1
86 self.last_real_container_index = current_item_index - 1
87 self.add_container_item_index = self.last_real_container_index + 2
88 self.Append("", None)
89 self.Append(_("Add new"), None)
90 if not selection_set:
91 self._select(0)
92
97