本文整理汇总了Python中gui.PopupBox.PopupBox.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python PopupBox.__init__方法的具体用法?Python PopupBox.__init__怎么用?Python PopupBox.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.PopupBox.PopupBox
的用法示例。
在下文中一共展示了PopupBox.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gui.PopupBox import PopupBox [as 别名]
# 或者: from gui.PopupBox.PopupBox import __init__ [as 别名]
def __init__(self, lines, file=None, parent='osd', text=' ', left=None, top=None, width=500,
height=350, bg_color=None, fg_color=None, icon=None,
border=None, bd_color=None, bd_width=None):
"""
Initialise a LogScroll instance
@param left: x coordinate. Integer
@param top: y coordinate. Integer
@param width: Integer
@param height: Integer
@param text: String to print.
@param bg_color: Background color (Color)
@param fg_color: Foreground color (Color)
@param icon: icon
@param border: Border
@param bd_color: Border color (Color)
@param bd_width: Border width Integer
"""
handler = None
self.lines = file is not None and open(file, 'rb').read() or lines
PopupBox.__init__(self, text, handler, top, left, width, height, icon, None, None, parent)
myfont = self.osd.getfont(config.OSD_DEFAULT_FONTNAME, config.OSD_DEFAULT_FONTSIZE)
import pprint
pprint.pprint(myfont.__dict__)
surf_w = myfont.stringsize('AAAAAAAAAA'*8)
data = self.osd.drawstringframed('\n'.join(self.lines), 0, 0, surf_w, 1000000, myfont,
align_h='left', align_v='top', fgcolor=self.osd.COL_BLACK, mode='hard', layer='')[1]
(ret_x0,ret_y0, ret_x1, ret_y1) = data
surf_h = ret_y1 - ret_y0
if height>surf_h:
surf_h=height
surf = pygame.Surface((surf_w, surf_h), 0, 32)
bg_c = self.bg_color.get_color_sdl()
surf.fill(bg_c)
y = 0
for line in self.lines:
colour = self.osd.COL_BLACK
if line.startswith('<so> '):
colour = self.osd.COL_WHITE
elif line.startswith('<se> '):
colour = self.osd.COL_ORANGE
line = line[4:]
self.osd.drawstringframed(line, 0, y, surf_w, surf_h, myfont, align_h='left', align_v='top',
fgcolor=colour, mode='hard', layer=surf)
#y += myfont.ptsize + 1
y += myfont.height
self.pb = RegionScroller(surf, 50, 50, width=width, height=height)
self.add_child(self.pb)