예제 #1
0
    def OnClick(self, event):
        """
        Handles the ``wx.EVT_BUTTON`` event for :class:`ColourSelect`.

        :param `event`: a :class:`wx.CommandEvent` event to be processed.
        """

        data = wx.ColourData()
        data.SetChooseFull(True)
        data.SetColour(self.colour)
        if self.customColours:
            for idx, clr in enumerate(self.customColours.Colours):
                if clr is not None:
                    data.SetCustomColour(idx, clr)

        dlg = wx.ColourDialog(wx.GetTopLevelParent(self), data)
        changed = dlg.ShowModal() == wx.ID_OK

        if changed:
            data = dlg.GetColourData()
            self.SetColour(data.GetColour())
            if self.customColours:
                self.customColours.Colours = \
                    [data.GetCustomColour(idx) for idx in range(0, 16)]

        dlg.Destroy()

        # moved after dlg.Destroy, since who knows what the callback will do...
        if changed:
            self.OnChange()
예제 #2
0
    def OnSelectColour(self, event):

        eventid = event.GetId()

        # Open a colour dialog
        data = wx.ColourData()

        dlg = wx.ColourDialog(self, data)

        if dlg.ShowModal() == wx.ID_OK:

            if eventid == MENU_SELECT_GRADIENT_COLOUR_BORDER:
                self.book.SetGradientColourBorder(
                    dlg.GetColourData().GetColour())
            elif eventid == MENU_SELECT_GRADIENT_COLOUR_FROM:
                self.book.SetGradientColourFrom(
                    dlg.GetColourData().GetColour())
            elif eventid == MENU_SELECT_GRADIENT_COLOUR_TO:
                self.book.SetGradientColourTo(dlg.GetColourData().GetColour())
            elif eventid == MENU_SET_ACTIVE_TEXT_COLOUR:
                self.book.SetActiveTabTextColour(
                    dlg.GetColourData().GetColour())
            elif eventid == MENU_SELECT_NONACTIVE_TEXT_COLOUR:
                self.book.SetNonActiveTabTextColour(
                    dlg.GetColourData().GetColour())
            elif eventid == MENU_SET_ACTIVE_TAB_COLOUR:
                self.book.SetActiveTabColour(dlg.GetColourData().GetColour())
            elif eventid == MENU_SET_TAB_AREA_COLOUR:
                self.book.SetTabAreaColour(dlg.GetColourData().GetColour())

            self.book.Refresh()
예제 #3
0
    def OnButton(self, evt):

        if not hasattr(self, "colourData"):
            self.colourData = wx.ColourData()

        self.colourData.SetColour(self.GetBackgroundColour())

        dlg = CCD.CubeColourDialog(self, self.colourData)

        if dlg.ShowModal() == wx.ID_OK:

            # If the user selected OK, then the dialog's wx.ColourData will
            # contain valid information. Fetch the data ...
            self.colourData = dlg.GetColourData()
            h, s, v, a = dlg.GetHSVAColour()

            # ... then do something with it. The actual colour data will be
            # returned as a three-tuple (r, g, b) in this particular case.
            colour = self.colourData.GetColour()
            self.log.WriteText(
                'You selected: %s: %d, %s: %d, %s: %d, %s: %d\n' %
                ("Red", colour.Red(), "Green", colour.Green(), "Blue",
                 colour.Blue(), "Alpha", colour.Alpha()))
            self.log.WriteText(
                'HSVA Components: %s: %d, %s: %d, %s: %d, %s: %d\n\n' %
                ("Hue", h, "Saturation", s, "Brightness", v, "Alpha", a))
            self.SetBackgroundColour(self.colourData.GetColour())
            self.Refresh()

        # Once the dialog is destroyed, Mr. wx.ColourData is no longer your
        # friend. Don't use it again!
        dlg.Destroy()
예제 #4
0
    def OnClick(self, event):
        win = wx.GetTopLevelParent(self)

        data = wx.ColourData()
        data.SetChooseFull(True)
        data.SetColour(self.value)
        [
            data.SetCustomColour(colour_index, win.customcolours[colour_index])
            for colour_index in range(0, 16)
        ]

        dlg = wx.ColourDialog(win, data)
        dlg.SetTitle("Select Colour")
        changed = dlg.ShowModal() == wx.ID_OK

        if changed:
            data = dlg.GetColourData()
            self.SetValue(data.GetColour())
            win.customcolours = [data.GetCustomColour(colour_index) \
                                 for colour_index in range(0, 16)]
        dlg.Destroy()

        if changed:
            nevt = ColourSelectEvent(id=self.GetId(), obj=self, val=self.value)
            wx.PostEvent(self.parent, nevt)
예제 #5
0
    def __onClick(self, ev):
        """Called when this ``ColourButton`` is pressed.

        Displays a :class:`wx.ColourDialog` allowing the user to select a new
        colour.
        """

        colourData = wx.ColourData()
        colourData.SetColour(self.__colour)

        dlg = wx.ColourDialog(self.GetTopLevelParent(), colourData)

        if dlg.ShowModal() != wx.ID_OK:
            return

        newColour = dlg.GetColourData().GetColour()
        newColour = [
            newColour.Red(),
            newColour.Green(),
            newColour.Blue(),
            newColour.Alpha()
        ]

        self.SetValue(newColour)

        wx.PostEvent(self, ColourButtonEvent(colour=newColour))
예제 #6
0
    def OnDoubleClickColorPick(self, event):
        selText = self.GetSelectedText().lower()
        if not len(selText) in (3, 6):
            return
        for char in selText:
            if not char in ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'):
                return
        if not self.GetCharAt(self.GetSelectionStart() - 1) == ord('#'):
            return
        selStart, selEnd = self.GetSelectionStart(), self.GetSelectionEnd()

        cd = wx.ColourData()
        hexColor = selText if len(selText) == 6 else '%s%s%s' % (selText[0] * 2,
                                                                 selText[1] * 2,
                                                                 selText[2] * 2)
        cd.SetColour(u'#%s' % hexColor)
        cc = ('#FFFFFF', '#EEEEEE', '#DDDDDD', '#CCCCCC',
              '#BBBBBB', '#AAAAAA', '#999999', '#888888',
              '#777777', '#666666', '#555555', '#444444',
              '#333333', '#222222', '#111111', '#000000')
        for i, col in enumerate(cc):
            cd.SetCustomColour(i, col)
        ColorHexString = self.ColorCubeDialog(self, colorData=cd)
        if ColorHexString:
            if len(selText) == 3 and (ColorHexString[1] == ColorHexString[2]) \
                                 and (ColorHexString[3] == ColorHexString[4]) \
                                 and (ColorHexString[5] == ColorHexString[6]):
                # Shorten back to #FFF three char hex.
                self.ReplaceSelection(u'%s%s%s' % (ColorHexString[1],
                                                   ColorHexString[3],
                                                   ColorHexString[5]))
            else:
                # Leave as #FFFFFF six char hex
                # Adjust for added alpha to hex. back to 6, not 8.
                self.ReplaceSelection(u'%s' % ColorHexString.lstrip('#')[:-2])
예제 #7
0
 def onChangeColour(self, evt):
     evtID = evt.GetId()
     
     # Restore custom colors
     custom = wx.ColourData()
     for key in range(len(self.config.customColors)): #key in self.config.customColors:
         custom.SetCustomColour(key, self.config.customColors[key])
     dlg = wx.ColourDialog(self, custom)
     dlg.GetColourData().SetChooseFull(True)
     
     # Show dialog and get new colour
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetColourData()
         newColour = list(data.GetColour().Get())
         dlg.Destroy()
         # Retrieve custom colors
         for i in xrange(15):
             self.config.customColors[i] = data.GetCustomColour(i)
     else:
         return
     
     if evtID == ID_unidecPanel_barEdgeColor:
         self.config.unidec_plot_bar_edge_color = convertRGB255to1(newColour)
         self.bar_edgeColor_Btn.SetBackgroundColour(newColour)
         
     elif evtID == ID_unidecPanel_fitLineColor:
         self.config.unidec_plot_fit_lineColor = convertRGB255to1(newColour)
         self.fit_lineColor_Btn.SetBackgroundColour(newColour)
