tuna/danmaQ

'QString' object has no attribute 'join' ERROR and color setting not work

xxairwolf opened this issue · 3 comments

openSUSE 13.1 64位 KDE桌面
Python 2.7.6
Qt version 4.8.5
发弹幕的时候不显示弹幕且有如下错误。
Traceback (most recent call last):
File "/home/xuxiao/Projects/danmaQ/danmaQ/app.py", line 104, in on_new_danmaku
dm = Danmaku(text, style=style, position=position, parent=self)
File "/home/xuxiao/Projects/danmaQ/danmaQ/danmaq_ui.py", line 67, in init
text = self.escape_text(text)
File "/home/xuxiao/Projects/danmaQ/danmaQ/danmaq_ui.py", line 62, in escape_text
text = re.sub(r'\n', r'\n', text)
File "/usr/lib64/python2.7/re.py", line 151, in sub
return compile(pattern, flags).sub(repl, string, count)
AttributeError: 'QString' object has no attribute 'join'
如果我把danmaq_ui.py", line 67注释掉,可以显示弹幕,但是颜色设置无效(就是说全都是白色弹幕)
@bigeagle 大大说“目测是参数类型不对,再试试?”
经过N次试错……
file danmaq_ui.py, line 67:
text = self.escape_text(text)
change to
text = self.escape_text(unicode(text))

file danmaq_ui.py, line 113:
tcolor, bcolor = color_styles.get(style, color_styles['white'])
change to
tcolor, bcolor = color_styles.get(str(style), color_styles['white'])
不知道是不是根治方法。

7dca6fd 中已修改 app.py,在传参的时候就进行了类型转换。你更新下再试?
另外主线 python 版本是 3.4,你试试用 python3 跑会不会有问题。

@bigeagle 嗯,用新pull的代码没问题了。python2.7也没问题。辛苦了

py2.7 中文问题已解决,多谢提醒