本文整理汇总了Python中wx.Rect方法的典型用法代码示例。如果您正苦于以下问题:Python wx.Rect方法的具体用法?Python wx.Rect怎么用?Python wx.Rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.Rect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveScreenshot
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def saveScreenshot(self, filename):
timestamp = self.getConfig('screenshot_timestamp')
folder = self.getConfig('screenshot_save_folder')
prefix = self.getConfig('screenshot_prefix')
file_format = self.getConfig('screenshot_format')
rect = None
if self.getConfig('screenshot_subsection'):
if (self.getConfig('screenshot_subsection_top') > 0 and
self.getConfig('screenshot_subsection_left') > 0 and
self.getConfig('screenshot_subsection_width') > 0 and
self.getConfig('screenshot_subsection_height') > 0):
rect = wx.Rect(
int(self.getConfig('screenshot_subsection_top')),
int(self.getConfig('screenshot_subsection_left')),
int(self.getConfig('screenshot_subsection_width')),
int(self.getConfig('screenshot_subsection_height'))
)
img = self.takeScreenshot(rect, timestamp)
self.saveImage(img, filename, folder, prefix, file_format)
示例2: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def OnPaint(self, evt):
# this doesnt appear to work at all...
width,height = self.GetSizeTuple()
# get drawing canvas
dc = wx.PaintDC(self)
dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))
# build rect
size = max(2, (width-10)*self.progress)
rect = wx.Rect(5,8, size ,5)
# draw rect
dc.Clear()
dc.BeginDrawing()
dc.DrawRoundedRectangleRect(rect, 2)
dc.EndDrawing()
示例3: Render
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def Render(self, cell, dc, state):
position = cell.GetPosition()
for device in self._Devices:
box = self.GetTextExtent(device['name'])
RADIUS = DeviceListRenderer.CORNER_RADIUS
if device['vendor'] == 'nvidia':
color = self._ColorDb.Find('LIME GREEN')
else:
color = self._ColorDb.Find('LIGHT GREY')
dc.SetBrush(wx.Brush(color))
dc.SetPen(wx.TRANSPARENT_PEN)
shadeRect = wx.Rect(
position,
wx.Size(box.GetWidth() + RADIUS*2, box.GetHeight() + RADIUS*2))
dc.DrawRoundedRectangle(shadeRect, RADIUS)
textRect = wx.Rect(
wx.Point(position.x + RADIUS, position.y + RADIUS), box)
self.RenderText(device['name'], 0, textRect, dc, state)
position = wx.Point(
position.x, (position.y + box.GetHeight() + RADIUS*2 + RADIUS))
return True
示例4: GetVisibleViewRect
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def GetVisibleViewRect(self):
width = 0
for n in xrange(self.GetColumnCount()):
width += self.GetColumnWidth(n)
height = 0
if self.GetItemCount() > 0:
i = self.GetTopItem()
r1 = self.GetItemRect(i)
last = min(i + self.GetCountPerPage(), self.GetItemCount() - 1)
r2 = self.GetItemRect(last)
height = r2.y + r2.height - r1.y
x, y = self._get_origin_offset()
# there is a 2 pixel strip on either side which is not part of the item
if '__WXMSW__' in wx.PlatformInfo:
x += 2
width -= 4
return wx.Rect(x, y, x+width, y+height)
示例5: GetMonitorDimensions
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def GetMonitorDimensions():
retval = []
def MonitorEnumProc(dummy1, dummy2, lprcMonitor, dummy3):
displayRect = lprcMonitor.contents
rect = wx.Rect(
displayRect.left,
displayRect.top,
displayRect.right - displayRect.left,
displayRect.bottom - displayRect.top
)
retval.append(rect)
return 1
EnumDisplayMonitors(0, None, MONITORENUMPROC(MonitorEnumProc), 0)
return retval
示例6: RefreshBoundingBox
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def RefreshBoundingBox(self):
if self.Type in (OUTPUT, INOUT):
bbx_x = self.Pos.x - CONNECTOR_SIZE
else:
bbx_x = self.Pos.x
if self.Type == INOUT:
bbx_width = self.Size[0] + 2 * CONNECTOR_SIZE
else:
bbx_width = self.Size[0] + CONNECTOR_SIZE
bbx_x = min(bbx_x, self.Pos.x + (self.Size[0] - self.NameSize[0]) // 2)
bbx_width = max(bbx_width, self.NameSize[0])
bbx_height = self.Size[1]
if self.ExecutionOrder != 0:
bbx_x = min(bbx_x, self.Pos.x + self.Size[0] - self.ExecutionOrderSize[0])
bbx_width = max(bbx_width, bbx_width + self.Pos.x + self.ExecutionOrderSize[0] - bbx_x - self.Size[0])
bbx_height = bbx_height + (self.ExecutionOrderSize[1] + 2)
self.BoundingBox = wx.Rect(bbx_x, self.Pos.y, bbx_width + 1, bbx_height + 1)
# Refresh the position of the variable connector
示例7: RefreshBoundingBox
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def RefreshBoundingBox(self):
# Calculate the size of the name outside the coil
text_width, text_height = self.Parent.GetTextExtent(self.Name)
# Calculate the bounding box size
if self.Name != "":
bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) // 2)
bbx_width = max(self.Size[0], text_width)
bbx_y = self.Pos.y - (text_height + 2)
bbx_height = self.Size[1] + (text_height + 2)
else:
bbx_x = self.Pos.x
bbx_width = self.Size[0]
bbx_y = self.Pos.y
bbx_height = self.Size[1]
self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
# Returns the block minimum size
示例8: TestPoint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def TestPoint(self, pt, direction=None, exclude=True):
inside = False
check_point = (not exclude) and (direction is None or self.Direction == direction)
if check_point:
# Calculate a square around the end point of this connector
parent_pos = self.ParentBlock.GetPosition()
x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE
y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE
width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE
height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE
rect = wx.Rect(x, y, width, height)
inside = rect.InsideXY(pt.x, pt.y)
return inside
# Draws the highlightment of this element if it is highlighted
示例9: HitTest
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def HitTest(self, pt, connectors=True):
test = False
for i in xrange(len(self.Points) - 1):
rect = wx.Rect(0, 0, 0, 0)
if i == 0 and self.StartConnected is not None:
x1 = self.Points[i].x - self.Segments[0][0] * CONNECTOR_SIZE
y1 = self.Points[i].y - self.Segments[0][1] * CONNECTOR_SIZE
else:
x1, y1 = self.Points[i].x, self.Points[i].y
if i == len(self.Points) - 2 and self.EndConnected is not None:
x2 = self.Points[i + 1].x + self.Segments[-1][0] * CONNECTOR_SIZE
y2 = self.Points[i + 1].y + self.Segments[-1][1] * CONNECTOR_SIZE
else:
x2, y2 = self.Points[i + 1].x, self.Points[i + 1].y
# Calculate a rectangle around the segment
rect = wx.Rect(min(x1, x2) - ANCHOR_DISTANCE, min(y1, y2) - ANCHOR_DISTANCE,
abs(x1 - x2) + 2 * ANCHOR_DISTANCE, abs(y1 - y2) + 2 * ANCHOR_DISTANCE)
test |= rect.InsideXY(pt.x, pt.y)
return test
# Returns the wire start or end point if the point given is on one of them
示例10: RefreshBoundingBox
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def RefreshBoundingBox(self):
# TODO: check and remove dead coded
#
# Calculate the bounding box size
# if self.Action:
# bbx_width = self.Size[0] + CONNECTOR_SIZE
# else:
# bbx_width = self.Size[0]
# if self.Initial:
# bbx_y = self.Pos.y
# bbx_height = self.Size[1]
# if self.Output:
# bbx_height += CONNECTOR_SIZE
# else:
# bbx_y = self.Pos.y - CONNECTOR_SIZE
# bbx_height = self.Size[1] + CONNECTOR_SIZE
# if self.Output:
# bbx_height += CONNECTOR_SIZE
# self.BoundingBox = wx.Rect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
# Refresh the positions of the step connectors
示例11: OnLeftDown
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def OnLeftDown(self, event, dc, scaling):
"""
Called when left mouse is pressed on Viewer. Starts to edit a new
rubberband bounding box
@param event: Mouse event
@param dc: Device Context of Viewer
@param scaling: PLCOpen scaling applied on Viewer
"""
# Save the point where mouse was pressed in Viewer unit, position may
# be modified by scroll and zoom applied on viewer
self.StartPoint = GetScaledEventPosition(event, dc, scaling)
# Initialize rubberband bounding box
self.CurrentBBox = wx.Rect(self.StartPoint.x, self.StartPoint.y, 0, 0)
# Change viewer mouse cursor to reflect a rubberband bounding box is
# edited
self.DrawingSurface.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
self.Redraw()
示例12: Paste
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def Paste(self, bbx=None):
if not self.Debug:
element = self.ParentWindow.GetCopyBuffer()
if bbx is None:
mouse_pos = self.Editor.ScreenToClient(wx.GetMousePosition())
middle = wx.Rect(0, 0, *self.Editor.GetClientSize()).InsideXY(mouse_pos.x, mouse_pos.y)
if middle:
x, y = self.CalcUnscrolledPosition(mouse_pos.x, mouse_pos.y)
else:
x, y = self.CalcUnscrolledPosition(0, 0)
new_pos = [int(x / self.ViewScale[0]), int(y / self.ViewScale[1])]
else:
middle = True
new_pos = [bbx.x, bbx.y]
result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug)
if not isinstance(result, string_types):
self.RefreshBuffer()
self.RefreshView(selection=result)
self.RefreshVariablePanel()
self.ParentWindow.RefreshPouInstanceVariablesPanel()
else:
message = wx.MessageDialog(self.Editor, result, "Error", wx.OK | wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
示例13: GetAxesBoundingBox
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def GetAxesBoundingBox(self, parent_coordinate=False):
"""
Return figure bounding box in wx coordinate
@param parent_coordinate: True if use parent coordinate (default False)
"""
# Calculate figure bounding box. Y coordinate is inverted in matplotlib
# figure comparing to wx panel
width, height = self.GetSize()
ax, ay, aw, ah = self.figure.gca().get_position().bounds
bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1,
aw * width + 2, ah * height + 1)
# If parent_coordinate, add Viewer position in parent
if parent_coordinate:
xw, yw = self.GetPosition()
bbox.x += xw
bbox.y += yw
return bbox
示例14: _Rect___repr__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def _Rect___repr__(self):
return "wx.Rect"+str(self.Get())
示例15: _Rect___reduce__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Rect [as 别名]
def _Rect___reduce__(self):
return (Rect, self.Get())