New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetForegroundColour and SetBackgroundColour not working on NumCtrl #808

Closed
miikeat opened this Issue Mar 30, 2018 · 2 comments

Comments

Projects
2 participants
@miikeat

miikeat commented Mar 30, 2018

Operating system: Windows 10
wxPython version: 4.0.1
Stock or custom build: stock
Python version: 3.6 x64
Stock or custom build: Stock

Description of the problem:

Setting the foreground or background colour on a NumCtrl (i guess all masked Ctrls are affected) only works when done on initialization.

This works:

    app=wx.App()
    frame=wx.Frame(None)
    num = NumCtrl(frame, value=0, foregroundColour='red', validBackgroundColour='blue')
    frame.Show(True)
    app.MainLoop()

And this not:

    app=wx.App()
    frame=wx.Frame(None)
    num = NumCtrl(frame, value=0)
    num.SetForegroundColour((255,0,0))
    num.SetBackgroundColour((0,0,255))
    frame.Show(True)
    app.MainLoop()
@miikeat

This comment has been minimized.

miikeat commented Apr 1, 2018

Wrote myself a little fix.
Seems like the only issue is, that the Set...Colour Methods also need to set the private variables

from wx.lib.masked import numctrl

class NumCtrl(numctrl.NumCtrl):
    def SetForegroundColour(self, color):
        super().SetForegroundColour(color)
        self._foregroundColour = color

    def SetBackgroundColour(self, color):
        super().SetBackgroundColour(color)
        self._validBackgroundColour = color
@RobinD42

This comment has been minimized.

Member

RobinD42 commented May 31, 2018

Fixed by #869

@RobinD42 RobinD42 closed this May 31, 2018

4.0.2 automation moved this from In progress to Done May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment