pyobjc

RUMPS Updating Application Title

徘徊边缘 提交于 2021-02-19 07:38:29
问题 So I've been working on a little python application using rumps and I'd like to periodically update the title of the application in the status bar. There appears to be a function in rumps that should do what I'm looking for but I can't seem to get it to work, here's an adaption of some example code that shows the issue I'm running into: import rumps class AwesomeStatusBarApp(rumps.App): def __init__(self): super(AwesomeStatusBarApp, self).__init__("Awesome App") self.menu = ["updating"]

Obtain list of all window titles on macOS from a Python script

怎甘沉沦 提交于 2021-02-08 10:16:38
问题 I'd like to be able to obtain a list of strings of all the window titles on macOS from a Python script. On Windows, there's a win32 api (the enumWindows() function) that can do this; I'd like the macOS equivalent. Is this possible? I assume I'll need to use pyobjc. 回答1: The following script is based on the comment by Mark Setchell and prints application names and window names (using Python 3.7): import Quartz windows = Quartz.CGWindowListCopyWindowInfo(Quartz

Obtain list of all window titles on macOS from a Python script

感情迁移 提交于 2021-02-08 10:16:16
问题 I'd like to be able to obtain a list of strings of all the window titles on macOS from a Python script. On Windows, there's a win32 api (the enumWindows() function) that can do this; I'd like the macOS equivalent. Is this possible? I assume I'll need to use pyobjc. 回答1: The following script is based on the comment by Mark Setchell and prints application names and window names (using Python 3.7): import Quartz windows = Quartz.CGWindowListCopyWindowInfo(Quartz

How do I read an image from file for use with the `PyObjC Vision` framework?

喜夏-厌秋 提交于 2020-12-14 23:50:14
问题 I am trying to detect and decode barcodes from a library of images. In most cases pyzbar simply works (see code here). However, in some cases, my iPhone can decode the QR code but zbar fails. As I am on a mac, I can make use of the same Vision framework that the iPhone uses and there are even python wrappers to the macOS ObjC frameworks. I tried using Quartz.CGImageSourceCreateWithURL but that returns a None no matter what I pass it. def read_image(path): imageSrc = Quartz

How do I read an image from file for use with the `PyObjC Vision` framework?

孤者浪人 提交于 2020-12-14 23:40:57
问题 I am trying to detect and decode barcodes from a library of images. In most cases pyzbar simply works (see code here). However, in some cases, my iPhone can decode the QR code but zbar fails. As I am on a mac, I can make use of the same Vision framework that the iPhone uses and there are even python wrappers to the macOS ObjC frameworks. I tried using Quartz.CGImageSourceCreateWithURL but that returns a None no matter what I pass it. def read_image(path): imageSrc = Quartz

Issue with Installing PyObjC for Python

帅比萌擦擦* 提交于 2020-08-08 06:28:16
问题 I was attempting to install PyObjC on my Mac OS X El Capitan, and about 40 minutes into the download, I received an error and it stopped. I tried installing using the following code in my terminal: pip install pyobjc The error says: Command python setup.py egg_info failed with error code 1 in /private/var/folders/6x/pl46qrrj2n51fs9z00cw46240000gn/T/pip_build_Dustin/pyobjc-framework -AVKit Storing debug log for failure in /Users/Dustin/Library/Logs/pip.log I am using Xcode Version 7.3 and have

How create local notification on MacOS Catalina pyobjc?

拟墨画扇 提交于 2020-06-21 05:08:18
问题 I am having some difficulty finding out how to send local notifications on Catalina using pyobjc. The closes example I have seen is this: PyObjC "Notifications are not allowed for this application" 回答1: I have also been searching for this answer, so I'd like to share what I've found: The first thing you'll notice is that the function notify() defines a class, then returns an instance of it. You might be wonderinf why you can't directly call Notification.send(params) . I tried it, but I was

PyObjC “Notifications are not allowed for this application”

隐身守侯 提交于 2020-06-17 09:54:28
问题 I'm trying to test a simple Python script to send out a macOS notification: import objc import UserNotifications from PyObjCTools import AppHelper def notif_callback(err): print("Error in notification callback:",err) def auth_callback(granted, err): print("Granted: ",granted,) print("Error in authorization request: ",err) content=UserNotifications.UNMutableNotificationContent.alloc().init() content.setTitle_("Test") r=UserNotifications.UNNotificationRequest.requestWithIdentifier_content

OS X: Move window from Python

时间秒杀一切 提交于 2020-06-13 04:32:14
问题 I'm trying to move around windows programatically from Python on OS X. I found a snippet of AppleScript here on Stackoverflow which does this, but I'd like to do it in Python or another "real" scripting language. This is my Python script, which does not work. I wrote the output of print commands below each of them. #!/usr/bin/python from Foundation import * from ScriptingBridge import * app = SBApplication.applicationWithBundleIdentifier_("com.apple.SystemEvents") finderProc = app.processes()

Writing Cocoa applications in Python 3

自作多情 提交于 2020-02-06 05:26:24
问题 It looks like PyObjC is not ported to Python 3 yet. Meanwhile is there a way to write Cocoa applications using Python 3? I am intending to start a new MacOSX GUI application project and though5 would want to use Python 3.x instead of Python 2.x. 回答1: For full-blown Cocoa, I think PyObjC is pretty much the only game in town. If you are coming to Cocoa from a Python background rather than to Python from an Obj-C Cocoa background, surely the learning curve of the Cocoa APIs is much steeper than