$ chmod +x /path/to/sp_qt_ctrl_panel_alt.py
$ cat /path/to/sp_qt_ctrl_panel_alt.py
#!/usr/bin/python3
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtWidgets import QApplication
import subprocess
class ExampleApp(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(ExampleApp, self).__init__(parent)
self.ui = uic.loadUi("/path/to/qt5designer/tab_test.ui", self)
channel = ["","JPOP","POPS","JAZZ","CLASSIC","BLUES"]
self.ui.local_channel_combo.addItems(channel)
self.ui.local_channel_combo.activated[str].connect(self.ui.onLocalMusicActivated)
self.ui.local_youtube_skip_btn.clicked.connect(self.ui.btnLocalYouTubeSkip)
self.ui.local_stop_btn.clicked.connect(self.ui.btnLocalStop)
self.ui.rpi_channel_combo.addItems(channel)
self.ui.rpi_channel_combo.activated[str].connect(self.ui.onRpiMusicActivated)
self.ui.rpi_youtube_skip_btn.clicked.connect(self.ui.btnRpiYouTubeSkip)
self.ui.rpi_stop_btn.clicked.connect(self.ui.btnRpiStop)
radiko = ["","JWave","InterFM897","TokyoFM","bayfm78","NACK5","FMヨコハマ","TBSラジオ","ニッポン放送","ラジオ日本","文化放送","ラジオNIKKEI第1","ラジオNIKKEI第2","放送大学","東京NHK第1","東京NHKFM"]
self.ui.local_radiko_combo.addItems(radiko)
self.ui.local_radiko_combo.activated[str].connect(self.ui.onLocalRadikoActivated)
self.ui.local_stop_btn_2.clicked.connect(self.ui.btnLocalStop)
self.ui.rpi_radiko_combo.addItems(radiko)
self.ui.rpi_radiko_combo.activated[str].connect(self.ui.onRpiRadikoActivated)
self.ui.rpi_stop_btn_2.clicked.connect(self.ui.btnRpiStop)
news = ["","Yahoo! Topics","BBC World News","ABC News"]
self.ui.local_news_combo.addItems(news)
self.ui.local_news_combo.activated[str].connect(self.ui.onLocalNewsActivated)
self.ui.local_stop_btn_3.clicked.connect(self.ui.btnLocalStop)
self.ui.rpi_news_combo.addItems(news)
self.ui.rpi_news_combo.activated[str].connect(self.ui.onRpiNewsActivated)
self.ui.rpi_stop_btn_3.clicked.connect(self.ui.btnRpiStop)
weather = ["","今日の天気","今日の気温","明日の天気","明日の気温","明後日の天気"]
self.ui.local_weather_combo.addItems(weather)
self.ui.local_weather_combo.activated[str].connect(self.ui.onLocalWeatherActivated)
self.ui.local_stop_btn_4.clicked.connect(self.ui.btnLocalStop)
self.ui.rpi_weather_combo.addItems(weather)
self.ui.rpi_weather_combo.activated[str].connect(self.ui.onRpiWeatherActivated)
self.ui.rpi_stop_btn_4.clicked.connect(self.ui.btnRpiStop)
self.ui.main_menu_btn.clicked.connect(self.ui.btnMainMenu)
self.ui.aircon_btn.clicked.connect(self.ui.btnAircon)
self.ui.tv_btn.clicked.connect(self.ui.btnTV)
self.ui.show()
def onLocalMusicActivated(self):
print("\"local_combo\" was selected")
if not (self.ui.local_channel_combo.currentText() == "JPOP" or self.ui.local_channel_combo.currentText() == "POPS"):
self.ui.local_youtube_skip_btn.setEnabled(False)
else:
self.ui.local_youtube_skip_btn.setEnabled(True)
if self.ui.local_channel_combo.currentText() == "":
pass
elif self.ui.local_channel_combo.currentText() == "JPOP":
subprocess.call("/path/to/youtube_jpop_playlist.sh &", shell=True)
elif self.ui.local_channel_combo.currentText() == "POPS":
subprocess.call("/path/to/youtube_pops_playlist.sh &", shell=True)
elif self.ui.local_channel_combo.currentText() == "JAZZ":
subprocess.call("/path/to/icecastjazz.sh &", shell=True)
elif self.ui.local_channel_combo.currentText() == "CLASSIC":
subprocess.call("/path/to/icecastclassical.sh &", shell=True)
elif self.ui.local_channel_combo.currentText() == "BLUES":
subprocess.call("/path/to/icecastblues.sh &", shell=True)
else:
pass
if not self.ui.local_channel_combo.currentText() == "":
self.ui.local_channel_combo.setEnabled(False)
self.ui.local_radiko_combo.setEnabled(False)
self.ui.local_news_combo.setEnabled(False)
else:
self.ui.local_channel_combo.setEnabled(True)
self.ui.local_radiko_combo.setEnabled(True)
self.ui.local_news_combo.setEnabled(True)
def btnLocalYouTubeSkip(self):
print("\"スキップ\" button was clicked")
subprocess.call("/path/to/skip_playlist.sh &", shell=True)
def btnLocalStop(self):
print("\"Stop Music\" button was clicked")
self.ui.local_channel_combo.setEnabled(True)
self.ui.local_radiko_combo.setEnabled(True)
self.ui.local_news_combo.setEnabled(True)
subprocess.call("/path/to/stop_radio.sh &", shell=True)
def onRpiMusicActivated(self):
print("\"raspi_combo\" was selected")
if not (self.ui.rpi_channel_combo.currentText() == "JPOP" or self.ui.rpi_channel_combo.currentText() == "POPS"):
self.ui.rpi_youtube_skip_btn.setEnabled(False)
else:
self.ui.rpi_youtube_skip_btn.setEnabled(True)
if self.ui.rpi_channel_combo.currentText() == "":
pass
elif self.ui.rpi_channel_combo.currentText() == "JPOP":
self.ui.rpi_youtube_skip_btn.setEnabled(True)
subprocess.call("/path/to/youtube_jpop_playlist_raspi.sh &", shell=True)
elif self.ui.rpi_channel_combo.currentText() == "POPS":
self.ui.rpi_youtube_skip_btn.setEnabled(True)
subprocess.call("/path/to/youtube_pops_playlist_raspi.sh &", shell=True)
elif self.ui.rpi_channel_combo.currentText() == "JAZZ":
subprocess.call("/path/to/icecastjazz_raspi.sh &", shell=True)
elif self.ui.rpi_channel_combo.currentText() == "CLASSIC":
subprocess.call("/path/to/icecastclassical_raspi.sh &", shell=True)
elif self.ui.rpi_channel_combo.currentText() == "BLUES":
subprocess.call("/path/to/icecastblues_raspi.sh &", shell=True)
else:
pass
if not self.ui.rpi_channel_combo.currentText() == "":
self.ui.rpi_channel_combo.setEnabled(False)
self.ui.rpi_radiko_combo.setEnabled(False)
self.ui.rpi_news_combo.setEnabled(False)
else:
self.ui.rpi_channel_combo.setEnabled(True)
self.ui.rpi_radiko_combo.setEnabled(True)
self.ui.rpi_news_combo.setEnabled(True)
def btnRpiYouTubeSkip(self):
print("\"Raspi スキップ\" button was clicked")
subprocess.call("/path/to/skip_playlist_raspi.sh &", shell=True)
def btnRpiStop(self):
print("\"Raspi Stop Music\" button was clicked")
self.ui.rpi_channel_combo.setEnabled(True)
self.ui.rpi_radiko_combo.setEnabled(True)
self.ui.rpi_news_combo.setEnabled(True)
subprocess.call("/path/to/stop_radio_raspi.sh &", shell=True)
def onLocalRadikoActivated(self):
print("\"local_combo\" was selected")
if self.ui.local_radiko_combo.currentText() == "":
pass
elif self.ui.local_radiko_combo.currentText() == "JWave":
subprocess.call("/path/to/radiko.sh -p FMJ &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "InterFM897":
subprocess.call("/path/to/radiko.sh -p INT &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "TokyoFM":
subprocess.call("/path/to/radiko.sh -p FMT &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "bayfm78":
subprocess.call("/path/to/radiko.sh -p BAYFM78 &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "NACK5":
subprocess.call("/path/to/radiko.sh -p NACK5 &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "FMヨコハマ":
subprocess.call("/path/to/radiko.sh -p YFM &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "TBSラジオ":
subprocess.call("/path/to/radiko.sh -p TBS &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "ニッポン放送":
subprocess.call("/path/to/radiko.sh -p LFR &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "ラジオ日本":
subprocess.call("/path/to/radiko.sh -p JORF &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "文化放送":
subprocess.call("/path/to/radiko.sh -p QRR &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "ラジオNIKKEI第1":
subprocess.call("/path/to/radiko.sh -p RN1 &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "ラジオNIKKEI第2":
subprocess.call("/path/to/radiko.sh -p RN2 &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "放送大学":
subprocess.call("/path/to/radiko.sh -p HOUSOU-DAIGAKU &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "東京NHK第1":
subprocess.call("/path/to/radiko.sh -p JOAK &", shell=True)
elif self.ui.local_radiko_combo.currentText() == "東京NHKFM":
subprocess.call("/path/to/radiko.sh -p JOAK-FM &", shell=True)
else:
pass
if not self.ui.local_radiko_combo.currentText() == "":
self.ui.local_channel_combo.setEnabled(False)
self.ui.local_radiko_combo.setEnabled(False)
self.ui.local_news_combo.setEnabled(False)
else:
self.ui.local_channel_combo.setEnabled(True)
self.ui.local_radiko_combo.setEnabled(True)
self.ui.local_news_combo.setEnabled(True)
def onRpiRadikoActivated(self):
print("\"raspi_radiko_combo\" was selected")
if self.ui.rpi_radiko_combo.currentText() == "":
pass
elif self.ui.rpi_radiko_combo.currentText() == "JWave":
subprocess.call("/path/to/radiko_raspi.sh FMJ &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "InterFM897":
subprocess.call("/path/to/radiko_raspi.sh INT &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "TokyoFM":
subprocess.call("/path/to/radiko_raspi.sh FMT &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "bayfm78":
subprocess.call("/path/to/radiko_raspi.sh BAYFM78 &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "NACK5":
subprocess.call("/path/to/radiko_raspi.sh NACK5 &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "FMヨコハマ":
subprocess.call("/path/to/radiko_raspi.sh YFM &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "TBSラジオ":
subprocess.call("/path/to/radiko_raspi.sh TBS &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "ニッポン放送":
subprocess.call("/path/to/radiko_raspi.sh LFR &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "ラジオ日本":
subprocess.call("/path/to/radiko_raspi.sh JORF &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "文化放送":
subprocess.call("/path/to/radiko_raspi.sh QRR &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "ラジオNIKKEI第1":
subprocess.call("/path/to/radiko_raspi.sh RN1 &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "ラジオNIKKEI第2":
subprocess.call("/path/to/radiko_raspi.sh RN2 &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "放送大学":
subprocess.call("/path/to/radiko_raspi.sh HOUSOU-DAIGAKU &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "東京NHK第1":
subprocess.call("/path/to/radiko_raspi.sh JOAK &", shell=True)
elif self.ui.rpi_radiko_combo.currentText() == "東京NHKFM":
subprocess.call("/path/to/radiko_raspi.sh JOAK-FM &", shell=True)
else:
pass
if not self.ui.rpi_radiko_combo.currentText() == "":
self.ui.rpi_channel_combo.setEnabled(False)
self.ui.rpi_radiko_combo.setEnabled(False)
self.ui.rpi_news_combo.setEnabled(False)
else:
self.ui.rpi_channel_combo.setEnabled(True)
self.ui.rpi_radiko_combo.setEnabled(True)
self.ui.rpi_news_combo.setEnabled(True)
def onLocalNewsActivated(self):
print("\"local_news_combo\" was selected")
if self.ui.local_news_combo.currentText() == "":
pass
elif self.ui.local_news_combo.currentText() == "Yahoo! Topics":
subprocess.call("/path/to/get_yahoo_news.py &", shell=True)
elif self.ui.local_news_combo.currentText() == "BBC World News":
subprocess.call("mplayer http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-eieuk &", shell=True)
elif self.ui.local_news_combo.currentText() == "ABC News":
subprocess.call("mplayer -playlist http://abc.net.au/res/streaming/audio/aac/news_radio.pls &", shell=True)
if not self.ui.local_news_combo.currentText() == "":
self.ui.local_channel_combo.setEnabled(False)
self.ui.local_radiko_combo.setEnabled(False)
self.ui.local_news_combo.setEnabled(False)
else:
self.ui.local_channel_combo.setEnabled(True)
self.ui.local_radiko_combo.setEnabled(True)
self.ui.local_news_combo.setEnabled(True)
def onRpiNewsActivated(self):
print("\"raspi_news_combo\" was selected")
if self.ui.rpi_news_combo.currentText() == "":
pass
elif self.ui.rpi_news_combo.currentText() == "Yahoo! Topics":
subprocess.call("/path/to/get_yahoo_news_raspi.sh &", shell=True)
elif self.ui.rpi_news_combo.currentText() == "BBC World News":
subprocess.call("/path/to/bbc_news_radio_raspi.sh &", shell=True)
elif self.ui.rpi_news_combo.currentText() == "ABC News":
subprocess.call("/path/to/bbc_news_radio_raspi.sh &", shell=True)
if not self.ui.rpi_news_combo.currentText() == "":
self.ui.rpi_channel_combo.setEnabled(False)
self.ui.rpi_radiko_combo.setEnabled(False)
self.ui.rpi_news_combo.setEnabled(False)
else:
self.ui.rpi_channel_combo.setEnabled(True)
self.ui.rpi_radiko_combo.setEnabled(True)
self.ui.rpi_news_combo.setEnabled(True)
def onLocalWeatherActivated(self):
print("\"local_weather_combo\" was selected")
if self.ui.local_weather_combo.currentText() == "":
pass
elif self.ui.local_weather_combo.currentText() == "今日の天気":
subprocess.call("/path/to/today_weather.py &", shell=True)
elif self.ui.local_weather_combo.currentText() == "今日の気温":
subprocess.call("/path/to/today_temperature.py &", shell=True)
elif self.ui.local_weather_combo.currentText() == "明日の天気":
subprocess.call("/path/to/tomorrow_weather.py &", shell=True)
elif self.ui.local_weather_combo.currentText() == "明日の気温":
subprocess.call("/path/to/tomorrow_temperature.py &", shell=True)
elif self.ui.local_weather_combo.currentText() == "明後日の天気":
subprocess.call("/path/to/day_after_tomorrow_weather.py &", shell=True)
def onRpiWeatherActivated(self):
print("\"raspi_weather_combo\" was selected")
if self.ui.rpi_weather_combo.currentText() == "":
pass
elif self.ui.rpi_weather_combo.currentText() == "今日の天気":
subprocess.call("/path/to/get_yahoo_weather_raspi.sh &", shell=True)
elif self.ui.rpi_weather_combo.currentText() == "今日の気温":
subprocess.call("/path/to/bbc_weather_radio_raspi.sh &", shell=True)
elif self.ui.rpi_weather_combo.currentText() == "明日の天気":
subprocess.call("/path/to/bbc_weather_radio_raspi.sh &", shell=True)
elif self.ui.rpi_weather_combo.currentText() == "明日の気温":
subprocess.call("/path/to/bbc_weather_radio_raspi.sh &", shell=True)
elif self.ui.rpi_weather_combo.currentText() == "明後日の天気":
subprocess.call("/path/to/bbc_weather_radio_raspi.sh &", shell=True)
def btnMainMenu(self):
print("\"メインメニュー\" button was clicked")
subprocess.call("/path/to/home_elec_panel.sh MAIN &", shell=True)
def btnAircon(self):
print("\"エアコン\" button was clicked")
subprocess.call("/path/to/home_elec_panel.sh AIRCON1 &", shell=True)
def btnTV(self):
print("\"テレビ\" button was clicked")
subprocess.call("/path/to/home_elec_panel.sh TV1 &", shell=True)
def main():
app = QApplication(sys.argv)
form = ExampleApp()
form.show()
app.exec_()
if __name__ == '__main__':
main()
$