~ubuntu-branches/ubuntu/trusty/gnuradio/trusty

« back to all changes in this revision

Viewing changes to gr-wxgui/src/python/forms/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Kamal Mostafa
  • Date: 2010-03-13 07:46:01 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100313074601-zjsa893a87bozyh7
Tags: 3.2.2.dfsg-1ubuntu1
* Fix build for Ubuntu lucid (LP: #260406)
  - add binary package dep for libusrp0, libusrp2-0: adduser
  - debian/rules clean: remove pre-built Qt moc files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright 2009 Free Software Foundation, Inc.
 
3
#
 
4
# This file is part of GNU Radio
 
5
#
 
6
# GNU Radio is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 3, or (at your option)
 
9
# any later version.
 
10
#
 
11
# GNU Radio is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with GNU Radio; see the file COPYING.  If not, write to
 
18
# the Free Software Foundation, Inc., 51 Franklin Street,
 
19
# Boston, MA 02110-1301, USA.
 
20
#
 
21
 
 
22
"""
 
23
The following classes will be available through gnuradio.wxgui.forms:
 
24
""" 
 
25
 
 
26
########################################################################
 
27
# External Converters
 
28
########################################################################
 
29
from converters import \
 
30
        eval_converter, str_converter, \
 
31
        float_converter, int_converter
 
32
 
 
33
########################################################################
 
34
# External Forms
 
35
########################################################################
 
36
from forms import \
 
37
        radio_buttons, drop_down, notebook, \
 
38
        button, toggle_button, single_button, \
 
39
        check_box, text_box, static_text, \
 
40
        slider, log_slider, gauge, \
 
41
        make_bold, DataEvent, EVT_DATA
 
42
 
 
43
########################################################################
 
44
# Helpful widgets
 
45
########################################################################
 
46
import wx
 
47
 
 
48
class static_box_sizer(wx.StaticBoxSizer):
 
49
        """
 
50
        A box sizer with label and border.
 
51
        @param parent the parent widget
 
52
        @param sizer add this widget to sizer if provided (optional)
 
53
        @param proportion the proportion when added to the sizer (default=0)
 
54
        @param flag the flag argument when added to the sizer (default=wx.EXPAND)
 
55
        @param label title label for this widget (optional)
 
56
        @param bold true to boldify the label
 
57
        @param orient the sizer orientation wx.VERTICAL or wx.HORIZONTAL (default=wx.VERTICAL)
 
58
        """
 
59
        def __init__(self, parent, label='', bold=False, sizer=None, orient=wx.VERTICAL, proportion=0, flag=wx.EXPAND):
 
60
                box = wx.StaticBox(parent=parent, label=label)
 
61
                if bold: make_bold(box)
 
62
                wx.StaticBoxSizer.__init__(self, box=box, orient=orient)
 
63
                if sizer: sizer.Add(self, proportion, flag)
 
64
 
 
65
class incr_decr_buttons(wx.BoxSizer):
 
66
        """
 
67
        A horizontal box sizer with a increment and a decrement button.
 
68
        @param parent the parent widget
 
69
        @param sizer add this widget to sizer if provided (optional)
 
70
        @param proportion the proportion when added to the sizer (default=0)
 
71
        @param flag the flag argument when added to the sizer (default=wx.EXPAND)
 
72
        @param label title label for this widget (optional)
 
73
        @param on_incr the callback for pressing the + button
 
74
        @param on_decr the callback for pressing the - button
 
75
        """
 
76
        def __init__(self, parent, on_incr, on_decr, label='', sizer=None, proportion=0, flag=wx.EXPAND):
 
77
                """
 
78
                @param parent the parent window
 
79
                @param on_incr the event handler for increment
 
80
                @param on_decr the event handler for decrement
 
81
                """
 
82
                wx.BoxSizer.__init__(self, wx.HORIZONTAL)
 
83
                buttons_box = wx.BoxSizer(wx.HORIZONTAL)
 
84
                self._incr_button = wx.Button(parent, label='+', style=wx.BU_EXACTFIT)
 
85
                self._incr_button.Bind(wx.EVT_BUTTON, on_incr)
 
86
                buttons_box.Add(self._incr_button, 0, wx.ALIGN_CENTER_VERTICAL)
 
87
                self._decr_button = wx.Button(parent, label=' - ', style=wx.BU_EXACTFIT)
 
88
                self._decr_button.Bind(wx.EVT_BUTTON, on_decr)
 
89
                buttons_box.Add(self._decr_button, 0, wx.ALIGN_CENTER_VERTICAL)
 
90
                if label: #add label
 
91
                        self.Add(wx.StaticText(parent, label='%s: '%label), 1, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
 
92
                        self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
 
93
                else: self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL)
 
94
                if sizer: sizer.Add(self, proportion, flag)
 
95
 
 
96
        def Disable(self, disable=True): self.Enable(not disable)
 
97
        def Enable(self, enable=True):
 
98
                if enable:
 
99
                        self._incr_button.Enable()
 
100
                        self._decr_button.Enable()
 
101
                else:
 
102
                        self._incr_button.Disable()
 
103
                        self._decr_button.Disable()