def _build(self, batch=None, group=None): Widget._build(self, batch) #, group) if self._label: self._label.delete() self._label = None if self._layout: self._layout.delete() self._layout = None if self._caret: self._caret.delete() self._caret = None # Dummy layout creation and deletion seems to make rendering faster doc = pyglet.text.document.UnformattedDocument('dummy') pyglet.text.layout.IncrementalTextLayout(doc, 1, 1, batch=self._batch).delete() if not self._active: self._label = cached.Label(text = self._text, multiline=False, batch=self._batch, group=self._fg_group, anchor_x='left', anchor_y='top') else: doc = pyglet.text.document.UnformattedDocument(self._text or ' ') self._layout = pyglet.text.layout.IncrementalTextLayout( doc, 1, 1, multiline=False, batch=self._batch, group=self._fg_group) self._layout.anchor_x = 'left' self._layout.anchor_y = 'top' self._caret = pyglet.text.caret.Caret(self._layout) self._deleted = False self._update_style() self._update_state() self._update_size()
def __init__(self, text='Label'): ''' Creates label. ''' self._text = text self._label = cached.Label(text=self._text) Widget.__init__(self) self.style = theme.Label
def __init__(self, text='Label'): ''' :Parameters: `text` : str Text to be displayed. ''' self._text = text self._label = cached.Label(text=self._text) Widget.__init__(self) self.style = theme.Label
def _build(self, batch=None, group=None): Widget._build(self, batch) self._label.delete() self._label = cached.Label(text=self._text, multiline=False, batch=self._batch, group=self._fg_group, anchor_x='left', anchor_y='top') self._deleted = False self._update_style() self._update_state() self._update_size()
def __init__(self, text='Entry', on_change=None): ''' Create entry. ''' self._text = text self._active = False self._label = cached.Label(text=self._text) doc = pyglet.text.document.UnformattedDocument(self._text or '') self._layout = pyglet.text.layout.IncrementalTextLayout(doc, 1, 1) self._caret = pyglet.text.caret.Caret(self._layout) Widget.__init__(self) self._focusable = True self._activable = True self._on_change_callback = on_change self.style = theme.Entry
def _build(self, batch=None, group=None): ''' Build entry and add it to batch and group. **Parameters** `batch` : `Batch` Optional graphics batch to add the object to. `group` : `Group` Optional graphics group to use. ''' Widget._build(self, batch) #, group) if self._label: self._label.delete() self._label = None if self._layout: self._layout.delete() self._layout = None if self._caret: self._caret.delete() self._caret = None # Dummy layout creation and deletion seems to make rendering faster doc = pyglet.text.document.UnformattedDocument('dummy') pyglet.text.layout.IncrementalTextLayout(doc, 1, 1, batch=self._batch).delete() if not self._active: self._label = cached.Label(text=self._text, multiline=False, batch=self._batch, group=self._fg_group, anchor_x='left', anchor_y='top') else: doc = pyglet.text.document.UnformattedDocument(self._text or '') self._layout = pyglet.text.layout.IncrementalTextLayout( doc, 1, 1, multiline=False, batch=self._batch, group=self._fg_group) self._layout.anchor_x = 'left' self._layout.anchor_y = 'top' self._caret = pyglet.text.caret.Caret(self._layout) self._deleted = False self._update_style() self._update_state() self._update_size()
def __init__(self, text='Entry', action=None): ''' :Parameters: `text` : str Text to be displayed within button `action` : function(button) Action to be executed when button is toggled ''' self._text = text self._active = False self._label = cached.Label(text = self._text) doc = pyglet.text.document.UnformattedDocument(self._text or ' ') self._layout = pyglet.text.layout.IncrementalTextLayout(doc,1,1) self._caret = pyglet.text.caret.Caret(self._layout) Widget.__init__(self) self._focusable = True self._activable = True self._action = action self.style = theme.Entry
def _build(self, batch=None, group=None): ''' Build widget and add it to batch and group. **Parameters** `batch` : `Batch` Optional graphics batch to add the object to. `group` : `Group` Optional graphics group to use. ''' Widget._build(self, batch) #, group) self._label.delete() self._label = cached.Label(text=self._text, multiline=False, batch=self._batch, group=self._fg_group, anchor_x='left', anchor_y='top') self._deleted = False self._update_style() self._update_state() self._update_size()