def load_user_info(self, user_name): # os.system('nohup python3 APIs.py &') # user_destinations = ["305 Swindon Way, West Lafayette, Indiana", "222 West Wood St, West Lafayette, Indiana", "West Madison Street, Chicago, Illinois"] file_path = "Users/%s/%sAPI.json" % (user_name, user_name) with open(file_path) as f: user_dict = json.load(f) self.rt = user_dict['map'] self.calendarEvents = user_dict['events'] self.weather_dict = user_dict['weather'] self.datetime = DateTime.DateTime() self.feed = feeds.Feeds() self.news_data = user_dict['news']
def load_user_info(self, user_dict): # os.system('nohup python3 APIs.py &') # user_destinations = ["305 Swindon Way, West Lafayette, Indiana", "222 West Wood St, West Lafayette, Indiana", "West Madison Street, Chicago, Illinois"] self.rt = maps.Maps(user_dict["address"], user_dict['freqDests']) self.calendarEvents = googleCalendar.Calendar() # fix to take in user id and get user's token self.weather = weather.Weather(user_dict["address"]) self.datetime = DateTime.DateTime() self.feed = feeds.Feeds() # Init newsapi = NewsApiClient(api_key='33ff7834a7ee40928e7bb90746c8b6e5') # top_headlines = newsapi.get_top_headlines(category=user_dict["newsCategories"][0] # language='en', # country='us') news_sources = newsapi.get_sources() news_url = ('https://newsapi.org/v2/top-headlines?' 'category=%s&' 'country=us&' 'apiKey=33ff7834a7ee40928e7bb90746c8b6e5' %(user_dict["newsCategories"][0])) # print(news_url) news_response = requests.get(news_url) self.news_data = news_response.json()
def load_user_info(self, user_name): # os.system('nohup python3 APIs.py &') # user_destinations = ["305 Swindon Way, West Lafayette, Indiana", "222 West Wood St, West Lafayette, Indiana", "West Madison Street, Chicago, Illinois"] file_path = "/home/pi/MirageSmartMirror/src/Users/%s/%sAPI.json" % ( user_name, user_name) try: with open(file_path) as f: user_dict = json.load(f) except: self.set_lockscreen_layout() return 0 self.rt = user_dict['map'] self.calendarEvents = user_dict['events'] self.weather_dict = user_dict['weather'] self.datetime = DateTime.DateTime() self.feed = feeds.Feeds() self.news_data = user_dict['news'] self.curr_user_name = user_dict['name'] return 1
def init_ui(self): # self.qt.showFullScreen() self.analog = analog.AnalogClock() self.rt = maps.Maps() self.calendarEvents = googleCalendar.Calendar() self.qt.resize(800, 800) datetime = QDateTime.currentDateTime() font = QFont('Helvetica', 18) font.setWeight(1) # Set background black self.darkPalette = QPalette() self.darkPalette.setColor(QPalette.Background, Qt.black) self.qt.setPalette(self.darkPalette) effect = QGraphicsDropShadowEffect() effect2 = QGraphicsDropShadowEffect() effect.setOffset(1, 1) effect2.setOffset(1, 1) effect.setBlurRadius(30) effect.setColor(QColor(255,255,255)) effect2.setBlurRadius(20) effect2.setColor(QColor(255,255,255)) # self.qt.setGraphicsEffect(effect) # self.qt.msb = QPushButton('Main screen') self.qt.gmb = QPushButton('Groom mode') self.qt.lsb = QPushButton('Lock screen') self.qt.l = QLabel() self.qt.time = QLabel("<font color='white'>" + datetime.toString("MMM d, yyyy hh:mm:ss AP") + "</font") self.qt.time.setFont(font) self.analog.setGraphicsEffect(effect) self.qt.time.setGraphicsEffect(effect2) # Main screen layout self.TimeWeatherBox = QHBoxLayout() self.welcomeBox = QHBoxLayout() self.appListBox = QHBoxLayout() self.appBox = QHBoxLayout() ### self.weather = weather.Weather() self.weather.weatherBox.setAlignment(Qt.AlignLeft) self.weather.setFixedHeight(150) self.TimeWeatherBox.addWidget(self.weather) self.datetime = DateTime.DateTime() self.datetime.setFixedHeight(150) self.TimeWeatherBox.addWidget(self.datetime) ### self.welcomeLabel = QLabel("<font color='white'>" + "Welcome, Amjad!" + "</font") self.welcomeLabel.setAlignment(Qt.AlignCenter) self.welcomeLabel.setFixedHeight(100) self.welcomeBox.addWidget(self.welcomeLabel) ### self.feed = feeds.Feeds() self.feed.setFixedWidth(800) self.appBox.addWidget(self.feed) ### self.appList = [] self.news = QPushButton('News') self.calendar = QPushButton('Calendar') self.routes = QPushButton('Routes') self.appList.append(self.news) self.appList.append(self.calendar) self.appList.append(self.routes) self.appList.append(self.qt.gmb) for app in self.appList: self.appListBox.addWidget(app) self.qt.digitaltime = QHBoxLayout() self.qt.analogclock = QHBoxLayout() # self.qt.welcomebox = QHBoxLayout() self.qt.digitaltime.addWidget(self.qt.time) self.qt.analogclock.addWidget(self.analog) # self.qt.feedBox.addWidget(self.qt.l) self.qt.h_box = QHBoxLayout() # self.qt.h_box.addStretch() self.qt.h_box.addWidget(self.qt.msb) # self.qt.h_box.addWidget(self.qt.gmb) # self.qt.h_box.addStretch() self.qt.v_box = QVBoxLayout() # self.qt.v_box.addWidget(self.qt.msb) self.qt.v_box.addLayout(self.qt.h_box) # self.qt.spacer = QSpacerItem(150, 150) # self.qt.v_box.addSpacerItem(self.qt.spacer) self.qt.v_box.addSpacing(150) self.qt.v_box.addLayout(self.qt.analogclock) self.qt.v_box.addLayout(self.qt.digitaltime) # self.qt.v_box.addSpacing(50) # self.qt.v_box.addLayout(self.qt.welcomebox) self.qt.setLayout(self.qt.v_box) self.qt.setWindowTitle('Lock screen') self.qt.digitaltime.setAlignment(Qt.AlignCenter) self.qt.msb.clicked.connect(self.msd) self.qt.gmb.clicked.connect(self.gmd) self.qt.lsb.clicked.connect(self.lsd) self.news.clicked.connect(self.news_headlines) self.calendar.clicked.connect(self.calendar_events) self.routes.clicked.connect(self.routes_info) self.init_timer() self.qt.showFullScreen()