Skip to content
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

traceback while changing HTMLLabel color #40

Closed
ccanepa opened this issue Aug 12, 2019 · 3 comments
Closed

traceback while changing HTMLLabel color #40

ccanepa opened this issue Aug 12, 2019 · 3 comments
Labels
crash Bugs which cause pyglet/python to crash reproducible Has example code which reproduces the issue

Comments

@ccanepa
Copy link
Contributor

ccanepa commented Aug 12, 2019

with this pure pyglet script

# file _pyglet_html_label.py
from __future__ import division, print_function, unicode_literals

import pyglet

window = pyglet.window.Window(640, 480)

x0 = window.width // 2
y0 = window.height // 2

t=0.0
color = (255, 255, 0, 255)

hlabel = pyglet.text.HTMLLabel('aloha',
                          x=x0, y=y0,
                          anchor_x='center')

@window.event
def on_draw():
    window.clear()
    hlabel.draw()

def update(dt):
    global t
    opacity = int(abs(255 - t % 511))
    hlabel.color = tuple(color[:3]) + (opacity,)
    t += dt

pyglet.clock.schedule_interval(update, 1 / 30.)
pyglet.app.run()

got crash with traceback

(py-cocos) E:\dev\cocos2019\test>python _pyglet_html_label.py
Traceback (most recent call last):
  File "_pyglet_html_label.py", line 29, in <module>
    pyglet.app.run()
  File "e:\dev\pyglet-2019\pyglet\app\__init__.py", line 144, in run
    event_loop.run()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 175, in run
    self._run()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 187, in _run
    timeout = self.idle()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 308, in idle
    redraw_all = self.clock.call_scheduled_functions(dt)
  File "e:\dev\pyglet-2019\pyglet\clock.py", line 327, in call_scheduled_functio
ns
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "_pyglet_html_label.py", line 25, in update
    hlabel.color = tuple(color[:3]) + (opacity,)
  File "e:\dev\pyglet-2019\pyglet\text\__init__.py", line 309, in color
    {'color': color})
  File "e:\dev\pyglet-2019\pyglet\text\document.py", line 512, in set_style
    self.dispatch_event('on_style_text', start, end, attributes)
  File "e:\dev\pyglet-2019\pyglet\event.py", line 400, in dispatch_event
    if handler(*args):
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 1062, in on_style_text
    self._update_color()
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 977, in _update_color
    for start, end, color in colors_iter.ranges(0, colors_iter.length):
AttributeError: 'RunIterator' object has no attribute 'length'

win7 64.bits, python 3.7

pyglet:
commit 58dfdb6 master github
Author: Benjamin Moran
Date: Fri Aug 9 09:43:50 2019 +0900

found this while testing cocos for next release, los-cocos/cocos#322

edit1: deleted reference to cocos version, irrelevant to this bugdemo.

@benmoran56
Copy link
Member

Fixed in master. To see the results, you need to update dt a little faster: t += dt * 100

@ccanepa
Copy link
Contributor Author

ccanepa commented Aug 13, 2019

Thanks Ben!

@benmoran56
Copy link
Member

Glad to help, and thanks for reporting it. I just pushed out 1.4.2 this morning. Unfortunately this fix did not go in, but we need to do another release soon anyway. There are a few bugs to solve first :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Bugs which cause pyglet/python to crash reproducible Has example code which reproduces the issue
Projects
None yet
Development

No branches or pull requests

2 participants