1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import wx
20
21 from timelinelib.editors.container import ContainerEditor
22 from timelinelib.wxgui.components.categorychoice import CategoryChoice
23 from timelinelib.wxgui.utils import BORDER
24 from timelinelib.wxgui.utils import _display_error_message
25 from timelinelib.wxgui.utils import _set_focus_and_select
26 import timelinelib.wxgui.utils as gui_utils
27
28
30
32 wx.Dialog.__init__(self, parent, title=title, name="container_editor",
33 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
34 self.db = db
35 self._create_gui()
36
38 sizer = wx.BoxSizer(wx.VERTICAL)
39 self._create_propeties_groupbox(sizer)
40 self._create_buttons(sizer)
41 self.SetSizerAndFit(sizer)
42 self.txt_name.SetFocus()
43
45 groupbox = wx.StaticBox(self, wx.ID_ANY, _("Container Properties"))
46 box = wx.StaticBoxSizer(groupbox, wx.VERTICAL)
47 self._create_properties_groupbox_content(box)
48 sizer.Add(box, flag=wx.EXPAND|wx.ALL, border=BORDER, proportion=1)
49
51 grid = wx.FlexGridSizer(4, 2, BORDER, BORDER)
52 grid.AddGrowableCol(1)
53 self._create_name_textctrl(grid)
54 self._create_categories_listbox(grid)
55 sizer.Add(grid, flag=wx.ALL|wx.EXPAND, border=BORDER)
56
58 self.txt_name = wx.TextCtrl(self, wx.ID_ANY, name="name")
59 label = wx.StaticText(self, label=_("Name:"))
60 grid.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
61 grid.Add(self.txt_name, flag=wx.EXPAND)
62
64 self.lst_category = CategoryChoice(self, self.db)
65 label = wx.StaticText(self, label=_("Category:"))
66 grid.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
67 grid.Add(self.lst_category)
68
72
73
75
79
82
84 return self.txt_name.GetValue().strip()
85
88
90 return self.lst_category.get()
91
93 _display_error_message(message, self)
94 _set_focus_and_select(self.txt_name)
95
98
100 self.EndModal(wx.ID_OK)
101
103 self.Bind(wx.EVT_BUTTON, self._btn_ok_on_click, id=wx.ID_OK)
104 self.Bind(wx.EVT_CHOICE, self.lst_category.on_choice, self.lst_category)
105
107 self.controller.save()
108
109
112 """
113 This dialog is used for two purposes, editing an existing container
114 event and creating a new container event (container==None).
115 The 'business logic' is handled by the controller.
116 """
117 - def __init__(self, parent, title, db, container=None):
120
121
122
123
126