예제 #8
0
def chooseColor():
    """Use system-dependent color chooser dialog to select color.

    Returns:
        RGB tuple or None.
    """
    app = wx.App()

    # setup defaults
    data = wx.ColourData()
    if wx.Platform == "__WXMAC__":
        data.SetChooseAlpha(False)
    data.SetChooseFull(True)
    data.SetColour(wx.WHITE)  # show colors on initial color wheel on mac

    # start and process the dialog
    color = None
    dlg = wx.ColourDialog(wx.GetApp().GetTopWindow(), data)
    if dlg.ShowModal() == wx.ID_OK:
        red = dlg.GetColourData().GetColour().Red()
        green = dlg.GetColourData().GetColour().Green()
        blue = dlg.GetColourData().GetColour().Blue()
        color = (red, green, blue)

    # clean up
    dlg.Destroy()
    return color
예제 #9
0
    def DefaultCB(self, e):

        self.Layout()

        if False: pass
        elif self.obj_dict['wtype'] == 'wx.ColourDialog':
            self.obj_dict['value'] = self.obj_dict['default']
            self.label.SetLabel( ` self.obj_dict['value'] `)

            c = wx.Colour(self.obj_dict['default'][0],
                          self.obj_dict['default'][1],
                          self.obj_dict['default'][2])
            #self.widget.GetColourData().SetColour(c);
            #self.widget.GetColourData().SetColour(self.obj_dict['value'])#seems 2B broken!
            colordata = wx.ColourData()
            colordata.SetChooseFull(True)
            colordata.SetColour(c)
            self.widget = wx.ColourDialog(self, colordata)

            self.showColourDialogB.SetBackgroundColour(self.obj_dict['value'])
            #Set value of widget, b/c widget is what gets queried @ SaveCB
            #print dir(self.widget)
            #print dir(self.widget.GetColourData())

        elif self.obj_dict['wtype'] == 'wx.CheckBox':
            self.widget.SetValue(int(self.obj_dict['default']))
            self.CheckBoxCB(None)

        elif self.obj_dict['wtype'] == 'wx.FileDialog':
            self.obj_dict['value'] = self.obj_dict['default_value']
            self.label.SetLabel(self.obj_dict['default_value'])
            if not self.obj_dict.has_key('default_path'): return
            if not self.obj_dict.has_key('default_value'): return

            if os.path.exists(
                    os.path.join(self.obj_dict['default_path'],
                                 self.obj_dict['default_value'])
            ):  #don't use '' for path!
                self.obj_dict['path'] = self.obj_dict['default_path']
                self.obj_dict['value'] = self.obj_dict['default_value']

        elif self.obj_dict['wtype'] == 'wx.ComboBox':
            self.widget.SetValue(self.obj_dict['value'])
            self.ComboCB(None)

        elif self.obj_dict['wtype'] == 'wx.TextCtrl':
            self.widget.SetValue(self.obj_dict['default'])

        elif self.obj_dict['wtype'] == 'wx.Slider':
            self.widget.SetValue(
                int(self.obj_dict['default'] * self.obj_dict['divisor']))
            self.SliderCB(None)

        elif self.obj_dict['wtype'] == 'wx.ImageDialog':
            self.obj_dict['value'] = self.obj_dict['default']
            self.label.SetLabel(self.obj_dict['value'])

        elif self.obj_dict['wtype'] == 'wx.SpinCtrl':
            self.widget.SetValue(int(self.obj_dict['default']))
            self.SpinCtrlCB(None)
    def onApply_color(self, evt):
        source = evt.GetEventObject().GetName()

        # Restore custom colors
        custom = wx.ColourData()
        for key in range(len(self.config.customColors)):
            custom.SetCustomColour(key, self.config.customColors[key])
        dlg = wx.ColourDialog(self, custom)
        dlg.GetColourData().SetChooseFull(True)

        # Show dialog and get new colour
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetColourData()
            newColour = list(data.GetColour().Get())
            dlg.Destroy()
            # Retrieve custom colors
            for i in xrange(15):
                self.config.customColors[i] = data.GetCustomColour(i)

            if source == "plot_tandem_labelled":
                self.plot_tandem_line_labelled_colorBtn.SetBackgroundColour(
                    newColour)
                self.config.msms_line_color_labelled = convertRGB255to1(
                    newColour)
            elif source == "plot_tandem_unlabelled":
                self.plot_tandem_line_unlabelled_colorBtn.SetBackgroundColour(
                    newColour)
                self.config.msms_line_color_unlabelled = convertRGB255to1(
                    newColour)
예제 #11
0
    def SetupColourDialog(self):
        colordata = wx.ColourData()
        colordata.SetChooseFull(True)
        colordata.SetColour(
            wx.Colour(self.obj_dict['value'][0], self.obj_dict['value'][1],
                      self.obj_dict['value'][2]))
        self.widget = wx.ColourDialog(self, colordata)
        #self.widget.GetColourData().SetColour(wx.Colour(self.obj_dict['value'][0],self.obj_dict['value'][1],self.obj_dict['value'][2]))
        #print self.widget.GetColourData().GetColour(),wx.Colour(self.obj_dict['value'][0],self.obj_dict['value'][1],self.obj_dict['value'][2])

        showColourDialogBID = wx.NewId()
        self.showColourDialogB = wx.Button(self,
                                           showColourDialogBID,
                                           "ShowDialog",
                                           size=self.button_size)
        self.showColourDialogB.SetBackgroundColour(
            wx.Colour(self.obj_dict['value'][0], self.obj_dict['value'][1],
                      self.obj_dict['value'][2]))
        self.sbsizer.Add(self.showColourDialogB)
        wx.EVT_BUTTON(self.showColourDialogB, showColourDialogBID,
                      self.ShowColourDialogCB)

        label_str = ''
        self.label = wx.StaticText(self,
                                   wx.NewId(),
                                   label_str,
                                   size=self.button_size)
        self.label.SetLabel( ` self.obj_dict['value'] `)
        self.sbsizer.Add(self.label)

        self.defaultB.SetBackgroundColour(self.obj_dict['default'])
예제 #12
0
def getColorDlg(parent=None, title='', default_colour=wx.BLACK):
    """
    Color picker dialog.

    :param parent: Parent form.
    :param title: Dialog form title.
    :param default_colour: Default colour.
    :return: Selected colour or default_colour.
    """
    dlg = None
    win_clear = False
    colour = default_colour
    try:
        if parent is None:
            parent = wx.Frame(None, -1, '')
            win_clear = True

        dlg = wx.ColourDialog(parent,
                              wx.ColourData().SetColour(default_colour))
        dlg.SetTitle(title)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            colour = dlg.GetColourData().GetColour()
        dlg.Destroy()
    finally:
        if dlg:
            dlg.Destroy()

        if win_clear:
            parent.Destroy()
    return colour
예제 #13
0
def icColorDlg(Win_=None, Title_='', Default_=wx.BLACK):
    """
    Диалог выбора цвета
    @param Win_: Ссылка на окно.
    @param Title_: Заголовок диалогового окна.
    @param Default_: Значение по умолчанию.
    @return: Возвращает выбранный цвет или Default_.
    """
    dlg = None
    win_clear = False
    try:
        if Win_ is None:
            Win_ = wx.Frame(None, -1, '')
            win_clear = True

        dlg = wx.ColourDialog(Win_, wx.ColourData().SetColour(Default_))
        dlg.SetTitle(Title_)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            color = dlg.GetColourData().GetColour()
        else:
            color = Default_
        dlg.Destroy()
        return color
    finally:
        if dlg:
            dlg.Destroy()

        # Удаляем созданное родительское окно
        if win_clear:
            Win_.Destroy()
예제 #14
0
 def test_lib_agw_cubecolourdialogCtor(self):
     colourData = wx.ColourData()
     colourData.SetColour(wx.RED)
     dlg = CCD.CubeColourDialog(self.frame, colourData, agwStyle=0)
     wx.CallLater(250, dlg.EndModal, wx.ID_OK)
     dlg.ShowModal()
     dlg.Destroy()
예제 #15
0
def prompt_for_rgba(parent, color, custom=None, use_float=False):
    data = wx.ColourData()
    data.SetChooseFull(True)
    if use_float:
        color = [a * 255 for a in color]
    data.SetColour(color)
    if custom is not None:
        for idx, clr in enumerate(custom.Colours):
            if clr is not None:
                data.SetCustomColour(idx, clr)

    dlg = color_dialog(wx.GetTopLevelParent(parent), data)
    changed = dlg.ShowModal() == wx.ID_OK

    if changed:
        data = dlg.GetColourData()
        color = data.GetColour()
        if use_float:
            color = [float(c / 255.0) for c in color]
        if custom is not None:
            custom.Colours = \
                [data.GetCustomColour(idx) for idx in range(0, 16)]
    else:
        color = None

    dlg.Destroy()
    return color
