printrun-src/printrun/gui/utils.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
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
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
18 def make_button(parent, label, callback, tooltip, container = None, size = wx.DefaultSize, style = 0):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
19 button = wx.Button(parent, -1, label, style = style, size = size)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
20 button.Bind(wx.EVT_BUTTON, callback)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
21 button.SetToolTip(wx.ToolTip(tooltip))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
22 if container:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
23 container.Add(button)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
24 return button
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
25
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
26 def make_autosize_button(*args):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
27 return make_button(*args, size = (-1, -1), style = wx.BU_EXACTFIT)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
28
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
29 def make_custom_button(root, parentpanel, i, style = 0):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30 btn = make_button(parentpanel, i.label, root.process_button,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
31 i.tooltip, style = style)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
32 btn.SetBackgroundColour(i.background)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
33 btn.SetForegroundColour("black")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
34 btn.properties = i
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
35 root.btndict[i.command] = btn
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
36 root.printerControls.append(btn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
37 return btn

mercurial