printrun-src/printrun/gui/widgets.py

Tue, 26 Sep 2017 19:08:02 +0200

author
mdd
date
Tue, 26 Sep 2017 19:08:02 +0200
changeset 36
f4730ef55ca8
parent 26
5c98c7e24b02
child 46
cce0af6351f0
permissions
-rw-r--r--

SVG options: offset, original scale
SVG Bugfix: "scale" does now really fit to dimensions

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 = {}
26
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
138 for group in ["Printer", "UI", "Viewer", "Colors", "External", "Laser"]:
15
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
26
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
182 self.notebook = notebook
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
183 self.group_list = group_list
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
184
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
185 def setPage(self, name):
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
186 self.notebook.ChangeSelection(self.group_list.index(name))
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
187
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
188 def PronterOptions(pronterface, defaulttab = None):
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
189 dialog = PronterOptionsDialog(pronterface)
26
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
190 if defaulttab:
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
191 # set the active tab before open dialog
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
192 dialog.setPage(defaulttab)
5c98c7e24b02 Add quick access button to laser options
mbayer
parents: 22
diff changeset
193
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
194 if dialog.ShowModal() == wx.ID_OK:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
195 for setting in pronterface.settings._all_settings():
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
196 old_value = setting.value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
197 setting.update()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
198 if setting.value != old_value:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
199 pronterface.set(setting.name, setting.value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
200 dialog.Destroy()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
201
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
202 class ButtonEdit(wx.Dialog):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
203 """Custom button edit dialog"""
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
204 def __init__(self, pronterface):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
205 wx.Dialog.__init__(self, None, title = _("Custom button"),
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
206 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
207 self.pronterface = pronterface
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
208 topsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
209 grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
210 grid.AddGrowableCol(1, 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
211 grid.Add(wx.StaticText(self, -1, _("Button title")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
212 self.name = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
213 grid.Add(self.name, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
214 grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
215 self.command = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
216 xbox = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
217 xbox.Add(self.command, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
218 self.command.Bind(wx.EVT_TEXT, self.macrob_enabler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
219 self.macrob = wx.Button(self, -1, "..", style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
220 self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
221 xbox.Add(self.macrob, 0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
222 grid.Add(xbox, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
223 grid.Add(wx.StaticText(self, -1, _("Color")), 0, wx.BOTTOM | wx.RIGHT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
224 self.color = wx.TextCtrl(self, -1, "")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
225 grid.Add(self.color, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
226 topsizer.Add(grid, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
227 topsizer.Add((0, 0), 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
228 topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
229 self.SetSizer(topsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
230
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
231 def macrob_enabler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
232 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
233 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
234 try:
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 hasattr(self.pronterface.__class__, u"do_" + macro):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
240 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
241 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
242 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
243 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
244 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
245 except:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
246 if macro == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
247 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
248 elif macro in self.pronterface.macros:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
249 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
250 elif len([c for c in macro if not c.isalnum() and c != "_"]):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
251 valid = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
252 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
253 valid = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
254 self.macrob.Enable(valid)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
255
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
256 def macrob_handler(self, e):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
257 macro = self.command.GetValue()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
258 macro = self.pronterface.edit_macro(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
259 self.command.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
260 if self.name.GetValue() == "":
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
261 self.name.SetValue(macro)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
262
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
263 class TempGauge(wx.Panel):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
264
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
265 def __init__(self, parent, size = (200, 22), title = "",
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
266 maxval = 240, gaugeColour = None, bgcolor = "#FFFFFF"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
267 wx.Panel.__init__(self, parent, -1, size = size)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
268 self.Bind(wx.EVT_PAINT, self.paint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
269 self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
270 self.bgcolor = wx.Colour()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
271 self.bgcolor.SetFromName(bgcolor)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
272 self.width, self.height = size
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
273 self.title = title
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
274 self.max = maxval
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
275 self.gaugeColour = gaugeColour
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
276 self.value = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
277 self.setpoint = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
278 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
279
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
280 def recalc(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
281 mmax = max(int(self.setpoint * 1.05), self.max)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
282 self.scale = float(self.width - 2) / float(mmax)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
283 self.ypt = max(16, int(self.scale * max(self.setpoint, self.max / 6)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
284
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
285 def SetValue(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
286 self.value = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
287 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
288
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
289 def SetTarget(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
290 self.setpoint = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
291 wx.CallAfter(self.Refresh)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
292
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
293 def interpolatedColour(self, val, vmin, vmid, vmax, cmin, cmid, cmax):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
294 if val < vmin: return cmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
295 if val > vmax: return cmax
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
296 if val <= vmid:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
297 lo, hi, val, valhi = cmin, cmid, val - vmin, vmid - vmin
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
298 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
299 lo, hi, val, valhi = cmid, cmax, val - vmid, vmax - vmid
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
300 vv = float(val) / valhi
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
301 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
302 rgb = map(lambda x: x * 0.8, rgb)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
303 return wx.Colour(*map(int, rgb))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
304
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
305 def paint(self, ev):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
306 self.width, self.height = self.GetClientSizeTuple()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
307 self.recalc()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
308 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
309 dc = wx.PaintDC(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
310 dc.SetBackground(wx.Brush(self.bgcolor))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
311 dc.Clear()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
312 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
313 # gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
314 gauge1 = wx.Colour(255, 255, 210)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
315 shadow1, shadow2 = wx.Colour(110, 110, 110), self.bgcolor
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
316 gc = wx.GraphicsContext.Create(dc)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
317 # draw shadow first
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
318 # corners
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
319 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 9, xE - 7, 9, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
320 gc.DrawRectangle(xE - 7, 1, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
321 gc.SetBrush(gc.CreateRadialGradientBrush(xE - 7, 17, xE - 7, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
322 gc.DrawRectangle(xE - 7, 17, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
323 gc.SetBrush(gc.CreateRadialGradientBrush(x0 + 6, 17, x0 + 6, 17, 8, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
324 gc.DrawRectangle(0, 17, x0 + 6, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
325 # edges
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
326 gc.SetBrush(gc.CreateLinearGradientBrush(xE - 6, 0, xE + 1, 0, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
327 gc.DrawRectangle(xE - 7, 9, 8, 8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
328 gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE - 2, x0, yE + 5, shadow1, shadow2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
329 gc.DrawRectangle(x0 + 6, yE - 2, xE - 12, 7)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
330 # draw gauge background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
331 gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0, x1 + 1, y1, cold, medium))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
332 gc.DrawRoundedRectangle(x0, y0, x1 + 4, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
333 gc.SetBrush(gc.CreateLinearGradientBrush(x1 - 2, y1, xE, y1, medium, hot))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
334 gc.DrawRoundedRectangle(x1 - 2, y1, xE - x1, yE, 6)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
335 # draw gauge
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
336 width = 12
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
337 w1 = y0 + 9 - width / 2
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
338 w2 = w1 + width
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
339 value = x0 + max(10, min(self.width + 1 - 2, int(self.value * self.scale)))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
340 # gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, gauge2))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
341 # 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
342 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
343 val_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
344 val_path.MoveToPoint(x0, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
345 val_path.AddLineToPoint(value, w1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
346 val_path.AddLineToPoint(value + 2, w1 + width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
347 val_path.AddLineToPoint(value + 2, w2 - width / 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
348 val_path.AddLineToPoint(value, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
349 # val_path.AddLineToPoint(value-4, 10)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
350 val_path.AddLineToPoint(x0, w2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
351 gc.DrawPath(val_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
352 # draw setpoint markers
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
353 setpoint = x0 + max(10, int(self.setpoint * self.scale))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
354 gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0))))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
355 setp_path = gc.CreatePath()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
356 setp_path.MoveToPoint(setpoint - 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
357 setp_path.AddLineToPoint(setpoint + 4, y0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
358 setp_path.AddLineToPoint(setpoint, y0 + 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
359 setp_path.MoveToPoint(setpoint - 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
360 setp_path.AddLineToPoint(setpoint + 4, yE)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
361 setp_path.AddLineToPoint(setpoint, yE - 5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
362 gc.DrawPath(setp_path)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
363 # draw readout
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
364 text = u"T\u00B0 %u/%u" % (self.value, self.setpoint)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
365 # 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
366 # gc.DrawText(text, 29,-2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
367 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
368 gc.DrawText(self.title, x0 + 19, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
369 gc.DrawText(text, x0 + 119, y0 + 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
370 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
371 gc.DrawText(self.title, x0 + 18, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
372 gc.DrawText(text, x0 + 118, y0 + 3)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
373
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
374 class SpecialButton(object):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
375
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
376 label = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
377 command = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
378 background = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
379 tooltip = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
380 custom = None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
381
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
382 def __init__(self, label, command, background = None,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
383 tooltip = None, custom = False):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
384 self.label = label
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
385 self.command = command
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
386 self.background = background
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
387 self.tooltip = tooltip
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
388 self.custom = custom

mercurial