Some more fine tuning, should implement more soon
This commit is contained in:
parent
590b060346
commit
4f97e2de91
37
gui.py
37
gui.py
|
|
@ -4,7 +4,7 @@ try:
|
|||
except:
|
||||
from Tkinter import *
|
||||
import ttk
|
||||
|
||||
import sys
|
||||
import request
|
||||
|
||||
def shon(tab):
|
||||
|
|
@ -27,21 +27,36 @@ def stat(tab):
|
|||
setstat(tab)
|
||||
|
||||
def setstat(tab):
|
||||
online=True
|
||||
if tab.vp.st_shutter=='Off':
|
||||
tab.btno.config(relief=SUNKEN)
|
||||
tab.btnf.config(relief=RAISED)
|
||||
else:
|
||||
elif tab.vp.st_shutter=='On':
|
||||
tab.btnf.config(relief=SUNKEN)
|
||||
tab.btno.config(relief=RAISED)
|
||||
tab.strstatus.set(tab.vp.strStatus())
|
||||
else:
|
||||
tab.btnf.config(relief=RAISED)
|
||||
tab.btno.config(relief=RAISED)
|
||||
online=False
|
||||
|
||||
tab.strstatus.set(tab.vp.strStatus())
|
||||
if not online:
|
||||
tab.lbstat.config(fg="red")
|
||||
else:
|
||||
tab.lbstat.config(fg='black')
|
||||
|
||||
# NOT CLEVER AT ALL
|
||||
def shall(listtab):
|
||||
for vp in listVP:
|
||||
vp.shutterOn()
|
||||
for tab in listtab:
|
||||
setstat(tab)
|
||||
|
||||
def opall(listtab):
|
||||
for vp in listVP:
|
||||
vp.shutterOff()
|
||||
for tab in listtab:
|
||||
setstat(tab)
|
||||
|
||||
def swall(listtab):
|
||||
for vp in listVP:
|
||||
|
|
@ -49,22 +64,24 @@ def swall(listtab):
|
|||
vp.shutterOff()
|
||||
else:
|
||||
vp.shutterOn()
|
||||
|
||||
for tab in listtab:
|
||||
setstat(tab)
|
||||
|
||||
print("Connecting to hosts")
|
||||
listVP=[request.VP('192.168.0.4'),
|
||||
request.VP('192.168.0.8')]
|
||||
|
||||
print("All hosts initialised")
|
||||
window = Tk()
|
||||
|
||||
window.title("Panasonic Remote GUI")
|
||||
window.geometry('350x200')
|
||||
|
||||
tabctrl=ttk.Notebook(window)
|
||||
lball=Label(window,text="ALL")
|
||||
btallsh=Button(window, text="SHUT",command=lambda: shall())
|
||||
btallop=Button(window, text="OPEN",command=lambda: opall())
|
||||
btallsw=Button(window, text="SWITCH",command=lambda: swall())
|
||||
lball=Label(window,text="Send all: ")
|
||||
listTab=[]
|
||||
btallsh=Button(window, text="SHUT",command=lambda: shall(listTab))
|
||||
btallop=Button(window, text="OPEN",command=lambda: opall(listTab))
|
||||
btallsw=Button(window, text="SWITCH",command=lambda: swall(listTab))
|
||||
# "ALL [SHUT] [OPEN] [SWITCH]"
|
||||
class tkTab(object):
|
||||
"""A tk tab"""
|
||||
|
|
@ -100,12 +117,12 @@ class tkTab(object):
|
|||
self.tab.bind("z", lambda x: shoff(self))
|
||||
self.tab.bind("<space>", lambda x:toggle(self))
|
||||
|
||||
listTab=[]
|
||||
for vp in listVP:
|
||||
listTab.append(tkTab(vp))
|
||||
setstat(listTab[-1])
|
||||
|
||||
tabctrl.pack(expand=1,fill='both')
|
||||
lball.pack(side=LEFT,padx=10)
|
||||
btallsh.pack(side=LEFT)
|
||||
btallop.pack(side=LEFT)
|
||||
btallsw.pack(side=LEFT)
|
||||
|
|
|
|||
22
request.py
22
request.py
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function
|
||||
import urllib2,sys
|
||||
import re
|
||||
try:
|
||||
|
|
@ -36,7 +37,7 @@ def openURL(cmd):
|
|||
return page
|
||||
except Exception as e:
|
||||
if isinstance(e,urllib2.URLError):
|
||||
print(" > Can't reach address: {}".format(url))
|
||||
print(" [Error] Can't reach address: {}".format(url),file=sys.stderr)
|
||||
pass
|
||||
return None
|
||||
|
||||
|
|
@ -54,7 +55,8 @@ def openSTATUS(cmd):
|
|||
|
||||
def dprint(st):
|
||||
if debug:
|
||||
print(st)
|
||||
print(st,file=sys.stderr)
|
||||
|
||||
ip="192.168.0.8"
|
||||
shutter_on=makeURL(ip,"shutter_on")
|
||||
shutter_off=makeURL(ip,"shutter_off")
|
||||
|
|
@ -65,7 +67,7 @@ class VP(object):
|
|||
def __init__(self, ip):
|
||||
super(VP, self).__init__()
|
||||
self.ip = ip
|
||||
print("Initialing {}".format(ip))
|
||||
print("Initialing {}".format(ip),file=sys.stderr)
|
||||
self.st_shutter=None
|
||||
self.st_osd=None
|
||||
self.st_input=None
|
||||
|
|
@ -74,17 +76,19 @@ class VP(object):
|
|||
self.status=makeSTATUS(ip)
|
||||
self.getStatus()
|
||||
if self.st_shutter==None:
|
||||
print(" > Unreachable")
|
||||
print(" [{}] Unreachable".format(ip),file=sys.stderr)
|
||||
else:
|
||||
print(" > Connected")
|
||||
print(" [{}] Connected".format(ip),file=sys.stderr)
|
||||
|
||||
def shutterOn(self):
|
||||
openURL(self.shutter_on)
|
||||
self.st_shutter='On'
|
||||
s=openURL(self.shutter_on)
|
||||
if s!=None:
|
||||
self.st_shutter='On'
|
||||
|
||||
def shutterOff(self):
|
||||
openURL(self.shutter_off)
|
||||
self.st_shutter='Off'
|
||||
s=openURL(self.shutter_off)
|
||||
if s!=None:
|
||||
self.st_shutter='Off'
|
||||
|
||||
def getStatus(self):
|
||||
stat=openSTATUS(self.status)
|
||||
|
|
|
|||
Reference in New Issue