Example #1
0
    def init_ui(self):
        """ Initializes all the secions in the layout """

        window_layout = QGridLayout()
        window_layout.setAlignment(QtCore.Qt.AlignTop)

        self.weather_controller = WeatherController()
        self.weather_controller.parse_weather({})

        self.weather_frame = Weather(self.weather_controller)
        window_layout.addWidget(self.weather_frame, 0, 0)

        self.running_clothes_frame = RunningClothes()

        window_layout.addWidget(self.running_clothes_frame, 1, 0)

        ui_palette = self.palette()
        ui_palette.setColor(self.backgroundRole(), QtCore.Qt.black)
        self.setPalette(ui_palette)

        #Set the layout and window
        self.setLayout(window_layout)
        self.move(300, 150)
        self.show()
        #start Fullscreen
        self.showFullScreen()

        # kick off the thread
        self.update_thread = UpdateThread()
        self.update_thread.update_clock.connect(self.callback_update_clock)
        self.update_thread.update_moon.connect(self.callback_update_moon)
        self.update_thread.update_indoor.connect(self.callback_update_indoor)
        self.update_thread.update_weather_and_clothes.connect(self.callback_update_weather_and_clothes)
        self.update_thread.update_person.connect(self.callback_update_person)
        self.update_thread.start()
Example #2
0
class UpdateForm(QWidget):

    done = pyqtSignal()
    update = pyqtSignal(str, int)

    def __init__(self, session, update_link):
        super(UpdateForm, self).__init__()
        uic.loadUi('update.ui', self)
        self.progressBar.setRange(0, 100)
        self.show()
        self.progressBar.setValue(0)
        self.session = session
        self.current_folder = os.getcwd()
        self.update_link = update_link
        self.update_file = None
        self.update_tool()
        self.done.connect(self.terminate)
        self.update.connect(self.update_ui)

    def update_tool(self):
        self.setWindowTitle("Updating")
        self.th = UpdateThread(self.update_file, self.current_folder, self.update_link, self)
        self.th.finished.connect(self.terminate)
        self.th.start()

    def terminate(self):
        subprocess.Popen([self.current_folder+'\poster.exe', ''])
        self.close()
        # sys.exit(1)

    def update_ui(self, label, progress):
        self.label.setText(label)
        self.progressBar.setValue(progress)
 def requestMasterInfo(self, masteruri, monitoruri):
     '''
 This method starts a thread to get the informations about the ROS master by
 the given RCP uri of the master_discovery node. If all informations are
 retrieved, a C{master_info_signal} of this class will be emitted. If for given
 masteruri a thread is already running, it will be inserted to the requested
 updates. For the same masteruri only one requested update can be stored. 
 On update error the requested update will be ignored.
 This method is thread safe. 
 
 @param masteruri: the URI of the remote ROS master
 @type masteruri: C{str}
 @param monitoruri: the URI of the monitor RPC interface of the master_discovery node
 @type monitoruri: C{str}
 '''
     self._lock.acquire(True)
     if (self.__updateThreads.has_key(masteruri)):
         self.__requestedUpdates[masteruri] = monitoruri
     else:
         upthread = UpdateThread(monitoruri)
         upthread.update_signal.connect(self._on_master_info)
         self.__updateThreads[masteruri] = upthread
         from urlparse import urlparse
         om = urlparse(masteruri)
         upthread.start()
     self._lock.release()
 def __create_update_thread(self, monitoruri, masteruri, delayed_exec):
   upthread = UpdateThread(monitoruri, masteruri, delayed_exec)
   self.__updateThreads[masteruri] = upthread
   upthread.update_signal.connect(self._on_master_info)
   upthread.master_errors_signal.connect(self._on_master_errors)
   upthread.error_signal.connect(self._on_error)
   upthread.start()
 def requestMasterInfo(self, masteruri, monitoruri):
   '''
   This method starts a thread to get the informations about the ROS master by
   the given RCP uri of the master_discovery node. If all informations are
   retrieved, a C{master_info_signal} of this class will be emitted. If for given
   masteruri a thread is already running, it will be inserted to the requested
   updates. For the same masteruri only one requested update can be stored. 
   On update error the requested update will be ignored.
   This method is thread safe. 
   
   @param masteruri: the URI of the remote ROS master
   @type masteruri: C{str}
   @param monitoruri: the URI of the monitor RPC interface of the master_discovery node
   @type monitoruri: C{str}
   '''
   self._lock.acquire(True)
   if (self.__updateThreads.has_key(masteruri)):
     self.__requestedUpdates[masteruri] = monitoruri
   else:
     upthread = UpdateThread(monitoruri)
     upthread.update_signal.connect(self._on_master_info)
     self.__updateThreads[masteruri] = upthread
     from urlparse import urlparse
     om = urlparse(masteruri)
     upthread.start()
   self._lock.release()
Example #6
0
 def __create_update_thread(self, monitoruri, masteruri, delayed_exec):
   upthread = UpdateThread(monitoruri, masteruri, delayed_exec)
   self.__updateThreads[masteruri] = upthread
   upthread.update_signal.connect(self._on_master_info)
   upthread.master_errors_signal.connect(self._on_master_errors)
   upthread.error_signal.connect(self._on_error)
   upthread.timediff_signal.connect(self._on_timediff)
   upthread.start()
 def _on_master_info(self, minfo):
     self.master_info_signal.emit(minfo)
     self._lock.acquire(True)
     try:
         thread = self.__updateThreads.pop(minfo.masteruri)
         del thread
         monitoruri = self.__requestedUpdates.pop(minfo.masteruri)
     except KeyError:
         pass
     else:
         upthread = UpdateThread(monitoruri)
         upthread.update_signal.connect(self._on_master_info)
         self.__updateThreads[minfo.masteruri] = upthread
         upthread.start()
     self._lock.release()
 def _on_master_info(self, minfo):
   self.master_info_signal.emit(minfo)
   self._lock.acquire(True)
   try:
     thread = self.__updateThreads.pop(minfo.masteruri)
     del thread
     monitoruri = self.__requestedUpdates.pop(minfo.masteruri)
   except KeyError:
     pass
   else:
     upthread = UpdateThread(monitoruri)
     upthread.update_signal.connect(self._on_master_info)
     self.__updateThreads[minfo.masteruri] = upthread
     upthread.start()
   self._lock.release()
     
Example #9
0
class UpdateForm(QWidget):

    done = pyqtSignal()
    update = pyqtSignal(str, int)

    def __init__(self, session, update_link, md5):
        super(UpdateForm, self).__init__()
        # uic.loadUi('ui/update.ui', self)
        self.resize(386, 101)
        self.move(300, 300)
        self.label = QtGui.QLabel("Updating...", self)
        self.label.setGeometry(120,10,151,31)
        self.progressBar = QtGui.QProgressBar(self)
        self.progressBar.setGeometry(70,40,271,21)
        self.progressBar.setRange(0, 100)
        self.show()
        self.progressBar.setValue(0)
        self.session = session
        self.current_folder = os.getcwd()
        self.update_link = update_link
        self.md5 = md5
        self.update_file = None
        self.update_tool()
        self.done.connect(self.terminate)
        self.update.connect(self.update_ui)

    def update_tool(self):
        self.setWindowTitle("Updating")
        self.th = UpdateThread(self.current_folder, self.update_link, self.md5, self)
        self.th.finished.connect(self.terminate)
        self.th.start()

    def terminate(self):
        print 'Update ok'
        subprocess.Popen(['storagon.exe'], creationflags=DETACHED_PROCESS, shell=True)
        if os.path.isfile('update.bat'):
            os.remove('update.bat')
        time.sleep(2)
        self.close()
        sys.exit(0)

    def update_ui(self, label, progress):
        self.label.setText(label)
        self.progressBar.setValue(progress)
Example #10
0
class UpdateForm(QWidget):

    done = pyqtSignal()
    update = pyqtSignal(str, int)

    def __init__(self, session, update_link, md5):
        super(UpdateForm, self).__init__()
        uic.loadUi(resource_path('update.ui'), self)
        self.progressBar.setRange(0, 100)
        self.show()
        self.md5 = md5
        self.progressBar.setValue(0)
        self.session = session
        self.current_folder = os.getcwd()
        self.update_link = update_link
        self.update_file = None
        self.update_tool()
        self.done.connect(self.terminate)
        self.update.connect(self.update_ui)
        self.setWindowTitle("Updating")

    def update_tool(self):
        self.th = UpdateThread(self.current_folder, self.update_link, self.md5, self)
        self.th.finished.connect(self.terminate)
        self.th.start()

    def terminate(self):
        print('Update ok')
        # Windows
        subprocess.Popen(['poster.exe'], creationflags=DETACHED_PROCESS, shell=True)
        # Mac and linux
        # subprocess.Popen(['./poster'], shell=True)

        time.sleep(1)
        self.close()
        sys.exit()

    def update_ui(self, label, progress):
        self.label.setText(label)
        self.progressBar.setValue(progress)
Example #11
0
class UpdateForm(QWidget):

    done = pyqtSignal()
    update = pyqtSignal(str, int)

    def __init__(self, session, update_link, md5):
        super(UpdateForm, self).__init__()
        uic.loadUi(resource_path('update.ui'), self)
        self.progressBar.setRange(0, 100)
        self.show()
        self.md5 = md5
        self.progressBar.setValue(0)
        self.session = session
        self.current_folder = os.getcwd()
        self.update_link = update_link
        self.update_file = None
        self.update_tool()
        self.done.connect(self.terminate)
        self.update.connect(self.update_ui)
        self.setWindowTitle("Updating")

    def update_tool(self):
        self.th = UpdateThread(self.current_folder, self.update_link, self.md5, self)
        self.th.finished.connect(self.terminate)
        self.th.start()

    def terminate(self):
        print('Update ok')
        os.system(resource_path("open.bat"))
        time.sleep(1)
        self.close()
        sys.exit()

    def update_ui(self, label, progress):
        self.label.setText(label)
        self.progressBar.setValue(progress)
