def __init__(self, expression_to_neutral=False):
        super().__init__()

        self.expression_to_neutral = expression_to_neutral
        if self.expression_to_neutral:
            self.title = "From Expression to Neutral"
        else:
            self.title = "3DMM"
        self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        self.setFixedSize(1200, 700)

        self.camera = Camera()
        self.progress_bar = QProgressBar(self)
        self.count = 0

        self.toolbar = self.addToolBar('Main Window')
        # self.toolbar_emotions = self.addToolBar('Emotions')

        self.expression = "neutral"
        self.picture_taken = False
        self.bool_onclick = None
        self.portrait = None
        self.model = Model(None, self.expression, self,
                           self.expression_to_neutral)
        self.video_widget = VideoWidget(self.camera)
        self.right_label = RightLabel(self, self.model)
        self.main_widget = MainWidget(self.video_widget, self.right_label,
                                      self.camera)
        self.setCentralWidget(self.main_widget)

        self.model.progress_bar.connect(self.set_progress_bar,
                                        type=Qt.QueuedConnection)
        self.combo_box = QComboBox(self)

        self.initUI()
 def __init__(self):
     self.main_widget = MainWidget()
     self.register_widget = RegisterWidget()
     self.info_window_widget = InfoWindowWidget()
     self.login_widget = LoginWidget()
     self.add_medical_record_widget = AddMedicalRecordWidget()
     self.show_medical_record_widget = ShowMedicalRecordWidget()
     self.update_medical_record_widget = UpdateMedicalRecordWidget()
     self.init_slots()
     self.init_connects()
     return
    def __init__(self, camera):
        super().__init__()

        self.title = "3DMM"
        # self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        # self.setFixedSize(1200, 700)
        # self.setGeometry(500, 100, 1200, 700)

        # self.right_label = RightLabel(self, self.model)
        self.camera = camera
        self.main_widget = MainWidget(self.camera, True)
class DigitalRecordSystem:
    def __init__(self):
        self.main_widget = MainWidget()
        self.register_widget = RegisterWidget()
        self.info_window_widget = InfoWindowWidget()
        self.login_widget = LoginWidget()
        self.add_medical_record_widget = AddMedicalRecordWidget()
        self.show_medical_record_widget = ShowMedicalRecordWidget()
        self.update_medical_record_widget = UpdateMedicalRecordWidget()
        self.init_slots()
        self.init_connects()
        return

    def init_slots(self):
        self.register_widget.signal_user.connect(self.info_window_widget.show)
        self.register_widget.signal_user.connect(
            self.info_window_widget.getUser)
        self.login_widget.regbtn.clicked.connect(self.register_widget.show)
        self.login_widget.signal_login.connect(self.main_widget.set_user_id)
        self.login_widget.signal_login.connect(self.main_widget.show)
        return

    def init_connects(self):
        self.main_widget.ui.add_button.clicked.connect(
            self.add_medical_record_widget.show)
        self.main_widget.ui.search_button.clicked.connect(
            self.show_search_widget)
        self.show_medical_record_widget.editButton.clicked.connect(
            self.show_edit_widget)

    def show_search_widget(self):
        name = self.main_widget.get_search_info()
        self.show_medical_record_widget.load_data(name)
        if self.show_medical_record_widget.refresh_data(
                self.main_widget.user_id):
            self.show_medical_record_widget.show()
        else:
            self.main_widget.search_fail_message()

    def show_edit_widget(self):
        name = self.show_medical_record_widget.data.get('name')
        self.update_medical_record_widget.load_data(name)
        if self.update_medical_record_widget.refresh_data(
                self.show_medical_record_widget.user_id):
            self.update_medical_record_widget.show()
            self.show_medical_record_widget.hide()
        else:
            return
