printrun-src/printrun/gui/widgets.py

Sat, 04 Jun 2016 13:07:59 +0200

author
mbayer
date
Sat, 04 Jun 2016 13:07:59 +0200
changeset 24
620f9cd7ee9d
parent 22
4c9bb8f93ae8
child 26
5c98c7e24b02
permissions
-rw-r--r--

Etikett BITMAP_FINISHED für den Änderungssatz e18b2a4ef561 ergänzt

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"),
22
4c9bb8f93ae8 Added the Lasercut settings to the pronterface options dialog
mbayer
parents: 15
diff changeset
123 "External": _("External commands"),
4c9bb8f93ae8 Added the Lasercut settings to the pronterface options dialog
mbayer
parents: 15
diff changeset
124 "Laser": "Lasercut options"}
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
125
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
126 class PronterOptionsDialog(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
127 """Options editor"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
128 def __init__(self, pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
129 wx.Dialog.__init__(self, parent = None, title = _("Edit settings"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
130 size = (400, 500), style = wx.DEFAULT_DIALOG_STYLE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
131 panel = wx.Panel(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
132 header = wx.StaticBox(panel, label = _("Settings"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
133 sbox = wx.StaticBoxSizer(header, wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
134 notebook = wx.Notebook(panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
135 all_settings = pronterface.settings._all_settings()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
136 group_list = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
137 groups = {}
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
138 for group in ["Printer", "UI", "Viewer", "Colors", "External"]:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
139 group_list.append(group)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
140 groups[group] = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
141 for setting in all_settings:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
142 if setting.group not in group_list:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
143 group_list.append(setting.group)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
144 groups[setting.group] = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
145 groups[setting.group].append(setting)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
146 for group in group_list:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
147 grouppanel = wx.Panel(notebook, -1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
148 notebook.AddPage(grouppanel, SETTINGS_GROUPS[group])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
149 settings = groups[group]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
150 grid = wx.GridBagSizer(hgap = 8, vgap = 2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
151 current_row = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
152 for setting in settings:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
153 if setting.name.startswith("separator_"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
154 sep = wx.StaticLine(grouppanel, size = (-1, 5), style = wx.LI_HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
155 grid.Add(sep, pos = (current_row, 0), span = (1, 2),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
156 border = 3, flag = wx.ALIGN_CENTER | wx.ALL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
157 current_row += 1
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
158 label, widget = setting.get_label(grouppanel), setting.get_widget(grouppanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
159 if setting.name.startswith("separator_"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
160 font = label.GetFont()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
161 font.SetWeight(wx.BOLD)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
162 label.SetFont(font)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
163 grid.Add(label, pos = (current_row, 0),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
164 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
165 grid.Add(widget, pos = (current_row, 1),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
166 flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
167 if hasattr(label, "set_default"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
168 label.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
169 if hasattr(widget, "Bind"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
170 widget.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
171 current_row += 1
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
172 grid.AddGrowableCol(1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
173 grouppanel.SetSizer(grid)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
174 sbox.Add(notebook, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
175 panel.SetSizer(sbox)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
176 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
177 topsizer.Add(panel, 1, wx.ALL | wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
178 topsizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
179 self.SetSizerAndFit(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
180 self.SetMinSize(self.GetSize())
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
181
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
182 def PronterOptions(pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
183 dialog = PronterOptionsDialog(pronterface)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
184 if dialog.ShowModal() == wx.ID_OK:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
185 for setting in pronterface.settings._all_settings():
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
186 old_value = setting.value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
187 setting.update()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
188 if setting.value != old_value:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
189 pronterface.set(setting.name, setting.value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
190 dialog.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
191
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
192 class ButtonEdit(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
193 """Custom button edit dialog"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
194 def __init__(self, pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
195 wx.Dialog.__init__(self, None, title = _("Custom button"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
196 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
197 self.pronterface = pronterface
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
198 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
199 grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
200 grid.AddGrowableCol(1, 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
201 grid.Add(wx.StaticText(self, -1, _("Button title")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
202 self.name = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
203 grid.Add(self.name, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
204 grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
205 self.command = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
206 xbox = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
207 xbox.Add(self.command, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
208 self.command.Bind(wx.EVT_TEXT, self.macrob_enabler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
209 self.macrob = wx.Button(self, -1, "..", style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
210 self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
211 xbox.Add(self.macrob, 0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
212 grid.Add(xbox, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
213 grid.Add(wx.StaticText(self, -1, _("Color")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
214 self.color = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
215 grid.Add(self.color, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
216 topsizer.Add(grid, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
217 topsizer.Add((0, 0), 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
218 topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
219 self.SetSizer(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
220
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
221 def macrob_enabler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
222 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
223 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
224 try:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
225 if macro == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
226 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
227 elif macro in self.pronterface.macros:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
228 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
229 elif hasattr(self.pronterface.__class__, u"do_" + macro):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
230 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
231 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
232 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
233 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
234 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
235 except:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
236 if macro == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
237 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
238 elif macro in self.pronterface.macros:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
239 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
240 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
241 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
242 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
243 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
244 self.macrob.Enable(valid)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
245
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
246 def macrob_handler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
247 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
248 macro = self.pronterface.edit_macro(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
249 self.command.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
250 if self.name.GetValue() == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
251 self.name.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
252
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
253 class TempGauge(wx.Panel):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
254
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
255 def __init__(self, parent, size = (200, 22), title = "",
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
256 maxval = 240, gaugeColour = None, bgcolor = "#FFFFFF"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
257 wx.Panel.__init__(self, parent, -1, size = size)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
258 self.Bind(wx.EVT_PAINT, self.paint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
259 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
260 self.bgcolor = wx.Colour()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
261 self.bgcolor.SetFromName(bgcolor)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
262 self.width, self.height = size
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
263 self.title = title
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
264 self.max = maxval
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
265 self.gaugeColour = gaugeColour
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
266 self.value = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
267 self.setpoint = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
268 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
269
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
270 def recalc(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
271 mmax = max(int(self.setpoint * 1.05), self.max)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
272 self.scale = float(self.width - 2) / float(mmax)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
273 self.ypt = max(16, int(self.scale * max(self.setpoint, self.max / 6)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
274
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
275 def SetValue(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
276 self.value = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
277 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
278
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
279 def SetTarget(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
280 self.setpoint = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
281 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
282
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
283 def interpolatedColour(self, val, vmin, vmid, vmax, cmin, cmid, cmax):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
284 if val < vmin: return cmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
285 if val > vmax: return cmax
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
286 if val <= vmid:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
287 lo, hi, val, valhi = cmin, cmid, val - vmin, vmid - vmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
288 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
289 lo, hi, val, valhi = cmid, cmax, val - vmid, vmax - vmid
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
290 vv = float(val) / valhi
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
291 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
292 rgb = map(lambda x: x * 0.8, rgb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
293 return wx.Colour(*map(int, rgb))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
294
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
295 def paint(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
296 self.width, self.height = self.GetClientSizeTuple()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
297 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
298 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
299 dc = wx.PaintDC(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
300 dc.SetBackground(wx.Brush(self.bgcolor))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
301 dc.Clear()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
302 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
303 # gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
304 gauge1 = wx.Colour(255, 255, 210)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
305 shadow1, shadow2 = wx.Colour(110, 110, 110), self.bgcolor
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
306 gc = wx.GraphicsContext.Create(dc)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
307 # draw shadow first
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
308 # corners
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
309 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 9, xE - 7, 9, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
310 gc.DrawRectangle(xE - 7, 1, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
311 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 17, xE - 7, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
312 gc.DrawRectangle(xE - 7, 17, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
313 gc.SetBrush(gc.CreateRadialGradientBrush(x0 + 6, 17, x0 + 6, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
314 gc.DrawRectangle(0, 17, x0 + 6, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
315 # edges
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
316 gc.SetBrush(gc.CreateLinearGradientBrush(xE - 6, 0, xE + 1, 0, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
317 gc.DrawRectangle(xE - 7, 9, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
318 gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE - 2, x0, yE + 5, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
319 gc.DrawRectangle(x0 + 6, yE - 2, xE - 12, 7)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
320 # draw gauge background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
321 gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0, x1 + 1, y1, cold, medium))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
322 gc.DrawRoundedRectangle(x0, y0, x1 + 4, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
323 gc.SetBrush(gc.CreateLinearGradientBrush(x1 - 2, y1, xE, y1, medium, hot))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
324 gc.DrawRoundedRectangle(x1 - 2, y1, xE - x1, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
325 # draw gauge
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
326 width = 12
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
327 w1 = y0 + 9 - width / 2
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
328 w2 = w1 + width
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
329 value = x0 + max(10, min(self.width + 1 - 2, int(self.value * self.scale)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
330 # gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, gauge2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
331 # 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
332 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
333 val_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
334 val_path.MoveToPoint(x0, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
335 val_path.AddLineToPoint(value, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
336 val_path.AddLineToPoint(value + 2, w1 + width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
337 val_path.AddLineToPoint(value + 2, w2 - width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
338 val_path.AddLineToPoint(value, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
339 # val_path.AddLineToPoint(value-4, 10)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
340 val_path.AddLineToPoint(x0, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
341 gc.DrawPath(val_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
342 # draw setpoint markers
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
343 setpoint = x0 + max(10, int(self.setpoint * self.scale))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
344 gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0))))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
345 setp_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
346 setp_path.MoveToPoint(setpoint - 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
347 setp_path.AddLineToPoint(setpoint + 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
348 setp_path.AddLineToPoint(setpoint, y0 + 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
349 setp_path.MoveToPoint(setpoint - 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
350 setp_path.AddLineToPoint(setpoint + 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
351 setp_path.AddLineToPoint(setpoint, yE - 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
352 gc.DrawPath(setp_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
353 # draw readout
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
354 text = u"T\u00B0 %u/%u" % (self.value, self.setpoint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
355 # 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
356 # gc.DrawText(text, 29,-2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
357 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
358 gc.DrawText(self.title, x0 + 19, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
359 gc.DrawText(text, x0 + 119, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
360 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
361 gc.DrawText(self.title, x0 + 18, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
362 gc.DrawText(text, x0 + 118, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
363
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
364 class SpecialButton(object):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
365
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
366 label = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
367 command = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
368 background = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
369 tooltip = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
370 custom = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
371
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
372 def __init__(self, label, command, background = None,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
373 tooltip = None, custom = False):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
374 self.label = label
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
375 self.command = command
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
376 self.background = background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
377 self.tooltip = tooltip
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
378 self.custom = custom

mercurial