No color in pyprogress

hi,
I cannot see color in pyprogress sample.
window is

and after half time :

image
There is no color. Is it expected?

platform windows10
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
wxPython 4.2.0

code to reproduce

import wx
import wx.lib.agw.pyprogress as PP

# Our normal wxApp-derived class, as usual
app = wx.App(0)

dlg = PP.PyProgress(None, -1, "PyProgress Example",
                    "An Informative Message",
                    agwStyle=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)

dlg.SetGaugeProportion(0.4)
dlg.SetGaugeSteps(50)
dlg.SetGaugeBackground(wx.BLACK)
dlg.SetFirstGradientColour(wx.WHITE)
dlg.SetSecondGradientColour(wx.BLUE)
max = 400
keepGoing = 1
count = 0
while keepGoing and count < max:
    count += 1
    wx.MilliSleep(30)
    if count >= max // 2:
        keepGoing = dlg.UpdatePulse("Half-time!")
    else:
        keepGoing = dlg.UpdatePulse()
dlg.Destroy()
app.MainLoop()

Hi,

I tested the code using Python 3.10.6 | wxPython 4.2.0 gtk3 (phoenix) wxWidgets 3.2.0 | Linux Mint 21.1.

I did get a black background, but didn’t get the gradient colours:

Screenshot at 2023-01-23 11-11-58

Looking in the pyprogress.py module in the definition for ProgressGauge.DrawProgress() there is a for-loop that draws the gradient as a series of vertical lines. At the end of the for-loop it recalculates the values of variables rf, gf and bf as floats. When I converted these to ints, I did get the gradient colours:

        for ii in range(int(self._pos), int(self._pos+interval)):
            currCol = (r1 + rf, g1 + gf, b1 + bf)
            dc.SetPen(wx.Pen(currCol, 2))
            dc.DrawLine(ii, 1, ii, ysize-2)
            rf = int(rf + rstep)
            gf = int(gf + gstep)
            bf = int(bf + bstep)

Screenshot at 2023-01-23 11-21-16

2 Likes

Is gauge changing?

Yes, the gauge moves as expected. I made a GIF to demonstrate. Note, the GIF flickers a bit more than the actual gauge.

pyprogress_2-2023-01-23_13.09.23

time is changing but nothing more

Hi Laurent,

I tested your code with wx 4.2.0 / Python 3.10.4 on Windows 64bit and confirmed there is no colour and no progress as you mentioned.
I’m not sure if this behavior is specific to Windows, but creating one dummy frame object worked:

import wx
import wx.lib.agw.pyprogress as PP

# Our normal wxApp-derived class, as usual
app = wx.App(0)

def test():
    dlg = PP.PyProgress(None, -1, "PyProgress Example",
                        "An Informative Message",
                        agwStyle=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME)
    
    dlg.SetGaugeProportion(0.4)
    dlg.SetGaugeSteps(50)
    dlg.SetGaugeBackground(wx.BLACK)
    dlg.SetFirstGradientColour(wx.WHITE)
    dlg.SetSecondGradientColour(wx.BLUE)
    max = 100
    keepGoing = 1
    count = 0
    while keepGoing and count < max:
        count += 1
        wx.MilliSleep(30)
        if count >= max // 2:
            keepGoing = dlg.UpdatePulse("Half-time!")
        else:
            keepGoing = dlg.UpdatePulse()
    dlg.Destroy()

wx.CallAfter(test) # Start after main loop

wx.Frame(None)
app.MainLoop()

The solution shown by Richard fixed the color problem on Windows as well.
image