本文整理汇总了Python中widget.Widget.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Widget.__init__方法的具体用法?Python Widget.__init__怎么用?Python Widget.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类widget.Widget
的用法示例。
在下文中一共展示了Widget.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, x=0, y=0, z=0, width=200, height=10,
font_size = 10, anchor_x='left', anchor_y='bottom',
value=0.50):
Widget.__init__(self,x,y,z,width,height,anchor_x,anchor_y)
fg = (1,1,1,1)
bg = (1,1,1,.5)
frame = Rectangle (x=0, y=0, z=z,
width=width, height=height, radius=(height-1)/2,
foreground=fg, background=bg,
anchor_x=anchor_x, anchor_y=anchor_y)
cursor = Ellipse (x=0, y=-.5+height/2, z=z,
width=height-1, height=height-1,
foreground=fg, background=fg,
anchor_x='center', anchor_y='center')
label = pyglet.text.Label('0',
font_name='Monaco',
font_size=8,
x=0, y=height+2,
anchor_x='center', anchor_y='bottom')
self._elements['frame'] = frame
self._elements['cursor'] = cursor
self._elements['label'] = label
self.set_cursor(value)
self._is_dragging = False
示例2: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, surface):
global root_widget
Widget.__init__(self, surface.get_rect())
self.surface = surface
root_widget = self
widget.root_widget = self
self.is_gl = surface.get_flags() & OPENGL <> 0
示例3: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, rows, row_spacing = 10, column_spacing = 10, **kwds):
col_widths = [0] * len(rows[0])
row_heights = [0] * len(rows)
for j, row in enumerate(rows):
for i, widget in enumerate(row):
if widget:
col_widths[i] = max(col_widths[i], widget.width)
row_heights[j] = max(row_heights[j], widget.height)
row_top = 0
for j, row in enumerate(rows):
h = row_heights[j]
y = row_top + h // 2
col_left = 0
for i, widget in enumerate(row):
if widget:
w = col_widths[i]
x = col_left
widget.midleft = (x, y)
col_left += w + column_spacing
row_top += h + row_spacing
width = max(1, col_left - column_spacing)
height = max(1, row_top - row_spacing)
r = Rect(0, 0, width, height)
#print "albow.controls.Grid: r =", r ###
#print "...col_widths =", col_widths ###
#print "...row_heights =", row_heights ###
Widget.__init__(self, r, **kwds)
self.add(rows)
示例4: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, client=None, responses=None,
default=0, cancel=-1, **kwds):
Widget.__init__(self, **kwds)
if client or responses:
rows = []
w1 = 0
w2 = 0
if client:
rows.append(client)
w1 = client.width
if responses:
buttons = Row([
Button(text, action=lambda t=text: self.dismiss(t))
for text in responses])
rows.append(buttons)
w2 = buttons.width
if w1 < w2:
a = 'l'
else:
a = 'r'
contents = Column(rows, align=a)
m = self.margin
contents.topleft = (m, m)
self.add(contents)
self.shrink_wrap()
if responses and default is not None:
self.enter_response = responses[default]
if responses and cancel is not None:
self.cancel_response = responses[cancel]
示例5: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, id, parent):
Widget.__init__(self, id, parent)
self._add_widget('histogram_table', HistogramTable)
self._add_widget('population_picker', PopulationPicker)
self._add_widget('dim_picker', Select)
self._add_widget('negative_values_picker', Select)
self._add_widget('apply', ApplyButton)
示例6: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, image, action = None, enable = None, **kwds):
if isinstance(image, basestring):
image = resource.get_image(image)
if image:
self.image = image
BaseButton.__init__(self, action, enable)
Widget.__init__(self, image.get_rect(), **kwds)
示例7: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, width, upper=None, **kwds):
Widget.__init__(self, **kwds)
self.set_size_for_text(width)
if upper is not None:
self.upper = upper
self.insertion_point = None
self.root = self.get_root()
示例8: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, **kwargs):
'''Create a slider control
Keyword arguments:
name -- unique widget identifier
min -- minimum value
max -- maximum value
value -- initial value
action -- callback to be invoked when the slider is moved
continuous -- if true, invoke action on every movement, else
invoke action only when the user releases the mouse button
'''
Widget.__init__(self, **kwargs)
self._min = kwargs.get('min', 0.0)
self._max = kwargs.get('max', 1.0)
self._value = kwargs.get('value', 0.5)
self.shapes['track'] = Rectangle()
self.shapes['knob'] = Rectangle()
self.action = kwargs.get('action', None)
self._continuous = kwargs.get('continuous', True)
self._focused = False
示例9: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, text='Label'):
''' Creates label. '''
self._text = text
self._label = cached.Label(text = self._text)
Widget.__init__(self)
self.style = theme.Label
示例10: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, items, keysColumn=None, buttonsColumn=None, item_spacing=None):
self.items = items
self.item_spacing = item_spacing
self.keysColumn = keysColumn
self.buttonsColumn = buttonsColumn
Widget.__init__(self)
self.buildWidgets()
示例11: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, x, y, w, **kwargs):
'''Create a text input control
Keyword arguments:
name -- unique widget identifier
text -- intitial value
action -- callback to be invoked when text is entered
'''
Widget.__init__(self, x, y, w, 1, kwargs.get('name'))
self.document = pyglet.text.document.UnformattedDocument(kwargs.get('text', ''))
self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, w-4, 1, multiline=False)
font = self.document.get_font()
height = font.ascent - font.descent
self.layout.x, self.layout.y = 2, 2
self.caret = pyglet.text.caret.Caret(self.layout)
self.elements['layout'] = self.layout
self.elements['frame'] = Rectangle()
self.action = kwargs.get('action', None)
self._focused = False
self.caret.visible = False
示例12: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, surface):
global root_widget
Widget.__init__(self, surface.get_rect())
self.surface = surface
root_widget = self
widget.root_widget = self
self.is_gl = surface.get_flags() & OPENGL != 0
self.idle_handlers = []
self.dont = False
self.shiftClicked = 0
self.shiftPlaced = -2
self.ctrlClicked = 0
self.ctrlPlaced = -2
self.altClicked = 0
self.altPlaced = -2
self.shiftAction = None
self.altAction = None
self.ctrlAction = None
self.editor = None
self.selectTool = None
self.movementMath = [-1, 1, 1, -1, 1, -1]
self.movementNum = [0, 0, 2, 2, 1, 1]
self.notMove = [False, False, False, False, False, False]
self.usedKeys = [False, False, False, False, False, False]
self.cameraMath = [-1., 1., -1., 1.]
self.cameraNum = [0, 0, 1, 1]
self.notMoveCamera = [False, False, False, False]
self.usedCameraKeys = [False, False, False, False]
示例13: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, x=0, y=0, z=0, width=300, height=300, anchor_x='left',
anchor_y='bottom', elements=[]):
fg = (.5,.5,.5, 1)
bg = (.5,.5,.5,.5)
Widget.__init__(self,x,y,z,width,height,anchor_x,anchor_y)
self.margin = 3
self.ropen = 0
length = len(elements)
for i in range(length):
elements[i].height = height / length - 2 * self.margin
elements[i].width = width - 2 * self.margin
elements[i].x = self.margin
elements[i].y = (height - self.margin) - (i + 2) * (elements[i].height + self.margin)
self._elements[i] = elements[i]
self._elements[i]._hidden = True
chooselabel = Label(text='...',
x=self.margin, y= (height - self.margin) - (
elements[i].height + self.margin),
height = height / length - 2 * self.margin,
width = width - 2 * self.margin)
frame = Rectangle (x=chooselabel.x, y=chooselabel.y + chooselabel.height, z=z,
width=chooselabel.width, height=-chooselabel.height, radius=0,
foreground=fg, background=bg,
anchor_x=anchor_x, anchor_y=anchor_y)
self._elements['chooselabel'] = chooselabel
self._elements['frame'] = frame
示例14: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, parent, name=None):
'''Initialise plotter.'''
Widget.__init__(self, parent, name=name)
if type(self) == NonOrthFunction:
self.readDefaults()
self.checker = FunctionChecker()
示例15: __init__
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import __init__ [as 别名]
def __init__(self, id, parent):
global NETWORKS
Widget.__init__(self, id, parent)
self._add_widget('dims', Select)
self._add_widget('edge_stat', Select)
self._add_widget('node_stat', Select)
self._add_widget('apply', ApplyButton)
self._add_widget('layout', LeftPanel)