def changeTextFont_(self, sender):
        "The user changed the current font selection, so update the default font"

        # Get font name and size from user defaults
        defaults = NSUserDefaultsController.sharedUserDefaultsController().values()
        fontName = getKey(defaults, 'FontName')
        fontSize = getKey(defaults, 'FontSize')

        # Create font from name and size; initialize font panel
        font = NSFont.fontWithName_size_(fontName, fontSize)
        if font is None:
            font = NSFont.systemFontOfSize_(NSFont.systemFontSize())
        NSFontManager.sharedFontManager().setSelectedFont_isMultiple_(font, False)
        NSFontManager.sharedFontManager().orderFrontFontPanel_(self)

        # Set window as firstResponder so we get changeFont: messages
        self.window().makeFirstResponder_(self.window())
    def changeTextFont_(self, sender):
        "The user changed the current font selection, so update the default font"

        # Get font name and size from user defaults
        defaults = NSUserDefaultsController.sharedUserDefaultsController(
        ).values()
        fontName = getKey(defaults, "FontName")
        fontSize = getKey(defaults, "FontSize")

        # Create font from name and size; initialize font panel
        font = NSFont.fontWithName_size_(fontName, fontSize)
        if font is None:
            font = NSFont.systemFontOfSize_(NSFont.systemFontSize())
        NSFontManager.sharedFontManager().setSelectedFont_isMultiple_(
            font, False)
        NSFontManager.sharedFontManager().orderFrontFontPanel_(self)

        # Set window as firstResponder so we get changeFont: messages
        self.window().makeFirstResponder_(self.window())
예제 #3
0
    def drawRect_(self, rect):
        defaults = NSUserDefaultsController.sharedUserDefaultsController().values()
        favoriteColor = NSUnarchiver.unarchiveObjectWithData_(getKey(defaults, 'FavoriteColor'))
        fontName = getKey(defaults, 'FontName')
        fontSize = getKey(defaults, 'FontSize')
        favoriteFont = NSFont.fontWithName_size_(fontName, fontSize)
        wordOfTheDay = getKey(defaults, 'WordOfTheDay')

        # Do the actual drawing
        myBounds = self.bounds() # = (x, y), (bw, bh)
        NSDrawLightBezel(myBounds, myBounds)
        favoriteColor.set()
        NSRectFill(NSInsetRect(myBounds, 2, 2))
        attrsDictionary = {NSFontAttributeName: favoriteFont}
        attrString = NSAttributedString.alloc().initWithString_attributes_(wordOfTheDay, attrsDictionary)
        attrSize = attrString.size() # = (bw, bh)
        attrString.drawAtPoint_(
            NSMakePoint(
                (attrSize.width / -2) + (myBounds.size.width / 2),
                (attrSize.height / -2) + (myBounds.size.height / 2),
            ),
        )
예제 #4
0
import rumps
import speedtest as st
from AppKit import NSAttributedString
from PyObjCTools.Conversion import propertyListFromPythonCollection
from Cocoa import (NSFont, NSFontAttributeName, NSColor,
                   NSForegroundColorAttributeName)

font = NSFont.fontWithName_size_("Monaco", 11.0)
red = NSColor.redColor()
yellow = NSColor.yellowColor()
green = NSColor.greenColor()


class SpeedTestApp(object):
    def __init__(self):
        self.config = {
            "app_name": "SpeedTest",
            "start": "Check Speed",
            "interval": 1500
        }
        self.app = rumps.App(self.config["app_name"])
        self.timer = rumps.Timer(self.on_tick, 60)
        self.interval = self.config["interval"]
        self.set_up_menu()
        self.update_button = rumps.MenuItem(title=self.config["start"],
                                            callback=self.check_speed)
        self.app.menu = [self.update_button]

    def set_up_menu(self):
        self.timer.stop()
        self.timer.count = 0
 def transformedValue_(self, aValue):
     font = NSFont.fontWithName_size_(aValue, 12)
     return font.displayName()
예제 #6
0
import plistlib

import launchd
import rumps
import subprocess

from AppKit import NSAttributedString
from PyObjCTools.Conversion import propertyListFromPythonCollection
from Cocoa import (NSFont, NSFontAttributeName, NSColor,
                   NSForegroundColorAttributeName)
from launchd.cmd import launchctl

ICON_PATH = "../assets/[email protected]"
USER_AGENTS = os.path.expanduser('~/Library/LaunchAgents')

FONT = NSFont.fontWithName_size_("Hack Nerd Font", 14.0)
color = {
    "red": NSColor.redColor(),
    "blue": NSColor.blueColor(),
    "green": NSColor.greenColor()
}
r_attr = propertyListFromPythonCollection(
    {
        # NSFontAttributeName: FONT,
        NSForegroundColorAttributeName: color['red']
    },
    conversionHelper=lambda x: x)
g_attr = propertyListFromPythonCollection(
    {
        # NSFontAttributeName: FONT,
        NSForegroundColorAttributeName: color['green']
 def transformedValue_(self, aValue):
     font = NSFont.fontWithName_size_(aValue, 12)
     return font.displayName()