Wed, 20 Jan 2021 10:15:13 +0100
updated and added new files for printrun
15 | 1 | # This file is part of the Printrun suite. |
2 | # | |
3 | # Printrun is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation, either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # Printrun is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | import wx | |
17 | ||
18 | from .utils import make_button | |
19 | ||
20 | class LogPane(wx.BoxSizer): | |
21 | ||
22 | def __init__(self, root, parentpanel = None): | |
23 | super(LogPane, self).__init__(wx.VERTICAL) | |
24 | if not parentpanel: parentpanel = root.panel | |
25 | root.logbox = wx.TextCtrl(parentpanel, style = wx.TE_MULTILINE, size = (350, -1)) | |
26 | root.logbox.SetMinSize((100, -1)) | |
27 | root.logbox.SetEditable(0) | |
28 | self.Add(root.logbox, 1, wx.EXPAND) | |
29 | bottom_panel = root.newPanel(parentpanel) | |
30 | lbrs = wx.BoxSizer(wx.HORIZONTAL) | |
31 | root.commandbox = wx.TextCtrl(bottom_panel, style = wx.TE_PROCESS_ENTER) | |
32 | root.commandbox.SetToolTip(wx.ToolTip(_("Send commands to printer\n(Type 'help' for simple\nhelp function)"))) | |
46 | 33 | root.commandbox.Hint = 'Command to [S]end' |
15 | 34 | root.commandbox.Bind(wx.EVT_TEXT_ENTER, root.sendline) |
35 | root.commandbox.Bind(wx.EVT_CHAR, root.cbkey) | |
46 | 36 | def deselect(ev): |
37 | # In Ubuntu 19.10, when focused, all text is selected | |
38 | lp = root.commandbox.LastPosition | |
39 | # print(f"SetSelection({lp}, {lp})") | |
40 | wx.CallAfter(root.commandbox.SetSelection, lp, lp) | |
41 | ev.Skip() | |
42 | root.commandbox.Bind(wx.EVT_SET_FOCUS, deselect) | |
43 | root.commandbox.history = [""] | |
15 | 44 | root.commandbox.histindex = 1 |
45 | lbrs.Add(root.commandbox, 1) | |
46 | root.sendbtn = make_button(bottom_panel, _("Send"), root.sendline, _("Send Command to Printer"), style = wx.BU_EXACTFIT, container = lbrs) | |
47 | bottom_panel.SetSizer(lbrs) | |
48 | self.Add(bottom_panel, 0, wx.EXPAND) |