Esempio n. 5
0
    def init_UI(self):

        ##  Set the theme
        self.set_stylesheet(self.opts["theme"])

        self.profiles = read_profiles()
        self.mainWidget = MainWidget(self)

        self.statusBar()
        self.build_menu_bar()

        self.setCentralWidget(self.mainWidget)

        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.center_window()
        self.setWindowTitle("qYoutube-DL")
        self.show()
class MainWindow(QMainWindow):
    def __init__(self, camera):
        super().__init__()

        self.title = "3DMM"
        # self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        # self.setFixedSize(1200, 700)
        # self.setGeometry(500, 100, 1200, 700)

        # self.right_label = RightLabel(self, self.model)
        self.camera = camera
        self.main_widget = MainWidget(self.camera, True)

        # self.initUI()

    def initUI(self):
        count = 0
        # self.addToolBarBreak()

    def activate(self):
        self.main_widget.activate()

    def deactivate(self):
        self.main_widget.deactivate()

    def closeEvent(self, event):
        self.camera.deactivate()
        self.main_widget.deactivate()
        event.accept()
Esempio n. 7
0
    def __init__(self):
        super().__init__()

        #   Styling
        self.setWindowTitle('WebPanes version 0.1')
        self.width = 800
        self.height = 600
        self.top = 200
        self.left = 400
        self.setWindowIcon(QtGui.QIcon('icon.png'))
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setStyleSheet('background: white')

        #   Main widget
        self.mainWidget = MainWidget()
        self.setCentralWidget(self.mainWidget)

        #   Toolbar
        self.gridToolbar = GridToolbar(self.mainWidget)
        self.addToolBar(self.gridToolbar)
Esempio n. 8
0
    def initUI(self):
        self.name_company = 'TU Berlin'
        self.name_product = 'Editor'
        self.scene = Scene()

        self.createActions()
        self.createMenus()
        self.createToolBars()
        #self.updateMenus()

        self.readSettings()
        # create node editor widget
        self.editor = MainWidget(self)
        self.setCentralWidget(self.editor)

        # status bar
        # self.createStatusBar()

        # set window properties
        self.setGeometry(200, 200, 800, 600)
        self.setWindowTitle("Editor")
        self.show()
Esempio n. 9
0
#!/usr/bin/python3

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from main_widget import MainWidget

app = QApplication(sys.argv)

# set icon for application
window_icon = QIcon("./resources/srt.ico")
if not window_icon.isNull():
    app.setWindowIcon(window_icon)

form = MainWidget()
form.show()

