本文整理汇总了Python中line.Line.hide方法的典型用法代码示例。如果您正苦于以下问题:Python Line.hide方法的具体用法?Python Line.hide怎么用?Python Line.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.hide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Textbox
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import hide [as 别名]
class Textbox(Label):
def __init__(self, interactor, string, on_editing_end=None,
highlight_color=None, highlight_opacity=None, **kwargs):
super(Textbox, self).__init__(interactor, string, **kwargs)
self.drag_interval = timedelta(0, .1)
self.editing = False
self.blank = False
self.edit_indicator = None
self.column = 0
self.row = 0
self.text = string
self.on_editing_end = on_editing_end
self.highlight_opacity = highlight_opacity
self.highlight_color = highlight_color
self.cursor = Line(
(0, 0), (1, 1), renderer=self.widget.GetCurrentRenderer(), width=2)
# Blink the cursor if we're editing.
self.blink_timer = self.interactor.CreateRepeatingTimer(600)
self.blink_observer = self.interactor.AddObserver(
"TimerEvent",
self.blink_cursor)
# All timer events trigger all listeners, so we will only update when
# the time elapsed is the expected period.
self.last_blink = datetime.now()
# Use the third argument (priority) to intercept key events before
# anything else does
self.keyboard_observer = self.interactor.AddObserver(
"KeyPressEvent",
self.typed,
1.0)
def blink_cursor(self, obj, event):
if datetime.now() - self.last_blink < timedelta(0, 0, 0, 400):
return
self.last_blink = datetime.now()
if self.editing:
self.place_cursor()
if self.cursor.showing:
self.cursor.hide()
else:
self.cursor.show()
self.manager.queue_render()
def show_cursor(self):
self.last_blink = datetime.now()
self.place_cursor()
self.cursor.show()
self.manager.queue_render()
def get_char(self):
keycode = self.interactor.GetKeyCode()
if len(keycode) == 0 or ord(keycode) > 126 or ord(keycode) < 33:
keycode = self.interactor.GetKeySym()
return keycode
def add_character(self, character):
rows = self.text.split("\n")
row = rows[self.row]
if self.column >= len(row):
# It shouldn't be possible for self.blank to be true here
# self.column will only be >= len(row) if we're navigating
# up from another row (indicating that blank is false, because
# there's text on another line)
row += character
rows[self.row] = row
if character == "\n":
self.column = 0
self.row += 1
else:
self.column = len(row)
else:
if self.blank:
self.blank = False
row = character
else:
row = row[:self.column] + character + row[self.column:]
rows[self.row] = row
if character != "\n":
self.column += 1
else:
self.row += 1
self.column = 0
self.text = "\n".join(rows)
def delete_character(self):
rows = self.text.split("\n")
if self.column == 0 and self.row > 0:
row = rows[self.row - 1]
self.column = len(row)
row += rows[self.row]
rows[self.row - 1] = row
del rows[self.row]
self.row -= 1
#.........这里部分代码省略.........