Package Gnumed :: Package timelinelib :: Package wxgui :: Package dialogs :: Package milestone :: Module view
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.dialogs.milestone.view

  1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
  2  # 
  3  # This file is part of Timeline. 
  4  # 
  5  # Timeline is free software: you can redistribute it and/or modify 
  6  # it under the terms of the GNU General Public License as published by 
  7  # the Free Software Foundation, either version 3 of the License, or 
  8  # (at your option) any later version. 
  9  # 
 10  # Timeline is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  # GNU General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU General Public License 
 16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
 17   
 18   
 19  import wx 
 20   
 21  from timelinelib.wxgui.framework import Dialog 
 22  from timelinelib.wxgui.dialogs.milestone.controller import EditMilestoneDialogController 
 23  from timelinelib.db.utils import safe_locking 
 24   
 25   
26 -class EditMilestoneDialog(Dialog):
27 28 """ 29 <BoxSizerVertical> 30 <StaticBoxSizerVertical label="$(groupbox_text)" border="ALL" > 31 <FlexGridSizer rows="0" columns="2" border="ALL"> 32 <StaticText 33 label="$(when_text)" 34 align="ALIGN_CENTER_VERTICAL" 35 /> 36 <TimePicker 37 time_type="$(time_type)" 38 config="$(config)" 39 name="dtp_time" 40 /> 41 <StaticText 42 label="$(description_text)" 43 align="ALIGN_CENTER_VERTICAL" 44 /> 45 <TextCtrl name="txt_description" /> 46 <StaticText 47 label="$(description_label)" 48 align="ALIGN_CENTER_VERTICAL" 49 /> 50 <TextCtrl name="txt_label" /> 51 <StaticText 52 align="ALIGN_CENTER_VERTICAL" 53 label="$(category_label)" 54 /> 55 <CategoryChoice 56 name="category_choice" 57 allow_add="True" 58 allow_edit="True" 59 timeline="$(db)" 60 align="ALIGN_LEFT" 61 /> 62 <StaticText 63 label="$(colour_text)" 64 align="ALIGN_CENTER_VERTICAL" 65 /> 66 <ColourSelect 67 name="colorpicker" 68 align="ALIGN_CENTER_VERTICAL" 69 width="60" 70 height="30" 71 /> 72 </FlexGridSizer> 73 </StaticBoxSizerVertical> 74 <DialogButtonsOkCancelSizer 75 border="LEFT|BOTTOM|RIGHT" 76 event_EVT_BUTTON__ID_OK="on_ok_clicked" 77 /> 78 </BoxSizerVertical> 79 """ 80
81 - def __init__(self, parent, title, db, config, milestone):
82 Dialog.__init__(self, EditMilestoneDialogController, parent, { 83 "groupbox_text": _("Milestone Properties"), 84 "when_text": _("When:"), 85 "time_type": db.time_type, 86 "description_text": _("Description:"), 87 "description_label": _("Label:"), 88 "category_label": _("Category:"), 89 "colour_text": _("Colour:"), 90 "config": config, 91 "db": db, 92 }, title=title) 93 self.controller.on_init(db, milestone) 94 self._milestone = milestone 95 self.txt_label.Bind(wx.EVT_CHAR, self.handle_keypress)
96
97 - def GetTime(self):
98 return self.dtp_time.get_value()
99
100 - def SetTime(self, start_time):
101 self.dtp_time.set_value(start_time)
102
103 - def GetDescription(self):
104 return self.txt_description.GetValue()
105
106 - def SetDescription(self, description):
107 if description is None: 108 self.txt_description.SetValue("") 109 else: 110 self.txt_description.SetValue(description)
111
112 - def GetLabel(self):
113 return self.txt_label.GetValue()
114
115 - def SetLable(self, label):
116 self.txt_label.SetValue(label)
117
118 - def GetCategory(self):
119 return self.category_choice.GetSelectedCategory()
120
121 - def SetCategory(self, value):
122 self.category_choice.Populate(select=value)
123
124 - def GetColour(self):
125 return self.colorpicker.GetValue()
126
127 - def SetColor(self, color):
128 self.colorpicker.SetValue(color)
129
130 - def handle_keypress(self, evt):
131 self.txt_label.Clear() 132 evt.Skip()
133 134
135 -def open_milestone_editor_for(edit_controller, parent, config, db, event=None):
136 137 def create_milestone_editor(): 138 if event is None: 139 label = _("Create Milestone") 140 else: 141 label = _("Edit Milestone") 142 return EditMilestoneDialog(parent, label, db, config, event)
143 144 def edit_function(): 145 dialog = create_milestone_editor() 146 dialog.ShowModal() 147 dialog.Destroy() 148 safe_locking(edit_controller, edit_function) 149