app.exec_()
class MainWindow(QMainWindow):
    def __init__(self, expression_to_neutral=False):
        super().__init__()

        self.expression_to_neutral = expression_to_neutral
        if self.expression_to_neutral:
            self.title = "From Expression to Neutral"
        else:
            self.title = "3DMM"
        self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        self.setFixedSize(1200, 700)

        self.camera = Camera()
        self.progress_bar = QProgressBar(self)
        self.count = 0

        self.toolbar = self.addToolBar('Main Window')
        # self.toolbar_emotions = self.addToolBar('Emotions')

        self.expression = "neutral"
        self.picture_taken = False
        self.bool_onclick = None
        self.portrait = None
        self.model = Model(None, self.expression, self,
                           self.expression_to_neutral)
        self.video_widget = VideoWidget(self.camera)
        self.right_label = RightLabel(self, self.model)
        self.main_widget = MainWidget(self.video_widget, self.right_label,
                                      self.camera)
        self.setCentralWidget(self.main_widget)

        self.model.progress_bar.connect(self.set_progress_bar,
                                        type=Qt.QueuedConnection)
        self.combo_box = QComboBox(self)

        self.initUI()

    def initUI(self):
        self.build_toolbar()
        # self.addToolBarBreak()

    def get_expression(self):
        return self.expression

    def get_bool_onclick(self):
        return self.bool_onclick

    def get_combo_box(self):
        return self.combo_box

    def set_progress_bar(self):
        if self.count <= 2:
            self.progress_bar.setValue(self.count * 50)
            self.count = self.count + 1
            return
        self.count = 0
        self.set_progress_bar()

    def build_toolbar(self):

        slide_bar = QSlider(Qt.Horizontal)
        slide_bar.setMinimum(0)
        slide_bar.setMaximum(8)
        slide_bar.setValue(3)
        slide_bar.valueChanged.connect(self.camera.setZoom)
        self.toolbar.addWidget(slide_bar)

        take_photo = QAction(QIcon('images/get_photo.png'), 'Take_Picture',
                             self)
        take_photo.setShortcut('Ctrl+Q')
        take_photo.triggered.connect(self.on_click)
        self.toolbar.addAction(take_photo)

        # self.progress_bar.setHidden(True)
        self.toolbar.addWidget(self.progress_bar)

        self.toolbar.addSeparator()

        # build slide fo upload pre-built patterns.looking for the pattern class
        if self.expression_to_neutral:
            self.combo_box.addItem("Face")
        else:
            self.combo_box.addItem("Neutral")
        self.combo_box.addItem("Surprise")
        self.combo_box.addItem("Happy")
        self.combo_box.addItem("Contempt")
        self.combo_box.addItem("Sadness")
        self.combo_box.addItem("Disgust")
        self.combo_box.addItem("Angry")
        self.combo_box.addItem("Fear")
        self.toolbar.addWidget(self.combo_box)
        self.combo_box.activated[str].connect(self.combo_changed)
        self.toolbar.addSeparator()

    def activate(self):
        self.main_widget.activate()
        self.show()

    def deactivate(self):
        self.main_widget.deactivate()

    def closeEvent(self, event):
        self.camera.deactivate()
        self.main_widget.deactivate()
        event.accept()

    def on_click(self):
        # self.progress_bar.setHidden(False)
        self.picture_taken = True
        self.bool_onclick = True
        self.portrait = self.camera.get_current_frame()
        self.portrait = resizeImage(self.portrait, 600)
        image = ndimage.gaussian_filter(self.portrait,
                                        sigma=(1.3, 1.3, 0),
                                        order=0)
        image = Image.fromarray(image)

        scipy.misc.imsave('expression_code/imgs/outfile.jpg', image)
        self.model.set_image('expression_code/imgs/outfile.jpg')
        self.right_label.activate()

    def combo_changed(self, text):
        self.bool_onclick = False
        self.expression = text.lower()
        if self.picture_taken:
            self.right_label.activate()
Esempio n. 11
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)

        central_widget = QWidget()
        main_layout = QGridLayout()

        # noinspection PyUnresolvedReferences
        if parser_args.type == 'formation':
            dis_label = QLabel("Синхронный полет")
            num_label = QLabel("Formation_1 ({})".format(counter))
        else:
            dis_label = QLabel("Командная гонка")
            num_label = QLabel("Race_1 ({})".format(counter))

        # noinspection PyUnresolvedReferences
        name_label = QLabel("{}".format(str(parser_args.team)))

        dis_label.setStyleSheet("QLabel { background-color: #808080; color: white; font-size: 24px; }")
        name_label.setStyleSheet("QLabel { background-color: #808080; color: white; font-size: 24px; }")
        num_label.setStyleSheet("QLabel { background-color: #808080; color: white; font-size: 24px; }")

        dis_label.setFixedHeight(LABEL_HEIGHT)
        name_label.setFixedHeight(LABEL_HEIGHT)
        num_label.setFixedHeight(LABEL_HEIGHT)

        dis_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        name_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        num_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        main_layout.addWidget(dis_label, 0, 0)
        main_layout.addWidget(name_label, 0, 1)
        main_layout.addWidget(num_label, 0, 2)

        main_layout.setColumnStretch(0, 1)
        main_layout.setColumnStretch(1, 3)
        main_layout.setColumnStretch(2, 3)

        # noinspection PyUnresolvedReferences
        if parser_args.type == 'formation':
            self.main_widget = MainWidget(formation=True)
        else:
            self.main_widget = MainWidget(formation=False)
        main_layout.addWidget(self.main_widget, 1, 0)

        main_layout.setAlignment(Qt.AlignRight)

        central_widget.setLayout(main_layout)
        self.setCentralWidget(central_widget)

        rospy.init_node('ui', anonymous=True)
        rospy.Subscriber('/collisions', String, self.main_widget.collisions_cb)
        rospy.Subscriber('/final', String, self.main_widget.final_cb)

        # noinspection PyUnresolvedReferences
        if parser_args.type == 'formation':
            rospy.Subscriber('/side_time', String, self.main_widget.side_time_cb)
            rospy.Subscriber('/msd_current', String, self.main_widget.msd_current_cb)
            rospy.Subscriber('/msd_overall', String, self.main_widget.msd_overall_cb)
            rospy.Subscriber('/reformation', String, self.main_widget.reformation_cb)
        else:
            rospy.Subscriber('/passes', String, self.main_widget.passes_cb)
            rospy.Subscriber('/times', String, self.main_widget.times_cb)
