Exemplo n.º 1
0
    def BuildEllipticButtons(self):

        # Here We Build Elliptic Buttons. Elliptic Buttons Are Somewhat
        # More Hostiles To Handle, Probably Because My Implementation
        # Is Lacking Somewhere, But They Look Nice However.

        esizer = wx.FlexGridSizer(2, 2, 5, 5)

        btn1 = SButton(self.panel, -1, "Ellipse 1")
        btn1.SetEllipseAxis(2, 1)
        btn1.SetButtonColour(wx.RED)
        btn1.SetLabelColour(wx.WHITE)
        btn1.SetFont(
            wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD, False))
        btn1.Bind(wx.EVT_BUTTON, self.OnEllipse)

        btn2 = SButton(self.panel, -1, "Ellipse 2")
        btn2.SetEllipseAxis(2, 3)
        btn2.SetAngleOfRotation(90)
        btn2.SetLabelColour(wx.BLUE)
        btn2.SetFont(
            wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD, True))
        btn2.Bind(wx.EVT_BUTTON, self.OnEllipse)

        bmp = wx.Bitmap(os.path.join(bitmapDir, "ffwd.png"),
                        wx.BITMAP_TYPE_PNG)
        btn3 = SBitmapTextToggleButton(self.panel, -1, bmp, "FFWD")
        bmp = wx.Bitmap(os.path.join(bitmapDir, "rewind.png"),
                        wx.BITMAP_TYPE_PNG)
        btn3.SetBitmapSelected(bmp)
        btn3.SetEllipseAxis(1.4, 1)
        btn3.Bind(wx.EVT_BUTTON, self.OnFFWDRewind)

        bmp = wx.Bitmap(os.path.join(bitmapDir, "round.png"),
                        wx.BITMAP_TYPE_PNG)
        btn4 = SBitmapButton(self.panel, -1, bmp)
        btn4.SetEllipseAxis(1, 1.4)
        btn4.Bind(wx.EVT_BUTTON, self.OnRound)

        esizer.Add(btn1, 1, wx.EXPAND | wx.ALL, 5)
        esizer.Add(btn2, 1, wx.EXPAND | wx.ALL, 5)
        esizer.Add(btn3, 1, wx.EXPAND | wx.ALL, 5)
        esizer.Add(btn4, 1, wx.EXPAND | wx.ALL, 5)

        esizer.AddGrowableRow(0)
        esizer.AddGrowableRow(1)
        esizer.AddGrowableCol(0)
        esizer.AddGrowableCol(1)

        return esizer
Exemplo n.º 2
0
    def BuildNineButtons(self):

        # We Build 9 Buttons With Different Colours And A Nice Text Rotation

        colours = [None, wx.BLUE, wx.RED, wx.GREEN, wx.NamedColour("Gold"),
                   wx.NamedColour("Cyan"), wx.NamedColour("Yellow"),
                   wx.NamedColour("Orange"), wx.NamedColour("Magenta")]

        labels = ["These", "Are", "Some", "Nice", "Text", "Appended",
                  "To Different", "Buttons", "Nice Eh?"]

        fnt = self.GetFont()
        
        fonts = [fnt, wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD),
                 wx.Font(10, wx.TELETYPE, wx.NORMAL, wx.NORMAL),
                 wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, True),
                 fnt, wx.Font(9, wx.DECORATIVE, wx.NORMAL, wx.BOLD),
                 wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, "Tahoma"),
                 fnt, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, True, "Verdana")]

        lcolours = [None, wx.WHITE, wx.NamedColour("Yellow"), wx.WHITE,
                    None, None, wx.BLUE, wx.WHITE, wx.WHITE]

        bsizer = wx.FlexGridSizer(3, 3, 5, 5)
        rotation = []

        for ii in xrange(9):
            
            btn = SButton(self.panel, -1, labels[ii])
            btn.SetButtonColour(colours[ii])
            btn.SetFont(fonts[ii])
            btn.SetLabelColour(lcolours[ii])
            btn.SetUseFocusIndicator(True)
            btn.SetAngleOfRotation(45*ii)
            rotation.append(45*ii)
            btn.Bind(wx.EVT_BUTTON, self.OnNineButtons)

            bsizer.Add(btn, 1, wx.EXPAND | wx.BOTTOM | wx.RIGHT, 5)

        bsizer.AddGrowableRow(0)
        bsizer.AddGrowableRow(1)
        bsizer.AddGrowableRow(2)
        bsizer.AddGrowableCol(0)
        bsizer.AddGrowableCol(1)
        bsizer.AddGrowableCol(2)

        self.buttonlabels = labels
        self.buttonrotation = rotation
        
        return bsizer            
Exemplo n.º 3
0
    def BuildMixedButtons(self):

        # Here We Build Some Buttons/Toggles With Different Properties
        # Notice That We Put Some Images Also For The "Selected" State
        # For A Button

        btsizer = wx.FlexGridSizer(2, 2, 5, 5)

        bmp = wx.Bitmap(os.path.join(bitmapDir, "italy.gif"),
                        wx.BITMAP_TYPE_GIF)
        btn1 = SBitmapButton(self.panel, -1, bmp)
        bmp = wx.Bitmap(os.path.join(bitmapDir, "canada.gif"),
                        wx.BITMAP_TYPE_GIF)
        btn1.SetBitmapSelected(bmp)
        btn1.Bind(wx.EVT_BUTTON, self.OnItalyCanada)

        bmp = wx.Bitmap(os.path.join(bitmapDir, "stop.png"),
                        wx.BITMAP_TYPE_PNG)
        btn2 = SBitmapTextToggleButton(self.panel, -1, bmp, "Toggle!")
        bmp = wx.Bitmap(os.path.join(bitmapDir, "play.png"),
                        wx.BITMAP_TYPE_PNG)
        btn2.SetBitmapSelected(bmp)
        btn2.Bind(wx.EVT_BUTTON, self.OnTogglePlayStop)

        btn3 = SButton(self.panel, -1, "Rotated")
        btn3.SetButtonColour(wx.Colour("Cyan"))
        btn3.SetLabelColour(wx.WHITE)
        btn3.SetFont(
            wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD, False))
        btn3.SetAngleOfRotation(90)
        btn3.Bind(wx.EVT_BUTTON, self.OnRotated1)

        btn4 = SButton(self.panel, -1, "Button!")
        btn4.SetAngleOfRotation(45)
        btn4.Bind(wx.EVT_BUTTON, self.OnRotated1)

        btsizer.Add(btn1, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
        btsizer.Add(btn2, 1, wx.EXPAND | wx.BOTTOM, 5)
        btsizer.Add(btn3, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
        btsizer.Add(btn4, 1, wx.EXPAND)

        btsizer.AddGrowableRow(0)
        btsizer.AddGrowableRow(1)
        btsizer.AddGrowableCol(0)
        btsizer.AddGrowableCol(1)

        return btsizer