本文整理汇总了Python中nltk.draw.util.CanvasFrame.scrollregion方法的典型用法代码示例。如果您正苦于以下问题:Python CanvasFrame.scrollregion方法的具体用法?Python CanvasFrame.scrollregion怎么用?Python CanvasFrame.scrollregion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.draw.util.CanvasFrame
的用法示例。
在下文中一共展示了CanvasFrame.scrollregion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RecursiveDescentApp
# 需要导入模块: from nltk.draw.util import CanvasFrame [as 别名]
# 或者: from nltk.draw.util.CanvasFrame import scrollregion [as 别名]
#.........这里部分代码省略.........
self._top.bind('<F1>', self.help)
#self._top.bind('<g>', self.toggle_grammar)
#self._top.bind('<Alt-g>', self.toggle_grammar)
#self._top.bind('<Control-g>', self.toggle_grammar)
self._top.bind('<Control-g>', self.edit_grammar)
self._top.bind('<Control-t>', self.edit_sentence)
def _init_buttons(self, parent):
# Set up the frames.
self._buttonframe = buttonframe = Frame(parent)
buttonframe.pack(fill='none', side='bottom', padx=3, pady=2)
Button(buttonframe, text='Step',
background='#90c0d0', foreground='black',
command=self.step,).pack(side='left')
Button(buttonframe, text='Autostep',
background='#90c0d0', foreground='black',
command=self.autostep,).pack(side='left')
Button(buttonframe, text='Expand', underline=0,
background='#90f090', foreground='black',
command=self.expand).pack(side='left')
Button(buttonframe, text='Match', underline=0,
background='#90f090', foreground='black',
command=self.match).pack(side='left')
Button(buttonframe, text='Backtrack', underline=0,
background='#f0a0a0', foreground='black',
command=self.backtrack).pack(side='left')
# Replace autostep...
# self._autostep_button = Button(buttonframe, text='Autostep',
# underline=0, command=self.autostep)
# self._autostep_button.pack(side='left')
def _configure(self, event):
self._autostep = 0
(x1, y1, x2, y2) = self._cframe.scrollregion()
y2 = event.height - 6
self._canvas['scrollregion'] = '%d %d %d %d' % (x1,y1,x2,y2)
self._redraw()
def _init_feedback(self, parent):
self._feedbackframe = feedbackframe = Frame(parent)
feedbackframe.pack(fill='x', side='bottom', padx=3, pady=3)
self._lastoper_label = Label(feedbackframe, text='Last Operation:',
font=self._font)
self._lastoper_label.pack(side='left')
lastoperframe = Frame(feedbackframe, relief='sunken', border=1)
lastoperframe.pack(fill='x', side='right', expand=1, padx=5)
self._lastoper1 = Label(lastoperframe, foreground='#007070',
background='#f0f0f0', font=self._font)
self._lastoper2 = Label(lastoperframe, anchor='w', width=30,
foreground='#004040', background='#f0f0f0',
font=self._font)
self._lastoper1.pack(side='left')
self._lastoper2.pack(side='left', fill='x', expand=1)
def _init_canvas(self, parent):
self._cframe = CanvasFrame(parent, background='white',
#width=525, height=250,
closeenough=10,
border=2, relief='sunken')
self._cframe.pack(expand=1, fill='both', side='top', pady=2)
canvas = self._canvas = self._cframe.canvas()
# Initially, there's no tree or text
self._tree = None
self._textwidgets = []
self._textline = None