Esempio n. 12
0
import sys
import qdarkstyle

if __name__ == '__main__':
    x = 0
    y = 0
    x1 = 0
    y1 = 0
    z = 0
    z1 = 0
    list_z = []
    nose_tmp = np.array([0, 0])
    app = QApplication(sys.argv)
    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
    frontal_camera = Camera(0)
    mainWid = MainWidget(frontal_camera)
    mainWid.activate()
    pygame.init()
    display = (800, 600)
    pygame.display.set_mode(display, DOUBLEBUF | OPENGL)
    gluPerspective(45, (display[0] / display[1]), 0.1, 50.0)

    glLightfv(GL_LIGHT0, GL_POSITION, (-40, 200, 100, 0.0))
    glLightfv(GL_LIGHT0, GL_AMBIENT, (0.2, 0.2, 0.2, 1.0))
    glLightfv(GL_LIGHT0, GL_DIFFUSE, (0.5, 0.5, 0.5, 1.0))
    glEnable(GL_LIGHT0)
    glEnable(GL_LIGHTING)
    glEnable(GL_COLOR_MATERIAL)
    glEnable(GL_DEPTH_TEST)
    glShadeModel(GL_SMOOTH)
    glTranslate(0, -2, -5)
Esempio n. 13
0
from PySide2.QtWidgets import *
from main_widget import MainWidget
from main_window import MainWindow


class main:
    def __init__(self):
        pass  # call __init__(self) of the custom base class here


if __name__ == "__main__":

    # Qt Application
    app = QApplication([])

    # main_widget
    app.main_widget = MainWidget()

    # QMainWindow using QWidget as central widget
    app.window = MainWindow(app)

    app.window.show()  # shows main window

    app.exec_()  # pauses this script until main window is closed
Esempio n. 14
0
 def main_window(self) -> None:
     self.setCentralWidget(MainWidget(self))
Esempio n. 15
0
def main():
    app = QApplication(sys.argv)

    widget = MainWidget()
    sys.exit(app.exec_())
    widget = widget
Esempio n. 16
0
import sys
from PySide2.QtWidgets import (
    QApplication, )

from main_widget import MainWidget

if __name__ == "__main__":
    tiny_linter_app = QApplication(sys.argv)

    main_widget = MainWidget()
    main_widget.resize(800, 600)
    main_widget.show()

    sys.exit(tiny_linter_app.exec_())
Esempio n. 17
0
 def __init__(self):
     super().__init__()
     self.setCentralWidget(MainWidget())
Esempio n. 18
0
import sys

from PySide2.QtWidgets import QApplication

from main_widget import MainWidget
from main_window import MainWindow

if __name__ == "__main__":
    app = QApplication()
    # app.setStyle('gtk')

    widget = MainWidget()
    window = MainWindow(widget)

    window.show()

    sys.exit(app.exec_())
Esempio n. 19
0
    def __init__(self):
        super().__init__()
        self.main_widget = MainWidget(parent_window=self)
        self.setCentralWidget(self.main_widget)

        self.statusBar().showMessage('Ready')

        self.statusbar_label = QLabel("0/0")

        self.statusBar().addPermanentWidget(self.statusbar_label)

        menubar = self.menuBar()

        self.is_ordered = False

        self.setWindowTitle("Data Analysis App")

        # add submenus to a menu
        file_menu = menubar.addMenu('File')
        help_menu = menubar.addMenu('Help')

        # add an action with a callback
        file_menu.addAction('Quit', self.destroy)

        # add separator
        file_menu.addSeparator()

        toolbar = self.addToolBar('File')

        toolbar.setMovable(False)
        toolbar.setFloatable(False)
        toolbar.setAllowedAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)

        dock = QDockWidget("Tools")

        dock_loaders_widget = QWidget(self)
        dock_preprocess_widget = QWidget(self)
        dock_regression_widget = QWidget(self)
        dock_classification_widget = QWidget(self)
        dock_clustering_widget = QWidget(self)
        dock_visualization_widget = QWidget(self)
        dock_demux_widget = QWidget(self)

        nodes_list_loaders = DragList()
        nodes_list_preprocess = DragList()
        nodes_list_regression = DragList()
        nodes_list_classification = DragList()
        nodes_list_clustering = DragList()
        nodes_list_visualization = DragList()
        nodes_list_demux = DragList()

        nodes_list_loaders.add_items(
            ['Csv Loader', 'Excel Loader', "Xml Loader", "Deserializer"],
            icon="icons/input24.png")
        nodes_list_preprocess.add_items(['Attribute Remover', 'Filter'],
                                        icon="icons/both24.png")
        nodes_list_regression.add_items(['Linear Regression'],
                                        icon="icons/both24.png")
        nodes_list_classification.add_items(
            ['Knn', 'SVM', 'Naive Bayes', 'Decision Tree'],
            icon="icons/both24.png")
        nodes_list_clustering.add_items(['K-Means', "Hierarchical"],
                                        icon="icons/both24.png")
        nodes_list_visualization.add_items([
            "Text output", "Scatter plot", "Pie Chart", "Predictor",
            "Serializer", "Simple Plot", "Histogram", "Csv Saver"
        ],
                                           icon="icons/output24.png")
        nodes_list_demux.add_items(
            ["1x2 Demux", "1x3 Demux", "1x4 Demux", "1x5 Demux"],
            icon="icons/demux.png")

        self.addDockWidget(Qt.LeftDockWidgetArea, dock)

        tab_widget = QTabWidget()
        tab_widget.setMovable(False)
        tab_widget.setTabPosition(QTabWidget.West)
        tab_widget.resize(100, 100)

        dock_layout_loaders = QHBoxLayout()
        dock_layout_preprocess = QHBoxLayout()
        dock_layout_regression = QHBoxLayout()
        dock_layout_classification = QHBoxLayout()
        dock_layout_clustering = QHBoxLayout()
        dock_layout_visualization = QHBoxLayout()
        dock_layout_demux = QHBoxLayout()

        dock_loaders_widget.setLayout(dock_layout_loaders)
        dock_preprocess_widget.setLayout(dock_layout_preprocess)
        dock_regression_widget.setLayout(dock_layout_regression)
        dock_classification_widget.setLayout(dock_layout_classification)
        dock_clustering_widget.setLayout(dock_layout_clustering)
        dock_visualization_widget.setLayout(dock_layout_visualization)
        dock_demux_widget.setLayout(dock_layout_demux)

        # dock_layout.addWidget(tab_widget)

        dock_layout_loaders.addWidget(nodes_list_loaders)
        dock_layout_preprocess.addWidget(nodes_list_preprocess)
        dock_layout_regression.addWidget(nodes_list_regression)
        dock_layout_classification.addWidget(nodes_list_classification)
        dock_layout_clustering.addWidget(nodes_list_clustering)
        dock_layout_visualization.addWidget(nodes_list_visualization)
        dock_layout_demux.addWidget(nodes_list_demux)

        tab_widget.addTab(dock_loaders_widget, 'Inputs')
        tab_widget.addTab(dock_preprocess_widget, 'Preprocessors')
        tab_widget.addTab(dock_regression_widget, 'Regression')
        tab_widget.addTab(dock_classification_widget, 'Classification')
        tab_widget.addTab(dock_clustering_widget, 'Clustering')
        tab_widget.addTab(dock_visualization_widget, 'Output')
        tab_widget.addTab(dock_demux_widget, "Demux")

        dock.setWidget(tab_widget)

        help_menu.addAction('About', self.show_about_dialog)
        help_menu.addAction("Credits", self.credits)
        help_menu.addAction("Node List", self._log_path)

        self.show()
