Ejemplo n.º 1
0
def init():
    """
    Initializes all the objects on the GUI by loading "EMMA.ui" which contains all the necessary UI elements and
    their placing. References them to properly named objects so they can be used in code. Displays the GUI.
    """
    global app, window, dead, frozen, play_pause_btn, skip_btn, vol_slider, vol_text, pause_EMMA_btn, registe_user_btn, \
        camera_img, live_img, prog_img, current_song_text, now_playing_text, register_window
    app = QApplication(sys.argv)
    window = EmmaWindow()
    uic.loadUi(os.path.join(sys.path[0], "user_interface/EMMA.ui"), window)
    dead = False  # Used to signal if EMMA and the GUI should stop.
    frozen = False  # Used to signal if EMMA should pause.

    # Find and reference the UI elements from EMMA.ui
    play_pause_btn = window.findChild(QPushButton, 'play_pause_btn')
    skip_btn = window.findChild(QPushButton, 'skip_btn')
    pause_EMMA_btn = window.findChild(QPushButton, 'pause_EMMA_btn')
    register_user_btn = window.findChild(QPushButton, 'register_user_btn')
    vol_slider = window.findChild(QSlider, 'vol_slider')
    vol_text = window.findChild(QLabel, 'vol_slider_text')
    current_song_text = window.findChild(QLabel, 'current_song_text')
    now_playing_text = window.findChild(QLabel, 'now_playing_text')
    camera_img = window.findChild(QLabel, 'camera_img')
    live_img = window.findChild(QLabel, 'live_img')
    prog_img = window.findChild(QLabel, 'prog_img')
    GUI_playlist.init(window)  # Links the playlist widget to its functions
    Playlist.set_volume(vol_slider.value())  # Make sure VLC has the same value as the slider initial value.

    register_window = QErrorMessage()  # Pop-up window for registering a user.
    register_window.setWindowTitle('Face Identification')
    register_window.setWindowIcon(QIcon('user_interface/emma_icon.png'))

    # Connects elements to callback functions
    play_pause_btn.clicked.connect(play_pause)
    skip_btn.clicked.connect(skip)
    vol_slider.valueChanged.connect(change_volume)
    pause_EMMA_btn.clicked.connect(start_pause_EMMA)
    register_user_btn.clicked.connect(register_user)
    current_song_text.hide()
    now_playing_text.hide()

    buttons_initialize(play_pause, skip)

    window.show()
Ejemplo n.º 2
0
def set_volume():
    current_volume = check_volume()
    vol_slider.setValue(current_volume)
    Playlist.set_volume(current_volume)
Ejemplo n.º 3
0
def change_volume():
    """
    Called when the slider value changes. Changes the volume of the player accordingly.
    """
    vol_text.setText("{}%".format(vol_slider.value()))
    Playlist.set_volume(vol_slider.value())