本文整理匯總了Python中wx.Display方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.Display方法的具體用法?Python wx.Display怎麽用?Python wx.Display使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wx
的用法示例。
在下文中一共展示了wx.Display方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: takeScreenshot
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def takeScreenshot(self, rect = None, timestamp=False):
"""Takes a screenshot of the screen at give pos & size (rect).
Code from Andrea -
http://lists.wxwidgets.org/pipermail/wxpython-users/2007-October/069666.html
"""
# use whole screen if none specified
if not rect:
#width, height = wx.DisplaySize()
#rect = wx.Rect(0,0,width,height)
x, y, width, height = wx.Display().GetGeometry()
rect = wx.Rect(x,y,width,height)
try:
# use two monitors if checked and available
if (self.getConfig('screenshot_dual_monitor')
and wx.Display_GetCount() > 0):
second = wx.Display(1)
x2, y2, width2, height2 = second.GetGeometry()
x3 = min(x,x2)
y3 = min(y, y2)
width3 = max(x+width, x2+width2) - x3
height3 = max(height-y3, height2-y3)
rect = wx.Rect(x3, y3, width3, height3)
except Exception, e:
self.warning(
"Exception while attempting to capture second "
+ "monitor: %s" % repr(e))
#Create a DC for the whole screen area
示例2: CheckCropping
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def CheckCropping(self):
""" Display frame at time "time" for video to check if cropping is fine.
Select ROI of interest by adjusting values in myconfig.py
USAGE for cropping:
clip.crop(x1=None, y1=None, x2=None, y2=None, width=None, height=None, x_center=None, y_center=None)
Returns a new clip in which just a rectangular subregion of the
original clip is conserved. x1,y1 indicates the top left corner and
x2,y2 is the lower right corner of the cropped region.
All coordinates are in pixels. Float numbers are accepted.
"""
videosource = self.video_source
self.x1 = int(self.cfg["video_sets"][videosource]["crop"].split(",")[0])
self.x2 = int(self.cfg["video_sets"][videosource]["crop"].split(",")[1])
self.y1 = int(self.cfg["video_sets"][videosource]["crop"].split(",")[2])
self.y2 = int(self.cfg["video_sets"][videosource]["crop"].split(",")[3])
if self.cropping == True:
# Select ROI of interest by drawing a rectangle
self.cid = RectangleSelector(
self.axes,
self.line_select_callback,
drawtype="box",
useblit=False,
button=[1],
minspanx=5,
minspany=5,
spancoords="pixels",
interactive=True,
)
self.canvas.mpl_connect("key_press_event", self.cid)
示例3: __init__
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def __init__(self):
displays = (
wx.Display(i) for i in range(wx.Display.GetCount())
) # Gets the number of displays
screenSizes = [
display.GetGeometry().GetSize() for display in displays
] # Gets the size of each display
index = 0 # For display 1.
screenWidth = screenSizes[index][0]
screenHeight = screenSizes[index][1]
self.gui_size = (screenWidth * 0.7, screenHeight * 0.55)
wx.Frame.__init__(
self,
None,
wx.ID_ANY,
"DeepLabCut",
size=wx.Size(self.gui_size),
pos=wx.DefaultPosition,
style=wx.RESIZE_BORDER | wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
)
dlcparent_path = auxiliaryfunctions.get_deeplabcut_path()
media_path = os.path.join(dlcparent_path, "gui", "media")
logo = os.path.join(media_path, "logo.png")
self.SetIcon(wx.Icon(logo))
self.SetSizeHints(
wx.Size(self.gui_size)
) # This sets the minimum size of the GUI. It can scale now!
# Here we create a panel and a notebook on the panel
self.panel = wx.Panel(self)
self.nb = wx.Notebook(self.panel)
# create the page windows as children of the notebook and add the pages to the notebook with the label to show on the tab
page1 = Welcome(self.nb, self.gui_size)
self.nb.AddPage(page1, "Welcome")
page2 = Create_new_project(self.nb, self.gui_size)
self.nb.AddPage(page2, "Manage Project")
self.sizer = wx.BoxSizer()
self.sizer.Add(self.nb, 1, wx.EXPAND)
self.panel.SetSizer(self.sizer)
示例4: load_geometry
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def load_geometry(self, geometry, default_size=None):
if '+' in geometry:
s, x, y = geometry.split('+')
x, y = int(x), int(y)
else:
x, y = -1, -1
s = geometry
if 'x' in s:
w, h = s.split('x')
w, h = int(w), int(h)
else:
w, h = -1, -1
i = 0
if '__WXMSW__' in wx.PlatformInfo:
i = wx.Display.GetFromWindow(self)
d = wx.Display(i)
(x1, y1, x2, y2) = d.GetGeometry()
x = min(x, x2-64)
y = min(y, y2-64)
if (w, h) <= (0, 0) and default_size is not None:
w = default_size.width
h = default_size.height
self.SetDimensions(x, y, w, h, sizeFlags=wx.SIZE_USE_EXISTING)
if (x, y) == (-1, -1):
self.CenterOnScreen()
示例5: _check_geometry
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def _check_geometry(self, x,y,width,height):
# check whether a significant part would be visible
geometry = wx.Rect(x,y,width,height)
for d in range(wx.Display.GetCount()):
display = wx.Display(d)
client_area = display.ClientArea
if not client_area.width or not client_area.height:
# the display info is broken on some installations
continue
intersection = client_area.Intersect(geometry)
if intersection.width>150 and intersection.height>150 or geometry.width==-1 or geometry.height==-1:
return True
return False
示例6: _position_dialog
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def _position_dialog(self, dialog, obj=None, pos=None, event=None):
if not hasattr(dialog, "GetScreenRect"):
return # e.g. _FileDialog is not really a dialog
if obj is None and pos is None and event is not None:
obj = event.GetEventObject()
if obj is not None:
display = wx.Display.GetFromWindow(obj)
rect = obj.GetScreenRect()
#pos = (rect.x + rect.width/2, rect.y + rect.height/2)
pos = rect.TopLeft + (rect.width/2, rect.height/2)
else:
display = wx.Display.GetFromPoint(pos)
if display<0:
dialog.CenterOnScreen()
return
display = wx.Display( display ).ClientArea
d_rect = dialog.GetScreenRect()
shift = pos - d_rect.TopLeft
#new_rect = wx.Rect( d_rect.TopLeft + shift, d_rect.Size ) # for Classic, RectPS would be required
new_rect = wx.Rect(d_rect.x+shift.x, d_rect.y+shift.y, d_rect.width, d_rect.height)
if display.Contains(new_rect.TopLeft) and display.Contains(new_rect.BottomRight):
dialog.SetPosition( new_rect.TopLeft )
return
# shift required
left, top = new_rect.TopLeft
if not display.Contains( new_rect.BottomRight ):
left += min(0, ( display.x + display.width ) - ( new_rect.x + new_rect.width ) )
top += min(0, ( display.y + display.height ) - ( new_rect.y + new_rect.height ) )
if top < display.Top: top = display.Top
if left < display.Left: left = display.Left
dialog.SetPosition( (left,top) )
示例7: __init__
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def __init__(self, parent, value, *args, **kwargs):
numDisplays = wx.Display().GetCount()
choices = ["Monitor %d" % (i + 1) for i in range(numDisplays)]
eg.Choice.__init__(self, parent, value, choices, *args, **kwargs)
示例8: init_layout_settings
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Display [as 別名]
def init_layout_settings(self):
# either load from file or init with defaults
display_area = wx.Display(0).ClientArea
default_pos = display_area.TopLeft
height = display_area.height
width = 800
default_size = (width,height)
self.layout_settings = {}
self.layout_settings["layout"] = 0
self.layout_settings["sash_positions"] = [[400, 380 ], # 0: palette and properties left; tree right
[height//2,400 ], # 1: palette and tree top; properties bottom
[2*height//3,height//3] ] # 2: all on top of each other
self.layout_settings["widths"] = [width,500] # for layouts 0/1 and 2
self.layout_settings["height"] = height
self.layout_settings["x"], self.layout_settings["y"] = default_pos
if not config.preferences.remember_geometry:
return default_pos, default_size, 0
# read from preferences
try:
layout = config.preferences.get_int("layout", "layout")
x = config.preferences.get_int("layout", "x")
y = config.preferences.get_int("layout", "y")
widths = [config.preferences.get_int("layout", "widths_l0"),
config.preferences.get_int("layout", "widths_l1")]
width = widths[0] if layout<2 else widths[1]
height = config.preferences.get_int("layout", "height")
sash_positions = [[config.preferences.get_int("layout", "sash_positions_l0_l0"),
config.preferences.get_int("layout", "sash_positions_l0_l1")],
[config.preferences.get_int("layout", "sash_positions_l1_l0"),
config.preferences.get_int("layout", "sash_positions_l1_l1")],
[config.preferences.get_int("layout", "sash_positions_l2_l0"),
config.preferences.get_int("layout", "sash_positions_l2_l1")]]
except:
return default_pos, default_size, 0
if layout<0 or layout>2 or not self._check_geometry(x, y, width, height):
return default_pos, default_size, 0
self.layout_settings["height"] = height
self.layout_settings["sash_positions"] = sash_positions
self.layout_settings["widths"] = widths
return (x,y), (widths[0],height), layout # return widths[0] as 0 is the initial setting