本文整理汇总了Python中gi.repository.Gdk.Rectangle方法的典型用法代码示例。如果您正苦于以下问题:Python Gdk.Rectangle方法的具体用法?Python Gdk.Rectangle怎么用?Python Gdk.Rectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gdk
的用法示例。
在下文中一共展示了Gdk.Rectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _gtk_draw
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def _gtk_draw(self, wid, cr):
if not self._screen:
return
# from random import random
# cr.rectangle(0, 0, self._pixel_width, self._pixel_height)
# cr.set_source_rgb(random(), random(), random())
# cr.fill()
self._cairo_surface.flush()
cr.save()
cr.rectangle(0, 0, self._pixel_width, self._pixel_height)
cr.clip()
cr.set_source_surface(self._cairo_surface, 0, 0)
cr.paint()
cr.restore()
if not self._busy and self._blink:
# Cursor is drawn separately in the window. This approach is
# simpler because it doesn't taint the internal cairo surface,
# which is used for scrolling
row, col = self._screen.row, self._screen.col
text, attrs = self._screen.get_cursor()
self._pango_draw(row, col, [(text, attrs,)], cr=cr, cursor=True)
x, y = self._get_coords(row, col)
currect = Rectangle(x, y, self._cell_pixel_width,
self._cell_pixel_height)
self._im_context.set_cursor_location(currect)
示例2: __getButtonRectangle
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def __getButtonRectangle(self, position):
starWidth, starHeight = self.getSizeOfSvg(self.bgSvg)
buttonWidth, buttonHeight = self.getSizeOfSvg(self.svgs[position])
buttonWidth = buttonWidth * self.size[0] / float(starWidth)
buttonHeight = buttonHeight * self.size[1] / float(starHeight)
dx_loc, dy_loc = DX_DY[position]
x_loc = ceil(dx_loc * (1 + PADDING_X) * buttonWidth - buttonWidth / 2. +
self.size[0] / 2.)
y_loc = ceil(dy_loc * (1 + PADDING_Y) * buttonHeight - buttonHeight / 2. +
self.size[1] / 2.)
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (x_loc, y_loc, ceil(buttonWidth),
ceil(buttonHeight))
return rect
示例3: _setHover
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def _setHover(self, cord):
if self._hover == cord:
return
if self._hover:
rectangle = rect(self.cord2RectRelative(self._hover))
# convert r from tuple to rect
# tmpr = r
# r = Gdk.Rectangle()
# r.x, r.y, r.width, r.height = tmpr
# if cord: r = r.union(rect(self.cord2RectRelative(cord)))
if cord:
rectangle = union(rectangle, rect(self.cord2RectRelative(cord)))
elif cord:
rectangle = rect(self.cord2RectRelative(cord))
# convert r from tuple to rect
# tmpr = r
# r = Gdk.Rectangle()
# r.x, r.y, r.width, r.height = tmpr
self._hover = cord
self.redrawCanvas(rectangle)
示例4: do_size_allocate
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def do_size_allocate(self, allocation):
child_allocation = Gdk.Rectangle()
child_allocation.x = self.border_width
child_allocation.y = self.border_width
self.set_allocation(allocation)
if self.get_has_window():
if self.get_realized():
self.get_window().move_resize(allocation.x, allocation.y, allocation.width, allocation.height)
# Allocate children as VBox does, always use all available width
for c in self.children:
if not c is None:
if c.get_visible():
min_size, nat_size = c.get_preferred_size()
child_allocation.width = allocation.width - (self.border_width * 2)
child_allocation.height = min_size.height
# TODO: Handle child that has window (where would i get it?)
c.size_allocate(child_allocation)
child_allocation.y += child_allocation.height + self.border_width
示例5: _open_popover_at
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def _open_popover_at(self, x, y):
rectangle = Gdk.Rectangle()
rectangle.x = x
rectangle.y = y
rectangle.height = 1
rectangle.width = 1
self._popover.set_pointing_to(rectangle)
self._popover.set_relative_to(self.get_image())
self._popover.popup()
self._entry.grab_focus()
self._preview_text()
# Usual text entry shortcuts don't work otherwise
self.set_action_sensitivity('paste', False)
self.set_action_sensitivity('select_all', False)
self.set_action_sensitivity('selection_cut', False)
self.set_action_sensitivity('selection_copy', False)
示例6: Rectangle
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def Rectangle(x, y, w, h):
r = Gdk.Rectangle()
r.x, r.y, r.width, r.height = x, y, w, h
return r
示例7: get_monitor_workarea_at_point
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def get_monitor_workarea_at_point(x, y):
"""Returns the workarea (Gdk.Rectangle) for the monitor at the given point"""
display = Gdk.Display.get_default()
if Gtk.get_minor_version() >= 22:
monitor = display.get_monitor_at_point(x, y)
return monitor.get_workarea()
screen = display.get_default_screen()
monitor_number = screen.get_monitor_at_point(x, y)
return screen.get_monitor_workarea(monitor_number)
示例8: redraw
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def redraw(self):
if self.get_window():
a = self.get_allocation()
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (0, 0, a.width, a.height)
self.get_window().invalidate_rect(rect, True)
self.get_window().process_updates(True)
示例9: expose
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def expose(self, widget, ctx):
context = widget.get_window().cairo_create()
clip_ext = context.clip_extents()
if clip_ext[0] > 0 or clip_ext[2] < self.get_allocated_width():
self.redraw_canvas()
return False
rec = Gdk.Rectangle()
rec.x, rec.y, rec.width, rec.height = clip_ext[0], clip_ext[1], \
clip_ext[2] - clip_ext[0], clip_ext[3] - clip_ext[1]
context.rectangle(rec.x, rec.y, rec.width, rec.height)
context.clip()
self.draw(context)
return False
示例10: redraw_canvas
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def redraw_canvas(self):
def do_redraw_canvas():
if self.get_window():
allocation = self.get_allocation()
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (0, 0, allocation.width,
allocation.height)
self.get_window().invalidate_rect(rect, True)
self.get_window().process_updates(True)
GLib.idle_add(do_redraw_canvas)
示例11: on_size_allocate
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def on_size_allocate(self, widget, requisition):
if self.get_window():
allocation = self.get_allocation()
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (allocation.x, allocation.y,
allocation.width, allocation.height)
unionrect = union(self.lastRectangle,
rect) if self.lastRectangle is not None else rect
self.get_window().invalidate_rect(unionrect, True)
self.get_window().process_updates(True)
self.lastRectangle = rect
示例12: union
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def union(r_zero, r_one):
""" Takes 2 rectangles and returns a rectangle that represents
the union of the two areas
Returns a Gdk.Rectangle
"""
x_min = min(r_zero.x, r_one.x)
y_min = min(r_zero.y, r_one.y)
w_max = max(r_zero.x + r_zero.width, r_one.x + r_one.width) - x_min
h_max = max(r_zero.y + r_zero.height, r_one.y + r_one.height) - y_min
rct = Gdk.Rectangle()
rct.x, rct.y, rct.width, rct.height = (x_min, y_min, w_max, h_max)
return rct
示例13: rect
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def rect(rectangle):
"""
Takes a list of 3 variables x,y,height and generates a rectangle
rectangle(list) : contains screen locations
returns a Gdk.Rectangle
"""
x_size, y_size = [int(floor(v)) for v in rectangle[:2]]
width = int(ceil(rectangle[2]))
if len(rectangle) == 4:
height = int(ceil(rectangle[3]))
else:
height = width
rct = Gdk.Rectangle()
rct.x, rct.y, rct.width, rct.height = (x_size, y_size, width, height)
return rct
示例14: expose
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def expose(self, widget, ctx):
context = widget.get_window().cairo_create()
start = time()
rectangle = Gdk.Rectangle()
clip_ext = ctx.clip_extents()
rectangle.x, rectangle.y = clip_ext[0], clip_ext[1]
rectangle.width, rectangle.height = clip_ext[2] - clip_ext[0], clip_ext[3] - clip_ext[1]
if False:
import profile
profile.runctx("self.draw(context, rectangle)", locals(), globals(), "/tmp/pychessprofile")
from pstats import Stats
stats = Stats("/tmp/pychessprofile")
stats.sort_stats('cumulative')
stats.print_stats()
else:
self.draw(context, rectangle)
# self.drawcount += 1
# self.drawtime += time() - start
# if self.drawcount % 100 == 0:
# print( "Average FPS: %0.3f - %d / %d" % \
# (self.drawcount/self.drawtime, self.drawcount, self.drawtime))
return False
############################################################################
# drawing functions #
############################################################################
###############################
# redrawCanvas #
###############################
示例15: redrawCanvas
# 需要导入模块: from gi.repository import Gdk [as 别名]
# 或者: from gi.repository.Gdk import Rectangle [as 别名]
def redrawCanvas(self, rect=None):
if self.get_window():
if not rect:
alloc = self.get_allocation()
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (0, 0, alloc.width, alloc.height)
self.get_window().invalidate_rect(rect, True)
self.get_window().process_updates(True)
###############################
# draw #
###############################
# draw called each time we hover on a case. WARNING it only redraw the case