1
2
3
4
5
6 import wx
7
8
9 import gettext
10
11
12
13
14
15
16 -class wxgTextExpansionEditAreaPnl(wx.ScrolledWindow):
17 - def __init__(self, *args, **kwds):
18
19 kwds["style"] = kwds.get("style", 0) | wx.BORDER_NONE | wx.TAB_TRAVERSAL
20 wx.ScrolledWindow.__init__(self, *args, **kwds)
21 self._TCTRL_keyword = wx.TextCtrl(self, wx.ID_ANY, "")
22 self._LBL_data = wx.StaticText(self, wx.ID_ANY, _("File"))
23 self._BTN_select_data_file = wx.Button(self, wx.ID_ANY, _("Se&lect"), style=wx.BU_EXACTFIT)
24 self._TCTRL_data_file = wx.TextCtrl(self, wx.ID_ANY, "")
25 self._CHBOX_is_encrypted = wx.CheckBox(self, wx.ID_ANY, _("Encrypted"))
26 self._LBL_text = wx.StaticText(self, wx.ID_ANY, _("Text"))
27 self._TCTRL_expansion = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE)
28 self._RBTN_private = wx.RadioButton(self, wx.ID_ANY, _("&Me only"), style=wx.RB_GROUP)
29 self._RBTN_public = wx.RadioButton(self, wx.ID_ANY, _("&All users"))
30
31 self.__set_properties()
32 self.__do_layout()
33
34 self.Bind(wx.EVT_BUTTON, self._on_select_data_file_button_pressed, self._BTN_select_data_file)
35
36
38
39 self.SetScrollRate(10, 10)
40 self._TCTRL_keyword.SetToolTip(_("The keyword you want to trigger this text expansion.\n\nTry to avoid words or abbreviations in their day-to-day form as you may want to use them verbatim. Rather prefix or suffix your keywords with, say, \"*\" or \"$\". It is wise to not suffix keywords with typical word separators, such as:\n\n ! ? . , : ; ) ] } / ' \" SPACE TAB LINEBREAK\n\nas those are needed to detect when to trigger keyword expansion."))
41 self._LBL_data.SetForegroundColour(wx.Colour(255, 127, 0))
42 self._BTN_select_data_file.SetToolTip(_("Select a file from which to load the binary data."))
43 self._BTN_select_data_file.Enable(False)
44 self._TCTRL_data_file.SetToolTip(_("File from which to load the binary data."))
45 self._TCTRL_data_file.Enable(False)
46 self._CHBOX_is_encrypted.SetToolTip(_("Check this if the data file is encrypted and needs decryption before use."))
47 self._CHBOX_is_encrypted.Enable(False)
48 self._LBL_text.SetForegroundColour(wx.Colour(255, 127, 0))
49 self._TCTRL_expansion.SetToolTip(_("This is the text the keyword will expand to. You can use any text-based punctuation and formatting.\n\nAny $[HINT]$ will make GNUmed prompt the user for input while displaying HINT for guidance."))
50 self._TCTRL_expansion.Enable(False)
51 self._RBTN_private.SetToolTip(_("Select this if you want to use this text expansion just for yourself."))
52 self._RBTN_private.Enable(False)
53 self._RBTN_public.SetToolTip(_("Select this if you want to enable all GNUmed users to invoke this expansion (unless they have defined their own expansion with the same keyword)."))
54 self._RBTN_public.Enable(False)
55 self._RBTN_public.SetValue(1)
56
57
58 - def __do_layout(self):
59
60 _gszr_main = wx.FlexGridSizer(5, 2, 1, 3)
61 __szr_scope = wx.BoxSizer(wx.HORIZONTAL)
62 __szr_file = wx.BoxSizer(wx.HORIZONTAL)
63 __lbl_keyword = wx.StaticText(self, wx.ID_ANY, _("Keyword"))
64 __lbl_keyword.SetForegroundColour(wx.Colour(255, 0, 0))
65 _gszr_main.Add(__lbl_keyword, 0, wx.ALIGN_CENTER_VERTICAL, 0)
66 _gszr_main.Add(self._TCTRL_keyword, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
67 _gszr_main.Add((20, 20), 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
68 __lbl_expands_to = wx.StaticText(self, wx.ID_ANY, _("Expansion"))
69 _gszr_main.Add(__lbl_expands_to, 0, wx.ALIGN_CENTER, 0)
70 _gszr_main.Add(self._LBL_data, 0, wx.ALIGN_CENTER_VERTICAL, 0)
71 __szr_file.Add(self._BTN_select_data_file, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
72 __szr_file.Add(self._TCTRL_data_file, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.RIGHT, 5)
73 __szr_file.Add(self._CHBOX_is_encrypted, 0, wx.ALIGN_CENTER_VERTICAL, 0)
74 _gszr_main.Add(__szr_file, 1, wx.EXPAND, 0)
75 _gszr_main.Add(self._LBL_text, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
76 _gszr_main.Add(self._TCTRL_expansion, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
77 __lbl_scope = wx.StaticText(self, wx.ID_ANY, _("Scope"))
78 _gszr_main.Add(__lbl_scope, 0, wx.ALIGN_CENTER_VERTICAL, 0)
79 __szr_scope.Add(self._RBTN_private, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.RIGHT, 5)
80 __szr_scope.Add(self._RBTN_public, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
81 __szr_scope.Add((20, 20), 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
82 _gszr_main.Add(__szr_scope, 1, wx.EXPAND, 0)
83 self.SetSizer(_gszr_main)
84 _gszr_main.Fit(self)
85 _gszr_main.AddGrowableRow(3)
86 _gszr_main.AddGrowableCol(1)
87 self.Layout()
88
89
91 print("Event handler '_on_select_data_file_button_pressed' not implemented!")
92 event.Skip()
93
94
95