当前位置: 首页>>代码示例>>Python>>正文


Python NSScreen.mainScreen方法代码示例

本文整理汇总了Python中AppKit.NSScreen.mainScreen方法的典型用法代码示例。如果您正苦于以下问题:Python NSScreen.mainScreen方法的具体用法?Python NSScreen.mainScreen怎么用?Python NSScreen.mainScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppKit.NSScreen的用法示例。


在下文中一共展示了NSScreen.mainScreen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
    def __init__(self):
        super(SplshApp, self).__init__('Splsh')
        self.icon = 'img/icon.png'

        try:
            self.screen_width = int(NSScreen.mainScreen().frame().size.width)
            self.screen_height = int(NSScreen.mainScreen().frame().size.height)
        except:
            self.screen_width = 1024
            self.screen_height = 768

        self.menu = [
            'x'.join([str(self.screen_width), str(self.screen_height)]),
            None,
            rumps.MenuItem('Next', key='n'),
            None,
            rumps.MenuItem('Gray Mood'),
            rumps.MenuItem('Blur'),
            rumps.MenuItem('Clear Cache', key='c'),
            None,
        ]

        # Path to dir for downloaded images
        self.media_dir = 'media/'
        # Extra url parameters
        self.gray_mood = False
        self.blur = False
开发者ID:Egregors,项目名称:pySplash,代码行数:29,代码来源:splsh.py

示例2: run

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def run(self):
     self._logger.debug('MainAction::run')
     destination = os.path.realpath('wllpx.jpg')
     tempFilename = os.path.realpath('temp.jpg')
     media = self._instagramFeed.getNext()
     self._settingsController.set('CURRENT_MEDIA_ID', media.id)
     self._downloader.fromUrl(media.url, tempFilename)
     width, height = int(NSScreen.mainScreen().frame().size.width), int(NSScreen.mainScreen().frame().size.height)
     self._wallpaperGenerator.generate(width, height, tempFilename, destination)
     self._wallpaperController.setWallpaper(destination)
开发者ID:jackdbernier,项目名称:wllpx,代码行数:12,代码来源:application.py

示例3: reflow

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
    def reflow(self, window_manager = None, screen = NSScreen.mainScreen(), space_id = None):
        menubar_offset = 0 if self.ignore_menu else 22

        windows = window_manager.get_managed_windows(screen, space_id)
        screen_frame = screen.frame()

        left = screen_frame[0][0] + self.border
        top = screen_frame[0][1] + self.border + menubar_offset
        right = screen_frame[1][0] - self.border
        bottom = screen_frame[1][1] - self.border - menubar_offset

        gutter_left = screen_frame[1][0] * self.ratio - self.gutter / 2
        gutter_right = gutter_left + self.gutter

        slave_count = len(windows) - 1
        logging.debug('Number of slave windows: %d.', slave_count)
        slave_height = ((bottom - top) - self.gutter * (slave_count - 1)) / slave_count
        logging.debug('Slave window height is %f.', slave_height)
        count = 0
        offset = 0
        for window in windows:
            if count == 0:
                window.frame = (left, top, gutter_left - left, bottom - top)
            else:
                window.position = (gutter_right, top + offset)
                window.size = (right - gutter_right, slave_height)
                offset += slave_height + self.gutter
                logging.debug('New window frame: %f, %f, %f, %f', window.position[0], window.position[1], window.size[0], window.size[1])
            count += 1
开发者ID:atheriel,项目名称:wm,代码行数:31,代码来源:layout.py

示例4: get_desktop_size

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
def get_desktop_size():
    """ Get the current desktop resolution. No more than 2K.

        Return a tuple of pixels (width, height)
    """
    from AppKit import NSScreen

    frame = NSScreen.mainScreen().frame()
    height = frame.size.height
    width = frame.size.width


    MAX_WIDTH = 2000
    MAX_HEIGHT = 2000

    if width > MAX_WIDTH or height > MAX_HEIGHT:
        if width > height:
            max = width
            ratio = max / MAX_WIDTH
        else:
            max = height
            ratio = max / MAX_HEIGHT
        width = width / ratio
        height = height / ratio

    return (int(width), int(height))
开发者ID:tracyhatemice,项目名称:EarthLivePython,代码行数:28,代码来源:wallpaper.py

示例5: __init__

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def __init__(self, style = 'standard', zoomable = None, **kwds):
     # We ignore zoomable, since it's the same as resizable.
     self._style = style
     options = dict(_default_options_for_style[style])
     for option in ['movable', 'closable', 'hidable', 'resizable']:
         if option in kwds:
             options[option] = kwds.pop(option)
     self._ns_style_mask = self._ns_window_style_mask(**options)
     if style == 'fullscreen':
         ns_rect = NSScreen.mainScreen().frame()
     else:
         ns_rect = NSRect(NSPoint(0, 0), NSSize(self._default_width, self._default_height))
     ns_window = PyGUI_NSWindow.alloc()
     ns_window.initWithContentRect_styleMask_backing_defer_(
         ns_rect, self._ns_style_mask, AppKit.NSBackingStoreBuffered, True)
     ns_content = PyGUI_NS_ContentView.alloc()
     ns_content.initWithFrame_(NSRect(NSPoint(0, 0), NSSize(0, 0)))
     ns_content.pygui_component = self
     ns_window.setContentView_(ns_content)
     ns_window.setAcceptsMouseMovedEvents_(True)
     ns_window.setDelegate_(ns_window)
     ns_window.pygui_component = self
     self._ns_window = ns_window
     GWindow.__init__(self, style = style, closable = options['closable'],
         _ns_view = ns_window.contentView(), _ns_responder = ns_window,
         _ns_set_autoresizing_mask = False,
         **kwds)
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:29,代码来源:Window.py

示例6: getScreenResolution

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
    def getScreenResolution(cls, index =-1):

        #-------------------------------------------------------------------------------------------
        if cls.isMac():
            try:
                import AppKit
                from AppKit import NSScreen

                if index == -1:
                    return int(NSScreen.mainScreen().frame().size.width), \
                           int(NSScreen.mainScreen().frame().size.height)

                i = 0
                for screen in AppKit.NSScreen.screens():
                    if i != index:
                        continue
                    return screen.frame().size.width, screen.frame().size.height
                return None
            except Exception:
                pass

            result = cls._getOsxDisplayInfo()
            if result['code'] or not 'out' in result:
                return None

            if index < 0:
                index = 0
            screenIndex = 0
            for line in result['out'].split('\n'):
                line = line.strip().lower()
                if not line.startswith('resolution:'):
                    continue
                if screenIndex != index:
                    continue

                result = re.search(r'(?P<width>[0-9]{3,})[^0-9]+(?P<height>[0-9]{3,})', line)
                return int(result.group('width')), int(result.group('height'))
            return None

        #-------------------------------------------------------------------------------------------
        if cls.isWindows():
            try:
                import ctypes
            except Exception:
                return None
            user32 = ctypes.windll.user32
            return int(user32.GetSystemMetrics(0)), int(user32.GetSystemMetrics(1))
开发者ID:sernst,项目名称:PyAid,代码行数:49,代码来源:OsUtils.py

示例7: isfullscreen

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def isfullscreen(self):
     """return true if fullscreen"""
     if len(self.windows)==0:
         return False
     f=NSScreen.mainScreen().frame()
     m=([f.origin.x,f.origin.y,f.size.width,f.size.height])
     w=self.windows[0].bounds
     return ([w[0],w[2],w[3]])==([m[0],m[2],m[3]])
开发者ID:ninioperdido,项目名称:presentacion_letsas4,代码行数:10,代码来源:safari.py

示例8: _stagger

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def _stagger(self):
     key_win = application()._ns_key_window
     if key_win:
         (x, y), (w, h) = key_win._ns_window.frame()
         p = self._ns_window.cascadeTopLeftFromPoint_(NSPoint(x, y + h))
         self._ns_window.setFrameTopLeftPoint_(p)
     else:
         (x, y), (w, h) = NSScreen.mainScreen().visibleFrame()
         ns_vis_topleft = NSPoint(x, y + h)
         self._ns_window.setFrameTopLeftPoint_(ns_vis_topleft)
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:12,代码来源:Window.py

示例9: get_icc_info

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
def get_icc_info():
    from AppKit import NSScreen     #@UnresolvedImport
    ms = NSScreen.mainScreen()
    info = do_get_screen_icc_info(ms)
    screens = NSScreen.screens()
    for i, screen in enumerate(screens):
        si = do_get_screen_icc_info(screen)
        if si:
            info[i] = si
    return info
开发者ID:ljmljz,项目名称:xpra,代码行数:12,代码来源:gui.py

示例10: _screen_size

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def _screen_size(cls):
     from AppKit import NSScreen
     return NSScreen.mainScreen().frame().size
开发者ID:annulen,项目名称:webkit,代码行数:5,代码来源:osx_browser_driver.py

