
import rumps
import config
import contribs

username = config.get_username()

class GithubTrayApp(rumps.App):

    @rumps.timer(60*5)
    def timer(self, sender):
        count = contribs.get_contribs(username)
        self.title = str(count)

    @rumps.clicked('Update')
    def onoff(self, sender):
        count = contribs.get_contribs(username)
        self.title = str(count)

    @rumps.clicked('Change Frequency')
    def onoff(self, sender):
        rumps.alert('jk! not ready yet!')

    @rumps.clicked('Change Username')    
    def prefs(self, _):
        rumps.alert('jk! not ready yet!')

if __name__ == "__main__":
    count = contribs.get_contribs(username)
    GithubTrayApp('Github', icon='github.png', title=str(count)).run()


import rumps
import config
import contribs

class GithubTrayApp(rumps.App):

    def __init__(self):
        super(GithubTrayApp, self).__init__('Github')
        self.count = rumps.MenuItem('commits')
        self.username = config.get_username()
        self.icon = 'github.png'
        self.menu = [ 
            self.count, 
            'Update Now', 
            'Change Frequency', 
            'Change Username' 
        ]
        self.update()

    def update(self):
        num = contribs.get_contribs(self.username)
        self.count.title = str(num) + ' commits'
        self.title = str(num)

    @rumps.timer(60*5)
    def timer(self, _):
        print('Running timer')
        self.update()

    @rumps.clicked('Update Now')
    def update_now(self, _):
        self.update()

    @rumps.clicked('Change Frequency')
    def change_frequency(_):
        rumps.alert('jk! not ready yet!')

    @rumps.clicked('Change Username')    
    def change_username(_):
        rumps.alert('jk! not ready yet!')

if __name__ == '__main__':
    GithubTrayApp().run()

Restructure app and display commit count as a disabled menu item
Restructure app and display commit count as a disabled menu item

  
  import rumps
  import config
  import contribs
  
- username = config.get_username()
- 
  class GithubTrayApp(rumps.App):
  
+     def __init__(self):
+         super(GithubTrayApp, self).__init__('Github')
+         self.count = rumps.MenuItem('commits')
+         self.username = config.get_username()
+         self.icon = 'github.png'
+         self.menu = [ 
+             self.count, 
+             'Update Now', 
+             'Change Frequency', 
+             'Change Username' 
+         ]
+         self.update()
+ 
+     def update(self):
+         num = contribs.get_contribs(self.username)
+         self.count.title = str(num) + ' commits'
+         self.title = str(num)
+ 
      @rumps.timer(60*5)
-     def timer(self, sender):
+     def timer(self, _):
-         count = contribs.get_contribs(username)
-         self.title = str(count)
+         print('Running timer')
+         self.update()
  
-     @rumps.clicked('Update')
+     @rumps.clicked('Update Now')
+     def update_now(self, _):
+         self.update()
-     def onoff(self, sender):
-         count = contribs.get_contribs(username)
-         self.title = str(count)
  
      @rumps.clicked('Change Frequency')
-     def onoff(self, sender):
+     def change_frequency(_):
          rumps.alert('jk! not ready yet!')
  
      @rumps.clicked('Change Username')    
-     def prefs(self, _):
+     def change_username(_):
          rumps.alert('jk! not ready yet!')
  
- if __name__ == "__main__":
+ if __name__ == '__main__':
+     GithubTrayApp().run()
-     count = contribs.get_contribs(username)
-     GithubTrayApp('Github', icon='github.png', title=str(count)).run()
  
Restructure app and display commit count as a disabled menu item
## Code Before:

import rumps
import config
import contribs

username = config.get_username()

class GithubTrayApp(rumps.App):

    @rumps.timer(60*5)
    def timer(self, sender):
        count = contribs.get_contribs(username)
        self.title = str(count)

    @rumps.clicked('Update')
    def onoff(self, sender):
        count = contribs.get_contribs(username)
        self.title = str(count)

    @rumps.clicked('Change Frequency')
    def onoff(self, sender):
        rumps.alert('jk! not ready yet!')

    @rumps.clicked('Change Username')    
    def prefs(self, _):
        rumps.alert('jk! not ready yet!')

if __name__ == "__main__":
    count = contribs.get_contribs(username)
    GithubTrayApp('Github', icon='github.png', title=str(count)).run()

## Instruction:
Restructure app and display commit count as a disabled menu item
## Code After:

import rumps
import config
import contribs

class GithubTrayApp(rumps.App):

    def __init__(self):
        super(GithubTrayApp, self).__init__('Github')
        self.count = rumps.MenuItem('commits')
        self.username = config.get_username()
        self.icon = 'github.png'
        self.menu = [ 
            self.count, 
            'Update Now', 
            'Change Frequency', 
            'Change Username' 
        ]
        self.update()

    def update(self):
        num = contribs.get_contribs(self.username)
        self.count.title = str(num) + ' commits'
        self.title = str(num)

    @rumps.timer(60*5)
    def timer(self, _):
        print('Running timer')
        self.update()

    @rumps.clicked('Update Now')
    def update_now(self, _):
        self.update()

    @rumps.clicked('Change Frequency')
    def change_frequency(_):
        rumps.alert('jk! not ready yet!')

    @rumps.clicked('Change Username')    
    def change_username(_):
        rumps.alert('jk! not ready yet!')

if __name__ == '__main__':
    GithubTrayApp().run()
