Пример #1
0
    def _createColorButtons(self):
        """Generate color buttons based on the presets defined in the `colors`
        module.

        When a user clicks on the buttons, it changes the current color the
        colorspace page is displaying.

        """
        # create buttons for each preset color
        colorList = list(colorNames)
        btnSize = wx.Size(120, 24)
        for color in colorList:
            btn = GenButton(self, size=btnSize, label=color, name=color)
            btn.colorData = col = Color(color, 'named')
            btn.SetOwnBackgroundColour(col.rgba255)

            # Compute the (perceived) luminance of the color, used to set the
            # foreground text to ensure it's legible on the background. Uses the
            # the luminance part of formula to convert RGB1 to YIQ.
            luminance = np.sum(np.asarray((0.299, 0.587, 0.114)) * col.rgb1)
            if luminance < 0.5:
                btn.SetForegroundColour(wx.WHITE)
            else:
                btn.SetForegroundColour(wx.BLACK)

            btn.SetBezelWidth(0)
            btn.SetUseFocusIndicator(False)
            btn.Bind(wx.EVT_BUTTON, self.onClick)
            self.sizer.Add(btn, 1, wx.ALL | wx.EXPAND, 0)
Пример #2
0
 def __init__(self, parent):
     ScrolledPanel.__init__(self, parent, size=(120,400), style=wx.VSCROLL | wx.BORDER_NONE)
     self.sizer = wx.GridBagSizer()
     self.parent = parent
     for i in range(len(colorNames)):
         color = list(colorNames)[i]
         btn = GenButton(self, size=(100, 30),
                            label=color, name=color)
         btn.SetOwnBackgroundColour(Color(color, 'named').rgba255)
         btn.SetBezelWidth(0)
         btn.SetUseFocusIndicator(False)
         btn.colorData = color
         #btn.SetBackgroundColour(wx.Colour(Color(color, 'named').rgba1))
         btn.Bind(wx.EVT_BUTTON, self.onClick)
         self.sizer.Add(btn, pos=(i,0))
     self.SetSizer(self.sizer)
     self.SetupScrolling()
Пример #3
0
 def __init__(self, parent, font, clickedCallback, texts, default):
     self.texts = texts
     self.clickedCallback = clickedCallback 
     self.buttons = []
     btnId = 10000
     for text in self.texts:
         btn = GenButton(parent, id = btnId, label = text)
         btn.SetBezelWidth(0)
         btn.SetUseFocusIndicator(False)
         btn.SetBackgroundColour(basePurple)
         if text == default:
     		btn.SetForegroundColour(btnForegroundSel)
         else:			
            	btn.SetForegroundColour(btnForeground)
         btn.SetFont(font)
         btn.Bind(wx.EVT_LEFT_DOWN, self.OnDown)
         btn.Bind(wx.EVT_LEFT_UP, self.OnUp)
         btn.Bind(wx.EVT_LEFT_DCLICK, self.DoNothing)
         btn.Bind(wx.EVT_MOTION, self.DoNothing)
 	    self.buttons.append(btn)
         btnId+=1
 	self.current = default
Пример #4
0
 def create_begin(self):
     main_sizer = wx.BoxSizer(wx.VERTICAL)
     self.SetFont(
         wx.Font(25,
                 wx.FONTFAMILY_MODERN,
                 wx.FONTSTYLE_NORMAL,
                 wx.FONTWEIGHT_BOLD,
                 faceName="Roboto"))
     begin_button = GenButton(self,
                              id=-1,
                              label="Arrange",
                              size=(200, 55),
                              style=wx.BORDER_SIMPLE)
     begin_button.SetForegroundColour(wx.Colour(255, 255, 255))
     begin_button.SetBezelWidth(1)
     begin_button.SetBackgroundColour('#5f9ad8')
     begin_button.SetCursor(wx.Cursor(
         wx.CURSOR_HAND))  #StockCursor deprecated
     begin_button.SetWindowStyleFlag(wx.RAISED_BORDER)
     main_sizer.AddStretchSpacer()
     main_sizer.Add(begin_button, 0, wx.CENTER)
     main_sizer.AddStretchSpacer()
     self.SetSizer(main_sizer)
     self.Bind(wx.EVT_BUTTON, self.onDir, begin_button)