示例11: __init__

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def __init__(self, posSize, title="", minSize=None, maxSize=None, textured=False,
             autosaveName=None, closable=True, miniaturizable=True, initiallyVisible=True,
             fullScreenMode=None, titleVisible=True, fullSizeContentView=False, screen=None):
     mask = self.nsWindowStyleMask
     if closable:
         mask = mask | NSClosableWindowMask
     if miniaturizable:
         mask = mask | NSMiniaturizableWindowMask
     if minSize or maxSize:
         mask = mask | NSResizableWindowMask
     if textured:
         mask = mask | NSTexturedBackgroundWindowMask
     if fullSizeContentView and osVersionCurrent >= osVersion10_10:
         mask = mask | NSFullSizeContentViewWindowMask
     # start the window
     ## too magical?
     if len(posSize) == 2:
         l = t = 100
         w, h = posSize
         cascade = True
     else:
         l, t, w, h = posSize
         cascade = False
     if screen is None:
         screen = NSScreen.mainScreen()
     frame = _calcFrame(screen.visibleFrame(), ((l, t), (w, h)))
     self._window = self.nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_screen_(
         frame, mask, NSBackingStoreBuffered, False, screen)
     if autosaveName is not None:
         # This also sets the window frame if it was previously stored.
         # Make sure we do this before cascading.
         self._window.setFrameAutosaveName_(autosaveName)
     if cascade:
         self._cascade()
     if minSize is not None:
         self._window.setMinSize_(minSize)
     if maxSize is not None:
         self._window.setMaxSize_(maxSize)
     self._window.setTitle_(title)
     self._window.setLevel_(self.nsWindowLevel)
     self._window.setReleasedWhenClosed_(False)
     self._window.setDelegate_(self)
     self._bindings = {}
     self._initiallyVisible = initiallyVisible
     # full screen mode
     if osVersionCurrent >= osVersion10_7:
         if fullScreenMode is None:
             pass
         elif fullScreenMode == "primary":
             self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenPrimary)
         elif fullScreenMode == "auxiliary":
             self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenAuxiliary)
     # titlebar visibility
     if osVersionCurrent >= osVersion10_10:
         if not titleVisible:
             self._window.setTitleVisibility_(NSWindowTitleHidden)
         else:
             self._window.setTitleVisibility_(NSWindowTitleVisible)
     # full size content view
     if fullSizeContentView and osVersionCurrent >= osVersion10_10:
         self._window.setTitlebarAppearsTransparent_(True)
开发者ID:typesupply,项目名称:vanilla,代码行数:63,代码来源:vanillaWindows.py

示例12: reload

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
from Foundation import NSColor, NSUserDefaults, NSMakeRange
from AppKit import NSScreen


# # # # # # # # # 
debugMode = False
# Glyphs.clearLog()
# # # # # # # # # 

try:
	reload(Customizables)
except: pass
excludedSubCategories = Customizables.excludedSubCategories


screenHeight = NSScreen.mainScreen().frame().size.height


##########################################################################
##########################################################################
##########################################################################
##########################################################################



class KernKraft(object):

	version = "1.8"
	# excludeCategories = []

	def __init__(self, Glyphs, thisFont, mID):
开发者ID:davelab6,项目名称:Kernkraft,代码行数:33,代码来源:KernKraftModule.py

示例13: int

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os.path
import Foundation
from AppKit import NSScreen

try:
    width, height = (int(NSScreen.mainScreen().frame().size.width), 
                    int(NSScreen.mainScreen().frame().size.height))
    extension_attribute = u"{0:g}\u00D7{1:g}".format(width, height)
    print(extension_attribute)
except:
    extension_attribute = "Unknown"

extension_attribute_result = u"<result>{0}</result>".format(extension_attribute)
print(extension_attribute_result)
开发者ID:Jaharmi,项目名称:extension_attribute,代码行数:32,代码来源:screen_resolution.py

示例14: get

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
 def get():
     from AppKit import NSScreen
     frame = NSScreen.mainScreen().frame()
     return (int(frame.size.width), int(frame.size.height))
开发者ID:Dexton,项目名称:wallpapermaker,代码行数:6,代码来源:get_resolution.py

示例15: screen_resolution

# 需要导入模块: from AppKit import NSScreen [as 别名]
# 或者: from AppKit.NSScreen import mainScreen [as 别名]
def screen_resolution():
    s = NSScreen.mainScreen().frame()
    return {'width': s.size.width, 'height':s.size.height}
开发者ID:pindia,项目名称:onemaus,代码行数:5,代码来源:controller.py


注:本文中的AppKit.NSScreen.mainScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。