~radina-matic/gtg/trunk

« back to all changes in this revision

Viewing changes to GTG/gtk/browser/simple_color_selector.py

  • Committer: Izidor Matušov
  • Date: 2013-02-25 08:29:31 UTC
  • Revision ID: izidor.matusov@gmail.com-20130225082931-fudjxno6sjv82kx0
Get rid of pylint messages

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# You should have received a copy of the GNU General Public License along with
17
17
# this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
# -----------------------------------------------------------------------------
19
 
# pylint: disable-msg=W0201
20
19
 
21
20
"""
22
21
simple_color_selector: a module defining a widget allowing to pick a color
45
44
 
46
45
 
47
46
class SimpleColorSelectorPaletteItem(gtk.DrawingArea):
48
 
# pylint: disable-msg=R0904,C0301
49
47
    """An item of the color selecctor palette"""
50
48
 
51
49
    def __init__(self, color=None):
63
61
        alloc = self.get_allocation()
64
62
        alloc_w, alloc_h = alloc[2], alloc[3]
65
63
        # Drawing context
66
 
        cr_ctxt = self.window.cairo_create()  # pylint: disable-msg=E1101
 
64
        cr_ctxt = self.window.cairo_create()
67
65
        gdkcontext = gtk.gdk.CairoContext(cr_ctxt)
68
66
 
69
67
        # Draw rectangle
103
101
            gdkcontext.stroke()
104
102
 
105
103
    ### callbacks ###
106
 
    def on_expose(self, widget, params):  # pylint: disable-msg=W0613
 
104
    def on_expose(self, widget, params):
107
105
        """Callback: redraws the widget when it is exposed"""
108
106
        self.__draw()
109
107
 
110
 
    def on_configure(self, widget, params):  # pylint: disable-msg=W0613
 
108
    def on_configure(self, widget, params):
111
109
        """Callback: redraws the widget when it is exposed"""
112
110
        self.__draw()
113
111
 
126
124
        return self.selected
127
125
 
128
126
 
129
 
class SimpleColorSelector(gtk.VBox):  # pylint: disable-msg=R0904,C0301
 
127
class SimpleColorSelector(gtk.VBox):
130
128
    """Widget displaying a palette of colors, possibly with a button allowing
131
129
     to define new colors."""
132
130
 
245
243
            self.custom_palette.show_all()
246
244
 
247
245
    # Handlers
248
 
    def on_color_clicked(self, widget, event):  # pylint: disable-msg=W0613
 
246
    def on_color_clicked(self, widget, event):
249
247
        """Callback: when a color is clicked, update the model and
250
248
        notify the parent"""
251
249
        # if re-click: unselect
260
258
            self.selected_col.set_selected(True)
261
259
        self.emit("color-changed")
262
260
 
263
 
    def on_color_add(self, widget):  # pylint: disable-msg=W0613
 
261
    def on_color_add(self, widget):
264
262
        """Callback: when adding a new color, show the color definition
265
263
        window, update the model, notifies the parent."""
266
264
        color_dialog = gtk.ColorSelectionDialog(_('Choose a color'))
267
265
        colorsel = color_dialog.colorsel
268
266
        if self.selected_col is not None:
269
267
            color = gtk.gdk.color_parse(self.selected_col.color)
270
 
            colorsel.set_current_color(color)  # pylint: disable-msg=E1101
 
268
            colorsel.set_current_color(color)
271
269
        response = color_dialog.run()
272
 
        new_color = colorsel.get_current_color()  # pylint: disable-msg=E1101
 
270
        new_color = colorsel.get_current_color()
273
271
        # Check response_id and set color if required
274
272
        if response == gtk.RESPONSE_OK and new_color:
275
273
            strcolor = gtk.color_selection_palette_to_string([new_color])