Esempio n. 20
0
    def __init__(self, data_provider):
        super().__init__()

        self.setCentralWidget(MainWidget(data_provider))
Esempio n. 21
0
 def __init__(self, parent=None):
     super(MainWindow, self).__init__(parent)
     self.mainWidget = MainWidget()
     self.setCentralWidget(self.mainWidget)
Esempio n. 22
0
class MainWindow(QMainWindow):

    opts = read_config()
    profiles = read_profiles()
    urls = []

    def __init__(self, debug=False):
        super().__init__()

        self.debug = debug

        self.icon_paths()

        self.init_UI()

    def icon_paths(self):

        self.defaultIconTheme = QIcon.themeName()

        iconPaths = QIcon.themeSearchPaths()
        iconPaths.append(icon_path())

        QIcon.setThemeSearchPaths(iconPaths)

        QIcon.setFallbackSearchPaths([icon_path("default")])
        QIcon.setFallbackThemeName("default")

        #QIcon.setThemeName( "default" )

    def init_UI(self):

        ##  Set the theme
        self.set_stylesheet(self.opts["theme"])

        self.profiles = read_profiles()
        self.mainWidget = MainWidget(self)

        self.statusBar()
        self.build_menu_bar()

        self.setCentralWidget(self.mainWidget)

        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.center_window()
        self.setWindowTitle("qYoutube-DL")
        self.show()

    def center_window(self):
        f = self.frameGeometry()
        center = QDesktopWidget().availableGeometry().center()
        f.moveCenter(center)
        self.move(f.topLeft())

    def build_menu_bar(self):

        get_icon = Icons().get_icon

        ##  Is this a system install?
        sysInstall = (os.path.expanduser('~') in sys.argv[0])

        ########  Actions

        ##  Save
        saveAction = QAction(
            QIcon(get_icon("document-save-symbolic", sysInstall)),
            "&Save Settings", self)
        saveAction.setShortcut("Ctrl+S")
        saveAction.setStatusTip("Save current settings")
        saveAction.triggered.connect(self.save_settings)

        ##  Import playlist
        importAction = QAction(
            QIcon(get_icon("document-open-symbolic", sysInstall)),
            "&Import URLs", self)
        importAction.setShortcut("Ctrl+I")
        importAction.setStatusTip("Import a saved list of URLs")
        importAction.triggered.connect(self.import_urls)

        ##  Export playlist
        exportAction = QAction(
            QIcon(get_icon("document-save-symbolic", sysInstall)),
            "&Export URLs", self)
        exportAction.setShortcut("Ctrl+E")
        exportAction.setStatusTip("Export URLs to a text file")
        exportAction.triggered.connect(self.export_urls)

        ##  Exit
        exitAction = QAction(
            QIcon(get_icon("application-exit-symbolic", sysInstall)), "&Exit",
            self)
        exitAction.setShortcut("Ctrl+Q")
        exitAction.setStatusTip("Exit the application")
        exitAction.triggered.connect(qApp.quit)

        ##  Go
        goAction = QAction(QIcon(get_icon("go-next-symbolic", sysInstall)),
                           "Download URLs", self)
        goAction.setShortcut("Return")
        goAction.setStatusTip("Download current URL list")
        goAction.triggered.connect(self.mainWidget.start_download)

        ##  Paste
        pasteAction = QAction(
            QIcon(get_icon("edit-paste-symbolic", sysInstall)), "&Paste", self)
        pasteAction.setShortcut("Ctrl+V")
        pasteAction.setStatusTip("Add URL from clipboard")
        pasteAction.triggered.connect(self.mainWidget.quick_add_item)

        ##  Set destination
        setDestAction = QAction(
            QIcon(get_icon("document-open-symbolic", sysInstall)),
            "Set &Download directory", self)
        setDestAction.setShortcut("Ctrl+D")
        setDestAction.setStatusTip("Choose your download directory")
        setDestAction.triggered.connect(self.mainWidget.set_destination)

        ##  Allow duplicates
        self.dupeAction = QAction("Allow duplicates", self)
        self.dupeAction.setStatusTip("Allow duplicate URLs in queue")
        self.dupeAction.setCheckable(True)
        if self.opts["duplicates"] == "true":
            self.dupeAction.setChecked(True)
        self.dupeAction.triggered.connect(self.check_dupe_box)

        ##  New folder for playlists
        self.playlistFolderAction = QAction("New folder for playlists", self)
        self.playlistFolderAction.setStatusTip(
            "Create a new folder for every playlist downloaded")
        self.playlistFolderAction.setCheckable(True)
        if self.opts["playlistFolder"] == "true":
            self.playlistFolderAction.setChecked(True)
        self.playlistFolderAction.triggered.connect(
            self.check_playlist_dir_box)

        ##  About action
        aboutAction = QAction(
            QIcon(get_icon("help-about-symbolic", sysInstall)), "&About", self)
        aboutAction.setStatusTip("Information about the program")
        aboutAction.triggered.connect(self.about)

        ##  ======  Theme actions
        ##  System default theme
        defaultThemeAction = QAction("Default", self)
        defaultThemeAction.setStatusTip("Set theme to system default")
        defaultThemeAction.triggered.connect(self.toggle_theme_default)

        ##  Light theme
        lightThemeAction = QAction("Light theme", self)
        lightThemeAction.setStatusTip("Use a light theme")
        lightThemeAction.triggered.connect(self.toggle_theme_light)

        ##  Dark theme
        darkThemeAction = QAction("Dark theme", self)
        darkThemeAction.setStatusTip("Use a dark theme")
        darkThemeAction.triggered.connect(self.toggle_theme_dark)

        ##  Create the menubar
        menuBar = self.menuBar()

        ##  Create file menu
        fileMenu = menuBar.addMenu("&File")
        fileMenu.addAction(saveAction)
        fileMenu.addAction(exportAction)
        fileMenu.addSeparator()
        fileMenu.addAction(importAction)
        fileMenu.addSeparator()
        fileMenu.addAction(goAction)
        fileMenu.addSeparator()
        fileMenu.addAction(exitAction)

        ##  Edit Menu
        editMenu = menuBar.addMenu("&Edit")
        editMenu.addAction(pasteAction)

        ##  Settins Menu
        settingsMenu = menuBar.addMenu("&Settings")
        themesMenu = settingsMenu.addMenu("Theme")
        settingsMenu.addSeparator()
        settingsMenu.addAction(setDestAction)
        settingsMenu.addSeparator()
        settingsMenu.addAction(self.dupeAction)
        settingsMenu.addAction(self.playlistFolderAction)

        ##  Themes submenu
        themesMenu.addAction(defaultThemeAction)
        themesMenu.addAction(lightThemeAction)
        themesMenu.addAction(darkThemeAction)

        ##  Help menu
        helpMenu = menuBar.addMenu("&Help")
        helpMenu.addAction(aboutAction)

    def import_urls(self):

        dDir = self.mainWidget.destEdit.text()

        filename, blank = QFileDialog.getOpenFileName(self, "Import URLs",
                                                      dDir)
        if filename != "":
            try:

                fin = open(filename, "r")
                rawUrls = fin.readlines()
                fin.close()

                urls = []
                for r in rawUrls:
                    urls.append(r.strip())

                self.load_urls(urls)

                self.statusBar().showMessage("URLs imported", 2000)

            except (OSError, PermissionError, FileNotFoundError):
                print("ERROR:  Cannot read from '%s'!  Unable to load URLs" %
                      filename)

    def export_urls(self):

        dDir = self.mainWidget.destEdit.text()

        filename, blank = QFileDialog.getSaveFileName(self, "Export URLs",
                                                      dDir)
        if filename != "":
            try:
                urls = self.mainWidget.get_urls()

                fout = open(filename, "w")
                fout.writelines(urls)
                fout.close()

                self.statusBar().showMessage("URLs exported", 2000)

            except (OSError, PermissionError, FileNotFoundError):
                print("ERROR:  Cannot write to '%s'!  Unable to export URLs" %
                      filename)

    def load_urls(self, urls):
        self.mainWidget.load_urls(urls)

    def write_config(self):

        self.opts["downloadPath"] = self.mainWidget.destEdit.text()
        self.opts["duplicates"] = str(self.dupeAction.isChecked()).lower()

        boolStr = str(self.playlistFolderAction.isChecked()).lower()
        self.opts["playlistFolder"] = boolStr

        write_config(self.opts)

    def save_settings(self):

        self.write_config()
        self.statusBar().showMessage("Settings saved", 2000)

    def check_dupe_box(self):
        self.opts["duplicates"] = str(self.dupeAction.isChecked()).lower()
        self.save_settings()

    def check_playlist_dir_box(self):
        boolStr = str(self.playlistFolderAction.isChecked()).lower()
        self.opts["playlistFolder"] = boolStr
        self.save_settings()

    def about(self):
        aboutStr = """
        qYoutube-DL is a basic PyQt5 frontend to Youtube-DL.

        Version:    %s
        License:    GPLv3 - https://www.gnu.org/licenses/gpl-3.0.txt
        Author:     James Hendrie - [email protected]
        Git:        https://github.com/jahendrie/qytdl
        """ % qytdl_version()
        msg = QMessageBox.about(self, "About qYoutube-DL", aboutStr)

    def toggle_theme_default(self):
        self.set_stylesheet()
        self.opts["theme"] = "default"
        self.write_config()

    def toggle_theme_light(self):
        self.set_stylesheet("light")
        self.opts["theme"] = "light"
        self.write_config()

    def toggle_theme_dark(self):
        self.set_stylesheet("dark")
        self.opts["theme"] = "dark"
        self.write_config()

    def set_stylesheet(self, ssStr=""):
        if ssStr == "dark" or ssStr == "light":
            ssFile = open(stylesheets_path("%s.qss" % ssStr), "r")
            self.setStyleSheet(ssFile.read())
            ssFile.close()
            QIcon.setThemeName(ssStr)

        else:
            self.setStyleSheet("")
            QIcon.setThemeName(self.defaultIconTheme)
Esempio n. 23
0
 def _init_ui(self):
     central_widget = MainWidget(parent=self)
     self.setCentralWidget(central_widget)
Esempio n. 24
0
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from main_widget import MainWidget

app = QApplication(sys.argv)

# set icon for application
window_icon = QIcon("./resources/srt.ico")
if not window_icon.isNull():
    app.setWindowIcon(window_icon)

form = MainWidget()
form.show()

app.exec_()