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

# Source Code for Module Gnumed.timelinelib.wxgui.dialogs.eraseditor.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.dialogs.eraseditor.controller import ErasEditorDialogController
    22  from timelinelib.wxgui.framework import Dialog
    23
    24
    25 -class ErasEditorDialog(Dialog):
    26
    27      """
    28      <BoxSizerVertical>
    29          <ListBox name="lb_eras" border="ALL" proportion="1" height="250"
    30              event_EVT_LISTBOX_DCLICK="on_dclick"
    31          />
    32          <DialogButtonsEditAddRemoveCloseSizer border="LEFT|RIGHT|BOTTOM"
    33              event_EVT_BUTTON__ID_ADD="on_add"
    34              event_EVT_BUTTON__ID_REMOVE="on_remove"
    35              event_EVT_BUTTON__ID_EDIT="on_edit"
    36          />
    37      </BoxSizerVertical>
    38      """
    39
    40 -    def __init__(self, parent, db, config):
    41          Dialog.__init__(self, ErasEditorDialogController, parent, {},
    42                          title=_("Edit Era's"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
    43          self.controller.on_init(db, config)
    44
    45 -    def SetEras(self, eras):
    46          for era in eras:
    47              self.lb_eras.Append(era.get_name(), era)
    48          if len(eras) > 0:
    49              self.lb_eras.SetSelection(0)
    50          self._EnableDisableButtons()
    51
    52 -    def GetSelectedEra(self):
    53          return self.lb_eras.GetClientData(self.lb_eras.GetSelection())
    54
    55 -    def UpdateEra(self, era):
    56          self.lb_eras.SetString(self.lb_eras.GetSelection(), era.get_name())
    57
    58 -    def AppendEra(self, era):
    59          self.lb_eras.Append(era.get_name(), era)
    60          self.lb_eras.Select(self.lb_eras.GetCount() - 1)
    61          self._EnableDisableButtons()
    62
    63 -    def RemoveEra(self, era):
    64          def select_era(inx):
    65              if self.lb_eras.GetCount() == inx:
    66                  inx -= 1
    67              if inx >= 0:
    68                  self.lb_eras.SetSelection(inx)
    69          inx = self.lb_eras.GetSelection()
    70          self.lb_eras.Delete(inx)
    71          select_era(inx)
    72          self._EnableDisableButtons()
    73
    74 -    def _EnableDisableButtons(self):
    75          if self.lb_eras.GetCount() == 0:
    76              self.btn_remove.Enable(False)
    77              self.btn_edit.Enable(False)
    78          else:
    79              self.btn_remove.Enable(True)
    80              self.btn_edit.Enable(True)
    81