本文整理汇总了Python中Tkinter.Frame.winfo_height方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.winfo_height方法的具体用法?Python Frame.winfo_height怎么用?Python Frame.winfo_height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.winfo_height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Chord
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import winfo_height [as 别名]
#.........这里部分代码省略.........
@title.setter
def title(self, text):
self._title = text
self._title_label.configure(text=text)
def _on_enter(self, event):
if not self._is_opened:
self._down_arrow_icon.configure(foreground=self._active_foreground)
self._right_arrow_icon.configure(foreground=self._active_foreground)
self.config(cursor=self._cursor)
def _on_leave(self, event):
if not self._is_opened:
self._down_arrow_icon.configure(foreground=self._foreground)
self._right_arrow_icon.configure(foreground=self._foreground)
self.config(cursor="arrow")
def _on_click(self, event):
if self._is_animating: return
self.toggle()
def open(self):
if self._is_animating: return
if not self._is_opened: self._open()
def _open(self):
self.body.pack()
self.body.pack_propagate(False)
self._icon_label.configure(image=self._down_arrow_icon, background = self._selected_background)
self._title_label.configure(foreground= self._selected_foreground, background = self._selected_background)
self._caption.configure(background = self._selected_background)
self._down_arrow_icon.configure(foreground=self._selected_foreground)
if self._body_height is None:
self._body_height= self.body.winfo_reqheight()
end_value = self._body_height
self.body.configure(width=self.winfo_width())
self._is_opened = True
self._is_animating = True
animation = Animation(
self,
ticks=16,
interval_time=0.01,
start_value=0,
end_value=end_value,
config_function=lambda height: self.body.configure(height=int(height)),
callback=self._on_finnish_animation)
animation.start_animation()
def _on_finnish_animation(self):
self._is_animating = False
if not self._is_opened:
self.body.pack_forget()
def close(self):
if self._is_animating:
return
if self._is_opened: self._close()
def _close(self):
self._icon_label.configure(image=self._right_arrow_icon, background = self._background)
self._title_label.configure(foreground= self._foreground, background = self._background)
self._caption.configure(background = self._background)
self._right_arrow_icon.configure(foreground=self._foreground)
start_value = self.body.winfo_height()
self._is_opened = False
self._is_animating = True
animation = Animation(
self,
ticks=16,
interval_time=0.01,
start_value=start_value,
end_value=0,
config_function=lambda height: self.body.configure(height=int(height)),
callback=self._on_finnish_animation)
animation.start_animation()
def toggle(self):
if self._is_opened:
self._close()
else:
self._open()
示例2: Scrolling_Area
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import winfo_height [as 别名]
#.........这里部分代码省略.........
self._frameWidth = float(self.innerframe.winfo_reqwidth())
# resize the visible part
if self._scroll_horizontally:
self.xview("scroll", 0, "unit")
if self._scroll_vertically:
self.yview("scroll", 0, "unit")
def xview(self, mode = None, value = None, units = None):
value = float(value)
clipperWidth = self._clipper.winfo_width()
frameWidth = self._frameWidth
_startX = self._startX
if mode is None:
return self.xscrollbar.get()
elif mode == 'moveto':
# absolute movement
self._startX = int(value * frameWidth)
else:
# mode == 'scroll'
# relative movement
if units == 'units':
jump = int(clipperWidth * self._jfraction)
else:
jump = clipperWidth
self._startX = self._startX + value * jump
if frameWidth <= clipperWidth:
# The scrolled frame is smaller than the clipping window.
self._startX = 0
hi = 1.0
#use expand by default
relwidth = 1
else:
# The scrolled frame is larger than the clipping window.
#use expand by default
if self._startX + clipperWidth > frameWidth:
self._startX = frameWidth - clipperWidth
hi = 1.0
else:
if self._startX < 0:
self._startX = 0
hi = (self._startX + clipperWidth) / frameWidth
relwidth = ''
if self._startX != _startX:
# Position frame relative to clipper.
self.innerframe.place(x = -self._startX, relwidth = relwidth)
lo = self._startX / frameWidth
self.xscrollbar.set(lo, hi)
def yview(self, mode = None, value = None, units = None):
value = float(value)
clipperHeight = self._clipper.winfo_height()
frameHeight = self._frameHeight
_startY = self._startY
if mode is None:
return self.yscrollbar.get()
elif mode == 'moveto':
self._startY = value * frameHeight
else: # mode == 'scroll'
if units == 'units':
jump = int(clipperHeight * self._jfraction)
else:
jump = clipperHeight
self._startY = self._startY + value * jump
if frameHeight <= clipperHeight:
# The scrolled frame is smaller than the clipping window.
self._startY = 0
hi = 1.0
# use expand by default
relheight = 1
else:
# The scrolled frame is larger than the clipping window.
# use expand by default
if self._startY + clipperHeight > frameHeight:
self._startY = frameHeight - clipperHeight
hi = 1.0
else:
if self._startY < 0:
self._startY = 0
hi = (self._startY + clipperHeight) / frameHeight
relheight = ''
if self._startY != _startY:
# Position frame relative to clipper.
self.innerframe.place(y = -self._startY, relheight = relheight)
lo = self._startY / frameHeight
self.yscrollbar.set(lo, hi)