forked from vlachoudis/bCNC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TerminalPage.py
183 lines (164 loc) · 5.65 KB
/
TerminalPage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# -*- coding: ascii -*-
# $Id$
#
# Author: vvlachoudis@gmail.com
# Date: 18-Jun-2015
__author__ = "Vasilis Vlachoudis"
__email__ = "vvlachoudis@gmail.com"
try:
from Tkinter import *
except ImportError:
from tkinter import *
import Utils
import Ribbon
import tkExtra
import CNCRibbon
#===============================================================================
# Terminal Group
#===============================================================================
class TerminalGroup(CNCRibbon.ButtonGroup):
def __init__(self, master, app):
CNCRibbon.ButtonGroup.__init__(self, master, N_("Terminal"), app)
b = Ribbon.LabelButton(self.frame, self, "<<TerminalClear>>",
image=Utils.icons["clean32"],
text=_("Clear"),
compound=TOP,
background=Ribbon._BACKGROUND)
b.pack(fill=BOTH, expand=YES)
tkExtra.Balloon.set(b, _("Clear terminal"))
#===============================================================================
# Commands Group
#===============================================================================
class CommandsGroup(CNCRibbon.ButtonMenuGroup):
def __init__(self, master, app):
CNCRibbon.ButtonMenuGroup.__init__(self, master, N_("Commands"), app,
[(_("Restore Settings"), "grbl_settings", app.grblRestoreSettings),
(_("Restore Workspace"), "grbl_params", app.grblRestoreWCS),
(_("Restore All"), "reset", app.grblRestoreAll),
])
self.grid3rows()
# Disable state for some SMOOTHIE commands
state=app.controller==Utils.GRBL and NORMAL or DISABLED,
# ---
col,row=0,0
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_settings"],
text=_("Settings"),
compound=LEFT,
anchor=W,
state=state,
command=self.app.viewSettings,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$$ Display settings of Grbl"))
if state == NORMAL: self.addWidget(b)
row += 1
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_params"],
text=_("Parameters"),
compound=LEFT,
anchor=W,
command=self.app.viewParameters,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$# Display parameters of Grbl"))
self.addWidget(b)
row += 1
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_state"],
text=_("State"),
compound=LEFT,
anchor=W,
command=self.app.viewState,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$G Display state of Grbl"))
self.addWidget(b)
# ---
col += 1
row = 0
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_build"],
text=_("Build"),
compound=LEFT,
anchor=W,
command=self.app.viewBuild,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$I Display build information of Grbl"))
self.addWidget(b)
row += 1
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_startup"],
text=_("Startup"),
compound=LEFT,
anchor=W,
state=state,
command=self.app.viewStartup,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$N Display startup configuration of Grbl"))
if state == NORMAL: self.addWidget(b)
row += 1
# FIXME Checkbutton!!!!!
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_check"],
text=_("Check gcode"),
compound=LEFT,
anchor=W,
state=state,
command=self.app.checkGcode,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$C Enable/Disable checking of gcode"))
if state == NORMAL: self.addWidget(b)
# ---
col += 1
row = 1
b = Ribbon.LabelButton(self.frame,
image=Utils.icons["grbl_help"],
text=_("Help"),
compound=LEFT,
anchor=W,
command=self.app.grblHelp,
background=Ribbon._BACKGROUND)
b.grid(row=row, column=col, padx=0, pady=0, sticky=NSEW)
tkExtra.Balloon.set(b, _("$ Display build information of Grbl"))
self.addWidget(b)
#===============================================================================
class TerminalFrame(CNCRibbon.PageFrame):
def __init__(self, master, app):
CNCRibbon.PageFrame.__init__(self, master, N_("Terminal"), app)
self.terminal = Text(self,
background="White",
width=20,
height=3,
wrap=NONE,
state=DISABLED)
self.terminal.pack(side=LEFT, fill=BOTH, expand=YES)
sb = Scrollbar(self, orient=VERTICAL, command=self.terminal.yview)
sb.pack(side=RIGHT, fill=Y)
self.terminal.config(yscrollcommand=sb.set)
self.terminal.tag_config("SEND", foreground="Blue")
self.terminal.tag_config("ERROR", foreground="Red")
#----------------------------------------------------------------------
def clear(self, event=None):
self.terminal["state"] = NORMAL
self.terminal.delete("1.0",END)
self.terminal["state"] = DISABLED
#----------------------------------------------------------------------
def copy(self, event=None):
return "break"
#===============================================================================
# Terminal Page
#===============================================================================
class TerminalPage(CNCRibbon.Page):
__doc__ = _("Serial Terminal")
_name_ = "Terminal"
_icon_ = "terminal"
#----------------------------------------------------------------------
# Add a widget in the widgets list to enable disable during the run
#----------------------------------------------------------------------
def register(self):
self._register((CommandsGroup,TerminalGroup),
(TerminalFrame,))