本文整理汇总了Python中base.Widget.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Widget.__init__方法的具体用法?Python Widget.__init__怎么用?Python Widget.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.Widget
的用法示例。
在下文中一共展示了Widget.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self,pos, size, steps=10,\
transparent=False, backcol=GREY, barfcol=DEEPSKYBLUE4, barbcol=BLACK):
"""pos is the postion to place this widget
size is a tuple with the width and height of the widget
steps is the amount of steps that should be taken to fill the bar, defaults to 10
The update call returns the number of steps taken, when the bar is full it will return False
"""
Widget.__init__(self)
self.end = size[0]
self.step = self.end / steps
self.steps = steps
self.backcol = backcol
self.barfcol = barfcol
self.barbcol = barbcol
self.image = pygame.Surface((size[0],size[1]))
self.image.fill(backcol)
self.rect = self.image.get_rect()
pygame.draw.rect(self.image, barbcol, self.rect.inflate(-8,-8),0)
self.barsurf = pygame.Surface((size[0]-8,size[1]-8))
self.barsurf.fill(barfcol)
self.barrect = self.barsurf.get_rect()
self.barend = self.step
self._initbar()
self.moveto(pos)
示例2: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, **kwds):
wx.MenuBar.__init__(self)
self.frame = place[0]
Widget.__init__(self, place, **kwds)
self.frame.Bind(wx.EVT_MENU, self.on_menu)
self.menus = {}
self.items = {}
示例3: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, parent=None, num_tiles=128, num_frames=64, *args, **kwargs):
Widget.__init__(self)
Frame.__init__(self, parent, *args, **kwargs)
self.num_frames = num_frames
self.num_tiles = num_tiles
self.frames = {}
示例4: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, data=None, columns=None, headers=False, editable=False,
connect={}, **kwds):
flags = wx.LC_REPORT|wx.LC_VIRTUAL|wx.BORDER_SUNKEN
if not headers:
flags |= wx.LC_NO_HEADER
if editable:
flags |= wx.LC_EDIT_LABELS
_xListCtrl.__init__(self, self, place[0], -1, style=flags)
Widget.__init__(self, place, connect, **kwds)
if data is None:
data = ListData()
if columns is None:
columns = [None]
self.selection = []
self._columns = columns
self._data = data
if hasattr(self._data, 'connect'):
self._data.connect('modified', self.update)
self.update()
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item_activated)
for event in (wx.EVT_LIST_ITEM_SELECTED, wx.EVT_LIST_ITEM_DESELECTED, wx.EVT_LIST_ITEM_FOCUSED):
self.Bind(event, self.on_update_selection)
self.can_drop = False
self.drop_formats = []
self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_click)
示例5: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, rect, fsize, bgcol=None, fgcol=None, padding=8, border=2, lines=1):
"""Starts empty, use set_text to fill it.
rect - Rect indicating the size of the box and position.
fsize - Font size
fgcol - text color (R,G,B), if None the theme color will be used.
bgcol - background color (R,G,B), if None the theme color will be used.
If bgcol is set to 'trans' the background will be transparent.
padding - space in pixels around the text
border - border in pixels, None means no border.
lines - how many previous lines of text should be visible (cheap scroll effect)
"""
if not fgcol:
fgcol = self.THEME['textview_fg_color']
if not bgcol:
bgcol = self.THEME['textview_bg_color']
self.fgcol = fgcol
self.bgcol = bgcol
self.padding = padding
self.fsize = fsize
self.image = pygame.Surface(rect.size)
self.image.fill(self.bgcol)
self.rect = self.image.get_rect()
if border:
pygame.draw.rect(self.image, BLACK, self.rect, border)
self.org_image = self.image.copy()
Widget.__init__(self, self.image)
self.rect.move_ip(rect.topleft)
self.prevlines = []
self.lines = lines
示例6: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, parent=None, statusbar=False, connect={}, **kwds):
wx.Frame.__init__(self, parent, -1)
Widget.__init__(self, None, connect, **kwds)
Container.__init__(self)
if statusbar:
self.CreateStatusBar()
self.parent = parent
示例7: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, txt, pos=(0, 0), fsize=18, padding=4, name='', fbold=True, **kwargs):
"""Button which shows a text
txt - string to display
pos - position to display the box
fsize - Font size
padding - space in pixels around the text
name - string to indicate this object
kwargs - bgcol, fgcol
"""
Widget.__init__(self)
if kwargs.has_key('fgcol'):
fgcol = kwargs['fgcol']
else:
fgcol = self.THEME['button_fg_color']
self.kwargs = kwargs
self.ImSelected = False
if type(txt) in (types.StringType, types.UnicodeType):
s = utils.char2surf(txt, fcol=fgcol, fsize=fsize, ttf=TTF, bold=fbold)
r = s.get_rect()
r.w += padding*2
r.h += padding*2
else:
s = txt
r = s.get_rect()
r.w += padding*2
r.h += padding*2
if kwargs.has_key('maxlength') and r.w > kwargs['maxlength']:
r.w = kwargs['maxlength']
self.pos = pos
self.padding = padding
self.name = name
self.r = r
self._setup(s)
示例8: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, multiline=False, connect={}, **kwds):
style = 0
if multiline:
style |= wx.TE_MULTILINE
else:
style |= wx.TE_PROCESS_ENTER
wx.TextCtrl.__init__(self, place[0], -1, style=style)
Widget.__init__(self, place, connect, **kwds)
示例9: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, **args):
ScrolledPanel.__init__(self, place[0], -1)#, style=wx.SUNKEN_BORDER)
Widget.__init__(self, place, **args)
Container.__init__(self)
self.layout = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.layout)
self.SetAutoLayout(True)
self.SetupScrolling()
示例10: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, connect={}, **kwds):
wx.Notebook.__init__(self, place[0], -1)
Widget.__init__(self, place, connect, **kwds)
# item images
self.imagelist = wx.ImageList(16, 16)
self.SetImageList(self.imagelist)
self.pixmaps = {}
self.pages = []
示例11: _setup
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def _setup(self):
# get all the surfaces
title = utils.char2surf(self.title, 24, ttf=TTF, fcol=self.THEME['dialog_title_fg_color'], bold=True)
if type(self.txt) == types.ListType or type(self.txt) in types.StringTypes:
tv = TextView(self.txt, (0, 0), pygame.Rect(0, 0, self.dialogwidth, 400),\
bgcol='trans',fsize=self.fsize ,\
fgcol=self.THEME['dialog_fg_color'], autofit=True, bold=self.fbold)
else: # we assume a SPWidget.Widget object
tv = self.txt
b = self.buttons_list[0]
# start building dialog
if self.dialogwidth and self.dialogheight:
r = pygame.Rect(0, 0, self.dialogwidth, self.dialogheight)
else:
r = pygame.Rect(0, 0, max(self.butspace,(tv.rect.w + (self.padding * 2)),100), \
title.get_rect().h + 8 + b.rect.h + tv.rect.h + (self.padding*3))
if r.w > 750:
r.w = 750
if r.h > 530:
r.h = 530
dlgsurf, dlgsizes = make_dialog_bg_dynamic(r.w+50, r.h+70, self.THEME)
r = dlgsurf.get_rect()
if not self.pos:
y = max(10, (600 - r.h) / 2)
x = (800 - r.w) / 2
self.pos = (x, y)
y = 10
x = 20
dlgsurf.blit(title, (x,y))
dlgsurf.blit(tv.image, (x, dlgsizes['title_area'].h))
Widget.__init__(self, dlgsurf)
self.image = dlgsurf
self.rect.move_ip(self.pos)
for k, v in dlgsizes.items():
dlgsizes[k].move_ip(self.pos)
x = self.rect.left + ((self.rect.w - (self.butspace + 16 * len(self.buttons_list))) / 2)
y = self.rect.bottom - self.buttons_list[0].rect.h *2
if len(self.buttons_list) == 2:
x = self.rect.left + 16
self.buttons_list[0].moveto((x, y), True)
x = self.rect.right - (self.buttons_list[1].rect.w + 16)
self.buttons_list[1].moveto((x, y), True)
else:
for b in self.buttons_list:
b.moveto((x, y), True)
x += b.rect.w + 16
self.dlgsizes = dlgsizes
示例12: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, parent=None, max_val=180, *args, **kwargs):
Widget.__init__(self)
Canvas.__init__(self, parent, borderwidth=0, *args, **kwargs)
self.line = None
self.label = None
self.max_val = max_val
self.color = 'black'
self.text_margin_bottom = 20
self.size = min(int(self.cget('width')), int(self.cget('height')))
self.create_arc(0, 0, self.size, self.size * 2, extent=180, fill='white')
示例13: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, **kwds):
_xTreeCtrl.__init__(self, self, place[0])
Widget.__init__(self, place, **kwds)
self.roots = []
self.items = []
self.SetIndent(10)
self.imagelist = wx.ImageList(16, 16)
self.SetImageList(self.imagelist)
self.pixmaps = {}
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_label_edit)
self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.on_expand)
self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.on_collapse)
self.tree = self
self.selection = None
示例14: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place):
wx.glcanvas.GLCanvas.__init__(self, place[0], -1, style=wx.glcanvas.WX_GL_DOUBLEBUFFER)
# , attribList =[wx.glcanvas.WX_GL_DOUBLEBUFFER])
Widget.__init__(self, place)
self.init = False
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
for event in (wx.EVT_LEFT_DOWN, wx.EVT_MIDDLE_DOWN, wx.EVT_RIGHT_DOWN):
self.Bind(event, self.OnMouseDown)
for event in (wx.EVT_LEFT_UP, wx.EVT_MIDDLE_UP, wx.EVT_RIGHT_UP):
self.Bind(event, self.OnMouseUp)
for event in (wx.EVT_LEFT_DCLICK, wx.EVT_MIDDLE_DCLICK, wx.EVT_RIGHT_DCLICK):
self.Bind(event, self.OnMouseDoubleClicked)
self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
self._lastsize = (-1, -1)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
示例15: __init__
# 需要导入模块: from base import Widget [as 别名]
# 或者: from base.Widget import __init__ [as 别名]
def __init__(self, place, data=None, **kwds):
_xTreeCtrl.__init__(self, self, place[0])
Widget.__init__(self, place, **kwds)
self.data = data
self.root = None
self.items = TwoWayDict()
self.selection = None
self.SetIndent(10)
self.imagelist = wx.ImageList(16, 16)
self.SetImageList(self.imagelist)
self.pixmaps = {}
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_label_edit)
# self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.on_expand)
# self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.on_collapse)
self._skip_event = False