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

Source Code for Module Gnumed.timelinelib.wxgui.dialogs.shortcutseditor.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  from timelinelib.wxgui.dialogs.shortcutseditor.controller import ShortcutsEditorDialogController 
20  from timelinelib.wxgui.framework import Dialog 
21  from timelinelib.wxgui.utils import display_warning_message 
22  from timelinelib.wxgui.utils import PopupTextWindow 
23   
24   
25 -class ShortcutsEditorDialog(Dialog):
26 27 """ 28 <BoxSizerVertical> 29 <FlexGridSizer name="grid" rows="0" columns="2" border="ALL" > 30 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(functions)" /> 31 <ComboBox name="cb_functions" style="CB_READONLY" width="280" align="ALIGN_CENTER_VERTICAL" 32 event_EVT_COMBOBOX="on_selection_changed" /> 33 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(modifiers)" /> 34 <ComboBox name="cb_modifiers" style="CB_READONLY" align="ALIGN_CENTER_VERTICAL" /> 35 <StaticText align="ALIGN_CENTER_VERTICAL" label="$(shortcutkey)" /> 36 <ComboBox name="cb_shortcut_keys" style="CB_READONLY" align="ALIGN_CENTER_VERTICAL" /> 37 </FlexGridSizer> 38 <DialogButtonsApplyCloseSizer 39 border="LEFT|BOTTOM|RIGHT" 40 event_EVT_BUTTON__ID_APPLY="on_apply_clicked" 41 /> 42 </BoxSizerVertical> 43 """ 44
45 - def __init__(self, parent, shortcut_config):
46 Dialog.__init__(self, ShortcutsEditorDialogController, parent, { 47 "functions": _("Functions:"), 48 "modifiers": _("Modifier:"), 49 "shortcutkey": _("Shortcut Key:"), 50 }, title=_("Edit Shortcuts")) 51 self.controller.on_init(shortcut_config)
52
53 - def SetFunctions(self, choices):
54 self.cb_functions.AppendItems(choices) 55 self.cb_functions.SetValue(choices[0])
56
57 - def SetModifiers(self, choices, value):
58 self.cb_modifiers.AppendItems(choices) 59 self.SetModifier(value)
60
61 - def SetModifier(self, value):
62 self.cb_modifiers.SetValue(value)
63
64 - def SetShortcutKeys(self, choices, value):
65 self.cb_shortcut_keys.AppendItems(choices) 66 self.SetShortcutKey(value)
67
68 - def SetShortcutKey(self, value):
69 self.cb_shortcut_keys.SetValue(value)
70
71 - def GetFunction(self):
72 return self.cb_functions.GetValue()
73
74 - def GetShortcutKey(self):
75 return self.cb_shortcut_keys.GetValue()
76
77 - def GetModifier(self):
78 return self.cb_modifiers.GetValue()
79
80 - def DisplayAckPopupWindow(self, text):
81 def calculate_ack_popup_window_position(): 82 return [a + b for a, b in zip(self.GetPosition(), self.btn_apply.GetPosition())]
83 PopupTextWindow(self, text, pos=calculate_ack_popup_window_position())
84
85 - def DisplayWarningMessage(self, text):
86 display_warning_message(text)
87