Button's label should stay left justified

Hi every body

I'm new here...

I have created a button with left justified label (see code),.
When the background coloumr of the button is changed,
the label is not left justified any more

import wx

class MyForm(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None)
        panel = wx.Panel(self)

        self.button = wx.Button(panel, size=(300, 20), label="Press
Me", style = wx.BU_LEFT)
        self.button.Bind(wx.EVT_BUTTON, self.onButton)
        self.Show()

    def onButton(self, event):
        self.button.SetBackgroundColour('Green')

if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    app.MainLoop()

Well, that smells like a bug to me. What OS and wxPython version? By
the way, the native button's on some platforms do not honor background
or foreground colors all the time. In fact, I've heard that they'll
sometimes ignore those methods depending on what theme is enabled.

I didn't find a generic button that allowed text alignment though, so
you may have to roll your own.

···

On Jul 30, 3:19 pm, Ilan <f28p...@gmail.com> wrote:

Hi every body

I'm new here...

I have created a button with left justified label (see code),.
When the background coloumr of the button is changed,
the label is not left justified any more

import wx

class MyForm(wx.Frame):

def \_\_init\_\_\(self\):
    wx\.Frame\.\_\_init\_\_\(self, None\)
    panel = wx\.Panel\(self\)

    self\.button = wx\.Button\(panel, size=\(300, 20\), label=&quot;Press

Me", style = wx.BU_LEFT)
self.button.Bind(wx.EVT_BUTTON, self.onButton)
self.Show()

def onButton\(self, event\):
    self\.button\.SetBackgroundColour\(&#39;Green&#39;\)

if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
app.MainLoop()

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi every body

I'm new here...

I have created a button with left justified label (see code),.
When the background coloumr of the button is changed,
the label is not left justified any more

When you change the color of a native button on MSW then it goes into "owner-drawn" mode, meaning that wx is doing the drawing of the button instead of Microsoft. My guess is that wx code simply does not pay attention to the alignment flags.

Mike Driscoll wrote:

I didn't find a generic button that allowed text alignment though, so
you may have to roll your own.

Alignment support can be added to the generic button classes by overriding the DrawLabel button in a derived class and drawing the label however you want.

···

On 7/30/10 1:19 PM, Ilan wrote:

--
Robin Dunn
Software Craftsman