Example #12
0
class AppUI(QWidget):
    """ Sets up the up the UI """
    def __init__(self):
        super(AppUI, self).__init__()
        self.init_ui()

    #####################################
    # Start - Build All section of the UI
    #####################################
    # Add all the sections to the main window
    def init_ui(self):
        """ Initializes all the secions in the layout """

        window_layout = QGridLayout()
        window_layout.setAlignment(QtCore.Qt.AlignTop)

        self.weather_controller = WeatherController()
        self.weather_controller.parse_weather({})

        self.weather_frame = Weather(self.weather_controller)
        window_layout.addWidget(self.weather_frame, 0, 0)

        self.running_clothes_frame = RunningClothes()

        window_layout.addWidget(self.running_clothes_frame, 1, 0)

        ui_palette = self.palette()
        ui_palette.setColor(self.backgroundRole(), QtCore.Qt.black)
        self.setPalette(ui_palette)

        #Set the layout and window
        self.setLayout(window_layout)
        self.move(300, 150)
        self.show()
        #start Fullscreen
        self.showFullScreen()

        # kick off the thread
        self.update_thread = UpdateThread()
        self.update_thread.update_clock.connect(self.callback_update_clock)
        self.update_thread.update_moon.connect(self.callback_update_moon)
        self.update_thread.update_indoor.connect(self.callback_update_indoor)
        self.update_thread.update_weather_and_clothes.connect(self.callback_update_weather_and_clothes)
        self.update_thread.update_person.connect(self.callback_update_person)
        self.update_thread.start()

    def callback_update_clock(self):
        """callback for updating the clock from the timing thread"""
        self.weather_frame.update_clock()

    def callback_update_moon(self):
        """callback for updating the clock from the timing thread"""
        self.weather_frame.update_moon()

    def callback_update_indoor(self, data):
        """callback for updating the indoor from the timing thread"""
        self.weather_frame.update_indoor_status(data)

    def callback_update_person(self):
        """
        Callback for updateing the person frame from the timing thread.
        Makes the current visible person invisible and the next person visible.
        Loops around when it hits the end of the person list.
        """
        people = self.running_clothes_frame.runner_widget_list
        number_of_people = len(people)
        j = 0
        index_to_set_visible = 0
        while j < number_of_people:
            if people[j].isVisible():
                people[j].setVisible(False)
                index_to_set_visible = j + 1
            j += 1

        if index_to_set_visible > number_of_people - 1:
            index_to_set_visible = 0

        people[index_to_set_visible].setVisible(True)

    def callback_update_weather_and_clothes(self, data):
        """callback to update the weather and clothing from the timeing thread"""
        self.weather_controller.parse_weather(data)
        self.weather_frame.update_display(self.weather_controller)
        
        running_frame = self.findChild(RunningClothes)
        self.update_clothing(running_frame)

    def update_clothing(self, running_frame):
        """Loops through the UI and hides the displayed clothing"""
        running_sub_frame = running_frame.findChild(QFrame)
        runner_frames = running_sub_frame.findChildren(QFrame)
        new_running_clothes_data = RunningClothesController.get_runner_data()

        for runner_frame in runner_frames:
            new_intensity_clothes_data = {}
            if runner_frame.__class__.__name__ == "QFrame":
                frame_runner_data = self.get_hidden_data(runner_frame)
                new_runner_data = RunningClothesController.get_updated_runner_data(new_running_clothes_data, frame_runner_data)

                intensity_frames = runner_frame.findChildren(QGroupBox)
                for intensity in intensity_frames:
                    intensity_frame_data = self.get_hidden_data(intensity)
                    if "data" in new_runner_data:
                        for new_intensity_data in new_runner_data["data"]:
                            if new_intensity_data["intensity_type"] == intensity_frame_data["type"]:
                                new_intensity_clothes_data = new_intensity_data["clothes"]

                        running_frame.hide_all_clothing(intensity)
                        running_frame.show_correct_clothing(intensity, new_intensity_clothes_data)

    def get_hidden_data(self, frame):
        """Gets data from hidden lables in frames"""
        data = {}
        for label in frame.findChildren(QLabel):
            if ":" in label.text():
                text = label.text().split(":")
                data[text[0]] =  text[1]
        return data

    def keyPressEvent(self, event):
        """
        handles key press event <Esc> closes and <return>
        switches from full screen to normal window
        """
        if str(event.key()) == str(QtCore.Qt.Key_Escape):
            self.close()
        elif str(event.key()) == str(QtCore.Qt.Key_Return):
            if self.isFullScreen():
                self.showNormal()
                self.setGeometry(300, 150, 500, 500)
            else:
                self.showFullScreen()
Example #13
0
 def update_tool(self):
     self.setWindowTitle("Updating")
     self.th = UpdateThread(self.current_folder, self.update_link, self.md5, self)
     self.th.finished.connect(self.terminate)
     self.th.start()