本文整理汇总了Python中widget.Widget类的典型用法代码示例。如果您正苦于以下问题:Python Widget类的具体用法?Python Widget怎么用?Python Widget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh
def refresh(self):
"""
Redraw border for EditBox and command an underlying window refresh.
"""
if self.__border:
rectangle(self.window, self.y-1, self.x-1, self.y+1, self.x+self.cols)
Widget.refresh(self)
示例2: _update_state
def _update_state(self):
''' Update state. '''
if self._deleted:
return
Widget._update_state(self)
self._label.color = self._style.colors[self._state]
示例3: __init__
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__
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
示例5: __init__
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]
示例6: on_mouse_scroll
def on_mouse_scroll(self, x, y, scroll_x, scroll_y):
Widget.on_mouse_scroll(self, x, y, scroll_x, scroll_y)
r = self.clip_rect()
for c in self.children:
if r.intersect(c.bounds()).hit_test(x, y):
c.on_mouse_scroll(x, y, scroll_x, scroll_y)
示例7: __init__
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)
示例8: load_widget
def load_widget(self, name, x=None, y=None):
"""
Load a widget with the given name at the specified coordinates (optional).
:param name: The name of the widget.
:param x: The x-coordinate.
:param y: The y-coordinate.
:type name: `str`
:type x: `int`
:type y: `int`
"""
x, y = int(x), int(y)
self.messages.debug("Loading widget '%s'..." % name)
# Initialize the widget...
widget = Widget(self.available_widgets.get_by_name(name)._path, backref=self)
widget.set_position(x, y)
# Add the widget to the list of currently active widgets:
self.widgets.add(widget, x, y)
widget.show()
示例9: __init__
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
示例10: __init__
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
示例11: __init__
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()
示例12: _move
def _move(self, x, y):
dx, dy = x - self.x, y - self.y
Widget._move(self, x, y)
widget = self._label or self._layout
if widget:
widget.x = widget.x + dx
widget.y = widget.y + dy
示例13: setFocusHandler
def setFocusHandler(self,focusHandler):
Widget.setFocusHandler(self,focusHandler)
if self.mInternalFocusHandler != None:
return None
for i in self.mWidgets:
i.setFocusHandler(focusHandler)
示例14: setInternalFocusHandler
def setInternalFocusHandler(self,focusHandler):
Widget.setInternalFocusHandler(self,focusHandler)
for i in self.mWidgets:
if self.mInternalFocusHandler == None:
i.setFocusHandler(self.getFocusHandler())
else:
i.setFocusHandler(self.mInternalFocusHandler)
示例15: addSettings
def addSettings(klass, s):
'''Construct list of settings.'''
Widget.addSettings(s)
s.add( setting.Distance( 'leftMargin',
'1.7cm',
descr=_('Distance from left of graph to edge'),
usertext=_('Left margin'),
formatting=True) )
s.add( setting.Distance( 'rightMargin',
'0.2cm',
descr=_('Distance from right of graph to edge'),
usertext=_('Right margin'),
formatting=True) )
s.add( setting.Distance( 'topMargin',
'0.2cm',
descr=_('Distance from top of graph to edge'),
usertext=_('Top margin'),
formatting=True) )
s.add( setting.Distance( 'bottomMargin',
'1.7cm',
descr=_('Distance from bottom of graph to edge'),
usertext=_('Bottom margin'),
formatting=True) )
s.add( setting.GraphBrush( 'Background',
descr = _('Background plot fill'),
usertext=_('Background')),
pixmap='settings_bgfill' )
s.add( setting.Line('Border', descr = _('Graph border line'),
usertext=_('Border')),
pixmap='settings_border')