本文整理汇总了Python中line.Line.detach方法的典型用法代码示例。如果您正苦于以下问题:Python Line.detach方法的具体用法?Python Line.detach怎么用?Python Line.detach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.detach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Textbox
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import detach [as 别名]
#.........这里部分代码省略.........
if w > max_width:
# Use for x offset calculations
max_width = w
if h < y:
y = y - h
else:
if row_at_point is None:
row_at_point = rows.index(row)
if row_at_point is None:
row_at_point = 0
# List was assembled backwards
row_bounds.reverse()
# Now let's find the column clicked...
row = row_bounds[row_at_point]
text = rows[row_at_point]
# If max_width == row[0], then offset is 0 and all of the calcs below
# still work
just = prop.GetJustificationAsString()
if just == "Left":
row_left = 0
elif just == "Centered":
row_left = (max_width - row[0]) / 2.
elif just == "Right":
row_left = max_width - row[0]
row_right = row_left + row[0]
if x < row_left:
# Clicked to the left of the row
return row_at_point, 0
if x > row_right:
# Clicked to the right of the row
return row_at_point, len(rows[row_at_point])
if row == '':
# Clicked on the blank row (inserted a space when calculating width
# earlier, for height considerations)
return row_at_point, 1
# OK, no easy answer; have to calc the width of each letter in the row till we find the column
# Start from left
w = 0
ind = 1
while row_left + w < x and ind < len(text):
w, _ = text_dimensions(text[:ind], prop, dpi)
ind += 1
return row_at_point, ind - 1
def show_highlight(self):
prop = self.actor.GetTextProperty()
prop.SetBackgroundColor(self.highlight_color)
prop.SetBackgroundOpacity(self.highlight_opacity)
def hide_highlight(self):
prop = self.actor.GetTextProperty()
prop.SetBackgroundOpacity(0)
def start_editing(self, point=None):
if point is not None:
self.row, self.column = self.row_col_at_point(*point)
else:
rows = self.text.split("\n")
self.row = len(rows) - 1
self.column = len(rows[-1])
self.place_cursor()
self.editing = True
def stop_editing(self):
self.editing = False
self.cursor.hide()
if self.blank:
self.text = ""
if self.on_editing_end:
self.on_editing_end(self)
if self.blank:
self.text = " "
def place(self):
super(Textbox, self).place()
if self.editing:
self.place_cursor()
def detach(self):
if self.cursor is not None:
self.cursor.detach()
self.cursor = None
self.interactor.DestroyTimer(self.blink_timer)
self.interactor.RemoveObserver(self.blink_observer)
self.interactor.RemoveObserver(self.keyboard_observer)
super(Textbox, self).detach()