printrun-src/printrun/gui/widgets.py

Fri, 03 Jun 2016 21:14:09 +0200

author
mbayer
date
Fri, 03 Jun 2016 21:14:09 +0200
changeset 19
234037fbca4b
parent 15
0bbb006204fc
child 22
4c9bb8f93ae8
permissions
-rw-r--r--

Bugfixing, Added M400 magic

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 import re
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
18
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
19 class MacroEditor(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
20 """Really simple editor to edit macro definitions"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
21
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
22 def __init__(self, macro_name, definition, callback, gcode = False):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
23 self.indent_chars = " "
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
24 title = " macro %s"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
25 if gcode:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
26 title = " %s"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
27 self.gcode = gcode
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
28 wx.Dialog.__init__(self, None, title = title % macro_name,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
29 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30 self.callback = callback
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
31 self.panel = wx.Panel(self, -1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
32 titlesizer = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
33 self.titletext = wx.StaticText(self.panel, -1, " _") # title%macro_name)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
34 titlesizer.Add(self.titletext, 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
35 self.findb = wx.Button(self.panel, -1, _("Find"), style = wx.BU_EXACTFIT) # New button for "Find" (Jezmy)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
36 self.findb.Bind(wx.EVT_BUTTON, self.find)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
37 self.okb = wx.Button(self.panel, -1, _("Save"), style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
38 self.okb.Bind(wx.EVT_BUTTON, self.save)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
39 self.Bind(wx.EVT_CLOSE, self.close)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
40 titlesizer.Add(self.findb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
41 titlesizer.Add(self.okb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
42 self.cancelb = wx.Button(self.panel, -1, _("Cancel"), style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
43 self.cancelb.Bind(wx.EVT_BUTTON, self.close)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
44 titlesizer.Add(self.cancelb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
45 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
46 topsizer.Add(titlesizer, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
47 self.e = wx.TextCtrl(self.panel, style = wx.HSCROLL | wx.TE_MULTILINE | wx.TE_RICH2, size = (400, 400))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
48 if not self.gcode:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
49 self.e.SetValue(self.unindent(definition))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
50 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
51 self.e.SetValue("\n".join(definition))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
52 topsizer.Add(self.e, 1, wx.ALL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
53 self.panel.SetSizer(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
54 topsizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
55 topsizer.Fit(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
56 self.Show()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
57 self.e.SetFocus()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
58
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
59 def find(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
60 # Ask user what to look for, find it and point at it ... (Jezmy)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
61 S = self.e.GetStringSelection()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
62 if not S:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
63 S = "Z"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
64 FindValue = wx.GetTextFromUser('Please enter a search string:', caption = "Search", default_value = S, parent = None)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
65 somecode = self.e.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
66 position = somecode.find(FindValue, self.e.GetInsertionPoint())
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
67 if position == -1:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
68 self.titletext.SetLabel(_("Not Found!"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
69 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
70 self.titletext.SetLabel(str(position))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
71
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
72 # ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
73 self.e.SetFocus()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
74 self.e.SetInsertionPoint(position)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
75 self.e.SetSelection(position, position + len(FindValue))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
76 self.e.ShowPosition(position)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
77
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
78 def ShowMessage(self, ev, message):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
79 dlg = wx.MessageDialog(self, message,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
80 "Info!", wx.OK | wx.ICON_INFORMATION)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
81 dlg.ShowModal()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
82 dlg.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
83
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
84 def save(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
85 self.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
86 if not self.gcode:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
87 self.callback(self.reindent(self.e.GetValue()))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
88 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
89 self.callback(self.e.GetValue().split("\n"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
90
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
91 def close(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
92 self.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
93
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
94 def unindent(self, text):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
95 self.indent_chars = text[:len(text) - len(text.lstrip())]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
96 if len(self.indent_chars) == 0:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
97 self.indent_chars = " "
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
98 unindented = ""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
99 lines = re.split(r"(?:\r\n?|\n)", text)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
100 if len(lines) <= 1:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
101 return text
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
102 for line in lines:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
103 if line.startswith(self.indent_chars):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
104 unindented += line[len(self.indent_chars):] + "\n"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
105 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
106 unindented += line + "\n"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
107 return unindented
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
108
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
109 def reindent(self, text):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
110 lines = re.split(r"(?:\r\n?|\n)", text)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
111 if len(lines) <= 1:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
112 return text
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
113 reindented = ""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
114 for line in lines:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
115 if line.strip() != "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
116 reindented += self.indent_chars + line + "\n"
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
117 return reindented
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
118
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
119 SETTINGS_GROUPS = {"Printer": _("Printer settings"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
120 "UI": _("User interface"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
121 "Viewer": _("Viewer"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
122 "Colors": _("Colors"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
123 "External": _("External commands")}
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
124
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
125 class PronterOptionsDialog(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
126 """Options editor"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
127 def __init__(self, pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
128 wx.Dialog.__init__(self, parent = None, title = _("Edit settings"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
129 size = (400, 500), style = wx.DEFAULT_DIALOG_STYLE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
130 panel = wx.Panel(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
131 header = wx.StaticBox(panel, label = _("Settings"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
132 sbox = wx.StaticBoxSizer(header, wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
133 notebook = wx.Notebook(panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
134 all_settings = pronterface.settings._all_settings()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
135 group_list = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
136 groups = {}
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
137 for group in ["Printer", "UI", "Viewer", "Colors", "External"]:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
138 group_list.append(group)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
139 groups[group] = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
140 for setting in all_settings:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
141 if setting.group not in group_list:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
142 group_list.append(setting.group)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
143 groups[setting.group] = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
144 groups[setting.group].append(setting)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
145 for group in group_list:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
146 grouppanel = wx.Panel(notebook, -1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
147 notebook.AddPage(grouppanel, SETTINGS_GROUPS[group])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
148 settings = groups[group]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
149 grid = wx.GridBagSizer(hgap = 8, vgap = 2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
150 current_row = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
151 for setting in settings:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
152 if setting.name.startswith("separator_"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
153 sep = wx.StaticLine(grouppanel, size = (-1, 5), style = wx.LI_HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
154 grid.Add(sep, pos = (current_row, 0), span = (1, 2),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
155 border = 3, flag = wx.ALIGN_CENTER | wx.ALL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
156 current_row += 1
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
157 label, widget = setting.get_label(grouppanel), setting.get_widget(grouppanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
158 if setting.name.startswith("separator_"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
159 font = label.GetFont()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
160 font.SetWeight(wx.BOLD)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
161 label.SetFont(font)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
162 grid.Add(label, pos = (current_row, 0),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
163 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
164 grid.Add(widget, pos = (current_row, 1),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
165 flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
166 if hasattr(label, "set_default"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
167 label.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
168 if hasattr(widget, "Bind"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
169 widget.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
170 current_row += 1
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
171 grid.AddGrowableCol(1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
172 grouppanel.SetSizer(grid)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
173 sbox.Add(notebook, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
174 panel.SetSizer(sbox)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
175 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
176 topsizer.Add(panel, 1, wx.ALL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
177 topsizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
178 self.SetSizerAndFit(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
179 self.SetMinSize(self.GetSize())
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
180
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
181 def PronterOptions(pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
182 dialog = PronterOptionsDialog(pronterface)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
183 if dialog.ShowModal() == wx.ID_OK:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
184 for setting in pronterface.settings._all_settings():
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
185 old_value = setting.value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
186 setting.update()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
187 if setting.value != old_value:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
188 pronterface.set(setting.name, setting.value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
189 dialog.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
190
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
191 class ButtonEdit(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
192 """Custom button edit dialog"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
193 def __init__(self, pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
194 wx.Dialog.__init__(self, None, title = _("Custom button"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
195 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
196 self.pronterface = pronterface
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
197 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
198 grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
199 grid.AddGrowableCol(1, 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
200 grid.Add(wx.StaticText(self, -1, _("Button title")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
201 self.name = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
202 grid.Add(self.name, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
203 grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
204 self.command = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
205 xbox = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
206 xbox.Add(self.command, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
207 self.command.Bind(wx.EVT_TEXT, self.macrob_enabler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
208 self.macrob = wx.Button(self, -1, "..", style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
209 self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
210 xbox.Add(self.macrob, 0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
211 grid.Add(xbox, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
212 grid.Add(wx.StaticText(self, -1, _("Color")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
213 self.color = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
214 grid.Add(self.color, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
215 topsizer.Add(grid, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
216 topsizer.Add((0, 0), 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
217 topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
218 self.SetSizer(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
219
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
220 def macrob_enabler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
221 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
222 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
223 try:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
224 if macro == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
225 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
226 elif macro in self.pronterface.macros:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
227 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
228 elif hasattr(self.pronterface.__class__, u"do_" + macro):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
229 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
230 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
231 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
232 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
233 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
234 except:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
235 if macro == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
236 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
237 elif macro in self.pronterface.macros:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
238 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
239 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
240 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
241 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
242 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
243 self.macrob.Enable(valid)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
244
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
245 def macrob_handler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
246 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
247 macro = self.pronterface.edit_macro(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
248 self.command.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
249 if self.name.GetValue() == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
250 self.name.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
251
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
252 class TempGauge(wx.Panel):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
253
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
254 def __init__(self, parent, size = (200, 22), title = "",
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
255 maxval = 240, gaugeColour = None, bgcolor = "#FFFFFF"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
256 wx.Panel.__init__(self, parent, -1, size = size)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
257 self.Bind(wx.EVT_PAINT, self.paint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
258 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
259 self.bgcolor = wx.Colour()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
260 self.bgcolor.SetFromName(bgcolor)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
261 self.width, self.height = size
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
262 self.title = title
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
263 self.max = maxval
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
264 self.gaugeColour = gaugeColour
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
265 self.value = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
266 self.setpoint = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
267 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
268
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
269 def recalc(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
270 mmax = max(int(self.setpoint * 1.05), self.max)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
271 self.scale = float(self.width - 2) / float(mmax)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
272 self.ypt = max(16, int(self.scale * max(self.setpoint, self.max / 6)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
273
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
274 def SetValue(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
275 self.value = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
276 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
277
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
278 def SetTarget(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
279 self.setpoint = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
280 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
281
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
282 def interpolatedColour(self, val, vmin, vmid, vmax, cmin, cmid, cmax):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
283 if val < vmin: return cmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
284 if val > vmax: return cmax
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
285 if val <= vmid:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
286 lo, hi, val, valhi = cmin, cmid, val - vmin, vmid - vmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
287 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
288 lo, hi, val, valhi = cmid, cmax, val - vmid, vmax - vmid
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
289 vv = float(val) / valhi
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
290 rgb = lo.Red() + (hi.Red() - lo.Red()) * vv, lo.Green() + (hi.Green() - lo.Green()) * vv, lo.Blue() + (hi.Blue() - lo.Blue()) * vv
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
291 rgb = map(lambda x: x * 0.8, rgb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
292 return wx.Colour(*map(int, rgb))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
293
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
294 def paint(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
295 self.width, self.height = self.GetClientSizeTuple()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
296 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
297 x0, y0, x1, y1, xE, yE = 1, 1, self.ypt + 1, 1, self.width + 1 - 2, 20
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
298 dc = wx.PaintDC(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
299 dc.SetBackground(wx.Brush(self.bgcolor))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
300 dc.Clear()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
301 cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
302 # gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
303 gauge1 = wx.Colour(255, 255, 210)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
304 shadow1, shadow2 = wx.Colour(110, 110, 110), self.bgcolor
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
305 gc = wx.GraphicsContext.Create(dc)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
306 # draw shadow first
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
307 # corners
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
308 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 9, xE - 7, 9, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
309 gc.DrawRectangle(xE - 7, 1, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
310 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 17, xE - 7, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
311 gc.DrawRectangle(xE - 7, 17, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
312 gc.SetBrush(gc.CreateRadialGradientBrush(x0 + 6, 17, x0 + 6, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
313 gc.DrawRectangle(0, 17, x0 + 6, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
314 # edges
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
315 gc.SetBrush(gc.CreateLinearGradientBrush(xE - 6, 0, xE + 1, 0, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
316 gc.DrawRectangle(xE - 7, 9, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
317 gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE - 2, x0, yE + 5, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
318 gc.DrawRectangle(x0 + 6, yE - 2, xE - 12, 7)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
319 # draw gauge background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
320 gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0, x1 + 1, y1, cold, medium))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
321 gc.DrawRoundedRectangle(x0, y0, x1 + 4, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
322 gc.SetBrush(gc.CreateLinearGradientBrush(x1 - 2, y1, xE, y1, medium, hot))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
323 gc.DrawRoundedRectangle(x1 - 2, y1, xE - x1, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
324 # draw gauge
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
325 width = 12
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
326 w1 = y0 + 9 - width / 2
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
327 w2 = w1 + width
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
328 value = x0 + max(10, min(self.width + 1 - 2, int(self.value * self.scale)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
329 # gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, gauge2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
330 # gc.SetBrush(gc.CreateLinearGradientBrush(0, 3, 0, 15, wx.Colour(255, 255, 255), wx.Colour(255, 90, 32)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
331 gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, self.interpolatedColour(value, x0, x1, xE, cold, medium, hot)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
332 val_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
333 val_path.MoveToPoint(x0, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
334 val_path.AddLineToPoint(value, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
335 val_path.AddLineToPoint(value + 2, w1 + width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
336 val_path.AddLineToPoint(value + 2, w2 - width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
337 val_path.AddLineToPoint(value, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
338 # val_path.AddLineToPoint(value-4, 10)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
339 val_path.AddLineToPoint(x0, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
340 gc.DrawPath(val_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
341 # draw setpoint markers
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
342 setpoint = x0 + max(10, int(self.setpoint * self.scale))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
343 gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0))))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
344 setp_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
345 setp_path.MoveToPoint(setpoint - 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
346 setp_path.AddLineToPoint(setpoint + 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
347 setp_path.AddLineToPoint(setpoint, y0 + 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
348 setp_path.MoveToPoint(setpoint - 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
349 setp_path.AddLineToPoint(setpoint + 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
350 setp_path.AddLineToPoint(setpoint, yE - 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
351 gc.DrawPath(setp_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
352 # draw readout
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
353 text = u"T\u00B0 %u/%u" % (self.value, self.setpoint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
354 # gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
355 # gc.DrawText(text, 29,-2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
356 gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
357 gc.DrawText(self.title, x0 + 19, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
358 gc.DrawText(text, x0 + 119, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
359 gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
360 gc.DrawText(self.title, x0 + 18, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
361 gc.DrawText(text, x0 + 118, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
362
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
363 class SpecialButton(object):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
364
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
365 label = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
366 command = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
367 background = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
368 tooltip = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
369 custom = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
370
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
371 def __init__(self, label, command, background = None,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
372 tooltip = None, custom = False):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
373 self.label = label
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
374 self.command = command
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
375 self.background = background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
376 self.tooltip = tooltip
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
377 self.custom = custom

mercurial