예제 #16
0
 def on_popup_seven(self, event=None):
     """
     Spawns a dialog for the first selected item to select the color.
     Redraws the list control with the new colors and then triggers an EVT_DELETE_SELECTION_2.
     :param event: Unused Event
     :return: None
     """
     # Change Color
     item = self.list.GetFirstSelected()
     col = self.list.GetItemBackgroundColour(item)
     print("Color In:", col)
     col = wx.Colour(int(col[0]),
                     int(col[1]),
                     int(col[2]),
                     alpha=int(col.alpha))
     col2 = wx.ColourData()
     col2.SetColour(col)
     colout = col2
     dlg = wx.ColourDialog(None, data=col2)
     if dlg.ShowModal() == wx.ID_OK:
         colout = dlg.GetColourData()
         colout = deepcopy(colout.GetColour())
         print("Color Out", colout)
     dlg.Destroy()
     self.list.SetItemBackgroundColour(item, col=colout)
     colout = colout.Get(includeAlpha=True)
     colout = ([
         colout[0] / 255., colout[1] / 255., colout[2] / 255.,
         colout[3] / 255.
     ])
     self.pres.on_color_change(item, colout)
예제 #17
0
    def OnDialogs(self, event):

        evId = event.GetId()

        if evId == 101:
            # wx.ColourDialog
            data = wx.ColourData()
            dlg = wx.ColourDialog(self, data)
            dlg.SetName("ColourDialog1")

        elif evId == 102:
            # wx.FontDialog
            data = wx.FontData()
            dlg = wx.FontDialog(self, data)
            dlg.SetName("FontDialog1")

        elif evId == 103:
            # wx.TextEntryDialog
            dlg = wx.TextEntryDialog(
                self, 'What is your favorite programming language?', 'Eh??',
                'Python')
            dlg.SetValue("Python is the best!")
            dlg.SetName("TextEntryDialog1")

        self._persistMgr.RegisterAndRestore(dlg)

        if dlg.ShowModal() == wx.ID_OK:
            self._persistMgr.Save(dlg)

        self._persistMgr.Unregister(dlg)
        dlg.Destroy()
예제 #18
0
    def set_color (self, event, i, parent):
	"Choose and set a color from a GUI color chooser."

        # setup current colour
        # we need to convert get_set_var[i], which could be string, to
        # a tuple...
        exec('colour_tuple = %s' % str(self.get_set_var[i]))
        cur_colour = wx.Colour(colour_tuple[0] * 255.0,
                              colour_tuple[1] * 255.0,
                              colour_tuple[2] * 255.0)
        ccd = wx.ColourData()
        ccd.SetColour(cur_colour)
        # often-used BONE custom colour
        ccd.SetCustomColour(0,wx.Colour(255, 239, 219))
        # we want the detailed dialog under windows        
        ccd.SetChooseFull(True)
        # do that thang
        dlg = ColourDialog(parent, ccd)
        
        if dlg.ShowModal() == wx.ID_OK:
            # the user wants this, we get to update the variables
            new_col = dlg.GetColourData().GetColour()
            self.get_set_var[i] = (float(new_col.Red()) / 255.0 * 1.0,
                                   float(new_col.Green()) / 255.0 * 1.0,
                                   float(new_col.Blue()) / 255.0 * 1.0)
            # now we need to update the frigging text input (and this is going
            # to trigger the callback in anycase, which is going to repeat the
            # line above, but with text)
            self.get_set_texts[i].SetValue(str(self.get_set_var[i]))

        dlg.Destroy()
