~phoenix1987/gtumbler/trunk

« back to all changes in this revision

Viewing changes to gtumbler_lib/BoundingBoxView.py

  • Committer: Gabriele N. Tornetta
  • Date: 2015-04-13 22:11:01 UTC
  • Revision ID: phoenix1987@gmail.com-20150413221101-on5p7eo205wsncwe
Resuming work on new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
        __gtype_name__ = "BoundingBoxView"
29
29
        
30
 
    __gsignals__ = {
31
 
        'box-changed' : (GObject.SIGNAL_RUN_FIRST,
32
 
                         None,
33
 
                         (int,) # @param: the new box index
34
 
                        ),
35
 
                        
36
 
        'value-changed' : (GObject.SIGNAL_RUN_FIRST,
37
 
                           None,
38
 
                           ()
39
 
                          ),
40
 
    }
41
 
    
42
 
    def __new__(cls):
43
 
        """Special static method that's automatically called by Python when 
44
 
        constructing a new instance of this class.
45
 
        
46
 
        Returns a fully instantiated BoundingBoxView object.
47
 
        """
48
 
        builder = get_builder('BoundingBoxView')
49
 
        new_object = builder.get_object("bounding_box_view")
50
 
        new_object.finish_initializing(builder)
51
 
        return new_object
52
 
 
53
 
    def finish_initializing(self, builder):
54
 
        """Called while initializing this instance in __new__
55
 
 
56
 
        finish_initializing should be called after parsing the UI definition
57
 
        and creating a BoundingBoxView object with it in order to finish
58
 
        initializing the start of the new BoundingBoxView instance.
59
 
        """
60
 
        # Get a reference to the builder and set up the signals.
61
 
        self.builder = builder
62
 
        self.ui = builder.get_ui(self, True)
63
 
        
64
 
        self._bboxes = [[.0] * 4 for i in range(5)]
65
 
        
66
 
    def on_cbo_box_changed(self, widget, *args):
 
30
        __gsignals__ = {
 
31
                'box-changed' : (GObject.SIGNAL_RUN_FIRST,
 
32
                                                 None,
 
33
                                                 (int,) # @param: the new box index
 
34
                                                ),
 
35
                                                
 
36
                'value-changed' : (GObject.SIGNAL_RUN_FIRST,
 
37
                                                   None,
 
38
                                                   ()
 
39
                                                  ),
 
40
        }
 
41
        
 
42
        def __new__(cls):
 
43
                """Special static method that's automatically called by Python when 
 
44
                constructing a new instance of this class.
 
45
                
 
46
                Returns a fully instantiated BoundingBoxView object.
 
47
                """
 
48
                builder = get_builder('BoundingBoxView')
 
49
                new_object = builder.get_object("bounding_box_view")
 
50
                new_object.finish_initializing(builder)
 
51
                return new_object
 
52
 
 
53
        def finish_initializing(self, builder):
 
54
                """Called while initializing this instance in __new__
 
55
 
 
56
                finish_initializing should be called after parsing the UI definition
 
57
                and creating a BoundingBoxView object with it in order to finish
 
58
                initializing the start of the new BoundingBoxView instance.
 
59
                """
 
60
                # Get a reference to the builder and set up the signals.
 
61
                self.builder = builder
 
62
                self.ui = builder.get_ui(self, True)
 
63
                
 
64
                self._bboxes = [[.0] * 4 for i in range(5)]
 
65
                
 
66
        def on_cbo_box_changed(self, widget, *args):
67
67
                n = widget.get_active()
68
68
                for widget, value in zip(BOX_WIDGETS, self._bboxes[n]):
69
69
                        getattr(self.ui, 'spb_%s' % widget).set_value(value)
70
 
        self.emit('box-changed', n)
71
 
 
72
 
    def on_spb_bottom_value_changed(self, widget, *args):
73
 
        self._bboxes[self.ui.cbo_box.get_active()][1] = widget.get_value()
74
 
        self.emit('value-changed')
75
 
 
76
 
    def on_spb_left_value_changed(self, widget, *args):
77
 
        self._bboxes[self.ui.cbo_box.get_active()][2] = widget.get_value()
78
 
        self.emit('value-changed')
79
 
 
80
 
    def on_spb_right_value_changed(self, widget, *args):
81
 
        self._bboxes[self.ui.cbo_box.get_active()][3] = widget.get_value()
82
 
        self.emit('value-changed')
83
 
 
84
 
    def on_spb_top_value_changed(self, widget, *args):
85
 
        self._bboxes[self.ui.cbo_box.get_active()][0] = widget.get_value()
86
 
        self.emit('value-changed')
 
70
                self.emit('box-changed', n)
 
71
 
 
72
        def on_spb_bottom_value_changed(self, widget, *args):
 
73
                self._bboxes[self.ui.cbo_box.get_active()][1] = widget.get_value()
 
74
                self.emit('value-changed')
 
75
 
 
76
        def on_spb_left_value_changed(self, widget, *args):
 
77
                self._bboxes[self.ui.cbo_box.get_active()][2] = widget.get_value()
 
78
                self.emit('value-changed')
 
79
 
 
80
        def on_spb_right_value_changed(self, widget, *args):
 
81
                self._bboxes[self.ui.cbo_box.get_active()][3] = widget.get_value()
 
82
                self.emit('value-changed')
 
83
 
 
84
        def on_spb_top_value_changed(self, widget, *args):
 
85
                self._bboxes[self.ui.cbo_box.get_active()][0] = widget.get_value()
 
86
                self.emit('value-changed')