printrun-src/printrun/gui/log.py

Wed, 20 Jan 2021 10:15:13 +0100

author
mdd
date
Wed, 20 Jan 2021 10:15:13 +0100
changeset 46
cce0af6351f0
parent 15
0bbb006204fc
permissions
-rw-r--r--

updated and added new files for printrun

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

mercurial