-
-
Save humbertoroa/2e79633727ec4b61567e to your computer and use it in GitHub Desktop.
example rumps toolbar app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rumps | |
from osxnotification import MountainLionNotification, UserData | |
from dataqueries import PLM | |
userData = UserData() | |
''' ToDo: Check for 10.8 ''' | |
plm = PLM(MountainLionNotification.alloc().init(), userData) | |
class Centric8StatusBarApp(rumps.App): | |
doCheck = False | |
def __init__(self): | |
super(Centric8StatusBarApp, self).__init__("Centric8") | |
self.menu = ["Favorites", "Requests", "Adopted Styles",None, "Set Host", "Set User", "Set Password",None] | |
@rumps.clicked("Favorites") | |
def checkFavorites(self, sender): | |
sender.state = not sender.state | |
plm.doCheckFavorites = sender.state == 1 | |
pass | |
@rumps.clicked("Requests") | |
def checkRequests(self, sender): | |
sender.state = not sender.state | |
plm.doCheckSupplierRequests = sender.state == 1 | |
pass | |
@rumps.clicked("Adopted Styles") | |
def checkApprovedStyles(self, sender): | |
sender.state = not sender.state | |
plm.doCheckApprovedStyles = sender.state == 1 | |
pass | |
@rumps.clicked("Set User") | |
def setUser(self, sender): | |
_user = userData.getValue(u'username') | |
window = rumps.Window('Please enter your PLM user name', 'User Name', None, None, None, (320, 25)) | |
window.default_text = _user if _user else '' | |
window.icon = 'csi.icns' | |
response = window.run() | |
userData.setValue(u'username', response.text) | |
pass | |
@rumps.clicked("Set Host") | |
def setHost(self, sender): | |
_host = userData.getValue(u'host') | |
window = rumps.Window('For example: http://demo.centricsoftware.com', 'Host Address', None, None, None, (320, 25)) | |
window.default_text = _host if _host else '' | |
window.icon = 'csi.icns' | |
response = window.run() | |
userData.setValue(u'host', response.text) | |
pass | |
@rumps.clicked("Set Password") | |
def setPassword(self, sender): | |
_password = userData.getValue(u'password') | |
window = rumps.Window('Please enter your PLM password', 'Password', None, None, None, (320, 25)) | |
window.default_text = _password if _password else '' | |
window.icon = 'csi.icns' | |
response = window.run() | |
userData.setValue(u'password', response.text) | |
pass | |
@rumps.timer(20) | |
def timerNotify(self, _): | |
plm.checkForUpdates() | |
pass | |
@rumps.timer(180) | |
def clearChanged(self, _): | |
plm.resetChangedNodes() | |
pass | |
if __name__ == "__main__": | |
app = Centric8StatusBarApp() | |
app.icon = 'csi-dark.icns' | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment