(self, widget)
When the palette colorbutton is clicked, open a dialog to
        configure a custom color.
When the palette colorbutton is clicked, open a dialog to
        configure a custom color.
When the palette colorbutton is clicked open a dialog to configure a custom color .
def edit_palette_button(self, widget):
        """When the palette colorbutton is clicked, open a dialog to
        configure a custom color."""
        terminator = Terminator()
        palette_id = self.get_palette_id(widget)
        orig = self.get_palette_color(palette_id)

        try:
            # Create the dialog to choose a custom color
            dialog = Gtk.ColorChooserDialog("Choose Palette Color")
            dialog.set_rgba(Gdk.RGBA.from_color(orig))

            def on_color_set(_, color):
                # The color is set, so save the palette config and refresh Terminator
                self.replace_palette_color(palette_id, dialog.get_rgba().to_color())
                terminator.reconfigure()
            dialog.connect('notify::rgba', on_color_set)

            # Show the dialog
            res = dialog.run()
            if res != Gtk.ResponseType.OK:
                # User cancelled the color change, so reset to the original.
                self.replace_palette_color(palette_id, orig)
                terminator.reconfigure()
        finally:
            if dialog:
                dialog.destroy()
def edit_palette_button ( self , widget ) : terminator = Terminator ( ) palette_id = self . get_palette_id ( widget ) orig = self . get_palette_color ( palette_id ) try : # Create the dialog to choose a custom color dialog = Gtk . ColorChooserDialog ( "Choose Palette Color" ) dialog . set_rgba ( Gdk . RGBA . from_color ( orig ) ) def on_color_set ( _ , color ) : # The color is set, so save the palette config and refresh Terminator self . replace_palette_color ( palette_id , dialog . get_rgba ( ) . to_color ( ) ) terminator . reconfigure ( ) dialog . connect ( 'notify::rgba' , on_color_set ) # Show the dialog res = dialog . run ( ) if res != Gtk . ResponseType . OK : # User cancelled the color change, so reset to the original. self . replace_palette_color ( palette_id , orig ) terminator . reconfigure ( ) finally : if dialog : dialog . destroy ( )