示例#1
0
    def OnForeClick(self, event):
        colordata = wx.ColourData()
        colordata.SetChooseFull(True)
        fore = self.obj_ID_FORE_VALUE.GetValue()
        if fore:
            colour = wx.Colour(*self.StrToRGB(fore))
            colordata.SetColour(colour)

        dlg = wx.ColourDialog(self, colordata)
        if dlg.ShowModal() == wx.ID_OK:
            color = dlg.GetColourData().GetColour()
            self.obj_ID_FORE_VALUE.SetValue(self.RGBToStr(color.Get()))
        dlg.Destroy()
        self.update = True
示例#2
0
    def on_change_high_color(self, event):
        """Change the high color and refresh display."""
        print("High color menu item clicked!")
        cd = wx.ColourDialog(self)
        cd.GetColourData().SetChooseFull(True)

        if cd.ShowModal() == wx.ID_OK:
            new_color = cd.GetColourData().Colour
            print("The color {} was chosen!".format(new_color))
            self.panel.on_color_change({'high': new_color, 'low': None})
            self.panel.Refresh()
        else:
            print("no color chosen :-(")
        cd.Destroy()
    def open_color_dialog(self, event):
        """ Opens the color dialog and sets the value upon return
        """
        color_data = wx.ColourData()
        color_data.SetColour(self.value)

        color_dialog = wx.ColourDialog(self.control, color_data)
        result = color_dialog.ShowModal()
        if result == wx.ID_CANCEL:
            return

        color = color_dialog.GetColourData().GetColour()
        self.value = color
        self.set_color()
示例#4
0
    def selectionCouleur(self, event):
        couleur_data = wx.ColourData()
        couleur_data.SetColour(self.text_Couleur.GetBackgroundColour())

        dlg = wx.ColourDialog(self, couleur_data)

        if dlg.ShowModal() == wx.ID_OK:
            self.couleur_fournisseur = dlg.GetColourData()
            couleur_data = self.couleur_fournisseur.GetColour()
            couleur_hex = couleur_data.GetAsString(wx.C2S_HTML_SYNTAX)
            self.text_Couleur.SetBackgroundColour(couleur_hex)
            self.text_Couleur.SetValue(couleur_hex)

        dlg.Destroy()
示例#5
0
 def on_button_layer(self,
                     event):  # wxGlade: OperationProperty.<event_handler>
     data = wx.ColourData()
     if self.operation.color is not None and self.operation.color != 'none':
         data.SetColour(wx.Colour(swizzlecolor(self.operation.color)))
     dlg = wx.ColourDialog(self, data)
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetColourData()
         color = data.GetColour()
         rgb = color.GetRGB()
         color = swizzlecolor(rgb)
         self.operation.color = Color(color, 1.0)
         self.button_layer_color.SetBackgroundColour(
             wx.Colour(swizzlecolor(self.operation.color)))
     self.device.signal('element_property_update', self.operation)
示例#6
0
def CreateColorPicker(self, currentcolor=wx.NullColour):
    # Simple wrapper class for creating color picker dialogs
    color = wx.ColourData()

    if not currentcolor is wx.NullColour:
        color.SetColour(currentcolor)

    tmp_dialog = wx.ColourDialog(self, color)
    evnt = tmp_dialog.ShowModal()

    if evnt == wx.ID_OK:
        rawcolordata = tmp_dialog.GetColourData()
        return rawcolordata.GetColour()
    else:
        return wx.NullColour
示例#7
0
    def OnAmbientChooseColor(self, event):

        dlg = wx.ColourDialog(self.parent)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetColourData()
            (r, g, b) = data.GetColour().Get()
            #print "Changing Background color to: ", str(float(r)) ,str(float(g)),str(float(b))
            self.ambientcolour.Set(r, g, b)
            self.window.sceneManager.ambientLight = ((float(r) / 255),
                                                     (float(g) / 255),
                                                     (float(b) / 255))
        dlg.Destroy()

        self.parent.update()
    def OnBackClick(self, event):
        colordata = wx.ColourData()
        colordata.SetChooseFull(True)
        back = self.obj_ID_BACK_VALUE.GetValue()
        if back:
            colour = wx.Colour(*self.StrToRGB(back))
            colordata.SetColour(colour)
            c = colordata.GetColour()

        dlg = wx.ColourDialog(self, colordata)
        if dlg.ShowModal()== wx.ID_OK:
            color = dlg.GetColourData().GetColour()
            self.obj_ID_BACK_VALUE.SetValue(self.RGBToStr(color.Get()))
        dlg.Destroy()
        self.update = True
示例#9
0
    def OnChooseColor(self, event):

        dlg = wx.ColourDialog(self.parent)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetColourData()
            (r, g, b) = data.GetColour().Get()
            #print "Changing Background color to: ", str(float(r)) ,str(float(g)),str(float(b))
            self.bgcolour.Set(r, g, b)
            self.ogreView.viewport.backgroundColour = ((float(r) / 255),
                                                       (float(g) / 255),
                                                       (float(b) / 255))
        dlg.Destroy()

        self.parent.update()
示例#10
0
 def on_rdc(self, event):
     x, y = event.GetX() - self.offset[0], event.GetY() - self.offset[1]
     self.idx = self.pick(x, y)
     if self.idx == -1: return
     dlg = wx.ColourDialog(self)
     dlg.GetColourData().SetChooseFull(True)
     if dlg.ShowModal() == wx.ID_OK:
         rst = dlg.GetColourData().GetColour()
         x = self.pts[self.idx][0]
         self.pts[self.idx] = (x, ) + rst[:-1]
         self.idx = -1
         self.cmap[:] = self.linear_color(self.pts)
         self.update = True
     dlg.Destroy()
     self.handle()
示例#11
0
    def OnClick(self, event):
        data = wx.ColourData()
        data.SetChooseFull(True)
        data.SetColour(self.colour)
        dlg = wx.ColourDialog(wx.GetTopLevelParent(self), data)
        changed = dlg.ShowModal() == wx.ID_OK

        if changed:
            data = dlg.GetColourData()
            self.SetColour(data.GetColour())
        dlg.Destroy()

        # moved after dlg.Destroy, since who knows what the callback will do...
        if changed:
            self.OnChange()
示例#12
0
 def click(event=None):
     color_data = wx.ColourData()
     color_data.SetColour(wx.Colour(swizzlecolor(ctrl.color)))
     dlg = wx.ColourDialog(self, color_data)
     if dlg.ShowModal() == wx.ID_OK:
         color_data = dlg.GetColourData()
         data = Color(
             swizzlecolor(color_data.GetColour().GetRGB()), 1.0
         )
         set_color(data)
         try:
             setattr(obj, param, data_type(data))
         except ValueError:
             # cannot cast to data_type, pass
             pass
示例#13
0
 def OnShowDialog(self, event):
     colour_data = wx.ColourData()
     # Initialize to the current colour of the panel
     colour = self.GetBackgroundColour()
     colour_data.SetColour(colour)
     # Use the extended dialog when available
     colour_data.SetChooseFull(True)
     # Construct the dialog
     dlg = wx.ColourDialog(self, colour_data)
     if dlg.ShowModal() == wx.ID_OK:
         # Change the background colour
         colour = dlg.GetColourData().GetColour()
         self.SetBackgroundColour(colour)
         self.Refresh()
     dlg.Destroy()
示例#14
0
 def set_bg_color(self, *args):
     d = wx.ColourDialog(self)
     d.GetColourData().SetChooseFull(True)
     if d.ShowModal() == wx.ID_OK:
         data = d.GetColourData()
         r, g, b = data.GetColour().Get()
         color = r / 255., g / 255., b / 255.
         self.canvas.OnColor(color)
         fg_r = 255 - r
         fg_g = 255 - g
         fg_b = 255 - b
         fg_color = fg_r / 255., fg_g / 255., fg_b / 255.
         self.renderOptions.set_fg_color(fg_color)
         self.render()
     return
示例#15
0
 def OnButtonPress(self, event):
     # Set the initial color of the color dialog
     # box to the current button color
     data = wx.ColourData()
     data.SetChooseFull(True)
     currentColor = self.GetBackgroundColour()
     data.SetColour(
         wx.Colour(currentColor[0], currentColor[1], currentColor[2]))
     # Get the new color from the user
     self.dlg = wx.ColourDialog(self, data)
     if self.dlg.ShowModal() == wx.ID_OK:
         self.color = \
             self.dlg.GetColourData().GetColour()[0:3] # Remove Opacity
         self.SetBackgroundColour(self.color)
     self.dlg.Destroy()
     event.Skip()
示例#16
0
    def OnSelectColor(self, evt):
        dlg = wx.ColourDialog(self)
        dlg.GetColourData().SetChooseFull(True)

        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetColourData()
            #            wx.TextAttr(colText, colBack=wx.NullColor, font=wx.NullFont)
            #            self.txt_chatInput.SetStyle(68, 82,
            #            self.txt_chatInput.textAttr.SetTextColour(data.GetColour())
            #          attr.SetTextColour(colour)
            attr = wx.TextAttr(data.GetColour())
            self.txt_chatInput.SetStyle(r, attr)

            #            print('You selected: %s\n' % str(data.GetColour().Get()))

        dlg.Destroy()
示例#17
0
    def __on_color_dlg(self, event, msg, data):
        import wx

        assert isinstance(data, ColorMixin)
        color_data = wx.ColourData()
        orig_color = data.color
        r, g, b = [int(x * 255) for x in data.color]
        color_data.SetColour(wx.Colour(r, g, b))
        window = self.__get_window_from_event(event)
        with wx.ColourDialog(window, color_data) as dlg:
            assert isinstance(dlg, wx.ColourDialog)
            dlg.Title = msg
            if dlg.ShowModal() == wx.ID_OK:
                color_data = dlg.GetColourData()
                data.color = tuple([float(x) / 255 for x in color_data.Colour])
                self.refresh()
    def change_low_color(self, event):
        print("Low Color menu item clicked!")
        cd = wx.ColourDialog(self)
        cd.GetColourData().SetChooseFull(True)

        if cd.ShowModal() == wx.ID_OK:
            new_color = cd.GetColourData().Colour
            print("The color {} was chosen!".format(new_color))
            self.panel.wm_panel.on_color_change({
                'high': None,
                'low': new_color
            })
            self.panel.wm_panel.Refresh()
        else:
            print("no color chosen :-(")
        cd.Destroy()
示例#19
0
    def onPointColour(self, event):
        """Change text colour."""

        colour = self.pointcolour.GetBackgroundColour()
        wxcolour = wx.ColourData()
        wxcolour.SetColour(colour)

        dialog = wx.ColourDialog(self, data=wxcolour)
        dialog.GetColourData().SetChooseFull(True)
        new_colour = None
        if dialog.ShowModal() == wx.ID_OK:
            new_colour = dialog.GetColourData().Colour
        dialog.Destroy()

        if new_colour:
            self.pointcolour.SetBackgroundColour(new_colour)
示例#20
0
    def on_button_press(self, event):
        dialog = wx.ColourDialog(self.panel)
        if dialog.ShowModal() == wx.ID_OK:
            colour = dialog.GetColourData()
            hex_colour = colour.Colour.GetAsString(flags=wx.C2S_HTML_SYNTAX)
            self.panel.SetBackgroundColour(colour.Colour)
            self.panel.Refresh()
            self.text.SetLabel(hex_colour)
            self.panel.Layout()
            col = colour.Colour
            if (col.red * 0.299 + col.green * 0.587 + col.blue * 0.114) > 186:
                self.text.SetForegroundColour('black')
            else:
                self.text.SetForegroundColour('white')

            self.event({'colour': colour.Colour, 'hex': hex_colour, 'key': self.key})
示例#21
0
文件: RibbonBar.py 项目: rwal127/Qube
    def OnColourGalleryButton(self, event):

        gallery = event.GetEventObject()
        if gallery is None:
            return

        self._ribbon.DismissExpandedPanel()
        if gallery.GetSelection():
            self._colour_data.SetColour(
                self.GetGalleryColour(gallery, gallery.GetSelection(),
                                      None)[0])

        dlg = wx.ColourDialog(self, self._colour_data)

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

            self._colour_data = dlg.GetColourData()
            clr = self._colour_data.GetColour()

            # Try to find colour in gallery
            item = None
            for i in xrange(gallery.GetCount()):
                item = gallery.GetItem(i)
                if self.GetGalleryColour(gallery, item, None)[0] == clr:
                    break
                else:
                    item = None

            # Colour not in gallery - add it
            if item == None:
                item = self.AddColourToGallery(
                    gallery, clr.GetAsString(wx.C2S_HTML_SYNTAX),
                    self._bitmap_creation_dc, clr)
                gallery.Realize()

            # Set selection
            gallery.EnsureVisible(item)
            gallery.SetSelection(item)

            # Send an event to respond to the selection change
            dummy = RB.RibbonGalleryEvent(
                RB.wxEVT_COMMAND_RIBBONGALLERY_SELECTED, gallery.GetId())
            dummy.SetEventObject(gallery)
            dummy.SetGallery(gallery)
            dummy.SetGalleryItem(item)
            self.GetEventHandler().ProcessEvent(dummy)
示例#22
0
 def onDoubleClick(self, event):
     #print event.m_itemIndex
     dlg = wx.ColourDialog(self)
     # Ensure the full colour dialog is displayed,
     # not the abbreviated version.
     dlg.GetColourData().SetChooseFull(True)
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetColourData()
     color = data.GetColour().Get()
     htmlColor = "#%02x%02x%02x" % color
     dlg.Destroy()
     index = event.m_itemIndex
     stored.plots[index]['Color'] = htmlColor
     self.plots[index].icon = self.plots[index].createIcon(
         self.plotsOlv, htmlColor)
     self.plotsOlv.RefreshObject(self.plots[index])
     pub.sendMessage('item.checked', data=self.checkedPlots)
示例#23
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent, wx.ID_ANY)
     rgb = 'None'
     dlg = wx.ColourDialog(self)
     dlg.GetColourData().SetChooseFull(True)
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetColourData()
         rgb = data.GetColour().Get()
         rgb = map(lambda x: "%.3f" % ((x-127.5)/127.5),list(rgb))
         rgb = '['+','.join(rgb)+']'
         if wx.TheClipboard.Open():
             #http://wiki.wxpython.org/AnotherTutorial#wx.TheClipboard
             wx.TheClipboard.Clear()
             wx.TheClipboard.SetData(wx.TextDataObject(str(rgb)))
             wx.TheClipboard.Close()
     dlg.Destroy()
     parent.new_rgb = rgb
示例#24
0
 def OnColor(self, event):
     """Launch color dialog"""
     button = event.GetEventObject()
     for i in range(0, len(self.lineCtrls)):
         if self.lineCtrls[i][2] == button:
             color = self.lineCtrls[i][1].GetValue()
             data = wx.ColourData()
             data.SetColour(self.MplToWxColour(color))
             dialog = wx.ColourDialog(self, data)
             dialog.GetColourData().SetChooseFull(True)
             if dialog.ShowModal() == wx.ID_OK:
                 data = dialog.GetColourData()
                 self.lineCtrls[i][1].SetValue("#%02x%02x%02x" %
                                               data.GetColour().Get())
                 self.lineCtrls[i][2].SetBackgroundColour(data.GetColour())
                 self.lineCtrls[i][2].ClearBackground()
                 self.lineCtrls[i][2].Refresh()
示例#25
0
 def configure_color(self, event):
     """ Asks the message color """
     # Creates a new color dialog
     dialog = wx.ColourDialog(None)
     dialog.GetColourData().SetChooseFull(True)
     dialog.GetColourData().SetColour(
         wx.Colour(self.message_color[0], self.message_color[1],
                   self.message_color[2]))
     # Asks the message color
     if dialog.ShowModal() == wx.ID_OK:
         # Reflects the new color
         data = dialog.GetColourData()
         self.message_color = data.GetColour().Get()
         self.button_color.SetBackgroundColour(self.message_color)
         self.button_color.SetForegroundColour(self.message_color)
     dialog.Destroy()
     return
示例#26
0
    def OnColor(self, event):

        annotation = self._get_selected_annotation()
        if annotation is None:
            return

        color_data = wx.ColourData()
        color_data.SetColour(self.ui.color.GetBackgroundColour())

        dialog = wx.ColourDialog(self, color_data)
        if dialog.ShowModal() != wx.ID_OK:
            return

        new_color = dialog.GetColourData().GetColour()
        self.ui.color.SetBackgroundColour(new_color)
        annotation.color = [c / 255. for c in new_color]
        self._image.render()
    def doubleclick(self, event):
        dlg = wx.ColourDialog(self)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetColourData()
            newcolor = tuple(
                [float(x) / 255 for x in data.GetColour().Get()])

            # idx = event.GetInt()
            # sid = self.listbox.GetString(idx)
            for idx in self.listbox.GetSelections():
                sid = self.listbox.GetString(idx)
                self.target.sid_color_map[sid] = newcolor

            self.target.status_changed()
            for child in self.target.children:
                child.propagate_down(UpdateEvent(None))
        dlg.Destroy()
示例#28
0
 def color(self):
     """display the colour dialog and select"""
     dlg = wx.ColourDialog(self)
     # get the full colour dialog
     # default is False and gives the abbreviated version
     dlg.GetColourData().SetChooseFull(True)
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetColourData()
         # gives red, green, blue tuple (r, g, b)
         # each rgb value has a range of 0 to 255
         rgb = data.GetColour().Get()
         #s = 'The selected colour (r, g, b) = %s' % str(rgb)
         #self.label.SetLabel(s)
         # set the panel's color and refresh
         #self.SetBackgroundColour(rgb)
         #self.Refresh()
     dlg.Destroy()
     return rgb
示例#29
0
 def OnButton(self, event):
     colourData = wx.ColourData()
     colourData.SetChooseFull(True)
     colourData.SetColour(self.value)
     for i, colour in enumerate(eg.config.colourPickerCustomColours):
         colourData.SetCustomColour(i, colour)
     dialog = wx.ColourDialog(self.GetParent(), colourData)
     dialog.SetTitle(self.title)
     if dialog.ShowModal() == wx.ID_OK:
         colourData = dialog.GetColourData()
         self.SetValue(colourData.GetColour().Get())
         event.Skip()
     eg.config.colourPickerCustomColours = [
         colourData.GetCustomColour(i).Get() for i in range(16)
     ]
     dialog.Destroy()
     evt = eg.ValueChangedEvent(self.GetId(), value=self.value)
     wx.PostEvent(self, evt)
示例#30
0
        def getColor(event):
            data = wx.ColourData()
            data.SetChooseFull(True)

            for i in range(0, 16):
                colour = wx.Colour(i * 16, i * 16, i * 16)
                data.SetCustomColour(i, colour)

            dialog = wx.ColourDialog(self, data)
            if dialog.ShowModal() == wx.ID_OK:
                retData = dialog.GetColourData()
                col = retData.GetColour()
                brush = wx.Brush(col, wx.SOLID)
                picture.setPaintBrushColor(
                    col[2],
                    col[1],
                    col[0],
                )