|
1 # This file is part of the Printrun suite. |
|
2 # |
|
3 # Printrun is free software: you can redistribute it and/or modify |
|
4 # it under the terms of the GNU General Public License as published by |
|
5 # the Free Software Foundation, either version 3 of the License, or |
|
6 # (at your option) any later version. |
|
7 # |
|
8 # Printrun is distributed in the hope that it will be useful, |
|
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 # GNU General Public License for more details. |
|
12 # |
|
13 # You should have received a copy of the GNU General Public License |
|
14 # along with Printrun. If not, see <http://www.gnu.org/licenses/>. |
|
15 |
|
16 import wx |
|
17 |
|
18 def make_button(parent, label, callback, tooltip, container = None, size = wx.DefaultSize, style = 0): |
|
19 button = wx.Button(parent, -1, label, style = style, size = size) |
|
20 button.Bind(wx.EVT_BUTTON, callback) |
|
21 button.SetToolTip(wx.ToolTip(tooltip)) |
|
22 if container: |
|
23 container.Add(button) |
|
24 return button |
|
25 |
|
26 def make_autosize_button(*args): |
|
27 return make_button(*args, size = (-1, -1), style = wx.BU_EXACTFIT) |
|
28 |
|
29 def make_custom_button(root, parentpanel, i, style = 0): |
|
30 btn = make_button(parentpanel, i.label, root.process_button, |
|
31 i.tooltip, style = style) |
|
32 btn.SetBackgroundColour(i.background) |
|
33 btn.SetForegroundColour("black") |
|
34 btn.properties = i |
|
35 root.btndict[i.command] = btn |
|
36 root.printerControls.append(btn) |
|
37 return btn |