Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from PyQt5 import QtWidgets, uic
- app = QtWidgets.QApplication([])
- ui = uic.loadUi("GUI.ui")
- url = ""
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- tv_ip=()
- def ON_TV1():
- print("TV1 ON")
- global url, params
- url = "http://172.16.216.21/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def ON_TV2():
- print("TV2 ON")
- global url, params
- url = "http://172.16.216.22/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def ON_TV3():
- print("TV3 ON")
- global url, params
- url = "http://172.16.216.23/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def ON_TV4():
- print("TV4 ON")
- global url, params
- url = "http://172.16.216.24/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def ON_TV5():
- print("TV5 ON")
- global url, params
- url = "http://172.16.216.25/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def ON_TV6():
- print("TV6 ON")
- global url, params
- url = "http://172.16.216.26/Power.cgi"
- params = {'rPOWR': '1', 'power': '1', 'ret': '', 'standby': '0'}
- def OFF_TV1():
- print("TV1 OFF")
- global url, params
- url = "http://172.16.216.21/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def OFF_TV2():
- print("TV2 OFF")
- global url, params
- url = "http://172.16.216.22/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def OFF_TV3():
- print("TV3 OFF")
- global url, params
- url = "http://172.16.216.23/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def OFF_TV4():
- print("TV4 OFF")
- global url, params
- url = "http://172.16.216.24/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def OFF_TV5():
- print("TV5 OFF")
- global url, params
- url = "http://172.16.216.25/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def OFF_TV6():
- print("TV6 OFF")
- global url, params
- url = "http://172.16.216.26/Power.cgi"
- params = {'rPOWR': '0', 'power': '0', 'ret': '', 'standby': '0'}
- def PostTV():
- print(url)
- #print(params)
- requests.post(url=url, data=params, auth=('', ''))
- #resp = requests.post(url=url, data=params, auth=('', ''))
- def ON_ALL():
- ON_TV1()
- PostTV()
- ON_TV2()
- PostTV()
- ON_TV3()
- PostTV()
- ON_TV4()
- PostTV()
- ON_TV5()
- PostTV()
- ON_TV6()
- PostTV()
- def OFF_ALL():
- OFF_TV1()
- PostTV()
- OFF_TV2()
- PostTV()
- OFF_TV3()
- PostTV()
- OFF_TV4()
- PostTV()
- OFF_TV5()
- PostTV()
- OFF_TV6()
- PostTV()
- ui.ON_TV1.pressed.connect(ON_TV1)
- ui.ON_TV2.pressed.connect(ON_TV2)
- ui.ON_TV3.pressed.connect(ON_TV3)
- ui.ON_TV4.pressed.connect(ON_TV4)
- ui.ON_TV5.pressed.connect(ON_TV5)
- ui.ON_TV6.pressed.connect(ON_TV6)
- ui.ON_TV1.released.connect(PostTV)
- ui.ON_TV2.released.connect(PostTV)
- ui.ON_TV3.released.connect(PostTV)
- ui.ON_TV4.released.connect(PostTV)
- ui.ON_TV5.released.connect(PostTV)
- ui.ON_TV6.released.connect(PostTV)
- ui.OFF_TV1.pressed.connect(OFF_TV1)
- ui.OFF_TV2.pressed.connect(OFF_TV2)
- ui.OFF_TV3.pressed.connect(OFF_TV3)
- ui.OFF_TV4.pressed.connect(OFF_TV4)
- ui.OFF_TV5.pressed.connect(OFF_TV5)
- ui.OFF_TV6.pressed.connect(OFF_TV6)
- ui.OFF_TV1.released.connect(PostTV)
- ui.OFF_TV2.released.connect(PostTV)
- ui.OFF_TV3.released.connect(PostTV)
- ui.OFF_TV4.released.connect(PostTV)
- ui.OFF_TV5.released.connect(PostTV)
- ui.OFF_TV6.released.connect(PostTV)
- ui.ON_ALL.pressed.connect(ON_ALL)
- ui.OFF_ALL.pressed.connect(OFF_ALL)
- ui.show()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement