Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from Tkinter import *
- import string
- import getpass
- from functools import partial
- import time
- import os
- import urllib2
- root = Tk()
- #Set up variables
- t = time.localtime()
- theday = t.tm_wday
- col1='#ccffff'
- col2='#ffffff'
- col3='#ffffcc'
- sn = 0
- s = 0
- dow = '0'
- callit = ['1','2','a.delete(0, END)', 'a.insert(0, 0)', 'b.delete(0, END)', 'b.insert(0, 0)','c.delete(0, END)', 'c.insert(0, 0)', 'u=int(a.get]', 'u=int(b.get)', 'u=int(c.get)']
- playit = ['a', 'q = a.get()', 'q = b.get()', 'q = c.get()']
- A = StringVar()
- B = StringVar()
- C = StringVar()
- cmda = lambda : play_songs(1)
- cmdb = lambda : play_songs(2)
- cmdc = lambda : play_songs(3)
- songlist = []
- song_count = 0
- maxsong = 0
- ######v="No Song\n chosen"
- msg2 = ' '
- msg3 = 'Click here to update songs if needed'
- msg4 = 'Broadcasting\n and jw.org'
- msg7 = '___________________________'
- myname = getpass.getuser()
- myname = "/home/" + myname
- mysongs = myname + "/songbook/"
- mystart = myname + "/my-startups"
- addin="0"
- tot=str(t.tm_year)
- if(t.tm_mon < 10):
- tot=tot + addin
- tot=tot + str(t.tm_mon)
- mydays = t.tm_mday - t.tm_wday
- if(mydays < 10):
- tot=tot + addin
- tot = tot + str(mydays)
- # ++ str(t.tm_mday - t.tm_wday) # + 4)
- saved = str(tot)
- fileget = "http://www.nelliott.co.uk/linux/" + saved
- os.chdir(mystart)
- myday = urllib2.urlopen(fileget)
- output = open(tot,'wb')
- output.write(myday.read())
- output.close()
- with open (saved, "r") as myfile:
- data=myfile.readline()
- myfile.close()
- #Launching Firefox to display TV.JW.ORG and JW.ORG websites
- def showtv():
- label6.configure(text = ' ')
- label6.update_idletasks()
- fire="/usr/bin/firefox -P kingdom-hall"
- # Try the one below if using external monitor
- # fire="Display=:0.1 /usr/bin/firefox -P kingdom-hall"
- retvalue = os.system(fire)
- # time.sleep(5)
- # offon="/usr/bin/xrandr --output HDMI1 --auto"
- #This needs re-writing to do it within python so is currently disabled
- def get_songs():
- label6.configure(text = 'Please wait\nupdating songbook')
- label6.update_idletasks()
- os.system('/home/norman/my-startups/grabsongs')
- label6.configure(text = 'Okay done')
- #Closes program
- def cmd1():
- root.quit()
- def cmd2():
- label6.configure(text = ' ')
- global sn
- global s
- global v
- s = s*10
- label2.configure(text = '\n' + str(s), bg=col3) #'\n' + str(s) + '\n', bg=col3)
- def play_songs(z):
- song = "0"
- me = int(z)*2
- you = me/2
- exec playit[you]
- u = int(q)
- if(u > 0):
- if(u <= maxsong):
- song ="vlc " + mysongs + songlist[u - 1] + " vlc://quit"
- print song
- exec callit[me]
- exec callit[me + 1]
- # if ( z == 2):
- # b.delete(0, END)
- # b.insert(0, 0)
- # if ( z == 3):
- # c.delete(0, END)
- # c.insert(0, 0)
- retvalue = os.system(song)
- #Open songs.txt which contains the list of song numbers
- myfile = myname + "/songbook/songs.txt"
- with open(myfile) as the_songs:
- for line in the_songs:
- lines=line.strip()
- songlist.append(lines)
- song_count += 1
- maxsong= song_count
- msg1=" Highest available song\n number is " + str(song_count)
- Button(root, text= msg4, font=("Helvetica", 14), command=showtv).grid(row=19, column=2, columnspan = 2, pady=10)
- Button(root, text='Exit', font=("Helvetica", 16), command=root.quit).grid(row = 20, column=2, columnspan = 2, padx=20, pady = 14)
- a = Entry(root, width = 4, textvariable=A, font=("Helvetica", 16))
- a.grid(row=10, column=2)
- a.delete(0, END)
- G = Button(root, text="Play", width=4, font=("Helvetica", 16), command=cmda).grid(row=10, column=3)
- b = Entry(root, width = 4, textvariable=B, font=("Helvetica", 16))
- b.grid(row=11, column=2)
- b.delete(0, END)
- H = Button(root, text="Play", width=4, font=("Helvetica", 16), command=cmdb).grid(row=11, column=3)
- c = Entry(root, width = 4, textvariable=C, font=("Helvetica", 16))
- c.grid(row=12, column=2)
- c.delete(0, END)
- I = Button(root, text="Play", width=4, font=("Helvetica", 16), command=cmdc).grid(row=12, column=3)
- #Set up labels with the correct songs
- if(theday < 5):
- a.insert(0, data[0:3])
- b.insert(0, data[3:6])
- c.insert(0, data[6:9])
- msg5 = "Songs for Thursday"
- else:
- a.insert(0, data[9:12])
- b.insert(0,data[12:15])
- c.insert(0,data[15:18])
- msg5 = " Songs for Sunday"
- label1 = Label(root, text=' ', width = 10)
- label1.grid(row = 8, column = 0)
- label2 =Label(root, text=msg1, width=20, font=("Helvetica", 14))
- label2.grid(row = 17, column = 2, columnspan=2, pady = 10)
- label3 = Label(root, text=msg2, width = 20)
- label3.grid(row = 8, column = 5)
- label4 = Label(root, text=msg5, font=("Helvetica", 12))
- label4.grid(row = 9, column = 2, columnspan=2)
- label5 = Label(root, text=msg7,font=("Helvetica", 12))
- label5.grid(row = 18, column = 1, columnspan=4)
- label6 = Label(root, text=msg2, width = 20)
- label6.grid(row = 8, column = 5)
- root.geometry("420x420+100+300") # width, height, x position (from left), y position (from top)
- root.title("Kingdom Hall software")
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement