コード例 #1
0
ファイル: PlotOptions.py プロジェクト: rocdat/STLIB
 def onClick(self, event):
     # Get a color.
     color = wx.GetColourFromUser(None)
     if color.IsOk():
         self.color = color
         self.colorButton.SetBitmapLabel(makeBitmap(color))
     event.Skip()
コード例 #2
0
 def onCellLeftClick(self, event):
     row, col = event.GetRow(), event.GetCol()
     if col in (1, 5):
         color = wx.GetColourFromUser(None)
         if color.IsOk():
             self.SetCellBackgroundColour(row, col, color)
     # Let the cell be selected.
     event.Skip()
コード例 #3
0
 def ChangePalette(self, event):
     pIdx = event.GetId()-self.ID_PALETTE_BMBS
     newColor = wx.GetColourFromUser(None, self.palColors[pIdx])
     #if newColor.Ok() == False: # Dialog cancelled
     if newColor.IsOk() == False: # Dialog cancelled
         return # No
     
     self.ChangePal(pIdx,newColor)
コード例 #4
0
 def OnChangeModelColor(self, event):
     menu = event.GetEventObject()
     model_id = menu.GetTitle()
     model = self.get_model(model_id)
     if model is not None:
         base_color = [int(x * 255) for x in model.base_color]
         new_color = wx.GetColourFromUser(self, base_color)
         new_color = [x / 255 for x in new_color]
         model.set_base_color(new_color)
         model.refresh()
         self.update_scene = True
コード例 #5
0
    def OnKeyDown(self, evt):
        if self.last_selected is not None:
            # Right key - Increase node value
            if evt.GetKeyCode() in (wx.WXK_RIGHT, wx.WXK_NUMPAD_RIGHT):
                n = self.last_selected
                n.value = self.pixel_to_hounsfield(
                    self.hounsfield_to_pixel(n.value) + 1)
                self.Refresh()
                self._generate_event()

            # Left key - Decrease node value
            elif evt.GetKeyCode() in (wx.WXK_LEFT, wx.WXK_NUMPAD_LEFT):
                n = self.last_selected
                n.value = self.pixel_to_hounsfield(
                    self.hounsfield_to_pixel(n.value) - 1)
                self.Refresh()
                self._generate_event()

            # Enter key - Change node colour
            elif evt.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER):
                n = self.last_selected
                colour_dialog = wx.GetColourFromUser(self, n.colour)
                if colour_dialog.IsOk():
                    r, g, b = colour_dialog.Get()
                    n.colour = r, g, b
                    self.Refresh()
                    self._generate_event()

            # Delete key - Deletes a node.
            elif evt.GetKeyCode() in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE):
                n = self.last_selected
                self.last_selected = None
                self.nodes.remove(n)
                self.Refresh()
                self._generate_event()

            # (Shift + )Tab key - selects the (previous) next node
            elif evt.GetKeyCode() == wx.WXK_TAB:
                n = self.last_selected
                self.nodes.sort()
                idx = self.nodes.index(n)
                if evt.ShiftDown():
                    nidx = (idx - 1) % len(self.nodes)
                else:
                    nidx = (idx + 1) % len(self.nodes)
                self.last_selected = self.nodes[nidx]
                self.Refresh()
        evt.Skip()
コード例 #6
0
ファイル: imwin_native.py プロジェクト: sgricci/digsby
    def OnBCToolClicked(self, event):
        """
        Set the background color for messages
        """
        tc = self.frame.notebook.ActiveTab.input_area.tc
        newcolor = wx.GetColourFromUser(self.frame, tc.BackgroundColour,
                                        _('Choose a background color'))

        if newcolor.IsOk():
            #input_area.tc.BackgroundColour = newcolor
            attrs = tc.GetDefaultStyle()
            attrs.SetBackgroundColour(newcolor)
            tc.SetDefaultStyle(attrs)

        tc.Refresh()
        self.frame.notebook.ActiveTab.FocusTextCtrl()
コード例 #7
0
 def OnDoubleClick(self, evt):
     """
     Used to change the colour of a point
     """
     point = self._has_clicked_in_a_point(evt.GetPosition())
     if point:
         i, j = point
         actual_colour = self.curves[i].nodes[j].colour
         colour_dialog = wx.GetColourFromUser(self, actual_colour)
         if colour_dialog.IsOk():
             i, j = point
             r, g, b = colour_dialog.Get()
             self.colours[i][j]['red'] = r / 255.0
             self.colours[i][j]['green'] = g / 255.0
             self.colours[i][j]['blue'] = b / 255.0
             self.curves[i].nodes[j].colour = (r, g, b)
             self.Refresh()
             nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i)
             self.GetEventHandler().ProcessEvent(nevt)
             return
     evt.Skip()
コード例 #8
0
    def OnDoubleClick(self, evt):
        w, h = self.GetVirtualSize()
        px, py = evt.GetPositionTuple()

        # Verifying if the user double-click in a node-colour.
        selected_node = self.get_node_clicked(px, py)
        if selected_node:
            # The user double-clicked a node colour. Give the user the
            # option to change the color from this node.
            colour_dialog = wx.GetColourFromUser(self, (0, 0, 0))
            if colour_dialog.IsOk():
                r, g, b = colour_dialog.Get()
                selected_node.colour = r, g, b
                self._generate_event()
        else:
            # The user doesn't clicked in a node colour. Creates a new node
            # colour with the DEFAULT_COLOUR
            vx = self.pixel_to_hounsfield(px)
            node = Node(vx, DEFAULT_COLOUR)
            self.nodes.append(node)
            self._generate_event()

        self.Refresh()
コード例 #9
0
ファイル: func.py プロジェクト: duolabmeng6/pyefun
def 组件_颜色选择器(初始颜色=None, 标题="请选择颜色", 父窗口=None):
    "选择颜色后返回颜色值(0,0,0,255),可添加参数,flags(标识),parent(父窗口),x,y"
    return wx.GetColourFromUser(父窗口, 初始颜色, 标题)
コード例 #10
0
ファイル: webkiteditor.py プロジェクト: sgricci/digsby
 def get_set_color(title, okfunc):
     c = wx.GetColourFromUser(f, caption=title)
     if c.IsOk(): okfunc(c.GetAsString(wx.C2S_HTML_SYNTAX))
コード例 #11
0
    editor = WebKitEditor(f)
    editor.SetPageSource('<html><body></body></html>')
    editor.MakeEditable(True)

    but = lambda label, callback: Button(
        f, label, callback, style=wx.BU_EXACTFIT)

    editbuttons = [
        ('B', editor.Bold),
        ('I', editor.Italic),
        ('U', editor.Underline),
        ('A+', lambda: editor.FontSizeDelta(True, 1)),
        ('A-', lambda: editor.FontSizeDelta(True, -1)),
        ('bg', lambda: editor.BackColor(
            True,
            wx.GetColourFromUser().GetAsString(wx.C2S_HTML_SYNTAX))),
        ('fg', lambda: editor.ForeColor(
            True,
            wx.GetColourFromUser().GetAsString(wx.C2S_HTML_SYNTAX))),
    ]

    # layout gui
    bsizer = wx.BoxSizer(wx.HORIZONTAL)
    for label, callback in editbuttons:
        bsizer.Add(but(label, callback))

    fs.Add(bsizer, 0, wx.EXPAND)
    fs.Add(editor, 1, wx.EXPAND)

    # run
    f.Show()
コード例 #12
0
ファイル: formattedinput.py プロジェクト: sgricci/digsby
    def OnBGColor(self,event):
        'Calls the color chooser for setting font background color.'

        newcolor = wx.GetColourFromUser(self, self.tc.BackgroundColour, _('Choose a background color'))
        self.update_bgcolor(newcolor)
コード例 #13
0
ファイル: formattedinput.py プロジェクト: sgricci/digsby
    def OnColor(self, event = None):
        "Calls the color chooser for setting font color."

        newcolor = wx.GetColourFromUser(self, self.tc.ForegroundColour, _('Choose a foreground color'))
        self.update_color(newcolor)
コード例 #14
0
#! /usr/bin/env python
# coding:utf-8

import wx

if __name__ == "__main__":
    app = wx.PySimpleApp()
    dialog = wx.ColourDialog(None)
    dialog.GetColourData().SetChooseFull(True)
    if dialog.ShowModal() == wx.ID_OK:
        data = dialog.GetColourData()
        print "You selected: %s\n" % str(data.GetColour().Get())

    dialog.Destroy()

    # 函数
    c = wx.Colour(255, 255, 255)
    retC = wx.GetColourFromUser(None, c)
    print(retC.Ok())
'''
wx.ColourData.SetChooseFull(self,int flag)
    Under Windows, tells the Windows colour dialog to display the full dialog with custom colour controls.
    Under other platforms, has no effect. The default value is true.
'''
コード例 #15
0
 def OnColorButton(self, event):
     oldtextcolor = self.textctrl.GetFormat().GetTextColour()
     self.textctrl.ApplyStyle(textcolor = wx.GetColourFromUser(self, oldtextcolor, _('Choose a foreground color')))
コード例 #16
0
 def _on_fg_color_clicked(self, e):
     color = wx.GetColourFromUser(
         self, self.editor.content_format['color']
         or '#000000').GetAsString(wx.C2S_HTML_SYNTAX)
     self.editor.format_content('color', color)
     self._display_color_format(color)
コード例 #17
0
 def OnBGColorButton(self, event):
     oldbgcolor = self.textctrl.GetFormat().GetTextColour()
     self.textctrl.ApplyStyle(bgcolor = wx.GetColourFromUser(self, oldbgcolor, _('Choose a background color')))
コード例 #18
0
 def _on_bg_color_clicked(self, e):
     color = wx.GetColourFromUser(
         self, self.editor.content_format['background']
         or '#ffffff').GetAsString(wx.C2S_HTML_SYNTAX)
     self.editor.format_content('background', color)
     self._display_background_format(color)
コード例 #19
0
 def on_press(event, ctl=ctl, parent=self):
     color = wx.GetColourFromUser(self, ctl.BackgroundColour)
     if any([x != -1 for x in color.Get()]):
         ctl.BackgroundColour = color
         ctl.Refresh()
コード例 #20
0
 def on_bkg_color(self, event):
     self.backgroundBrush = wx.Brush(
         wx.GetColourFromUser(colInit=self.backgroundBrush.Colour))
     self.draw()