Maxmad68 / PyTouchBar

A NSTouchBar Wrapper for Python
GNU General Public License v3.0
49 stars 11 forks source link

PyTouchBar

A NSTouchBar Wrapper for Python. It only works (for the moment) with Tkinter and PyGame.
It mainly depends on PyObjc to wrap NSTouchBar and related classes.
It also includes a wrapper to the haptic trackpad, allowing your Python program to trigger trackpad vibrations.
Note: It will (of course) only works on MacBook Pro with TouchBars, or on a TouchBar Simulator (you have a good one here.)

What's new

0.2.0:

Installation

To install PyTouchBar, just copy-paste the following command into a terminal:

pip install PyTouchBar

Example

Here is a simple example displaying a window with a label, and displaying a button in the touchbar.

from tkinter import *
import PyTouchBar

root = Tk()
PyTouchBar.prepare_tk_windows(root) # Tell PyTouchBar that the "root" window will have a TouchBar

# Build Tkinter interface
lbl = Label(root, text="Hello World")
lbl.pack()

# Build TouchBar
def action(button):
    print ("Button Pressed !")

btn = PyTouchBar.items.Button(title="Button", action=action)
PyTouchBar.set_touchbar([btn])

root.mainloop()

How to Use

All documentation is included in the wiki