예제 #19
0
파일: widgets.py 프로젝트: sdob/maptiler
	def onColor(self, evt):
		color = wx.ColourData()
		color.SetColour(self.color)
		dlg = wx.ColourDialog(self, data=color)

		# Ensure the full colour dialog is displayed, 
		# not the abbreviated version.
		dlg.GetColourData().SetChooseFull(True)

		if dlg.ShowModal() == wx.ID_OK:

			# If the user selected OK, then the dialog's wx.ColourData will
			# contain valid information. Fetch the data ...
			data = dlg.GetColourData()

			# ... then do something with it. The actual colour data will be
			# returned as a three-tuple (r, g, b) in this particular case.
			self.color = data.GetColour().Get()
			#print 'You selected: %s\n' % str(self.color)

			bmp = wx.EmptyBitmap(16, 16)
			dc = wx.MemoryDC(bmp)
			dc.SetBackground(wx.Brush(data.GetColour().Get()))
			dc.Clear()
						
			self.bcolor.SetBitmapLabel(bmp)
			self.ch1.SetValue(True)

		# Once the dialog is destroyed, Mr. wx.ColourData is no longer your
		# friend. Don't use it again!
		dlg.Destroy()
예제 #20
0
    def pick(self, *args):
        """
		Open a wx.ColourDialog to edit the colour currently selected in the picker
		"""

        selection = self.selection_list_box.GetSelection()
        if selection == -1:
            return

        selection_string = self.selection_list_box.GetString(selection)
        if selection_string == '':
            return

        colour = wx.ColourData()
        colour.SetColour(selection_string)

        dlg = wx.ColourDialog(self, data=colour)

        res = dlg.ShowModal()
        if res == wx.ID_OK:
            self.selection_list_box.Delete(selection)
            self.selection_list_box.InsertItems(
             [dlg.GetColourData().GetColour().GetAsString(wx.C2S_HTML_SYNTAX)],
             selection)  # yapf: disable
            self.selection_list_box.SetSelection(selection)
            self.update_selection_preview()
            dlg.Destroy()
예제 #21
0
 def OnButton_Custom(self, evt):
     data = wx.ColourData()
     data.SetChooseFull(True)
     dialog = wx.ColourDialog(self.parent, data)
     if dialog.ShowModal() == wx.ID_OK:
         self.PickColor(dialog.GetColourData().Colour)
     dialog.Destroy()
예제 #22
0
    def on_background_button_click(self, event):
        """Handle background button click event."""

        color = None
        data = wx.ColourData()
        data.SetChooseFull(True)

        alpha = None

        text = self.m_background_textbox.GetValue()
        if text == "":
            rgb = RGBA("#FFFFFF")
        else:
            rgb = RGBA(text)
            if len(text) == 9:
                alpha == text[7:9]

        # set the default color in the chooser
        data.SetColour(wx.Colour(rgb.r, rgb.g, rgb.b))

        # construct the chooser
        dlg = wx.ColourDialog(self, data)

        if dlg.ShowModal() == wx.ID_OK:
            # set the panel background color
            color = dlg.GetColourData().GetColour().GetAsString(
                wx.C2S_HTML_SYNTAX)
            self.m_background_textbox.SetValue(
                color if alpha is None else color + alpha)
        dlg.Destroy()
        event.Skip()
예제 #23
0
파일: dlg.py 프로젝트: XHermitOne/defis
def getColorDlg(parent=None, title='', default=wx.BLACK):
    """
    Диалог выбора цвета
    @param parent: Ссылка на окно.
    @param title: Заголовок диалогового окна.
    @param default: Значение по умолчанию.
    @return: Возвращает выбранный цвет или default.
    """
    result = (0, 0, 0)
    dlg = None
    win_clear = False
    try:
        if parent is None:
            parent = wx.Frame(None, -1, '')
            win_clear = True

        dlg = wx.ColourDialog(parent, wx.ColourData().SetColour(default))
        dlg.SetTitle(title)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            result = dlg.GetColourData().GetColour()
        else:
            result = default
    finally:
        dlg.Destroy()

        # Удаляем созданное родительское окно
        if win_clear:
            parent.Destroy()
    return result
예제 #24
0
 def SelectNewColour(self):
     c = self.GetColor()
     data = wx.ColourData()
     data.SetColour(wx.Colour(c.red, c.green, c.blue))
     dlg = wx.ColourDialog(self.GetRibbon(), data)
     if dlg.ShowModal() == wx.ID_OK:
         # Colour did change.
         self.SetColor(self.wxToCadColor(dlg.GetColourData().GetColour()))
예제 #25
0
 def ShowDialog(self):
     self.color_data = wx.ColourData()
     self.color_data.SetColour(self.cur_color)
     self.color_dialog = colordialog.CubeColourDialog(None, self.color_data)
     if self.color_dialog.ShowModal() == wx.ID_OK:
         self.color_data = self.color_dialog.GetColourData()
         self.cur_color = self.color_data.GetColour()
     self.color_dialog.Destroy()
예제 #26
0
 def __init__(self, parent):
     ccd = wx.ColourData()
     # often-used BONE custom colour
     ccd.SetCustomColour(0, wx.Colour(255, 239, 219))
     # we want the detailed dialog under windows
     ccd.SetChooseFull(True)
     # create the dialog
     self._colourDialog = wx.ColourDialog(parent, ccd)
예제 #27
0
 def _create_control(self, parent):
     wx_colour = self.color.to_toolkit()
     data = wx.ColourData()
     data.SetColour(wx_colour)
     if wx_version >= (4, 1):
         data.SetChooseAlpha(self.show_alpha)
     dialog = wx.ColourDialog(parent, data)
     return dialog
예제 #28
0
    def on_popup_five(self, event=None):
        """
        Spawns a dialog for the first selected item to select the color.
        Redraws the list control with the new colors and then triggers an EVT_DELETE_SELECTION_2.
        :param event: Unused Event
        :return: None
        """
        # Change Color
        item = self.list_ctrl.GetFirstSelected()
        col = self.list_ctrl.GetItemBackgroundColour(item)
        print("Color In:", col)
        col = wx.Colour(int(col[0]),
                        int(col[1]),
                        int(col[2]),
                        alpha=int(col.alpha))
        col2 = wx.ColourData()
        col2.SetColour(col)
        colout = col2
        dlg = wx.ColourDialog(None, data=col2)
        if dlg.ShowModal() == wx.ID_OK:
            coloutdlg = dlg.GetColourData()
            colout = deepcopy(coloutdlg.GetColour())
            print("Color Out", colout)
            dlg.Destroy()
        else:
            dlg.Destroy()
            return
        topcolor = ([colout[0] / 255., colout[1] / 255., colout[2] / 255.])
        self.list_ctrl.SetItemBackgroundColour(item, col=colout)

        luminance = ud.get_luminance(wx.Colour(colout), type=2)
        #print(wx.Colour(colout), luminance)
        if luminance < luminance_cutoff:
            self.list_ctrl.SetItemTextColour(item, col=white_text)
        else:
            self.list_ctrl.SetItemTextColour(item, col=black_text)

        peak = tofloat(self.list_ctrl.GetItem(item, col=1).GetText())
        i = ud.nearest(self.pks.masses, peak)
        self.pks.peaks[i].color = topcolor

        num = self.list_ctrl.GetSelectedItemCount()
        for i in range(1, num):
            item = self.list_ctrl.GetNextSelected(item)
            self.list_ctrl.SetItemBackgroundColour(item, col=colout)

            if luminance < luminance_cutoff:
                self.list_ctrl.SetItemTextColour(item, col=white_text)
            else:
                self.list_ctrl.SetItemTextColour(item, col=black_text)

            peak = tofloat(self.list_ctrl.GetItem(item, col=1).GetText())
            i = ud.nearest(self.pks.masses, peak)
            self.pks.peaks[i].color = topcolor

        newevent = wx.PyCommandEvent(self.EVT_DELETE_SELECTION_2._getEvtType(),
                                     self.GetId())
        self.GetEventHandler().ProcessEvent(newevent)
예제 #29
0
 def buttonClick(e):
     data = wx.ColourData()
     data.SetChooseFull(True)
     data.SetColour(button.GetBackgroundColour())
     dialog = wx.ColourDialog(self, data)
     if dialog.ShowModal() == wx.ID_OK:
         (red, green, blue) = dialog.GetColourData().GetColour().Get()
         color = wx.Colour(red, green, blue, 255)
         button.SetBackgroundColour(color)
예제 #30
0
 def OnLeftDown(self, evt):
     data = wx.ColourData()
     data.SetColour(self.GetValue())
     dlg = wx.ColourDialog(self, data)
     if dlg.ShowModal() == wx.ID_OK:
         self.SetValue('#%02X%02X%02X' %
                       dlg.GetColourData().GetColour().Get())
         self.SetModified()
     dlg.Destroy()