[wxPython] Button border and colour

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Button border and colour

Gordon Williams
Hello All,

I am having some problems with buttons.  I cant change the style of the
border and the colour of the button.

The 3D effect of these buttons is also not very good as the white line is
missing from the bottom and right edges when the button is depressed.  Can
this be fixed?

I would also like to know if the width of the border can be changed to make
the button stand out?  Is there a way to set the boarder to say 4 pixels?

thanks,

Gordon Williams






from wxPython.wx import *

#----------------------------------------------------------------------

class TestPanel(wxPanel):
    def __init__(self, parent):
        wxPanel.__init__(self, parent, -1)
        but_Hello1_ID= wxNewId()
        but_Hello2_ID= wxNewId()
       
         
        wxButton(self, but_Hello1_ID, "Hello THICK FRAME", wxPoint(20, 20),
         style= wxTHICK_FRAME).SetDefault()
        EVT_BUTTON(self, but_Hello1_ID, self.OnClick)

        X=wxButton(self, but_Hello2_ID, "HELLO SUNKEN BORDER and blue!",
             wxPoint(20, 60), wxSize(-1, -1), style=wxSUNKEN_BORDER)
        X.SetBackgroundColour(wxBLUE)     ###### should be blue
        EVT_BUTTON(self, but_Hello2_ID, self.OnClick)
       
        wxButton(self, 10, "HELLO DOUBLE BORDER!",
             wxPoint(20, 90), wxSize(-1, -1), style=wxDOUBLE_BORDER)
        EVT_BUTTON(self, 10, self.OnClick)
       
        wxButton(self, 20, "HELLO SIMPLE BORDER!",
             wxPoint(20, 120), wxSize(-1, -1), style=wxSIMPLE_BORDER)
        EVT_BUTTON(self, 20, self.OnClick)
         
       
        self.SetBackgroundColour(wxNamedColour("MEDIUM ORCHID"))


    def OnClick(self, event):
        print "Click! (%d)\n" % event.GetId()


if __name__ == '__main__':

    class MainFrame(wxFrame):
        def __init__(self):
            wxFrame.__init__(self, NULL, -1, "Testing...")

            self.CreateStatusBar()
            mainmenu = wxMenuBar()
            menu = wxMenu()
            menu.Append(200, 'E&xit', 'Get the heck outta here!')
            mainmenu.Append(menu, "&File")
            self.SetMenuBar(mainmenu)
            EVT_MENU(self, 200, self.OnExit)
           
            self.panel = TestPanel(self)
            self.SetSize(wxSize(400, 500))

        def OnCloseWindow(self, event):
            self.Destroy()

        def OnExit(self, event):
            self.Close(true)


    class TestApp(wxApp):
       
        def OnInit(self):
            frame = MainFrame()
            frame.Show(true)
            self.SetTopWindow(frame)
            return true
   

    app = TestApp(0)
    app.MainLoop()
 


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Button border and colour

Robin Dunn
> I am having some problems with buttons.  I cant change the style of the
> border and the colour of the button.
>

I noticed the issue of color on the wxButton for wxMSW myself a few days ago
and have asked wxwin-developers about it.  It works okay for wxGTK.

> The 3D effect of these buttons is also not very good as the white line is
> missing from the bottom and right edges when the button is depressed.  Can
> this be fixed?
>
> I would also like to know if the width of the border can be changed to make
> the button stand out?  Is there a way to set the boarder to say 4 pixels?
>

For the rest of these you'll have to talk to Bill Gates about since the
native control is used. ;-)

I am thinking about implementing a wxGenericButton that won't use the native
control but will just draw itself.  It would easily be able to support things
like what you ask for and could be easily extended to implement a
wxToggleButton as well.  The trouble is, I don't know when I'll be able to
get to it.  If anybody wants to take this on let me know and I'll share more
details of my idea with you.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users