diff --git a/run_app_GUI.py b/iTunes Rating App.py similarity index 86% rename from run_app_GUI.py rename to iTunes Rating App.py index 7bb446c..74c9d27 100644 --- a/run_app_GUI.py +++ b/iTunes Rating App.py @@ -76,15 +76,19 @@ class iTunes_com_thread(Thread): #-------------------------------------------------------------- class MainWindow(wx.Frame): def __init__(self, parent, title=''): - #Create the main window? + #Create the main window super(MainWindow, self).__init__( parent, title=title, + style= wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP ) #-------------------------------------------------------------- #Create a file manu filemenu = wx.Menu() + #Create a panel + self.panel = wx.Panel(self) + self.flashing_panel = False #Define menu items menu_about = filemenu.Append( wx.ID_ABOUT, @@ -109,7 +113,6 @@ class MainWindow(wx.Frame): #set the directory variable to the current directory of this script self.dirname = os.getcwd() - #Create 3 sizers to arange objects in self.main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.info_sizer = wx.BoxSizer(wx.VERTICAL) @@ -134,10 +137,10 @@ class MainWindow(wx.Frame): self.buttons[i].Bind(wx.EVT_BUTTON, self.OnButton) #Create a text object - self.artist_text = wx.StaticText(self, label="Artist:\t") - self.song_text = wx.StaticText(self, label="Title:\t") - self.album_text = wx.StaticText(self, label="Album:\t") - self.rating_text = wx.StaticText(self, label="Rating:\t") + self.artist_text = wx.StaticText(self.panel, label="Artist:\t") + self.song_text = wx.StaticText(self.panel, label="Title:\t") + self.album_text = wx.StaticText(self.panel, label="Album:\t") + self.rating_text = wx.StaticText(self.panel, label="Rating:\t") for i in ( self.song_text, @@ -161,10 +164,13 @@ class MainWindow(wx.Frame): self.main_sizer.Add(self.info_sizer, 2, wx.EXPAND) #Select the sizer to use for the main window - self.SetSizer(self.main_sizer) self.SetAutoLayout(1) #Fit sizer 1 to window - self.SetSizerAndFit(self.main_sizer) + self.panel.SetSizerAndFit(self.main_sizer) + + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(self.panel) + self.SetSizerAndFit(sizer) #initialize comunication thread iTunes_com_thread() @@ -207,6 +213,7 @@ class MainWindow(wx.Frame): self.artist_text.SetLabel("Artist:\t" + t["artist"]) self.song_text.SetLabel("Title:\t" + t["track_name"]) self.album_text.SetLabel("Album:\t" + t["album"]) + self.rating_text.SetLabel("Rating:\t" + str(t["rating"]/20)) if update_artwork: if not artwork: img = wx.Image("nocover.jpg", wx.BITMAP_TYPE_ANY) @@ -216,6 +223,18 @@ class MainWindow(wx.Frame): img = wx.Image(artwork, wx.BITMAP_TYPE_ANY) img = img.Scale(120,120) self.icon = wx.StaticBitmap(self, bitmap=wx.BitmapFromImage(img)) + if t["duration"] - t["position"] <= 30: + if self.panel.GetBackgroundColour() == "Yellow": + self.panel.SetBackgroundColour(wx.NullColour) + self.panel.Refresh() + else: + self.panel.SetBackgroundColour("Yellow") + self.panel.Refresh() + else: + if self.panel.GetBackgroundColour() == "Yellow": + self.panel.SetBackgroundColour(wx.NullColour) + self.panel.Refresh() + #-------------------------------------------------------------- app = wx.App(False) diff --git a/itunes_scripts.scpt b/itunes_scripts.scpt index 357b9c1..185d355 100644 --- a/itunes_scripts.scpt +++ b/itunes_scripts.scpt @@ -10,8 +10,12 @@ on get_current_track_info() set track_comments to the comment of the current track set track_name to the name of the current track set track_rating to the rating of the current track + set track_duration to the duration of the current track + set track_finish to the finish of the current track + set track_start to the start of the current track + set track_position to the player position end tell - return {album:track_album, artist:track_artist, track_name:track_name} + return {album:track_album, artist:track_artist, track_name:track_name, rating:track_rating, duration:track_duration, finish:track_finish, start:track_start, position:track_position} end get_current_track_info on set_current_track_rating(track_rating) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..14f742f --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +""" +This is a setup.py script generated by py2applet + +Usage: + python setup.py py2app +""" + +from setuptools import setup + +APP = ['iTunes Rating App.py'] +DATA_FILES = [] +OPTIONS = {'argv_emulation': False} + +setup( + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], +)