Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World directions #4

Open
dregaladodiaz opened this issue Jul 19, 2021 · 5 comments
Open

Hello World directions #4

dregaladodiaz opened this issue Jul 19, 2021 · 5 comments

Comments

@dregaladodiaz
Copy link

I ran testTk() function but my touch bar didn't change at all. Am I missing something? If there is simpler way to run a hello world example, please give me some directions.

python touchbar.py
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

Hardware
Complete MacBook Pro 16-Inch "Core i7" 2.6 2019 Specs

OSX

❯ sw_vers
ProductName:	macOS
ProductVersion:	11.4
BuildVersion:	20F71

I just created a virtual environment an install following requirements
requirements.txt

pyobjc==7.3
pyobjc-core==7.3
pyobjc-framework-Accessibility==7.3
pyobjc-framework-Accounts==7.3
pyobjc-framework-AddressBook==7.3
pyobjc-framework-AdServices==7.3
pyobjc-framework-AdSupport==7.3
pyobjc-framework-AppleScriptKit==7.3
pyobjc-framework-AppleScriptObjC==7.3
pyobjc-framework-ApplicationServices==7.3
pyobjc-framework-AppTrackingTransparency==7.3
pyobjc-framework-AuthenticationServices==7.3
pyobjc-framework-AutomaticAssessmentConfiguration==7.3
pyobjc-framework-Automator==7.3
pyobjc-framework-AVFoundation==7.3
pyobjc-framework-AVKit==7.3
pyobjc-framework-BusinessChat==7.3
pyobjc-framework-CalendarStore==7.3
pyobjc-framework-CallKit==7.3
pyobjc-framework-CFNetwork==7.3
pyobjc-framework-ClassKit==7.3
pyobjc-framework-CloudKit==7.3
pyobjc-framework-Cocoa==7.3
pyobjc-framework-Collaboration==7.3
pyobjc-framework-ColorSync==7.3
pyobjc-framework-Contacts==7.3
pyobjc-framework-ContactsUI==7.3
pyobjc-framework-CoreAudio==7.3
pyobjc-framework-CoreAudioKit==7.3
pyobjc-framework-CoreBluetooth==7.3
pyobjc-framework-CoreData==7.3
pyobjc-framework-CoreHaptics==7.3
pyobjc-framework-CoreLocation==7.3
pyobjc-framework-CoreMedia==7.3
pyobjc-framework-CoreMediaIO==7.3
pyobjc-framework-CoreMIDI==7.3
pyobjc-framework-CoreML==7.3
pyobjc-framework-CoreMotion==7.3
pyobjc-framework-CoreServices==7.3
pyobjc-framework-CoreSpotlight==7.3
pyobjc-framework-CoreText==7.3
pyobjc-framework-CoreWLAN==7.3
pyobjc-framework-CryptoTokenKit==7.3
pyobjc-framework-DeviceCheck==7.3
pyobjc-framework-DictionaryServices==7.3
pyobjc-framework-DiscRecording==7.3
pyobjc-framework-DiscRecordingUI==7.3
pyobjc-framework-DiskArbitration==7.3
pyobjc-framework-DVDPlayback==7.3
pyobjc-framework-EventKit==7.3
pyobjc-framework-ExceptionHandling==7.3
pyobjc-framework-ExecutionPolicy==7.3
pyobjc-framework-ExternalAccessory==7.3
pyobjc-framework-FileProvider==7.3
pyobjc-framework-FileProviderUI==7.3
pyobjc-framework-FinderSync==7.3
pyobjc-framework-FSEvents==7.3
pyobjc-framework-GameCenter==7.3
pyobjc-framework-GameController==7.3
pyobjc-framework-GameKit==7.3
pyobjc-framework-GameplayKit==7.3
pyobjc-framework-ImageCaptureCore==7.3
pyobjc-framework-IMServicePlugIn==7.3
pyobjc-framework-InputMethodKit==7.3
pyobjc-framework-InstallerPlugins==7.3
pyobjc-framework-InstantMessage==7.3
pyobjc-framework-Intents==7.3
pyobjc-framework-IOSurface==7.3
pyobjc-framework-iTunesLibrary==7.3
pyobjc-framework-KernelManagement==7.3
pyobjc-framework-LatentSemanticMapping==7.3
pyobjc-framework-LaunchServices==7.3
pyobjc-framework-libdispatch==7.3
pyobjc-framework-LinkPresentation==7.3
pyobjc-framework-LocalAuthentication==7.3
pyobjc-framework-MapKit==7.3
pyobjc-framework-MediaAccessibility==7.3
pyobjc-framework-MediaLibrary==7.3
pyobjc-framework-MediaPlayer==7.3
pyobjc-framework-MediaToolbox==7.3
pyobjc-framework-Metal==7.3
pyobjc-framework-MetalKit==7.3
pyobjc-framework-MetalPerformanceShaders==7.3
pyobjc-framework-MetalPerformanceShadersGraph==7.3
pyobjc-framework-MLCompute==7.3
pyobjc-framework-ModelIO==7.3
pyobjc-framework-MultipeerConnectivity==7.3
pyobjc-framework-NaturalLanguage==7.3
pyobjc-framework-NetFS==7.3
pyobjc-framework-Network==7.3
pyobjc-framework-NetworkExtension==7.3
pyobjc-framework-NotificationCenter==7.3
pyobjc-framework-OpenDirectory==7.3
pyobjc-framework-OSAKit==7.3
pyobjc-framework-OSLog==7.3
pyobjc-framework-PassKit==7.3
pyobjc-framework-PencilKit==7.3
pyobjc-framework-Photos==7.3
pyobjc-framework-PhotosUI==7.3
pyobjc-framework-PreferencePanes==7.3
pyobjc-framework-PushKit==7.3
pyobjc-framework-Quartz==7.3
pyobjc-framework-QuickLookThumbnailing==7.3
pyobjc-framework-ReplayKit==7.3
pyobjc-framework-SafariServices==7.3
pyobjc-framework-SceneKit==7.3
pyobjc-framework-ScreenSaver==7.3
pyobjc-framework-ScreenTime==7.3
pyobjc-framework-ScriptingBridge==7.3
pyobjc-framework-SearchKit==7.3
pyobjc-framework-Security==7.3
pyobjc-framework-SecurityFoundation==7.3
pyobjc-framework-SecurityInterface==7.3
pyobjc-framework-ServiceManagement==7.3
pyobjc-framework-Social==7.3
pyobjc-framework-SoundAnalysis==7.3
pyobjc-framework-Speech==7.3
pyobjc-framework-SpriteKit==7.3
pyobjc-framework-StoreKit==7.3
pyobjc-framework-SyncServices==7.3
pyobjc-framework-SystemConfiguration==7.3
pyobjc-framework-SystemExtensions==7.3
pyobjc-framework-UniformTypeIdentifiers==7.3
pyobjc-framework-UserNotifications==7.3
pyobjc-framework-UserNotificationsUI==7.3
pyobjc-framework-VideoSubscriberAccount==7.3
pyobjc-framework-VideoToolbox==7.3
pyobjc-framework-Virtualization==7.3
pyobjc-framework-Vision==7.3
pyobjc-framework-WebKit==7.3
PyTouchBar==0.2.0

touchbar.py

# from import *
from PyTouchBar import set_touchbar, TouchBarItems, Alignment, prepare_tk_windows
from tkinter import *

def testTk():
	fen = Tk()
	
	prepare_tk_windows(fen)
	btn = Button(fen, text="Hello")
	btn.pack()
	
	btn1 = TouchBarItems.SegmentedControls.Control(title='Hello', alignment = Alignment.left, selected = True, width = 100)
	btn2 = TouchBarItems.SegmentedControls.Control(title='World', alignment = Alignment.right, enabled = True, width = 100)
	
	def action(segCont):
		print (list(segCont.selectedItems()))
		pass
		
	segcon = TouchBarItems.SegmentedControls([
		btn1,
		btn2
	], action = action, type = TouchBarItems.SegmentedControls.Type.select_one)
	
	set_touchbar([segcon])
	fen.mainloop()


if __name__ == '__main__':
    testTk()
@Maxmad68
Copy link
Owner

Good morning,
Sorry for the late response,
Uh, that's strange... The touchbar normally changes when the window is focused, can you confirm the Tkinter window was on the front?

This is a simple "Hello World" program, it just shows a "Hello World!" label on the touchbar for an empty tkinter window:

from PyTouchBar import *

fen = Tk()

prepare_tk_windows(fen)

lbl = TouchBarItems.Label(text = "Hello World!")
set_touchbar([lbl])

fen.mainloop()

@letsgo00
Copy link

letsgo00 commented Oct 6, 2021

Hi, this example does not work for me too, I get a blank touchbar on python 3.10

EDIT: Found the solution, after I added a label or something to the TK window the Label on the touchbar showed up

@dregaladodiaz
Copy link
Author

from PyTouchBar import *

fen = Tk()

prepare_tk_windows(fen)

lbl = TouchBarItems.Label(text = "Hello World!")
set_touchbar([lbl])

fen.mainloop()

Using Python 3.8.2 and requirements.txt listed above it works me!, thanks @Maxmad68 .
Hint: it didn't works with VSCode integrated terminal, use Terminal instead.

@dregaladodiaz
Copy link
Author

Good morning, Sorry for the late response, Uh, that's strange... The touchbar normally changes when the window is focused, can you confirm the Tkinter window was on the front?

This is a simple "Hello World" program, it just shows a "Hello World!" label on the touchbar for an empty tkinter window:

from PyTouchBar import *

fen = Tk()

prepare_tk_windows(fen)

lbl = TouchBarItems.Label(text = "Hello World!")
set_touchbar([lbl])

fen.mainloop()

Any ideas to force Tkinter window to be in front?

@SamyBencherif
Copy link

SamyBencherif commented Apr 8, 2022

Any ideas to force Tkinter window to be in front?

I recall another thread from a while ago (different project) where it was concluded that this is not possible in mac OS. Not saying that it's actually impossible... but I wouldn't get your hopes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants