1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from timelinelib.wxgui.dialogs.editcategory.controller import EditCategoryDialogController
20 from timelinelib.wxgui.framework import Dialog
21 from timelinelib.wxgui.utils import display_error_message
22 from timelinelib.wxgui.utils import _set_focus_and_select
23
24
26
27 """
28 <BoxSizerVertical>
29 <FlexGridSizer rows="6" columns="2" growableColumns="1" proportion="1" border="ALL">
30 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(name_text)" />
31 <TextCtrl name="txt_name" width="150" />
32 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(color_text)" />
33 <ColourSelect name="colorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
34 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(progress_color_text)" />
35 <ColourSelect name="progresscolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
36 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(done_color_text)" />
37 <ColourSelect name="donecolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
38 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(font_color_text)" />
39 <ColourSelect name="fontcolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
40 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(parent_text)" />
41 <CategoryChoice name="category_choice" allow_add="True" timeline="$(db)" align="ALIGN_CENTER_VERTICAL" />
42 </FlexGridSizer>
43 <DialogButtonsOkCancelSizer
44 border="LEFT|BOTTOM|RIGHT"
45 event_EVT_BUTTON__ID_OK="on_ok_clicked"
46 />
47 </BoxSizerVertical>
48 """
49
50 - def __init__(self, parent, title, db, category):
51 Dialog.__init__(self, EditCategoryDialogController, parent, {
52 "db": db,
53 "name_text": _("Name:"),
54 "color_text": _("Color:"),
55 "progress_color_text": _("Progress Color:"),
56 "done_color_text": _("Done Color:"),
57 "font_color_text": _("Font Color:"),
58 "parent_text": _("Parent:"),
59 }, title=title)
60 self.controller.on_init(db, category)
61
63 self.category_choice.Populate(exclude=exclude)
64 self.Fit()
65
67 return self.txt_name.GetValue().strip()
68
71
74
77
80
82 self.progresscolorpicker.SetValue(new_color)
83
86
88 self.donecolorpicker.SetValue(new_color)
89
92
94 self.fontcolorpicker.SetValue(new_color)
95
98
101
103 msg = _("Category name '%s' not valid. Must be non-empty.")
104 display_error_message(msg % name, self)
105 _set_focus_and_select(self.txt_name)
106
108 msg = _("Category name '%s' already in use.")
109 display_error_message(msg % name, self)
110 _set_focus_and_select(self.txt_name)
111
114