Exemplo n.º 1
0
    def __init__(self, exp):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.setWindowIcon(QIcon('icons/main.ico'))

        # Setup status bar. Cannot do this in the Designer.
        self.btn_idle = QPushButton("Record", self)
        self.btn_idle.setStyleSheet("background-color : red")
        self.btn_idle.setCheckable(True)
        self.ui.statusbar.addWidget(self.btn_idle)

        self.exp = exp
        self.threadpool = QThreadPool()

        # Setup the GUI windows
        # self.showMaximized()
        self.set_windows()

        # Menu bar function binding
        self.ui.actionNew.triggered.connect(self.OnNewExperiment)
        self.ui.actionOpen.triggered.connect(self.OnOpenExperiment)
        self.ui.actionSave.triggered.connect(self.OnSaveExperiment)
        self.ui.actionTileWindows.triggered.connect(self.OnTileWindows)
        self.ui.actionOpenWindows.triggered.connect(self.OnShowWindows)
        self.ui.actionLoadScript.triggered.connect(self.OnLoadScript)
        self.ui.actionReloadScript.triggered.connect(self.OnReloadScript)
        # Status bar
        self.btn_idle.clicked.connect(self.OnRecord)
        # Keyboard shortcuts
        self.full_screen = False
        self.shortcut_full_screen = QShortcut(QKeySequence('F11'), self)
        self.shortcut_full_screen.activated.connect(self.OnFullScreen)

        # Start looking for data files
        self.start_file_thread()
        self.start_plot_thread()

        self.showMaximized()  # Open the application in full screen mode
        self.show()
Exemplo n.º 2
0
    def __init__(self, parent, init_val):
        super(EditVal_Dialog, self).__init__(parent)

        # shortcut
        save_shortcut = QShortcut(QKeySequence.Save, self)
        save_shortcut.activated.connect(self.save_triggered)

        main_layout = QVBoxLayout()

        self.val_text_edit = QPlainTextEdit()
        val_str = ''
        try:
            val_str = str(init_val)
        except Exception as e:
            msg_box = QMessageBox(QMessageBox.Warning, 'Value parsing failed',
                                  'Couldn\'t stringify value', QMessageBox.Ok,
                                  self)
            msg_box.setDefaultButton(QMessageBox.Ok)
            msg_box.exec_()
            self.reject()

        self.val_text_edit.setPlainText(val_str)

        main_layout.addWidget(self.val_text_edit)

        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel
                                      | QDialogButtonBox.Ok)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)

        main_layout.addWidget(button_box)

        self.setLayout(main_layout)
        self.resize(450, 300)

        self.setWindowTitle('edit val')
Exemplo n.º 3
0
    def __init__(self):
        """
        Widget with a single edit line that can be displayed or hidden at wish. A press on <Enter> displays it, and
        <Escape> hides it.
        """
        QWidget.__init__(self)

        self.sig_create: Signal = None
        self.creator: str = None

        self.create_field = QLineEdit()

        # Shortcuts
        self.create_field.returnPressed.connect(self.__on_create)
        QShortcut(QKeySequence("Escape"), self.create_field).activated.connect(
            lambda: self.hide_field())  # Cancel

        # Layout
        layout = QHBoxLayout()
        layout.setMargin(0)
        layout.addWidget(self.create_field)
        self.setLayout(layout)

        self.hide_field()
Exemplo n.º 4
0
    def __init__(self, app):
        """
        Initializes main window. Initial section is set to home.
        
        :param app: The QT app.
        :type app: QApplication
        """
        super().__init__()

        self._widget = self._loadTemplate(self.TEMPLATE)

        self._home = HomeSection(self, self._widget.mainContent)
        self._experiment = ExperimentSection(self, self._widget.mainContent)

        #Main content is Stacked Widget.
        self._widget.mainContent.addWidget(self._home.widget)
        self._widget.mainContent.addWidget(self._experiment.widget)

        #register click events

        self._widget.menuFileNewExperiment.triggered.connect(
            partial(self.goExperiment, None))
        self._widget.menuFileLoadExperiment.triggered.connect(
            self.goLoadExperiment)
        self._widget.menuFileSaveExperiment.triggered.connect(
            self.goSaveExperiment)
        self._widget.menuFileSaveAsExperiment.triggered.connect(
            partial(self.goSaveExperiment, True))

        self._widget.menuFileExit.triggered.connect(app.quit)

        #shortcuts
        self._saveShortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_S),
                                       self._widget)

        self.goHome()
Exemplo n.º 5
0
    def __init__(self, parent=None, view=None):
        super().__init__(parent)
        self._parent = parent 
        self._view = view 
        self._layout = QHBoxLayout(self)
        self.setStyleSheet("""
            QLineEdit{background-color: #232323; border: 1px solid #999999;}
            QLineEdit:focus {border: 1px solid #FFFFFF;}
        """)

        # Search Bar 
        self._search_bar = QLineEdit(self)
        self._view.urlChanged.connect(self.setNewUrlOnPageChange)

        self._find_text_entry = QLineEdit(self)
        self._find_text_entry.textChanged.connect(self.textEditFindWebText)
        

        self.addAction(self._view.page().action(self._view.page().Reload))

  
        #self.addAction(self._parent._view.page().action(self._parent._view.page().Back))
        #self.addAction(self._parent._view.page().action(self._parent._view.page().Forward))

        self._find_text_entry.setMaximumWidth(150)
        self._find_text_button = QPushButton(self)
        self._find_text_button.setFlat(True)
        self._find_text_label = QLabel("   Find text:")
        self._find_text_button.setIcon(QIcon(os.path.join('images', 'find.png')))
        self._find_text_button.clicked.connect(self.findWebText)
        self._find_shortcut = QShortcut(QKeySequence("Ctrl+f"), self)
        self._find_shortcut.activated.connect(self.findTextShortcut)
        self._last_word = ""

        self._layout.addWidget(self._search_bar)
        self._layout.addWidget(self._find_text_label)
Exemplo n.º 6
0
 def shortcuts(self):
     self.quit = QShortcut(QKeySequence("Ctrl+q"), self)
     self.quit.activated.connect(self.close)
Exemplo n.º 7
0
    def initToolLeftGridLayout(self):
        bx, by = self.buttonScale
        bC = self.buttonCol
        blankSize = self.blankSize

        self.toolLeftGridGroupBox = QGroupBox()
        layout = QGridLayout()

        # Foreground Background Unknown
        buttonGroup = MyButtonGroup(self, "Foreground&Background&Unknown")
        self.colorBox = QGroupBox()
        colorLayout = QVBoxLayout()
        foregroundRadio = MyColorButton(self, "Foreground")
        foregroundRadio.setIcon(QIcon("icon/icon_1.png"))
        foregroundRadio.setShortcut("1")
        colorLayout.addWidget(foregroundRadio)
        buttonGroup.addRadioButton(foregroundRadio, 0)

        backgroundRadio = MyColorButton(self, "Background")
        backgroundRadio.setIcon(QIcon("icon/icon_2.png"))
        backgroundRadio.setShortcut("2")
        colorLayout.addWidget(backgroundRadio)
        buttonGroup.addRadioButton(backgroundRadio, 1)

        unknownRadio = MyColorButton(self, "Unknown")
        unknownRadio.setIcon(QIcon("icon/icon_3.png"))
        unknownRadio.setShortcut("3")
        colorLayout.addWidget(unknownRadio)
        buttonGroup.addRadioButton(unknownRadio, 2)
        self.colorBox.setLayout(colorLayout)
        # ~~~~~

        buttonGroup2 = MyButtonGroup(self, "Pen&Filler")
        self.colorBox2 = QGroupBox()
        colorLayout = QVBoxLayout()
        penRadio = MyToolButton(self, "画笔 (Q)")
        penRadio.setIcon(QIcon("icons/brush.png"))
        penRadio.setShortcut("q")
        colorLayout.addWidget(penRadio)
        buttonGroup2.addRadioButton(penRadio, 0)

        fillerRadio = MyToolButton(self, "填充 (W)")
        fillerRadio.setIcon(QIcon("icons/filler.png"))
        fillerRadio.setShortcut("w")
        colorLayout.addWidget(fillerRadio)
        buttonGroup2.addRadioButton(fillerRadio, 1)
        self.colorBox2.setLayout(colorLayout)
        # ~~~~~
        # drawButtonGroup = MyButtonGroup(self, "Pen&Filler")
        # self.toolBox = QGroupBox()
        # colorLayout = QVBoxLayout()
        # penRadio = MyColorButton(self, "Pen")
        # foregroundRadio.setIcon(QIcon("icon/icon_1.png"))
        # colorLayout.addWidget(foregroundRadio)
        # buttonGroup.addRadioButton(foregroundRadio, 0)

        # fillerRadio = MyColorButton(self, "Filler")
        # backgroundRadio.setIcon(QIcon("icon/icon_2.png"))
        # colorLayout.addWidget(backgroundRadio)
        # buttonGroup.addRadioButton(backgroundRadio, 1)

        # pen
        penButton = MyPushButton(self, config.getText("Pen"), "Pen")
        penButton.setFixedSize(QSize(80, 40))
        # pen slider
        penSlider = MySlider(self, "PenSlider", Qt.Horizontal)
        self.setSlider(penSlider, "PenSlider")
        penSlider.setTickPosition(QSlider.TicksBothSides)
        lef, rig, typ = config.sliderConfig["PenSlider"]
        penSlider.setSliderType(lef, rig, type=typ)
        penSlider.setFixedSize(QSize(bx * 3 + config.defaultBlank * 2, by))
        self.setSlider(penSlider, "PenSlider")

        # filler
        fillerButton = MyPushButton(self, config.getText("Filler"), "Filler")
        fillerButton.setFixedSize(QSize(80, 40))
        # filler slider
        fillerSlider = MySlider(self, "FillerSlider", Qt.Horizontal)
        self.setSlider(fillerSlider, "FillerSlider")
        fillerSlider.setTickPosition(QSlider.TicksBothSides)
        lef, rig, typ = config.sliderConfig["FillerSlider"]
        fillerSlider.setSliderType(lef, rig, type=typ)
        fillerSlider.setFixedSize(QSize(bx * 3 + config.defaultBlank * 2, by))
        self.setSlider(fillerSlider, "FillerSlider")

        # clean trimap
        cleantrimapButton = MyPushButton(self,
                                         config.getText("SolveForeground"),
                                         "SolveForeground")
        cleantrimapButton.setIcon(QIcon("icons/clearscreen.png"))
        # cleanShortut = QShortcut(QKeySequence("Ctrl+C"), self)
        # cleanShortcut.activated.connect(self.clear)
        undoButton = MyPushButton(self, config.getText("Undo"), "Undo")
        undoButton.setIcon(QIcon("icons/undo.png"))
        # undoButton.setShortcut("Ctrl+Z")
        undoShortcut = QShortcut(QKeySequence("Ctrl+Z"), self)
        undoShortcut.activated.connect(self.undo)
        redoButton = MyPushButton(self, config.getText("Redo"), "Redo")
        redoButton.setIcon(QIcon("icons/redo.png"))
        # redoButton.setShortcut("Ctrl+Y")
        redoShortcut = QShortcut(QKeySequence("Ctrl+Y"), self)
        redoShortcut.activated.connect(self.redo)

        # cleantrimapButton.setFixedSize(QSize(80,40))

        fileUnknownButton = MyPushButton(self, config.getText("FillUnknown"),
                                         "FillUnknown")
        unknownUpButton = MyPushButton(self, config.getText("UnknownUp"),
                                       "UnknownUp")
        unknownDownButton = MyPushButton(self, config.getText("UnknownDown"),
                                         "UnknownDown")
        # fileUnknownButton.setFixedSize(QSize(self.width(),40))
        #fileUnknownButton.setFixedHeight(60)
        # unknownUpButton.setFixedHeight(40)
        # unknownUpButton.setFixedSize(QSize(self.width(),40))

        runButton = MyPushButton(self, config.getText("Run"), "Run")
        # runShortcut = QShortcut(QKeySequence("Ctrl+R"), self)
        # runShortcut.activated.connect(self.run)
        runButton.setFixedHeight(60)
        runButton.setStyleSheet("QPushButton{color:white;font-size:18px;}"
                                "QPushButton:hover{background-color:#05f}"
                                "QPushButton{background-color:#477be4}"
                                "QPushButton{border:2px}"
                                "QPushButton{border-radius:10px}"
                                "QPushButton{padding:2px 4px}")
        # runButton.setShortcut("Ctrl+R")
        penSlider.setStyleSheet("QSlider{padding:0px 0px}")
        layout.setSpacing(0)
        layout.addWidget(self.colorBox, 0, 0, 2, 1)
        layout.addWidget(self.colorBox2, 0, 1, 2, 1)

        # layout.addWidget(penButton, 0, 1)
        layout.addWidget(penSlider, 0, 2, 1, 4)
        # layout.addWidget(fillerButton, 1, 1)
        layout.addWidget(fillerSlider, 1, 2, 1, 4)
        layout.addWidget(cleantrimapButton, 2, 0)
        layout.addWidget(undoButton, 2, 1)
        layout.addWidget(redoButton, 2, 2)
        layout.addWidget(fileUnknownButton, 3, 0, 2, 1)
        layout.addWidget(unknownUpButton, 3, 1)
        layout.addWidget(unknownDownButton, 3, 2)
        layout.addWidget(runButton, 2, 4, 2, 2)
        self.toolLeftGridGroupBox.setLayout(layout)
Exemplo n.º 8
0
    def __init__(self, main_window, parent_script, config=None):
        super(Flow, self).__init__()

        # SHORTCUTS
        place_new_node_shortcut = QShortcut(QKeySequence('Shift+P'), self)
        place_new_node_shortcut.activated.connect(
            self.place_new_node_by_shortcut)
        move_selected_nodes_left_shortcut = QShortcut(
            QKeySequence('Shift+Left'), self)
        move_selected_nodes_left_shortcut.activated.connect(
            self.move_selected_nodes_left)
        move_selected_nodes_up_shortcut = QShortcut(QKeySequence('Shift+Up'),
                                                    self)
        move_selected_nodes_up_shortcut.activated.connect(
            self.move_selected_nodes_up)
        move_selected_nodes_right_shortcut = QShortcut(
            QKeySequence('Shift+Right'), self)
        move_selected_nodes_right_shortcut.activated.connect(
            self.move_selected_nodes_right)
        move_selected_nodes_down_shortcut = QShortcut(
            QKeySequence('Shift+Down'), self)
        move_selected_nodes_down_shortcut.activated.connect(
            self.move_selected_nodes_down)
        select_all_shortcut = QShortcut(QKeySequence('Ctrl+A'), self)
        select_all_shortcut.activated.connect(self.select_all)
        copy_shortcut = QShortcut(QKeySequence.Copy, self)
        copy_shortcut.activated.connect(self.copy)
        cut_shortcut = QShortcut(QKeySequence.Cut, self)
        cut_shortcut.activated.connect(self.cut)
        paste_shortcut = QShortcut(QKeySequence.Paste, self)
        paste_shortcut.activated.connect(self.paste)

        # UNDO/REDO
        self.undo_stack = QUndoStack(self)
        self.undo_action = self.undo_stack.createUndoAction(self, 'undo')
        self.undo_action.setShortcuts(QKeySequence.Undo)
        self.redo_action = self.undo_stack.createRedoAction(self, 'redo')
        self.redo_action.setShortcuts(QKeySequence.Redo)

        undo_shortcut = QShortcut(QKeySequence.Undo, self)
        undo_shortcut.activated.connect(self.undo_activated)
        redo_shortcut = QShortcut(QKeySequence.Redo, self)
        redo_shortcut.activated.connect(self.redo_activated)

        # GENERAL ATTRIBUTES
        self.parent_script = parent_script
        self.all_node_instances: [NodeInstance] = []
        self.all_node_instance_classes = main_window.all_node_instance_classes  # ref
        self.all_nodes = main_window.all_nodes  # ref
        self.gate_selected: PortInstanceGate = None
        self.dragging_connection = False
        self.ignore_mouse_event = False  # for stylus - see tablet event
        self.last_mouse_move_pos: QPointF = None
        self.node_place_pos = QPointF()
        self.left_mouse_pressed_in_flow = False
        self.mouse_press_pos: QPointF = None
        self.tablet_press_pos: QPointF = None
        self.auto_connection_gate = None  # stores the gate that we may try to auto connect to a newly placed NI
        self.panning = False
        self.pan_last_x = None
        self.pan_last_y = None
        self.current_scale = 1
        self.total_scale_div = 1

        # SETTINGS
        self.algorithm_mode = Flow_AlgorithmMode()
        self.viewport_update_mode = Flow_ViewportUpdateMode()

        # CREATE UI
        scene = QGraphicsScene(self)
        scene.setItemIndexMethod(QGraphicsScene.NoIndex)
        scene.setSceneRect(0, 0, 10 * self.width(), 10 * self.height())

        self.setScene(scene)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
        self.setRenderHint(QPainter.Antialiasing)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setDragMode(QGraphicsView.RubberBandDrag)
        scene.selectionChanged.connect(self.selection_changed)
        self.setAcceptDrops(True)

        self.centerOn(
            QPointF(self.viewport().width() / 2,
                    self.viewport().height() / 2))

        # NODE CHOICE WIDGET
        self.node_choice_proxy = FlowProxyWidget(self)
        self.node_choice_proxy.setZValue(1000)
        self.node_choice_widget = NodeChoiceWidget(
            self, main_window.all_nodes)  # , main_window.node_images)
        self.node_choice_proxy.setWidget(self.node_choice_widget)
        self.scene().addItem(self.node_choice_proxy)
        self.hide_node_choice_widget()

        # ZOOM WIDGET
        self.zoom_proxy = FlowProxyWidget(self)
        self.zoom_proxy.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
        self.zoom_proxy.setZValue(1001)
        self.zoom_widget = FlowZoomWidget(self)
        self.zoom_proxy.setWidget(self.zoom_widget)
        self.scene().addItem(self.zoom_proxy)
        self.set_zoom_proxy_pos()

        # STYLUS
        self.stylus_mode = ''
        self.current_drawing = None
        self.drawing = False
        self.drawings = []
        self.stylus_modes_proxy = FlowProxyWidget(self)
        self.stylus_modes_proxy.setFlag(
            QGraphicsItem.ItemIgnoresTransformations, True)
        self.stylus_modes_proxy.setZValue(1001)
        self.stylus_modes_widget = FlowStylusModesWidget(self)
        self.stylus_modes_proxy.setWidget(self.stylus_modes_widget)
        self.scene().addItem(self.stylus_modes_proxy)
        self.set_stylus_proxy_pos()
        self.setAttribute(Qt.WA_TabletTracking)

        # DESIGN THEME
        Design.flow_theme_changed.connect(self.theme_changed)

        if config:
            config: dict

            # algorithm mode
            if config.keys().__contains__('algorithm mode'):
                if config['algorithm mode'] == 'data flow':
                    self.parent_script.widget.ui.algorithm_data_flow_radioButton.setChecked(
                        True)
                    self.algorithm_mode.mode_data_flow = True
                else:  # 'exec flow'
                    self.parent_script.widget.ui.algorithm_exec_flow_radioButton.setChecked(
                        True)
                    self.algorithm_mode.mode_data_flow = False

            # viewport update mode
            if config.keys().__contains__('viewport update mode'):
                if config['viewport update mode'] == 'sync':
                    self.parent_script.widget.ui.viewport_update_mode_sync_radioButton.setChecked(
                        True)
                    self.viewport_update_mode.sync = True
                else:  # 'async'
                    self.parent_script.widget.ui.viewport_update_mode_async_radioButton.setChecked(
                        True)
                    self.viewport_update_mode.sync = False

            node_instances = self.place_nodes_from_config(config['nodes'])
            self.connect_nodes_from_config(node_instances,
                                           config['connections'])
            if list(config.keys()).__contains__(
                    'drawings'
            ):  # not all (old) project files have drawings arr
                self.place_drawings_from_config(config['drawings'])
            self.undo_stack.clear()
Exemplo n.º 9
0
    def __init__(self, config):
        super(MainWindow, self).__init__()

        QFontDatabase.addApplicationFont(
            'resources/fonts/poppins/Poppins-Medium.ttf')
        QFontDatabase.addApplicationFont(
            'resources/fonts/source code pro/SourceCodePro-Regular.ttf')

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.splitter.setSizes([120, 800])
        self.setWindowTitle('Ryven')
        self.setWindowIcon(QIcon('resources/pics/program_icon2.png'))
        self.load_stylesheet('dark')
        self.ui.scripts_tab_widget.removeTab(0)

        # menu actions
        self.flow_design_actions = []
        self.setup_menu_actions()

        # shortcuts
        save_shortcut = QShortcut(QKeySequence.Save, self)
        save_shortcut.activated.connect(self.on_save_project_triggered)
        import_nodes_shortcut = QShortcut(QKeySequence('Ctrl+i'), self)
        import_nodes_shortcut.activated.connect(self.on_import_nodes_triggered)

        # clear temp folder
        if not os.path.exists('temp'):
            os.mkdir('temp')
        for f in os.listdir('temp'):
            os.remove('temp/' + f)

        # GENERAL ATTRIBUTES
        self.scripts = []
        self.custom_nodes = []
        self.all_nodes = [
            SetVariable_Node(),
            GetVariable_Node(),
            Val_Node(),
            Result_Node()
        ]
        self.package_names = []

        #   holds NI subCLASSES for imported nodes:
        self.all_node_instance_classes = {
            self.all_nodes[0]: SetVar_NodeInstance,
            self.all_nodes[1]: GetVar_NodeInstance,
            self.all_nodes[2]: Val_NodeInstance,
            self.all_nodes[3]: Result_NodeInstance
        }  # (key: node obj, val: NI subclass) (used in Flow)

        #   custom subclasses for input widgets
        #   {node : {str: PortInstanceWidget-subclass}} (used in PortInstance)
        self.custom_node_input_widget_classes = {}

        # UI
        self.scripts_list_widget = ScriptsListWidget(self, self.scripts)
        self.ui.scripts_scrollArea.setWidget(self.scripts_list_widget)
        self.ui.add_new_script_pushButton.clicked.connect(
            self.create_new_script_button_pressed)
        self.ui.new_script_name_lineEdit.returnPressed.connect(
            self.create_new_script_LE_return_pressed)

        if config['config'] == 'create plain new project':
            self.try_to_create_new_script()
        elif config['config'] == 'open project':
            print('importing packages...')
            self.import_packages(config['required packages'])
            print('loading project...')
            self.parse_project(config['content'])
            print('finished')

        print('''
        CONTROLS
            placing nodes: right mouse
            selecting components: left mouse
            panning: middle mouse
            saving: ctrl+s
        ''')

        Design.set_flow_theme()
        Design.set_flow_theme()  # temporary
        #   the double call is just a temporary fix for an issue I will address in a future release.
        #   Problem: because the signal emitted when setting a flow theme is directly connected to the according slots
        #   in NodeInstance as well as NodeInstance_TitleLabel, the NodeInstance's slot (which starts an animation which
        #   uses the title label's current and theme dependent color) could get called before the title
        #   label's slot has been called to reinitialize this color. This results in wrong color end points for the
        #   title label when activating animations.
        #   This is pretty nasty since I cannot think of a nice fix for this issue other that not letting the slot
        #   methods be called directly from the emitted signal but instead through a defined procedure like before.

        # maybe this will be necessary due to scheduling issues when loading flows
        # for s in self.scripts:
        #     s.flow.viewport().update()

        self.resize(1500, 800)
Exemplo n.º 10
0
    def __init__(self, route=None):
        super().__init__()

        layout = QVBoxLayout()
        self.route = route

        self.thread_pool = QThreadPool()

        layout_send = QHBoxLayout()
        self.send_button = QPushButton('Send')
        self.send_button.clicked.connect(self.make_request)

        self.search_line = QLineEdit()
        self.search_line.setPlaceholderText('Search')
        self.search_line.textChanged.connect(self.search_result_reset)
        self.search_line.returnPressed.connect(self.search_result)

        self.response_status_label = QLabel()
        self.response_status_label.setFont(FONT_ROUTE)
        self.response_status_label.hide()

        self.elapsed_time_label = QLabel()
        self.elapsed_time_label.setFont(FONT_ROUTE)
        self.elapsed_time_label.hide()

        self.search_summary_label = QLabel()
        self.search_summary_label.setFont(FONT_ROUTE)
        self.search_summary_label.hide()

        if route is not None:
            layout_send.addWidget(self.send_button)

        layout_send.addWidget(self.response_status_label)
        layout_send.addWidget(self.elapsed_time_label)
        layout_send.addStretch(1)

        layout_send.addWidget(self.search_summary_label)
        layout_send.addWidget(self.search_line)

        layout.addLayout(layout_send)

        self.result_text_edit = ResultTextEdit()
        self.result_text_edit.setReadOnly(True)
        self.result_text_edit.setFont(TEXT_FONT)
        self.result_text_edit.setContextMenuPolicy(Qt.NoContextMenu)

        self.result_text_edit.search.connect(self.focus)

        self.shortcut = QShortcut(QKeySequence("Ctrl+Return"), self,
                                  self.make_request)

        self.result_text_edit.setUndoRedoEnabled(False)

        self.highlighter = TextHighlighter(self.result_text_edit.document())

        layout.addWidget(self.result_text_edit)

        if route is not None:
            saved_result = load_request_result(route)
            self.result_text_edit.setPlainText(saved_result)

        self.setLayout(layout)
Exemplo n.º 11
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Signals
        #self.ui.convert_btn.clicked.connect(self.onwin2lin)
        self.ui.copy_btn.clicked.connect(self.copy2clipboard)
        self.ui.open_btn.clicked.connect(self.open_path)
        self.ui.clear_btn.clicked.connect(self.clear_win_path)

        self.ui.converted_path_field.textChanged.connect(self.path_check)

        self.ui.prefix_box.currentTextChanged.connect(self.onwin2lin)
        self.ui.win_prefix_box.currentTextChanged.connect(self.set_win_prefix)

        self.ui.path_field.textChanged.connect(self.onwin2lin)
        self.ui.convert_space_box.clicked.connect(self.onwin2lin)

        self.ui.check_prefix_dict.clicked.connect(self.onwin2lin)

        self.ui.add_fav_btn.clicked.connect(self.add_fav)

        self.ui.fav_list_widget.itemDoubleClicked.connect(self.load_fav)

        # delete cmd from cmdlist
        QShortcut(QKeySequence(Qt.Key_Delete), self.ui.fav_list_widget,
                  self.delete_fav)

        # popultate prefix list
        self.ui.prefix_box.clear()
        self.ui.prefix_box.addItem("")

        # add home to prefix list
        self.home = pathlib.Path.home()
        self.ui.prefix_box.addItem(str(self.home))

        # add custom prefix_list from config
        for i in config.prefix_list:
            self.ui.prefix_box.addItem(i)

        # add win prefix list from config
        for i in config.prefix_dict.keys():
            self.ui.win_prefix_box.addItem(i)

        # set config checkboxes
        if config.prefix_dict_checkbox_state == True:
            self.ui.check_prefix_dict.setChecked(True)
        else:
            self.ui.check_prefix_dict.setChecked(False)

        if config.replace_spaces_checkbox_state == True:
            self.ui.convert_space_box.setChecked(True)
        else:
            self.ui.convert_space_box.setChecked(False)

        # create favorite list
        self.favlist = []

        # read favorite file
        self.read_fav_file()

        # start
        self.win2lin()
Exemplo n.º 12
0
    def __init__(self, config):
        super(MainWindow, self).__init__()

        QFontDatabase.addApplicationFont('fonts/poppins/Poppins-Medium.ttf')
        QFontDatabase.addApplicationFont(
            'fonts/source code pro/SourceCodePro-Regular.ttf')

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.splitter.setSizes([120, 800])
        self.setWindowTitle('pyScript')
        self.setWindowIcon(QIcon('stuff/pics/program_icon.png'))
        self.load_stylesheet('dark')
        self.ui.scripts_tab_widget.removeTab(0)
        self.ui.actionImport_Nodes.triggered.connect(
            self.on_import_nodes_triggered)
        self.ui.actionSave_Project.triggered.connect(
            self.on_save_project_triggered)
        self.ui.actionDesignDark_Std.triggered.connect(
            self.on_dark_std_design_triggered)
        self.ui.actionDesignDark_Tron.triggered.connect(
            self.on_dark_tron_design_triggered)
        self.ui.actionEnableDebugging.triggered.connect(
            self.on_enable_debugging_triggered)
        self.ui.actionDisableDebugging.triggered.connect(
            self.on_disable_debugging_triggered)
        self.ui.actionSave_Pic_Viewport.triggered.connect(
            self.on_save_scene_pic_viewport_triggered)
        self.ui.actionSave_Pic_Whole_Scene_scaled.triggered.connect(
            self.on_save_scene_pic_whole_triggered)

        # Shortcuts
        save_shortcut = QShortcut(QKeySequence.Save, self)
        save_shortcut.activated.connect(self.on_save_project_triggered)

        self.custom_nodes = []
        self.all_nodes = [SetVariable_Node(), GetVariable_Node()]

        # holds NI subCLASSES for imported nodes:
        self.all_node_instance_classes = {
            self.all_nodes[0]: SetVar_NodeInstance,
            self.all_nodes[1]: GetVar_NodeInstance
        }  # (key: node obj, val: NI subclass) (used in Flow)

        self.custom_node_input_widget_classes = {
        }  # {node : {str: PortInstanceWidget-subclass}} (used in PortInstance)

        # self.node_images = {
        #     self.all_nodes[0]: self.get_node_image(self.all_nodes[0]),
        #     self.all_nodes[1]: self.get_node_image(self.all_nodes[1])
        # }  # {node: QImage}

        # clear temp folder
        for f in os.listdir('temp'):
            os.remove('temp/' + f)

        self.scripts = []
        self.scripts_list_widget = ScriptsListWidget(self, self.scripts)
        self.ui.scripts_scrollArea.setWidget(self.scripts_list_widget)
        self.ui.add_new_script_pushButton.clicked.connect(
            self.create_new_script_button_pressed)
        self.ui.new_script_name_lineEdit.returnPressed.connect(
            self.create_new_script_le_return_pressed)

        self.design_style = 'dark std'

        if config['config'] == 'create plain new project':
            self.try_to_create_new_script()
        elif config['config'] == 'open project':
            self.import_required_packages(config['required packages'])
            self.parse_project(config['content'])

        self.resize(1500, 800)
Exemplo n.º 13
0
    def __init__(self, ui_demo=False):
        super(MainWindow, self).__init__()
        self.setupUi(self)
        self.grid_layout = QGridLayout()

        self.btnDetectClient.clicked.connect(self.detectClients)
        self.lineEditIpRange.returnPressed.connect(self.detectClients)
        self.btnSelectAllClients.clicked.connect(self.selectAllCLients)

        shortcut = QShortcut(QKeySequence(self.tr("Ctrl+A")), self)
        shortcut.activated.connect(self.selectAllCLients)

        self.btnUnselectClients.clicked.connect(self.unselectAllCLients)
        self.btnSelectExam.clicked.connect(self.selectExamByWizard)
        self.btnSelectExam.setEnabled(True)

        self.btnPrepareExam.clicked.connect(self.prepareExam)
        self.btnPrepareExam.setEnabled(False)

        self.btnGetExams.clicked.connect(self.retrieveExamFilesByWizard)
        self.btnGetExams.setEnabled(True)
        self.btnSaveExamLog.clicked.connect(self.saveExamLog)
        # self.btnSaveExamLog.setEnabled(False)

        self.actionBearbeiten.triggered.connect(self.openConfigDialog)
        self.actionAlle_Benutzer_benachrichtigen.triggered.connect(
            self.sendMessage)
        self.actionAlle_Clients_zur_cksetzen.triggered.connect(
            self.resetClients)
        self.actionAlle_Clients_rebooten.triggered.connect(
            self.rebootAllClients)
        self.actionAlle_Clients_herunterfahren.triggered.connect(
            self.shutdownAllClients)
        self.actionOnlineHelp.triggered.connect(self.openHelpUrl)
        self.actionOfflineHelp.triggered.connect(self.openHelpUrlOffline)
        self.actionSortClientByCandidateName.triggered.connect(
            self.sortButtonsByCandidateName)
        self.actionSortClientByComputerName.triggered.connect(
            self.sortButtonsByComputerName)
        self.actionVersionInfo.triggered.connect(self.showVersionInfo)
        self.actionDisplayIPs.triggered.connect(self.toggleClientIpDisplay)

        self.btnApplyCandidateNames.clicked.connect(self.applyCandidateNames)
        self.btnNameClients.clicked.connect(self.activateNameTab)

        self.btnBlockUsb.clicked.connect(self.blockUsb)
        self.btnBlockWebAccess.clicked.connect(self.blockWebAccess)

        self.appTitle = 'ECMan - Exam Client Manager'
        self.setWindowTitle(self.appTitle)

        self.logger = Logger(self.textEditLog)

        self.lb_directory = None
        self.advancedUi = False
        self.configure()
        self.show()
        if ui_demo is False:
            self.detectClients()

        else:
            self.clientFrame.setLayout(self.grid_layout)
            for i in range(6):
                self.addTestClient(i + 100)

        self.statusBar = QStatusBar()
        self.setStatusBar(self.statusBar)
Exemplo n.º 14
0
    def __init__(self):
        super().__init__()
        self.setAttribute(
            Qt.WA_DeleteOnClose
        )  # let Qt delete stuff before the python garbage-collector gets to work
        self.repo = None
        self.branches_model = None

        # instantiate main window
        self.ui = ui.Ui_MainWindow()
        self.ui.setupUi(self)

        self.fs_watch = QFileSystemWatcher(self)
        self.fs_watch.fileChanged.connect(self.on_file_changed)
        self.fs_watch.directoryChanged.connect(self.on_dir_changed)

        self.settings = QSettings(QSettings.IniFormat, QSettings.UserScope,
                                  'pqgit', 'config')

        # for comparison
        self.new_c_id, self.old_c_id = None, None

        # window icon
        cwd = os.path.dirname(os.path.realpath(__file__))
        self.setWindowIcon(QIcon(os.path.join(cwd, 'Git-Icon-White.png')))
        self.setWindowTitle('pqgit')

        # size and position
        self.move(self.settings.value('w/pos', QPoint(200, 200)))
        self.resize(self.settings.value('w/size', QSize(1000, 1000)))
        self.ui.hist_splitter.setSizes([
            int(s) for s in self.settings.value('w/hist_splitter', [720, 360])
        ])
        self.ui.cinf_splitter.setSizes([
            int(s) for s in self.settings.value('w/cinf_splitter', [360, 360])
        ])
        self.ui.diff_splitter.setSizes([
            int(s)
            for s in self.settings.value('w/diff_splitter', [150, 1200, 230])
        ])

        # open repo dir
        open_shortcut = QShortcut(QKeySequence('Ctrl+O'), self)
        open_shortcut.activated.connect(self.open_dir)

        # set-up ui
        self.branches_model = BranchesModel()
        self.ui.tvBranches.setModel(self.branches_model)
        self.ui.tvBranches.selectionModel().selectionChanged.connect(
            self.branches_selection_changed)
        self.ui.tvBranches.resizeColumnsToContents()

        self.history_model = HistoryModel()
        self.ui.tvHistory.setModel(self.history_model)
        self.ui.tvHistory.selectionModel().selectionChanged.connect(
            self.history_selection_changed)

        self.files_model = FilesModel()
        self.ui.tvFiles.setModel(self.files_model)
        self.ui.tvFiles.selectionModel().selectionChanged.connect(
            self.files_selection_changed)

        self.ui.tvFiles.doubleClicked.connect(self.on_file_doubleclicked)

        for view in (self.ui.tvBranches, self.ui.tvHistory, self.ui.tvFiles):
            view.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.Stretch)
            view.setSelectionBehavior(QAbstractItemView.SelectRows)
            view.setShowGrid(False)
            view.verticalHeader().setDefaultSectionSize(
                QApplication.font().pointSize() + 2)
            view.verticalHeader().hide()

        self.ui.teDiff.setFont(QFont('Monospace'))

        self.difftools = []

        timer = QTimer(self)
        timer.timeout.connect(self.on_timer)
        timer.start(5000)

        self.dir_name = self.settings.value('last_opened_repo', None)

        try:
            pygit2.Repository(self.dir_name)
        except Exception:  #pylint: disable=broad-except
            self.open_dir()
            return

        self.open_repo()
Exemplo n.º 15
0
    def __init__(self, parent=None):
        super(CmdLib, self).__init__(parent)

        # open ui file directly
        ui_file = QFile('mainwindow.ui')
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        self.window = loader.load(ui_file)
        ui_file.close()

        # app name and version
        self.appname = "CmdLib"
        self.version = "0.1"

        # set fixed window size
        #self.window.setFixedSize(self.window.size())

        # set title and center window
        self.window.setWindowTitle(self.appname)
        self.center_window()

        # print available styles
        print(QStyleFactory.keys())

        ##### SIGNALS

        # run command
        self.window.button_run_term.clicked.connect(self.run_cmd_term)

        # load cmd
        #self.window.cmd_list.clicked.connect(self.load_cmd)
        self.window.cmd_list.itemSelectionChanged.connect(self.load_cmd)
        #self.window.cmd_list.currentRowChanged.connect(self.load_cmd)

        # add cmd to list
        self.window.button_to_list.clicked.connect(self.save_cmd)

        # delete cmd
        self.window.button_delete_cmd.clicked.connect(self.delete_cmd)

        # multi cmd mode
        self.window.multicmd_mode.clicked.connect(self.multicmd_mode)

        # is script mode
        self.window.check_script.clicked.connect(self.is_script)

        # search
        self.window.search_box.currentTextChanged.connect(self.search_cmds)

        # workdir
        self.window.set_workdir.clicked.connect(self.set_workdir)
        self.window.open_workdir.clicked.connect(self.open_workdir)
        self.window.workdir_line.editingFinished.connect(self.check_workdir)

        # show help from helpbox
        self.window.show_helpbox.clicked.connect(self.show_help)

        # new cmd
        self.window.new_button.clicked.connect(self.new_cmd)
        # copy cmd
        self.window.copy_button.clicked.connect(self.copy2clipboard)
        # add file name
        self.window.addfile_button.clicked.connect(self.on_insert_file_name)
        # open file
        self.window.openfile_button.clicked.connect(self.on_open_file_button)

        # if cmd selection is changed
        self.window.cmd_field.selectionChanged.connect(
            self.set_open_file_button)

        # check name
        self.window.name_field.textChanged.connect(self.check_name)
        # check command
        self.window.cmd_field.textChanged.connect(self.check_command)

        # DROP signal!!
        self.window.cmd_list.model().rowsMoved.connect(self.reorder_cmds)

        # menu/actions
        self.window.actionBackupLib.triggered.connect(self.backup)
        self.window.actionExportLib.triggered.connect(self.exportlib)
        self.window.actionImportLib.triggered.connect(self.importlib)

        self.window.actionInsert_File_Name.triggered.connect(
            self.on_insert_file_name)
        self.window.actionInsert_File_Path.triggered.connect(
            self.on_insert_file_path)
        self.window.actionExport2Script.triggered.connect(self.export2script)

        self.window.actionGet_File_Name.triggered.connect(
            self.on_copy_file_name)
        self.window.actionGet_File_Path.triggered.connect(
            self.on_copy_file_path)
        self.window.actionOpen_Scripts_Folder.triggered.connect(
            self.open_scriptsdir)
        self.window.actionOpen_File.triggered.connect(self.open_file)
        self.window.actionOpen_Script.triggered.connect(self.open_script)

        self.window.actionAbout.triggered.connect(self.on_about)

        # extra shortcuts
        # delete cmd from cmdlist
        QShortcut(QKeySequence(Qt.Key_Delete), self.window.cmd_list,
                  self.delete_cmd)

        # save cmd
        QShortcut(QKeySequence("Ctrl+S"), self.window, self.on_save_cmd)

        # new cmd
        QShortcut(QKeySequence("Ctrl+N"), self.window, self.new_cmd)

        # new cmd
        QShortcut(QKeySequence("Ctrl+H"), self.window, self.show_help)

        # run in term
        QShortcut(QKeySequence("Ctrl+Return"), self.window, self.run_cmd_term)

        # focus on search
        QShortcut(QKeySequence("Ctrl+F"), self.window, self.focus_search)

        # focus on lib
        QShortcut(QKeySequence("Ctrl+L"), self.window, self.focus_lib)
        QShortcut(QKeySequence(Qt.Key_Tab), self.window, self.focus_lib)

        # trigger when quitting
        app.aboutToQuit.connect(self.on_quit)

        # update cmd list
        self.update_cmd_list()

        # select first cmd
        self.window.cmd_list.setCurrentRow(0)

        # load init command
        self.load_cmd()

        # set search box to All
        self.window.search_box.setCurrentIndex(0)

        #set focus on search box
        self.focus_search()

        # if provided, set first argument to workdir
        self.set_workdir_with_arg()

        # make start backup
        self.df.to_csv("./backups/cmds.csv", index=False)

        # show main window
        self.window.show()
Exemplo n.º 16
0
    def initUI(self):

        # Master layout
        self.win = QWidget()
        L_master = QGridLayout(self.win)

        # Left subwindow, for widgets
        win_left = QWidget(self.win)
        L_left = QGridLayout(win_left)
        L_master.addWidget(win_left, 0, 0, 1, 3)

        # Right subwindow, for images
        win_right = QWidget(self.win)
        L_right = QGridLayout(win_right)
        L_master.addWidget(win_right, 0, 3, 1, 1)

        # Add four LabeledImageViews to this window
        liv_labels = ['(1) Raw', '(2) Filtered', '(3) Convolved', '(4) Binary']
        self.LIVs = [LabeledImageView(parent=win_left, label=liv_labels[j]) \
            for j in range(4)]
        for j in range(4):
            L_left.addWidget(self.LIVs[j], j % 2, j // 2)
            self.LIVs[j].setImage(self.images[j])

        # Link the views between the ImageViews
        for j in range(1, 4):
            self.LIVs[j].ImageView.view.setXLink(self.LIVs[0].ImageView.view)
            self.LIVs[j].ImageView.view.setYLink(self.LIVs[0].ImageView.view)

        # Set up three ScatterPlotItems for each of the first three ImageViews,
        # for overlaying detections as symbols
        self.SPIs = [ScatterPlotItem() for j in range(3)]
        for i in range(3):
            self.SPIs[i].setParentItem(self.LIVs[i].ImageView.imageItem)

        ## WIDGETS

        widget_align = Qt.AlignTop
        slider_min_width = 125

        # Frame slider
        self.frame_slider = IntSlider(minimum=self.start_frame,
                                      maximum=self.stop_frame,
                                      interval=1,
                                      name='Frame',
                                      init_value=0,
                                      min_width=slider_min_width,
                                      parent=win_right)
        L_right.addWidget(self.frame_slider, 0, 0, alignment=widget_align)
        self.frame_slider.assign_callback(self.frame_slider_callback)

        # Select filtering method
        filter_methods = keys_to_str(FILTER_SLIDER_CONFIG.keys())
        self.M_filter = LabeledQComboBox(filter_methods,
                                         "Filter method",
                                         init_value="identity",
                                         parent=win_right)
        L_right.addWidget(self.M_filter, 1, 0, alignment=widget_align)
        self.M_filter.assign_callback(self.M_filter_callback)

        # Select filtering chunk size
        chunk_size_choices = [
            str(i) for i in [2, 5, 10, 15, 20, 30, 40, 60, 80, 100, 200]
        ]
        self.M_chunk_size = LabeledQComboBox(chunk_size_choices, "Chunk size")
        L_right.addWidget(self.M_chunk_size, 2, 0, alignment=widget_align)
        self.M_chunk_size.assign_callback(self.M_chunk_size_callback)
        self.M_chunk_size.setCurrentText(str(self.ChunkFilter.chunk_size))

        # Three semantically-flexible filtering FloatSliders
        self.filter_sliders = [
            FloatSlider(parent=win_right, min_width=slider_min_width)
            for j in range(3)
        ]
        for i in range(len(self.filter_sliders)):
            L_right.addWidget(self.filter_sliders[i],
                              i + 3,
                              0,
                              alignment=widget_align)
            self.filter_sliders[i].assign_callback(
                getattr(self, "filter_slider_%d_callback" % i))
            self.filter_sliders[i].hide()

        # Button to change ROI
        self.B_change_roi = QPushButton("Change ROI", win_right)
        L_right.addWidget(self.B_change_roi, 6, 0, alignment=widget_align)
        self.B_change_roi.clicked.connect(self.B_change_roi_callback)

        # Button to change frame range
        self.B_change_frame_range = QPushButton("Change frame range",
                                                win_right)
        L_right.addWidget(self.B_change_frame_range,
                          7,
                          0,
                          alignment=widget_align)
        self.B_change_frame_range.clicked.connect(
            self.B_change_frame_range_callback)

        # Select detection method
        detect_methods = keys_to_str(DETECT_SLIDER_CONFIG.keys())
        self.M_detect = LabeledQComboBox(detect_methods,
                                         "Detect method",
                                         init_value="llr",
                                         parent=win_right)
        L_right.addWidget(self.M_detect, 0, 1, alignment=widget_align)

        # Set the initial detection method and arguments
        init_detect_method = 'llr'
        self.M_detect.setCurrentText(init_detect_method)
        self.detect_kwargs = {DETECT_SLIDER_CONFIG[init_detect_method][i]['name']: \
            DETECT_SLIDER_CONFIG[init_detect_method][i]['init_value'] \
                for i in DETECT_SLIDER_CONFIG[init_detect_method].keys()}
        self.detect_kwargs['method'] = init_detect_method
        self.M_detect.assign_callback(self.M_detect_callback)

        # Four semantically-flexible detection FloatSliders
        self.detect_sliders = [
            FloatSlider(parent=win_right, min_width=slider_min_width)
            for j in range(4)
        ]
        for i in range(len(self.detect_sliders)):
            L_right.addWidget(self.detect_sliders[i],
                              i + 1,
                              1,
                              alignment=widget_align)
            self.detect_sliders[i].assign_callback(
                getattr(self, "detect_slider_%d_callback" % i))

        # Autoscale the detection threshold
        self.B_auto_threshold = QPushButton("Rescale threshold",
                                            parent=win_right)
        L_right.addWidget(self.B_auto_threshold, 6, 1, alignment=widget_align)
        self.B_auto_threshold.clicked.connect(self.B_auto_threshold_callback)

        # Overlay detections as symbols
        self.B_spot_overlay_state = False
        self.B_spot_overlay = QPushButton("Overlay detections",
                                          parent=win_right)
        L_right.addWidget(self.B_spot_overlay, 7, 1, alignment=widget_align)
        self.B_spot_overlay.clicked.connect(self.B_spot_overlay_callback)

        # Change the symbol used for spot overlays
        symbol_choices = ['+', 'o', 'open +']
        self.M_symbol = LabeledQComboBox(symbol_choices,
                                         "Spot symbol",
                                         init_value='o',
                                         parent=win_right)
        L_right.addWidget(self.M_symbol, 5, 1, alignment=widget_align)
        self.M_symbol.assign_callback(self.M_symbol_callback)

        # Save result to file
        self.B_save = QPushButton("Save settings", parent=win_right)
        L_right.addWidget(self.B_save, 8, 1, alignment=widget_align)
        self.B_save.clicked.connect(self.B_save_callback)

        # Show individual spots
        self.B_show_spots = QPushButton("Show individual spots",
                                        parent=win_right)
        L_right.addWidget(self.B_show_spots, 9, 1, alignment=widget_align)
        self.B_show_spots.clicked.connect(self.B_show_spots_callback)

        ## EMPTY WIDGETS
        for j in range(8, 24):
            _ql = QLabel(win_right)
            L_right.addWidget(_ql, j, 0, alignment=widget_align)

        ## KEYBOARD SHORTCUTS - tab right/left through frames
        self.left_shortcut = QShortcut(QKeySequence(QtGui_Qt.Key_Left),
                                       self.win)
        self.right_shortcut = QShortcut(QKeySequence(QtGui_Qt.Key_Right),
                                        self.win)
        self.left_shortcut.activated.connect(self.tab_prev_frame)
        self.right_shortcut.activated.connect(self.tab_next_frame)

        ## INITIALIZATION
        self.change_detect_method(init_detect_method)
        self.filter()
        self.detect()
        self.auto_threshold()
        self.update_images(1,
                           2,
                           3,
                           autoRange=True,
                           autoLevels=True,
                           autoHistogramRange=True)

        # Resize GUI
        self.win.resize(self.gui_width, self.gui_height)

        # Show the main window
        self.win.show()
Exemplo n.º 17
0
# Main
if __name__ == "__main__":
	app = QApplication(sys.argv)

	# Main Window
	main_window = MainWindow()
	# main_window.resize(300, 300)
	main_window.setWindowTitle("UI From Variables")

	# Vertical Box
	layout = QVBoxLayout()
	layout.setAlignment(Qt.AlignTop)
	layout.setMargin(0)
	
	# Panels
	for i in range(1):
		panel = Panel(f"Panel {i + 1}", code)
		layout.addWidget(panel)

	main_window.setLayout(layout)

	# Stylesheet
	with open(assets.stylesheets["default"], "r") as stylesheet:
		main_window.setStyleSheet(stylesheet.read())
	
	main_window.show()

	# Shortcuts
	QShortcut(QKeySequence("Ctrl+Q"), main_window, main_window.close)

	sys.exit(app.exec_())
Exemplo n.º 18
0
 def __init__(self, parent: QWidget = None):
     super().__init__(parent)
     self.closeTabShortcut = QShortcut(QKeySequence("Ctrl+W"), self, self.closeCurrentTab)
Exemplo n.º 19
0
    def __init__(self, path_to_rom=""):
        super(MainWindow, self).__init__()

        self.setWindowIcon(icon("foundry.ico"))

        file_menu = QMenu("File")

        open_rom_action = file_menu.addAction("&Open ROM")
        open_rom_action.triggered.connect(self.on_open_rom)
        self.open_m3l_action = file_menu.addAction("&Open M3L")
        self.open_m3l_action.triggered.connect(self.on_open_m3l)

        file_menu.addSeparator()

        self.save_rom_action = file_menu.addAction("&Save ROM")
        self.save_rom_action.triggered.connect(self.on_save_rom)
        self.save_rom_as_action = file_menu.addAction("&Save ROM as ...")
        self.save_rom_as_action.triggered.connect(self.on_save_rom_as)
        """
        file_menu.AppendSeparator()
        """
        self.save_m3l_action = file_menu.addAction("&Save M3L")
        self.save_m3l_action.triggered.connect(self.on_save_m3l)
        """
        file_menu.Append(ID_SAVE_LEVEL_TO, "&Save Level to", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_APPLY_IPS_PATCH, "&Apply IPS Patch", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_ROM_PRESET, "&ROM Preset", "")
        """
        file_menu.addSeparator()
        settings_action = file_menu.addAction("&Settings")
        settings_action.triggered.connect(show_settings)
        file_menu.addSeparator()
        exit_action = file_menu.addAction("&Exit")
        exit_action.triggered.connect(lambda _: self.close())

        self.menuBar().addMenu(file_menu)
        """
        edit_menu = wx.Menu()

        edit_menu.Append(ID_EDIT_LEVEL, "&Edit Level", "")
        edit_menu.Append(ID_EDIT_OBJ_DEFS, "&Edit Object Definitions", "")
        edit_menu.Append(ID_EDIT_PALETTE, "&Edit Palette", "")
        edit_menu.Append(ID_EDIT_GRAPHICS, "&Edit Graphics", "")
        edit_menu.Append(ID_EDIT_MISC, "&Edit Miscellaneous", "")
        edit_menu.AppendSeparator()
        edit_menu.Append(ID_FREE_FORM_MODE, "&Free form Mode", "")
        edit_menu.Append(ID_LIMIT_SIZE, "&Limit Size", "")
        """

        self.level_menu = QMenu("Level")

        self.select_level_action = self.level_menu.addAction("&Select Level")
        self.select_level_action.triggered.connect(self.open_level_selector)

        self.reload_action = self.level_menu.addAction("&Reload Level")
        self.reload_action.triggered.connect(self.reload_level)
        self.level_menu.addSeparator()
        self.edit_header_action = self.level_menu.addAction("&Edit Header")
        self.edit_header_action.triggered.connect(self.on_header_editor)
        self.edit_autoscroll = self.level_menu.addAction("Edit Autoscrolling")
        self.edit_autoscroll.triggered.connect(self.on_edit_autoscroll)

        self.menuBar().addMenu(self.level_menu)

        self.object_menu = QMenu("Objects")

        view_blocks_action = self.object_menu.addAction("&View Blocks")
        view_blocks_action.triggered.connect(self.on_block_viewer)
        view_objects_action = self.object_menu.addAction("&View Objects")
        view_objects_action.triggered.connect(self.on_object_viewer)
        self.object_menu.addSeparator()
        view_palettes_action = self.object_menu.addAction(
            "View Object Palettes")
        view_palettes_action.triggered.connect(self.on_palette_viewer)

        self.menuBar().addMenu(self.object_menu)

        self.view_menu = QMenu("View")
        self.view_menu.triggered.connect(self.on_menu)

        action = self.view_menu.addAction("Mario")
        action.setProperty(ID_PROP, ID_MARIO)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_mario"])

        action = self.view_menu.addAction("&Jumps on objects")
        action.setProperty(ID_PROP, ID_JUMP_OBJECTS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jump_on_objects"])

        action = self.view_menu.addAction("Items in blocks")
        action.setProperty(ID_PROP, ID_ITEM_BLOCKS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_items_in_blocks"])

        action = self.view_menu.addAction("Invisible items")
        action.setProperty(ID_PROP, ID_INVISIBLE_ITEMS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_invisible_items"])

        action = self.view_menu.addAction("Autoscroll Path")
        action.setProperty(ID_PROP, ID_AUTOSCROLL)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_autoscroll"])

        self.view_menu.addSeparator()

        action = self.view_menu.addAction("Jump Zones")
        action.setProperty(ID_PROP, ID_JUMPS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jumps"])

        action = self.view_menu.addAction("&Grid lines")
        action.setProperty(ID_PROP, ID_GRID_LINES)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_grid"])

        action = self.view_menu.addAction("Resize Type")
        action.setProperty(ID_PROP, ID_RESIZE_TYPE)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_expansion"])

        self.view_menu.addSeparator()

        action = self.view_menu.addAction("&Block Transparency")
        action.setProperty(ID_PROP, ID_TRANSPARENCY)
        action.setCheckable(True)
        action.setChecked(SETTINGS["block_transparency"])

        self.view_menu.addSeparator()
        self.view_menu.addAction(
            "&Save Screenshot of Level").triggered.connect(self.on_screenshot)
        """
        self.view_menu.Append(ID_BACKGROUND_FLOOR, "&Background & Floor", "")
        self.view_menu.Append(ID_TOOLBAR, "&Toolbar", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_ZOOM, "&Zoom", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_USE_ROM_GRAPHICS, "&Use ROM Graphics", "")
        self.view_menu.Append(ID_PALETTE, "&Palette", "")
        self.view_menu.AppendSeparator()
        self.view_menu.Append(ID_MORE, "&More", "")
        """

        self.menuBar().addMenu(self.view_menu)

        help_menu = QMenu("Help")
        """
        help_menu.Append(ID_ENEMY_COMPATIBILITY, "&Enemy Compatibility", "")
        help_menu.Append(ID_TROUBLESHOOTING, "&Troubleshooting", "")
        help_menu.AppendSeparator()
        help_menu.Append(ID_PROGRAM_WEBSITE, "&Program Website", "")
        help_menu.Append(ID_MAKE_A_DONATION, "&Make a Donation", "")
        help_menu.AppendSeparator()
        """
        update_action = help_menu.addAction("Check for updates")
        update_action.triggered.connect(self.on_check_for_update)

        help_menu.addSeparator()

        video_action = help_menu.addAction("Feature Video on YouTube")
        video_action.triggered.connect(lambda: open_url(feature_video_link))

        github_action = help_menu.addAction("Github Repository")
        github_action.triggered.connect(lambda: open_url(github_link))

        discord_action = help_menu.addAction("SMB3 Rom Hacking Discord")
        discord_action.triggered.connect(lambda: open_url(discord_link))

        help_menu.addSeparator()

        about_action = help_menu.addAction("&About")
        about_action.triggered.connect(self.on_about)

        self.menuBar().addMenu(help_menu)

        self.block_viewer = None
        self.object_viewer = None

        self.level_ref = LevelRef()
        self.level_ref.data_changed.connect(self._on_level_data_changed)

        self.context_menu = ContextMenu(self.level_ref)
        self.context_menu.triggered.connect(self.on_menu)

        self.level_view = LevelView(self, self.level_ref, self.context_menu)

        self.scroll_panel = QScrollArea()
        self.scroll_panel.setWidgetResizable(True)
        self.scroll_panel.setWidget(self.level_view)

        self.setCentralWidget(self.scroll_panel)

        self.spinner_panel = SpinnerPanel(self, self.level_ref)
        self.spinner_panel.zoom_in_triggered.connect(self.level_view.zoom_in)
        self.spinner_panel.zoom_out_triggered.connect(self.level_view.zoom_out)
        self.spinner_panel.object_change.connect(self.on_spin)

        self.object_list = ObjectList(self, self.level_ref, self.context_menu)

        self.object_dropdown = ObjectDropdown(self)
        self.object_dropdown.object_selected.connect(
            self._on_placeable_object_selected)

        self.level_size_bar = LevelSizeBar(self, self.level_ref)
        self.enemy_size_bar = EnemySizeBar(self, self.level_ref)

        self.jump_list = JumpList(self, self.level_ref)
        self.jump_list.add_jump.connect(self.on_jump_added)
        self.jump_list.edit_jump.connect(self.on_jump_edit)
        self.jump_list.remove_jump.connect(self.on_jump_removed)

        splitter = QSplitter(self)
        splitter.setOrientation(Qt.Vertical)

        splitter.addWidget(self.object_list)
        splitter.setStretchFactor(0, 1)
        splitter.addWidget(self.jump_list)

        splitter.setChildrenCollapsible(False)

        level_toolbar = QToolBar("Level Info Toolbar", self)
        level_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        level_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        level_toolbar.setOrientation(Qt.Horizontal)
        level_toolbar.setFloatable(False)

        level_toolbar.addWidget(self.spinner_panel)
        level_toolbar.addWidget(self.object_dropdown)
        level_toolbar.addWidget(self.level_size_bar)
        level_toolbar.addWidget(self.enemy_size_bar)
        level_toolbar.addWidget(splitter)

        level_toolbar.setAllowedAreas(Qt.LeftToolBarArea | Qt.RightToolBarArea)

        self.addToolBar(Qt.RightToolBarArea, level_toolbar)

        self.object_toolbar = ObjectToolBar(self)
        self.object_toolbar.object_selected.connect(
            self._on_placeable_object_selected)

        object_toolbar = QToolBar("Object Toolbar", self)
        object_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        object_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        object_toolbar.setFloatable(False)

        object_toolbar.addWidget(self.object_toolbar)
        object_toolbar.setAllowedAreas(Qt.LeftToolBarArea
                                       | Qt.RightToolBarArea)

        self.addToolBar(Qt.LeftToolBarArea, object_toolbar)

        self.menu_toolbar = QToolBar("Menu Toolbar", self)
        self.menu_toolbar.setOrientation(Qt.Horizontal)
        self.menu_toolbar.setIconSize(QSize(20, 20))

        self.menu_toolbar.addAction(
            icon("settings.svg"),
            "Editor Settings").triggered.connect(show_settings)
        self.menu_toolbar.addSeparator()
        self.menu_toolbar.addAction(
            icon("folder.svg"), "Open ROM").triggered.connect(self.on_open_rom)
        self.menu_toolbar.addAction(
            icon("save.svg"), "Save Level").triggered.connect(self.on_save_rom)
        self.menu_toolbar.addSeparator()

        self.undo_action = self.menu_toolbar.addAction(icon("rotate-ccw.svg"),
                                                       "Undo Action")
        self.undo_action.triggered.connect(self.level_ref.undo)
        self.undo_action.setEnabled(False)
        self.redo_action = self.menu_toolbar.addAction(icon("rotate-cw.svg"),
                                                       "Redo Action")
        self.redo_action.triggered.connect(self.level_ref.redo)
        self.redo_action.setEnabled(False)

        self.menu_toolbar.addSeparator()
        play_action = self.menu_toolbar.addAction(icon("play-circle.svg"),
                                                  "Play Level")
        play_action.triggered.connect(self.on_play)
        play_action.setWhatsThis(
            "Opens an emulator with the current Level set to 1-1.\nSee Settings."
        )
        self.menu_toolbar.addSeparator()
        self.menu_toolbar.addAction(icon("zoom-out.svg"),
                                    "Zoom Out").triggered.connect(
                                        self.level_view.zoom_out)
        self.menu_toolbar.addAction(icon("zoom-in.svg"),
                                    "Zoom In").triggered.connect(
                                        self.level_view.zoom_in)
        self.menu_toolbar.addSeparator()
        header_action = self.menu_toolbar.addAction(icon("tool.svg"),
                                                    "Edit Level Header")
        header_action.triggered.connect(self.on_header_editor)
        header_action.setWhatsThis(
            "<b>Header Editor</b><br/>"
            "Many configurations regarding the level are done in its header, like the length of "
            "the timer, or where and how Mario enters the level.<br/>")

        self.jump_destination_action = self.menu_toolbar.addAction(
            icon("arrow-right-circle.svg"), "Go to Jump Destination")
        self.jump_destination_action.triggered.connect(
            self._go_to_jump_destination)
        self.jump_destination_action.setWhatsThis(
            "Opens the level, that can be reached from this one, e.g. by entering a pipe."
        )

        self.menu_toolbar.addSeparator()

        whats_this_action = QWhatsThis.createAction()
        whats_this_action.setWhatsThis(
            "Click on parts of the editor, to receive help information.")
        whats_this_action.setIcon(icon("help-circle.svg"))
        whats_this_action.setText("Starts 'What's this?' mode")
        self.menu_toolbar.addAction(whats_this_action)

        self.menu_toolbar.addSeparator()
        self.warning_list = WarningList(self, self.level_ref)

        warning_action = self.menu_toolbar.addAction(
            icon("alert-triangle.svg"), "Warning Panel")
        warning_action.setWhatsThis("Shows a list of warnings.")
        warning_action.triggered.connect(self.warning_list.show)
        warning_action.setDisabled(True)

        self.warning_list.warnings_updated.connect(warning_action.setEnabled)

        self.addToolBar(Qt.TopToolBarArea, self.menu_toolbar)

        self.status_bar = ObjectStatusBar(self, self.level_ref)
        self.setStatusBar(self.status_bar)

        self.delete_shortcut = QShortcut(QKeySequence(Qt.Key_Delete), self,
                                         self.remove_selected_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_X), self, self._cut_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_C), self, self._copy_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_V), self, self._paste_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Z), self, self.level_ref.undo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Y), self, self.level_ref.redo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Z), self,
                  self.level_ref.redo)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Plus), self,
                  self.level_view.zoom_in)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Minus), self,
                  self.level_view.zoom_out)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_A), self,
                  self.level_view.select_all)

        self.on_open_rom(path_to_rom)

        self.showMaximized()
Exemplo n.º 20
0
    def __init__(self, aPath, parent=None):
        super(VideoPlayer, self).__init__(parent)

        self.setAttribute(Qt.WA_NoSystemBackground, True)
        self.setAcceptDrops(True)
        self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.StreamPlayback)
        self.mediaPlayer.mediaStatusChanged.connect(self.printMediaData)
        self.mediaPlayer.setVolume(80)
        self.videoWidget = QVideoWidget(self)

        self.lbl = QLineEdit('00:00:00')
        self.lbl.setReadOnly(True)
        self.lbl.setFixedWidth(70)
        self.lbl.setUpdatesEnabled(True)
        self.lbl.setStyleSheet(stylesheet(self))
        self.lbl.selectionChanged.connect(lambda: self.lbl.setSelection(0, 0))

        self.elbl = QLineEdit('00:00:00')
        self.elbl.setReadOnly(True)
        self.elbl.setFixedWidth(70)
        self.elbl.setUpdatesEnabled(True)
        self.elbl.setStyleSheet(stylesheet(self))
        self.elbl.selectionChanged.connect(
            lambda: self.elbl.setSelection(0, 0))

        self.playButton = QPushButton()
        self.playButton.setEnabled(False)
        self.playButton.setFixedWidth(32)
        self.playButton.setStyleSheet("background-color: black")
        self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
        self.playButton.clicked.connect(self.play)

        self.positionSlider = QSlider(Qt.Horizontal, self)
        self.positionSlider.setStyleSheet(stylesheet(self))
        self.positionSlider.setRange(0, 100)
        self.positionSlider.sliderMoved.connect(self.setPosition)
        self.positionSlider.setSingleStep(2)
        self.positionSlider.setPageStep(20)
        self.positionSlider.setAttribute(Qt.WA_TranslucentBackground, True)

        self.clip = QApplication.clipboard()
        self.process = QProcess(self)
        self.process.readyRead.connect(self.dataReady)
        self.process.finished.connect(self.playFromURL)

        self.myurl = ""

        controlLayout = QHBoxLayout()
        controlLayout.setContentsMargins(5, 0, 5, 0)
        controlLayout.addWidget(self.playButton)
        controlLayout.addWidget(self.lbl)
        controlLayout.addWidget(self.positionSlider)
        controlLayout.addWidget(self.elbl)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.videoWidget)
        layout.addLayout(controlLayout)

        self.setLayout(layout)

        self.myinfo = "©2016\nAxel Schneider\n\nMouse Wheel = Zoom\nUP = Volume Up\nDOWN = Volume Down\n" + \
                "LEFT = < 1 Minute\nRIGHT = > 1 Minute\n" + \
                "SHIFT+LEFT = < 10 Minutes\nSHIFT+RIGHT = > 10 Minutes"

        self.widescreen = True

        #### shortcuts ####
        self.shortcut = QShortcut(QKeySequence("q"), self)
        self.shortcut.activated.connect(self.handleQuit)
        self.shortcut = QShortcut(QKeySequence("u"), self)
        self.shortcut.activated.connect(self.playFromURL)

        self.shortcut = QShortcut(QKeySequence("y"), self)
        self.shortcut.activated.connect(self.getYTUrl)

        self.shortcut = QShortcut(QKeySequence("o"), self)
        self.shortcut.activated.connect(self.openFile)
        self.shortcut = QShortcut(QKeySequence(" "), self)
        self.shortcut.activated.connect(self.play)
        self.shortcut = QShortcut(QKeySequence("f"), self)
        self.shortcut.activated.connect(self.handleFullscreen)
        self.shortcut = QShortcut(QKeySequence("i"), self)
        self.shortcut.activated.connect(self.handleInfo)
        self.shortcut = QShortcut(QKeySequence("s"), self)
        self.shortcut.activated.connect(self.toggleSlider)
        self.shortcut = QShortcut(QKeySequence(Qt.Key_Right), self)
        self.shortcut.activated.connect(self.forwardSlider)
        self.shortcut = QShortcut(QKeySequence(Qt.Key_Left), self)
        self.shortcut.activated.connect(self.backSlider)
        self.shortcut = QShortcut(QKeySequence(Qt.Key_Up), self)
        self.shortcut.activated.connect(self.volumeUp)
        self.shortcut = QShortcut(QKeySequence(Qt.Key_Down), self)
        self.shortcut.activated.connect(self.volumeDown)
        self.shortcut = QShortcut(
            QKeySequence(Qt.ShiftModifier + Qt.Key_Right), self)
        self.shortcut.activated.connect(self.forwardSlider10)
        self.shortcut = QShortcut(QKeySequence(Qt.ShiftModifier + Qt.Key_Left),
                                  self)
        self.shortcut.activated.connect(self.backSlider10)

        self.mediaPlayer.setVideoOutput(self.videoWidget)
        self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
        self.mediaPlayer.positionChanged.connect(self.positionChanged)
        self.mediaPlayer.durationChanged.connect(self.durationChanged)
        self.mediaPlayer.error.connect(self.handleError)

        print("QT5 Player started")
        print("press 'o' to open file (see context menu for more)")
        self.suspend_screensaver()
Exemplo n.º 21
0
    def __init__(self, is_person=False, parent=None):
        super().__init__(parent)
        self.is_person = is_person
        self.module: TableModule = locator.get_scoped(
            "ModuleService").get_module("Characters")
        self.proxy_model = QSortFilterProxyModel()
        self.proxy_model.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.proxy_model.setSourceModel(self.module.entries_model)
        self.characters_list_view.setModel(self.proxy_model)
        self.selection: Optional[PropertyContainer] = None

        self.character_details_form_1 = PropertyForm(
            self.module.element_template, category="character_description_1")
        self.character_details_form_contents_1.setLayout(
            self.character_details_form_1)
        self.character_details_form_2 = PropertyForm(
            self.module.element_template, category="character_description_2")
        self.character_details_form_contents_2.setLayout(
            self.character_details_form_2)
        self.character_details_form_2.fix_editor_width(100)
        self.stats_editor = MergedStatsEditor(
            ["Bases", "Growths", "Modifiers", "Penalties", "Bonuses"])
        self.stats_form = PropertyForm(self.module.element_template,
                                       category="stats")
        self.stats_layout.addWidget(self.stats_editor)
        self.stats_layout.addLayout(self.stats_form)
        self.skills_form = PropertyForm(self.module.element_template,
                                        category="skills",
                                        sort_editors=True)
        self.skills_contents.setLayout(self.skills_form)
        self.flags_editor = MergedFlagsEditor(
            ["Bitflags (1)", "Bitflags (2)", "Bitflags (3)", "Bitflags (4)"],
            self.module.element_template)
        self.flags_editor_2 = MergedFlagsEditor(
            ["Bitflags (5)", "Bitflags (6)", "Bitflags (7)", "Bitflags (8)"],
            self.module.element_template)
        self.misc_form = PropertyForm(self.module.element_template,
                                      category="misc")
        self.misc_layout.addWidget(self.flags_editor)
        self.misc_layout.addWidget(self.flags_editor_2)
        self.misc_layout.addLayout(self.misc_form)
        self.ids_form = PropertyForm(self.module.element_template,
                                     category="ids")
        self.ids_tab.setLayout(self.ids_form)
        self.classes_form = PropertyForm(self.module.element_template,
                                         category="classes",
                                         sort_editors=True)
        self.classes_tab.setLayout(self.classes_form)
        if not self.is_person:
            self.dialogue_tab = DialogueEditor()
            self.supports_tab = QWidget()
            self.supports_layout = QHBoxLayout()
            self.supports_widget = FE14SupportWidget()
            self.supports_scroll = QScrollArea()
            self.supports_scroll_contents = QWidget()
            self.supports_scroll.setWidget(self.supports_scroll_contents)
            self.supports_scroll.setWidgetResizable(True)
            self.supports_layout.addWidget(self.supports_widget)
            self.supports_layout.addWidget(self.supports_scroll)
            self.supports_tab.setLayout(self.supports_layout)
            self.supports_form = PropertyForm(self.module.element_template,
                                              category="supports")
            self.supports_scroll_contents.setLayout(self.supports_form)
            self.tab_widget.addTab(self.supports_tab, "Supports")
            self.tab_widget.addTab(self.dialogue_tab, "Dialogue")

        self.context_menu = QMenu(self)
        self.context_menu.addActions(
            [self.action_add, self.action_remove, self.action_copy_to])
        self.clear_selection_shortcut = QShortcut(QKeySequence.Cancel, self)

        self._install_signals()
        self._clear()
Exemplo n.º 22
0
    def __init__(self, config):
        super(MainWindow, self).__init__()

        QFontDatabase.addApplicationFont(
            'resources/fonts/poppins/Poppins-Medium.ttf')
        QFontDatabase.addApplicationFont(
            'resources/fonts/source code pro/SourceCodePro-Regular.ttf')

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.splitter.setSizes([120, 800])
        self.setWindowTitle('Ryven')
        self.setWindowIcon(QIcon('resources/pics/program_icon2.png'))
        self.load_stylesheet('dark')
        self.ui.scripts_tab_widget.removeTab(0)

        # menu actions
        self.setup_menu_actions()

        # shortcuts
        save_shortcut = QShortcut(QKeySequence.Save, self)
        save_shortcut.activated.connect(self.on_save_project_triggered)

        # clear temp folder
        if not os.path.exists('temp'):
            os.mkdir('temp')
        for f in os.listdir('temp'):
            os.remove('temp/' + f)

        # GENERAL ATTRIBUTES
        self.scripts = []
        self.custom_nodes = []
        self.all_nodes = [
            SetVariable_Node(),
            GetVariable_Node(),
            Val_Node(),
            Result_Node()
        ]
        self.package_names = []

        #   holds NI subCLASSES for imported nodes:
        self.all_node_instance_classes = {
            self.all_nodes[0]: SetVar_NodeInstance,
            self.all_nodes[1]: GetVar_NodeInstance,
            self.all_nodes[2]: Val_NodeInstance,
            self.all_nodes[3]: Result_NodeInstance
        }  # (key: node obj, val: NI subclass) (used in Flow)

        #   custom subclasses for input widgets
        #   {node : {str: PortInstanceWidget-subclass}} (used in PortInstance)
        self.custom_node_input_widget_classes = {}

        # UI
        self.scripts_list_widget = ScriptsListWidget(self, self.scripts)
        self.ui.scripts_scrollArea.setWidget(self.scripts_list_widget)
        self.ui.add_new_script_pushButton.clicked.connect(
            self.create_new_script_button_pressed)
        self.ui.new_script_name_lineEdit.returnPressed.connect(
            self.create_new_script_LE_return_pressed)

        if config['config'] == 'create plain new project':
            self.try_to_create_new_script()
        elif config['config'] == 'open project':
            print('importing packages...')
            self.import_packages(config['required packages'])
            print('loading project...')
            self.parse_project(config['content'])
            print('finished')

        print('''
        CONTROLS
            placing nodes: right mouse
            selecting components: left mouse
            panning: middle mouse
            saving: ctrl+s
        ''')

        self.set_flow_design('dark std')
        self.resize(1500, 800)
Exemplo n.º 23
0
    def __init__(self) -> None:
        """SCOUTS Constructor. Defines all aspects of the GUI."""

        # ###
        # ### Main Window setup
        # ###

        # Inherits from QMainWindow
        super().__init__()
        self.rootdir = get_project_root()
        self.threadpool = QThreadPool()
        # Sets values for QMainWindow
        self.setWindowTitle("SCOUTS")
        self.setWindowIcon(
            QIcon(
                os.path.abspath(os.path.join(self.rootdir, 'src',
                                             'scouts.ico'))))
        # Creates StackedWidget as QMainWindow's central widget
        self.stacked_pages = QStackedWidget(self)
        self.setCentralWidget(self.stacked_pages)
        # Creates Widgets for individual "pages" and adds them to the StackedWidget
        self.main_page = QWidget()
        self.samples_page = QWidget()
        self.gating_page = QWidget()
        self.pages = (self.main_page, self.samples_page, self.gating_page)
        for page in self.pages:
            self.stacked_pages.addWidget(page)
        # ## Sets widget at program startup
        self.stacked_pages.setCurrentWidget(self.main_page)

        # ###
        # ### MAIN PAGE
        # ###

        # Main page layout
        self.main_layout = QVBoxLayout(self.main_page)

        # Title section
        # Title
        self.title = QLabel(self.main_page)
        self.title.setText('SCOUTS - Single Cell Outlier Selector')
        self.title.setStyleSheet(self.style['title'])
        self.title.adjustSize()
        self.main_layout.addWidget(self.title)

        # ## Input section
        # Input header
        self.input_header = QLabel(self.main_page)
        self.input_header.setText('Input settings')
        self.input_header.setStyleSheet(self.style['header'])
        self.main_layout.addChildWidget(self.input_header)
        self.input_header.adjustSize()
        self.main_layout.addWidget(self.input_header)
        # Input frame
        self.input_frame = QFrame(self.main_page)
        self.input_frame.setFrameShape(QFrame.StyledPanel)
        self.input_frame.setLayout(QFormLayout())
        self.main_layout.addWidget(self.input_frame)
        # Input button
        self.input_button = QPushButton(self.main_page)
        self.input_button.setStyleSheet(self.style['button'])
        self.set_icon(self.input_button, 'x-office-spreadsheet')
        self.input_button.setObjectName('input')
        self.input_button.setText(' Select input file (.xlsx or .csv)')
        self.input_button.clicked.connect(self.get_path)
        # Input path box
        self.input_path = QLineEdit(self.main_page)
        self.input_path.setObjectName('input_path')
        self.input_path.setStyleSheet(self.style['line edit'])
        # Go to sample naming page
        self.samples_button = QPushButton(self.main_page)
        self.samples_button.setStyleSheet(self.style['button'])
        self.set_icon(self.samples_button, 'preferences-other')
        self.samples_button.setText(' Name samples...')
        self.samples_button.clicked.connect(self.goto_samples_page)
        # Go to gating page
        self.gates_button = QPushButton(self.main_page)
        self.gates_button.setStyleSheet(self.style['button'])
        self.set_icon(self.gates_button, 'preferences-other')
        self.gates_button.setText(' Gating && outlier options...')
        self.gates_button.clicked.connect(self.goto_gates_page)
        # Add widgets above to input frame Layout
        self.input_frame.layout().addRow(self.input_button, self.input_path)
        self.input_frame.layout().addRow(self.samples_button)
        self.input_frame.layout().addRow(self.gates_button)

        # ## Analysis section
        # Analysis header
        self.analysis_header = QLabel(self.main_page)
        self.analysis_header.setText('Analysis settings')
        self.analysis_header.setStyleSheet(self.style['header'])
        self.analysis_header.adjustSize()
        self.main_layout.addWidget(self.analysis_header)
        # Analysis frame
        self.analysis_frame = QFrame(self.main_page)
        self.analysis_frame.setFrameShape(QFrame.StyledPanel)
        self.analysis_frame.setLayout(QVBoxLayout())
        self.main_layout.addWidget(self.analysis_frame)
        # Cutoff text
        self.cutoff_text = QLabel(self.main_page)
        self.cutoff_text.setText('Type of outlier to select:')
        self.cutoff_text.setToolTip(
            'Choose whether to select outliers using the cutoff value from a reference\n'
            'sample (OutR) or by using the cutoff value calculated for each sample\n'
            'individually (OutS)')
        self.cutoff_text.setStyleSheet(self.style['label'])
        # Cutoff button group
        self.cutoff_group = QButtonGroup(self)
        # Cutoff by sample
        self.cutoff_sample = QRadioButton(self.main_page)
        self.cutoff_sample.setText('OutS')
        self.cutoff_sample.setObjectName('sample')
        self.cutoff_sample.setStyleSheet(self.style['radio button'])
        self.cutoff_sample.setChecked(True)
        self.cutoff_group.addButton(self.cutoff_sample)
        # Cutoff by reference
        self.cutoff_reference = QRadioButton(self.main_page)
        self.cutoff_reference.setText('OutR')
        self.cutoff_reference.setObjectName('ref')
        self.cutoff_reference.setStyleSheet(self.style['radio button'])
        self.cutoff_group.addButton(self.cutoff_reference)
        # Both cutoffs
        self.cutoff_both = QRadioButton(self.main_page)
        self.cutoff_both.setText('both')
        self.cutoff_both.setObjectName('sample ref')
        self.cutoff_both.setStyleSheet(self.style['radio button'])
        self.cutoff_group.addButton(self.cutoff_both)
        # Markers text
        self.markers_text = QLabel(self.main_page)
        self.markers_text.setStyleSheet(self.style['label'])
        self.markers_text.setText('Show results for:')
        self.markers_text.setToolTip(
            'Individual markers: for each marker, select outliers\n'
            'Any marker: select cells that are outliers for AT LEAST one marker'
        )
        # Markers button group
        self.markers_group = QButtonGroup(self)
        # Single marker
        self.single_marker = QRadioButton(self.main_page)
        self.single_marker.setText('individual markers')
        self.single_marker.setObjectName('single')
        self.single_marker.setStyleSheet(self.style['radio button'])
        self.single_marker.setChecked(True)
        self.markers_group.addButton(self.single_marker)
        # Any marker
        self.any_marker = QRadioButton(self.main_page)
        self.any_marker.setText('any marker')
        self.any_marker.setObjectName('any')
        self.any_marker.setStyleSheet(self.style['radio button'])
        self.markers_group.addButton(self.any_marker)
        # Both methods
        self.both_methods = QRadioButton(self.main_page)
        self.both_methods.setText('both')
        self.both_methods.setObjectName('single any')
        self.both_methods.setStyleSheet(self.style['radio button'])
        self.markers_group.addButton(self.both_methods)
        # Tukey text
        self.tukey_text = QLabel(self.main_page)
        self.tukey_text.setStyleSheet(self.style['label'])
        # Tukey button group
        self.tukey_text.setText('Tukey factor:')
        self.tukey_group = QButtonGroup(self)
        # Low Tukey value
        self.tukey_low = QRadioButton(self.main_page)
        self.tukey_low.setText('1.5')
        self.tukey_low.setStyleSheet(self.style['radio button'])
        self.tukey_low.setChecked(True)
        self.tukey_group.addButton(self.tukey_low)
        # High Tukey value
        self.tukey_high = QRadioButton(self.main_page)
        self.tukey_high.setText('3.0')
        self.tukey_high.setStyleSheet(self.style['radio button'])
        self.tukey_group.addButton(self.tukey_high)
        # Add widgets above to analysis frame layout
        self.analysis_frame.layout().addWidget(self.cutoff_text)
        self.cutoff_buttons = QHBoxLayout()
        for button in self.cutoff_group.buttons():
            self.cutoff_buttons.addWidget(button)
        self.analysis_frame.layout().addLayout(self.cutoff_buttons)
        self.analysis_frame.layout().addWidget(self.markers_text)
        self.markers_buttons = QHBoxLayout()
        for button in self.markers_group.buttons():
            self.markers_buttons.addWidget(button)
        self.analysis_frame.layout().addLayout(self.markers_buttons)
        self.analysis_frame.layout().addWidget(self.tukey_text)
        self.tukey_buttons = QHBoxLayout()
        for button in self.tukey_group.buttons():
            self.tukey_buttons.addWidget(button)
        self.tukey_buttons.addWidget(QLabel())  # aligns row with 2 buttons
        self.analysis_frame.layout().addLayout(self.tukey_buttons)

        # ## Output section
        # Output header
        self.output_header = QLabel(self.main_page)
        self.output_header.setText('Output settings')
        self.output_header.setStyleSheet(self.style['header'])
        self.output_header.adjustSize()
        self.main_layout.addWidget(self.output_header)
        # Output frame
        self.output_frame = QFrame(self.main_page)
        self.output_frame.setFrameShape(QFrame.StyledPanel)
        self.output_frame.setLayout(QFormLayout())
        self.main_layout.addWidget(self.output_frame)
        # Output button
        self.output_button = QPushButton(self.main_page)
        self.output_button.setStyleSheet(self.style['button'])
        self.set_icon(self.output_button, 'folder')
        self.output_button.setObjectName('output')
        self.output_button.setText(' Select output folder')
        self.output_button.clicked.connect(self.get_path)
        # Output path box
        self.output_path = QLineEdit(self.main_page)
        self.output_path.setStyleSheet(self.style['line edit'])
        # Generate CSV checkbox
        self.output_csv = QCheckBox(self.main_page)
        self.output_csv.setText('Export multiple text files (.csv)')
        self.output_csv.setStyleSheet(self.style['checkbox'])
        self.output_csv.setChecked(True)
        # Generate XLSX checkbox
        self.output_excel = QCheckBox(self.main_page)
        self.output_excel.setText('Export multiple Excel spreadsheets (.xlsx)')
        self.output_excel.setStyleSheet(self.style['checkbox'])
        self.output_excel.clicked.connect(self.enable_single_excel)
        # Generate single, large XLSX checkbox
        self.single_excel = QCheckBox(self.main_page)
        self.single_excel.setText(
            'Also save one multi-sheet Excel spreadsheet')
        self.single_excel.setToolTip(
            'After generating all Excel spreadsheets, SCOUTS combines them into '
            'a single\nExcel spreadsheet where each sheet corresponds to an output'
            'file from SCOUTS')
        self.single_excel.setStyleSheet(self.style['checkbox'])
        self.single_excel.setEnabled(False)
        self.single_excel.clicked.connect(self.memory_warning)
        # Add widgets above to output frame layout
        self.output_frame.layout().addRow(self.output_button, self.output_path)
        self.output_frame.layout().addRow(self.output_csv)
        self.output_frame.layout().addRow(self.output_excel)
        self.output_frame.layout().addRow(self.single_excel)

        # ## Run & help-quit section
        # Run button (stand-alone)
        self.run_button = QPushButton(self.main_page)
        self.set_icon(self.run_button, 'system-run')
        self.run_button.setText(' Run!')
        self.run_button.setStyleSheet(self.style['run button'])
        self.main_layout.addWidget(self.run_button)
        self.run_button.clicked.connect(self.run)
        # Help-quit frame (invisible)
        self.helpquit_frame = QFrame(self.main_page)
        self.helpquit_frame.setLayout(QHBoxLayout())
        self.helpquit_frame.layout().setMargin(0)
        self.main_layout.addWidget(self.helpquit_frame)
        # Help button
        self.help_button = QPushButton(self.main_page)
        self.set_icon(self.help_button, 'help-about')
        self.help_button.setText(' Help')
        self.help_button.setStyleSheet(self.style['md button'])
        self.help_button.clicked.connect(self.get_help)
        # Quit button
        self.quit_button = QPushButton(self.main_page)
        self.set_icon(self.quit_button, 'process-stop')
        self.quit_button.setText(' Quit')
        self.quit_button.setStyleSheet(self.style['md button'])
        self.quit_button.clicked.connect(self.close)
        # Add widgets above to help-quit layout
        self.helpquit_frame.layout().addWidget(self.help_button)
        self.helpquit_frame.layout().addWidget(self.quit_button)

        # ###
        # ### SAMPLES PAGE
        # ###

        # Samples page layout
        self.samples_layout = QVBoxLayout(self.samples_page)

        # ## Title section
        # Title
        self.samples_title = QLabel(self.samples_page)
        self.samples_title.setText('Name your samples')
        self.samples_title.setStyleSheet(self.style['title'])
        self.samples_title.adjustSize()
        self.samples_layout.addWidget(self.samples_title)
        # Subtitle
        self.samples_subtitle = QLabel(self.samples_page)
        string = (
            'Please name the samples to be analysed by SCOUTS.\n\nSCOUTS searches the first '
            'column of your data\nand locates the exact string as part of the sample name.'
        )
        self.samples_subtitle.setText(string)
        self.samples_subtitle.setStyleSheet(self.style['label'])
        self.samples_subtitle.adjustSize()
        self.samples_layout.addWidget(self.samples_subtitle)

        # ## Sample addition section
        # Sample addition frame
        self.samples_frame = QFrame(self.samples_page)
        self.samples_frame.setFrameShape(QFrame.StyledPanel)
        self.samples_frame.setLayout(QGridLayout())
        self.samples_layout.addWidget(self.samples_frame)
        # Sample name box
        self.sample_name = QLineEdit(self.samples_page)
        self.sample_name.setStyleSheet(self.style['line edit'])
        self.sample_name.setPlaceholderText('Sample name ...')
        # Reference check
        self.is_reference = QCheckBox(self.samples_page)
        self.is_reference.setText('Reference?')
        self.is_reference.setStyleSheet(self.style['checkbox'])
        # Add sample to table
        self.add_sample_button = QPushButton(self.samples_page)
        QShortcut(QKeySequence("Return"), self.add_sample_button,
                  self.write_to_sample_table)
        self.set_icon(self.add_sample_button, 'list-add')
        self.add_sample_button.setText(' Add sample (Enter)')
        self.add_sample_button.setStyleSheet(self.style['button'])
        self.add_sample_button.clicked.connect(self.write_to_sample_table)
        # Remove sample from table
        self.remove_sample_button = QPushButton(self.samples_page)
        QShortcut(QKeySequence("Delete"), self.remove_sample_button,
                  self.remove_from_sample_table)
        self.set_icon(self.remove_sample_button, 'list-remove')
        self.remove_sample_button.setText(' Remove sample (Del)')
        self.remove_sample_button.setStyleSheet(self.style['button'])
        self.remove_sample_button.clicked.connect(
            self.remove_from_sample_table)
        # Add widgets above to sample addition layout
        self.samples_frame.layout().addWidget(self.sample_name, 0, 0)
        self.samples_frame.layout().addWidget(self.is_reference, 1, 0)
        self.samples_frame.layout().addWidget(self.add_sample_button, 0, 1)
        self.samples_frame.layout().addWidget(self.remove_sample_button, 1, 1)

        # ## Sample table
        self.sample_table = QTableWidget(self.samples_page)
        self.sample_table.setColumnCount(2)
        self.sample_table.setHorizontalHeaderItem(0,
                                                  QTableWidgetItem('Sample'))
        self.sample_table.setHorizontalHeaderItem(
            1, QTableWidgetItem('Reference?'))
        self.sample_table.horizontalHeader().setSectionResizeMode(
            0, QHeaderView.Stretch)
        self.sample_table.horizontalHeader().setSectionResizeMode(
            1, QHeaderView.ResizeToContents)
        self.samples_layout.addWidget(self.sample_table)

        # ## Save & clear buttons
        # Save & clear frame (invisible)
        self.saveclear_frame = QFrame(self.samples_page)
        self.saveclear_frame.setLayout(QHBoxLayout())
        self.saveclear_frame.layout().setMargin(0)
        self.samples_layout.addWidget(self.saveclear_frame)
        # Clear samples button
        self.clear_samples = QPushButton(self.samples_page)
        self.set_icon(self.clear_samples, 'edit-delete')
        self.clear_samples.setText(' Clear table')
        self.clear_samples.setStyleSheet(self.style['md button'])
        self.clear_samples.clicked.connect(self.prompt_clear_data)
        # Save samples button
        self.save_samples = QPushButton(self.samples_page)
        self.set_icon(self.save_samples, 'document-save')
        self.save_samples.setText(' Save samples')
        self.save_samples.setStyleSheet(self.style['md button'])
        self.save_samples.clicked.connect(self.goto_main_page)
        # Add widgets above to save & clear layout
        self.saveclear_frame.layout().addWidget(self.clear_samples)
        self.saveclear_frame.layout().addWidget(self.save_samples)

        # ###
        # ### GATING PAGE
        # ###

        # Gating page layout
        self.gating_layout = QVBoxLayout(self.gating_page)

        # ## Title section
        # Title
        self.gates_title = QLabel(self.gating_page)
        self.gates_title.setText('Gating & outlier options')
        self.gates_title.setStyleSheet(self.style['title'])
        self.gates_title.adjustSize()
        self.gating_layout.addWidget(self.gates_title)

        # ## Gating options section
        # Gating header
        self.gate_header = QLabel(self.gating_page)
        self.gate_header.setText('Gating')
        self.gate_header.setStyleSheet(self.style['header'])
        self.gate_header.adjustSize()
        self.gating_layout.addWidget(self.gate_header)

        # Gating frame
        self.gate_frame = QFrame(self.gating_page)
        self.gate_frame.setFrameShape(QFrame.StyledPanel)
        self.gate_frame.setLayout(QFormLayout())
        self.gating_layout.addWidget(self.gate_frame)
        # Gating button group
        self.gating_group = QButtonGroup(self)
        # Do not gate samples
        self.no_gates = QRadioButton(self.gating_page)
        self.no_gates.setObjectName('no_gate')
        self.no_gates.setText("Don't gate samples")
        self.no_gates.setStyleSheet(self.style['radio button'])
        self.no_gates.setChecked(True)
        self.gating_group.addButton(self.no_gates)
        self.no_gates.clicked.connect(self.activate_gate)
        # CyToF gating
        self.cytof_gates = QRadioButton(self.gating_page)
        self.cytof_gates.setObjectName('cytof')
        self.cytof_gates.setText('Mass Cytometry gating')
        self.cytof_gates.setStyleSheet(self.style['radio button'])
        self.cytof_gates.setToolTip(
            'Exclude cells for which the average expression of all\n'
            'markers is below the selected value')
        self.gating_group.addButton(self.cytof_gates)
        self.cytof_gates.clicked.connect(self.activate_gate)
        # CyToF gating spinbox
        self.cytof_gates_value = QDoubleSpinBox(self.gating_page)
        self.cytof_gates_value.setMinimum(0)
        self.cytof_gates_value.setMaximum(1)
        self.cytof_gates_value.setValue(0.1)
        self.cytof_gates_value.setSingleStep(0.05)
        self.cytof_gates_value.setEnabled(False)
        # scRNA-Seq gating
        self.rnaseq_gates = QRadioButton(self.gating_page)
        self.rnaseq_gates.setText('scRNA-Seq gating')
        self.rnaseq_gates.setStyleSheet(self.style['radio button'])
        self.rnaseq_gates.setToolTip(
            'When calculating cutoff, ignore reads below the selected value')
        self.rnaseq_gates.setObjectName('rnaseq')
        self.gating_group.addButton(self.rnaseq_gates)
        self.rnaseq_gates.clicked.connect(self.activate_gate)
        # scRNA-Seq gating spinbox
        self.rnaseq_gates_value = QDoubleSpinBox(self.gating_page)
        self.rnaseq_gates_value.setMinimum(0)
        self.rnaseq_gates_value.setMaximum(10)
        self.rnaseq_gates_value.setValue(0)
        self.rnaseq_gates_value.setSingleStep(1)
        self.rnaseq_gates_value.setEnabled(False)
        # export gated population checkbox
        self.export_gated = QCheckBox(self.gating_page)
        self.export_gated.setText('Export gated cells as an output file')
        self.export_gated.setStyleSheet(self.style['checkbox'])
        self.export_gated.setEnabled(False)
        # Add widgets above to Gate frame layout
        self.gate_frame.layout().addRow(self.no_gates, QLabel())
        self.gate_frame.layout().addRow(self.cytof_gates,
                                        self.cytof_gates_value)
        self.gate_frame.layout().addRow(self.rnaseq_gates,
                                        self.rnaseq_gates_value)
        self.gate_frame.layout().addRow(self.export_gated, QLabel())

        # ## Outlier options section
        # Outlier header
        self.outlier_header = QLabel(self.gating_page)
        self.outlier_header.setText('Outliers')
        self.outlier_header.setStyleSheet(self.style['header'])
        self.outlier_header.adjustSize()
        self.gating_layout.addWidget(self.outlier_header)
        # Outlier frame
        self.outlier_frame = QFrame(self.gating_page)
        self.outlier_frame.setFrameShape(QFrame.StyledPanel)
        self.outlier_frame.setLayout(QVBoxLayout())
        self.gating_layout.addWidget(self.outlier_frame)
        # Top outliers information
        self.top_outliers = QLabel(self.gating_page)
        self.top_outliers.setStyleSheet(self.style['label'])
        self.top_outliers.setText(
            'By default, SCOUTS selects the top outliers from the population')
        self.top_outliers.setStyleSheet(self.style['label'])
        # Bottom outliers data
        self.bottom_outliers = QCheckBox(self.gating_page)
        self.bottom_outliers.setText('Include results for low outliers')
        self.bottom_outliers.setStyleSheet(self.style['checkbox'])
        # Non-outliers data
        self.not_outliers = QCheckBox(self.gating_page)
        self.not_outliers.setText('Include results for non-outliers')
        self.not_outliers.setStyleSheet(self.style['checkbox'])
        # Add widgets above to Gate frame layout
        self.outlier_frame.layout().addWidget(self.top_outliers)
        self.outlier_frame.layout().addWidget(self.bottom_outliers)
        self.outlier_frame.layout().addWidget(self.not_outliers)

        # ## Save/back button
        self.save_gates = QPushButton(self.gating_page)
        self.set_icon(self.save_gates, 'go-next')
        self.save_gates.setText(' Back to main menu')
        self.save_gates.setStyleSheet(self.style['md button'])
        self.gating_layout.addWidget(self.save_gates)
        self.save_gates.clicked.connect(self.goto_main_page)

        # ## Add empty label to take vertical space
        self.empty_label = QLabel(self.gating_page)
        self.empty_label.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
        self.gating_layout.addWidget(self.empty_label)
Exemplo n.º 24
0
    def __init__(self, parent):
        """ standard constructor: set up class variables, ui elements
            and layout """

        # TODO: split current piece info into separate lineedits for title, album name and length
        # TODO: make time changeable by clicking next to the slider (not only
        #       by dragging the slider)
        # TODO: add "about" action to open info dialog in new "help" menu
        # TODO: add option to loop current piece (?)
        # TODO: more documentation
        # TODO: add some "whole piece time remaining" indicator? (complicated)
        # TODO: implement a playlist of pieces that can be edited and enable
        #       going back to the previous piece (also un- and re-shuffling?)
        # TODO: implement debug dialog as menu action (if needed)

        if not isinstance(parent, PiecesMainWindow):
            raise ValueError('Parent widget must be a PiecesMainWindow')

        super(PiecesPlayer, self).__init__(parent=parent)

        # -- declare and setup variables for storing information --
        # various data
        self._set_str = ''  # string of currently loaded directory sets
        self._pieces = {}  # {<piece1>: [<files piece1 consists of>], ...}
        self._playlist = []  # list of keys of self._pieces (determines order)
        self._shuffled = True  # needed for (maybe) reshuffling when looping
        # doc for self._history:
        # key: timestamp ('HH:MM:SS'),
        # value: info_str of piece that started playing at that time
        self._history = {}
        self._status = 'Paused'
        self._current_piece = {'title': '', 'files': [], 'play_next': 0}
        self._default_volume = 60  # in percent from 0 - 100
        self._volume_before_muted = self._default_volume
        # set to true by self.__event_movement_ended and used by self.__update
        self._skip_to_next = False
        # vlc-related variables
        self._vlc_instance = VLCInstance()
        self._vlc_mediaplayer = self._vlc_instance.media_player_new()
        self._vlc_mediaplayer.audio_set_volume(self._default_volume)
        self._vlc_medium = None
        self._vlc_events = self._vlc_mediaplayer.event_manager()

        # -- create and setup ui elements --
        # buttons
        self._btn_play_pause = QPushButton(QIcon(get_icon_path('play')), '')
        self._btn_previous = QPushButton(QIcon(get_icon_path('previous')), '')
        self._btn_next = QPushButton(QIcon(get_icon_path('next')), '')
        self._btn_volume = QPushButton(QIcon(get_icon_path('volume-high')), '')
        self._btn_loop = QPushButton(QIcon(get_icon_path('loop')), '')
        self._btn_loop.setCheckable(True)
        self._btn_play_pause.clicked.connect(self.__action_play_pause)
        self._btn_previous.clicked.connect(self.__action_previous)
        self._btn_next.clicked.connect(self.__action_next)
        self._btn_volume.clicked.connect(self.__action_volume_clicked)
        # labels
        self._lbl_current_piece = QLabel('Current piece:')
        self._lbl_movements = QLabel('Movements:')
        self._lbl_time_played = QLabel('00:00')
        self._lbl_time_left = QLabel('-00:00')
        self._lbl_volume = QLabel('100%')
        # needed so that everything has the same position
        # independent of the number of digits of volume
        self._lbl_volume.setMinimumWidth(55)
        # sliders
        self._slider_time = QSlider(Qt.Horizontal)
        self._slider_volume = QSlider(Qt.Horizontal)
        self._slider_time.sliderReleased.connect(
            self.__event_time_changed_by_user)
        self._slider_volume.valueChanged.connect(self.__event_volume_changed)
        self._slider_time.setRange(0, 100)
        self._slider_volume.setRange(0, 100)
        self._slider_volume.setValue(self._default_volume)
        self._slider_volume.setMinimumWidth(100)
        # other elements
        self._checkbox_loop_playlist = QCheckBox('Loop playlist')
        self._lineedit_current_piece = QLineEdit()
        self._lineedit_current_piece.setReadOnly(True)
        self._lineedit_current_piece.textChanged.connect(
            self.__event_piece_text_changed)
        self._listwidget_movements = QListWidget()
        self._listwidget_movements.itemClicked.connect(
            self.__event_movement_selected)

        # -- create layout and insert ui elements--
        self._layout = QVBoxLayout(self)
        # row 0 (name of current piece)
        self._layout_piece_name = QHBoxLayout()
        self._layout_piece_name.addWidget(self._lbl_current_piece)
        self._layout_piece_name.addWidget(self._lineedit_current_piece)
        self._layout.addLayout(self._layout_piece_name)
        # rows 1 - 5 (movements of current piece)
        self._layout.addWidget(self._lbl_movements)
        self._layout.addWidget(self._listwidget_movements)
        # row 6 (time)
        self._layout_time = QHBoxLayout()
        self._layout_time.addWidget(self._lbl_time_played)
        self._layout_time.addWidget(self._slider_time)
        self._layout_time.addWidget(self._lbl_time_left)
        self._layout.addLayout(self._layout_time)
        # row 7 (buttons and volume)
        self._layout_buttons_and_volume = QHBoxLayout()
        self._layout_buttons_and_volume.addWidget(self._btn_play_pause)
        self._layout_buttons_and_volume.addWidget(self._btn_previous)
        self._layout_buttons_and_volume.addWidget(self._btn_next)
        self._layout_buttons_and_volume.addWidget(self._btn_loop)
        self._layout_buttons_and_volume.addSpacing(40)
        # distance between loop and volume buttons: min. 40, but stretchable
        self._layout_buttons_and_volume.addStretch()
        self._layout_buttons_and_volume.addWidget(self._btn_volume)
        self._layout_buttons_and_volume.addWidget(self._slider_volume)
        self._layout_buttons_and_volume.addWidget(self._lbl_volume)
        self._layout.addLayout(self._layout_buttons_and_volume)

        # -- setup hotkeys --
        self._KEY_CODES_PLAY_PAUSE = [269025044]
        self._KEY_CODES_NEXT = [269025047]
        self._KEY_CODES_PREVIOUS = [269025046]
        self._keyboard_listener = keyboard.Listener(on_press=self.__on_press)
        self._keyboard_listener.start()
        QShortcut(QKeySequence('Space'), self, self.__action_play_pause)

        # -- various setup --
        self._timer = QTimer(self)
        self._timer.timeout.connect(self.__update)
        self._timer.start(100)  # update every 100ms
        self.setMinimumWidth(900)
        self.setMinimumHeight(400)
        # get directory set(s) input and set up self._pieces
        # (exec_ means we'll wait for the user input before continuing)
        DirectorySetChooseDialog(self, self.set_pieces_and_playlist).exec_()
        # skip to next movement / next piece when current one has ended
        self._vlc_events.event_attach(VLCEventType.MediaPlayerEndReached,
                                      self.__event_movement_ended)
Exemplo n.º 25
0
    def construct(self):
        self.hBoxLayout = QHBoxLayout()
        self.prevButton = QPushButton("Prev", self)
        self.prevButton.setShortcut("Alt+O")

        self.resetButton = QPushButton("Reset", self)
        self.resetButton.setShortcut("Alt+R")

        self.qTextEditAddRow = QTextEdit()
        self.qTextEditAddRow.setFixedHeight(20)
        self.qTextEditAddRow.setFixedWidth(60)

        self.qTextEditDeleteRow = QTextEdit()
        self.qTextEditDeleteRow.setFixedHeight(20)
        self.qTextEditDeleteRow.setFixedWidth(60)

        self.qTextEdit = QTextEdit()
        self.qTextEdit.setFixedHeight(20)
        self.qTextEdit.setFixedWidth(60)

        self.qTextEdit2 = QTextEdit()
        self.qTextEdit2.setFixedHeight(20)
        self.qTextEdit2.setFixedWidth(500)

        self.shortcutText=QShortcut(QtGui.QKeySequence("Alt+M"), self)
        self.shortcutText.activated.connect(self.qTextEdit2.setFocus)

        self.goButton = QPushButton("Go", self)
        self.goButton.setShortcut("Alt+G")
        self.nextButton = QPushButton("Next", self)
        self.nextButton.setShortcut("Alt+P")
        self.addRowButton = QPushButton("Add Row", self)
        self.deleteRowButton = QPushButton("Delete Row", self)
        self.hBoxLayout.addWidget(self.prevButton)
        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.resetButton)
        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.qTextEditAddRow)
        self.hBoxLayout.addWidget(self.addRowButton)
        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.qTextEditDeleteRow)
        self.hBoxLayout.addWidget(self.deleteRowButton)
        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.qTextEdit)
        self.hBoxLayout.addWidget(self.goButton)

        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.qTextEdit2)

        self.hBoxLayout.addStretch()
        self.hBoxLayout.addWidget(self.nextButton)
        self.vBoxLayout.addLayout(self.hBoxLayout)

        self.chBoxLayout = QHBoxLayout()
        self.chBoxLayout.addStretch()
        cb_ids = ["ID", "FORM", "LEMMA", "UPOS", "XPOS", "FEATS", "HEAD", "DEPREL", "DEPS", "MISC"]
        cb_ids2 = ["Abbr", "Animacy", "Aspect", "Case", "Clusivity", "Definite", "Degree", "Echo", "Evident", "Foreign", "Gender", "Mood", "NounClass", "Number"]
        cb_ids3 = ["Number[psor]", "NumType", "Person", "Person[psor]", "Polarity", "Polite", "Poss", "PronType", "Reflex", "Register", "Tense", "VerbForm", "Voice"]
        for cb_id in cb_ids:
            cb = QCheckBox(cb_id)
            cb.setChecked(True)
            cb.stateChanged.connect(self.cb_change)
            self.chBoxLayout.addWidget(cb)
        
        self.chBoxLayout.addStretch()
        self.vBoxLayout.addLayout(self.chBoxLayout)

        self.chBoxLayout_2 = QHBoxLayout()
        self.chBoxLayout_2.addStretch()
        for cb_id in cb_ids2:
            cb = QCheckBox(cb_id)
            cb.setChecked(False)
            cb.stateChanged.connect(self.cb_change)
            self.chBoxLayout_2.addWidget(cb)

        self.chBoxLayout_2.addStretch()
        self.vBoxLayout.addLayout(self.chBoxLayout_2)

        self.chBoxLayout_3 = QHBoxLayout()
        self.chBoxLayout_3.addStretch()
        for cb_id in cb_ids3:
            cb = QCheckBox(cb_id)
            cb.setChecked(False)
            cb.stateChanged.connect(self.cb_change)
            self.chBoxLayout_3.addWidget(cb)

        self.chBoxLayout_3.addStretch()
        self.vBoxLayout.addLayout(self.chBoxLayout_3)

        self.qTextEdit.setText(str(self.sentence_id))

        self.noteDictionary = {}
        noteFile = open(self.notename, "r")
        for note in noteFile:
            noteSplitted = note.split(" --- ")
            noteID = noteSplitted[0]
            noteContent = noteSplitted[1].rstrip()
            self.noteDictionary[noteID] = noteContent
        noteFile.close()

        self.connect(self.prevButton, QtCore.SIGNAL('clicked()'), self.go_prev)
        self.connect(self.resetButton, QtCore.SIGNAL('clicked()'), self.reset)
        self.connect(self.goButton, QtCore.SIGNAL('clicked()'), self.go)
        self.connect(self.nextButton, QtCore.SIGNAL('clicked()'), self.go_next)
        self.connect(self.addRowButton, QtCore.SIGNAL('clicked()'), self.add_row)
        self.connect(self.deleteRowButton, QtCore.SIGNAL('clicked()'), self.delete_row)

        # create table here
        self.tableWidget = QTableWidget(self)

        self.tableWidget.itemChanged.connect(self.handle_change)

        self.connect(self.tableWidget.verticalHeader(), QtCore.SIGNAL("sectionClicked(int)"), self.agg)

        self.qTextEditError = QTextEdit()
        self.qTextEditError.setReadOnly(True)

        self.splitter = QSplitter(Qt.Vertical)
        self.splitter.addWidget(self.tableWidget)
        self.splitter.addWidget(self.qTextEditError)
        self.vBoxLayout.addWidget(self.splitter)

        self.webView = QWebEngineView()

        self.update_table()
        self.update_html()
        self.check_errors()

        self.splitter2 = QSplitter(Qt.Vertical)
        self.splitter2.addWidget(self.splitter)
        self.splitter2.addWidget(self.webView)
        self.vBoxLayout.addWidget(self.splitter2)

        self.webView.loadFinished.connect(self.finito)

        self.first_time = False
Exemplo n.º 26
0
    def __init__(self, path_to_rom=""):
        super(MainWindow, self).__init__()

        self.setWindowIcon(icon("foundry.ico"))

        file_menu = QMenu("File")

        open_rom_action = file_menu.addAction("&Open ROM")
        open_rom_action.triggered.connect(self.on_open_rom)
        self.open_m3l_action = file_menu.addAction("&Open M3L")
        self.open_m3l_action.triggered.connect(self.on_open_m3l)

        file_menu.addSeparator()

        save_rom_action = file_menu.addAction("&Save ROM")
        save_rom_action.triggered.connect(self.on_save_rom)
        save_rom_as_action = file_menu.addAction("&Save ROM as ...")
        save_rom_as_action.triggered.connect(self.on_save_rom_as)
        """
        file_menu.AppendSeparator()
        """
        self.save_m3l_action = file_menu.addAction("&Save M3L")
        self.save_m3l_action.triggered.connect(self.on_save_m3l)
        """
        file_menu.Append(ID_SAVE_LEVEL_TO, "&Save Level to", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_APPLY_IPS_PATCH, "&Apply IPS Patch", "")
        file_menu.AppendSeparator()
        file_menu.Append(ID_ROM_PRESET, "&ROM Preset", "")
        """
        file_menu.addSeparator()
        settings_action = file_menu.addAction("&Settings")
        settings_action.triggered.connect(show_settings)
        file_menu.addSeparator()
        exit_action = file_menu.addAction("&Exit")
        exit_action.triggered.connect(lambda _: self.close())

        self.menuBar().addMenu(file_menu)
        """
        edit_menu = wx.Menu()

        edit_menu.Append(ID_EDIT_LEVEL, "&Edit Level", "")
        edit_menu.Append(ID_EDIT_OBJ_DEFS, "&Edit Object Definitions", "")
        edit_menu.Append(ID_EDIT_PALETTE, "&Edit Palette", "")
        edit_menu.Append(ID_EDIT_GRAPHICS, "&Edit Graphics", "")
        edit_menu.Append(ID_EDIT_MISC, "&Edit Miscellaneous", "")
        edit_menu.AppendSeparator()
        edit_menu.Append(ID_FREE_FORM_MODE, "&Free form Mode", "")
        edit_menu.Append(ID_LIMIT_SIZE, "&Limit Size", "")
        """

        level_menu = QMenu("Level")

        select_level_action = level_menu.addAction("&Select Level")
        select_level_action.triggered.connect(self.open_level_selector)
        """
        level_menu.Append(ID_GOTO_NEXT_AREA, "&Go to next Area", "")
        level_menu.AppendSeparator()
        """
        self.reload_action = level_menu.addAction("&Reload Level")
        self.reload_action.triggered.connect(self.reload_level)
        level_menu.addSeparator()
        self.edit_header_action = level_menu.addAction("&Edit Header")
        self.edit_header_action.triggered.connect(self.on_header_editor)
        """
        level_menu.Append(ID_EDIT_POINTERS, "&Edit Pointers", "")
        """

        self.menuBar().addMenu(level_menu)

        object_menu = QMenu("Objects")

        view_blocks_action = object_menu.addAction("&View Blocks")
        view_blocks_action.triggered.connect(self.on_block_viewer)
        view_objects_action = object_menu.addAction("&View Objects")
        view_objects_action.triggered.connect(self.on_object_viewer)
        """
        object_menu.AppendSeparator()
        object_menu.Append(ID_CLONE_OBJECT_ENEMY, "&Clone Object/Enemy", "")
        object_menu.AppendSeparator()
        object_menu.Append(ID_ADD_3_BYTE_OBJECT, "&Add 3 Byte Object", "")
        object_menu.Append(ID_ADD_4_BYTE_OBJECT, "&Add 4 Byte Object", "")
        object_menu.Append(ID_ADD_ENEMY, "&Add Enemy", "")
        object_menu.AppendSeparator()
        object_menu.Append(ID_DELETE_OBJECT_ENEMY, "&Delete Object/Enemy", "")
        object_menu.Append(ID_DELETE_ALL, "&Delete All", "")
        """

        self.menuBar().addMenu(object_menu)

        view_menu = QMenu("View")
        view_menu.triggered.connect(self.on_menu)

        action = view_menu.addAction("Mario")
        action.setProperty(ID_PROP, ID_MARIO)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_mario"])

        action = view_menu.addAction("&Jumps on objects")
        action.setProperty(ID_PROP, ID_JUMP_OBJECTS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jump_on_objects"])

        action = view_menu.addAction("Items in blocks")
        action.setProperty(ID_PROP, ID_ITEM_BLOCKS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_items_in_blocks"])

        action = view_menu.addAction("Invisible items")
        action.setProperty(ID_PROP, ID_INVISIBLE_ITEMS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_invisible_items"])

        view_menu.addSeparator()

        action = view_menu.addAction("Jump Zones")
        action.setProperty(ID_PROP, ID_JUMPS)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_jumps"])

        action = view_menu.addAction("&Grid lines")
        action.setProperty(ID_PROP, ID_GRID_LINES)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_grid"])

        action = view_menu.addAction("Resize Type")
        action.setProperty(ID_PROP, ID_RESIZE_TYPE)
        action.setCheckable(True)
        action.setChecked(SETTINGS["draw_expansion"])

        view_menu.addSeparator()

        action = view_menu.addAction("&Block Transparency")
        action.setProperty(ID_PROP, ID_TRANSPARENCY)
        action.setCheckable(True)
        action.setChecked(SETTINGS["block_transparency"])

        view_menu.addSeparator()
        view_menu.addAction("&Save Screenshot of Level").triggered.connect(
            self.on_screenshot)
        """
        view_menu.Append(ID_BACKGROUND_FLOOR, "&Background & Floor", "")
        view_menu.Append(ID_TOOLBAR, "&Toolbar", "")
        view_menu.AppendSeparator()
        view_menu.Append(ID_ZOOM, "&Zoom", "")
        view_menu.AppendSeparator()
        view_menu.Append(ID_USE_ROM_GRAPHICS, "&Use ROM Graphics", "")
        view_menu.Append(ID_PALETTE, "&Palette", "")
        view_menu.AppendSeparator()
        view_menu.Append(ID_MORE, "&More", "")
        """

        self.menuBar().addMenu(view_menu)

        help_menu = QMenu("Help")
        """
        help_menu.Append(ID_ENEMY_COMPATIBILITY, "&Enemy Compatibility", "")
        help_menu.Append(ID_TROUBLESHOOTING, "&Troubleshooting", "")
        help_menu.AppendSeparator()
        help_menu.Append(ID_PROGRAM_WEBSITE, "&Program Website", "")
        help_menu.Append(ID_MAKE_A_DONATION, "&Make a Donation", "")
        help_menu.AppendSeparator()
        """
        update_action = help_menu.addAction("Check for updates")
        update_action.triggered.connect(self.on_check_for_update)

        help_menu.addSeparator()

        video_action = help_menu.addAction("Feature Video on YouTube")
        video_action.triggered.connect(lambda: open_url(feature_video_link))

        discord_action = help_menu.addAction("SMB3 Rom Hacking Discord")
        discord_action.triggered.connect(lambda: open_url(discord_link))

        help_menu.addSeparator()

        about_action = help_menu.addAction("&About")
        about_action.triggered.connect(self.on_about)

        self.menuBar().addMenu(help_menu)

        self.level_selector = LevelSelector(parent=self)

        self.block_viewer = None
        self.object_viewer = None

        self.level_ref = LevelRef()
        self.level_ref.data_changed.connect(self._on_level_data_changed)

        self.context_menu = ContextMenu(self.level_ref)
        self.context_menu.triggered.connect(self.on_menu)

        self.level_view = LevelView(self, self.level_ref, self.context_menu)

        self.scroll_panel = QScrollArea()
        self.scroll_panel.setWidgetResizable(True)
        self.scroll_panel.setWidget(self.level_view)

        self.setCentralWidget(self.scroll_panel)

        self.spinner_panel = SpinnerPanel(self, self.level_ref)
        self.spinner_panel.zoom_in_triggered.connect(self.level_view.zoom_in)
        self.spinner_panel.zoom_out_triggered.connect(self.level_view.zoom_out)
        self.spinner_panel.object_change.connect(self.on_spin)

        self.object_list = ObjectList(self, self.level_ref, self.context_menu)

        self.object_dropdown = ObjectDropdown(self)
        self.object_dropdown.object_selected.connect(
            self._on_placeable_object_selected)

        self.level_size_bar = LevelSizeBar(self, self.level_ref)
        self.enemy_size_bar = EnemySizeBar(self, self.level_ref)

        self.jump_list = JumpList(self, self.level_ref)
        self.jump_list.add_jump.connect(self.on_jump_added)
        self.jump_list.edit_jump.connect(self.on_jump_edit)
        self.jump_list.remove_jump.connect(self.on_jump_removed)

        splitter = QSplitter(self)
        splitter.setOrientation(Qt.Vertical)

        splitter.addWidget(self.object_list)
        splitter.setStretchFactor(0, 1)
        splitter.addWidget(self.jump_list)

        splitter.setChildrenCollapsible(False)

        level_toolbar = QToolBar("Level Info Toolbar", self)
        level_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        level_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        level_toolbar.setOrientation(Qt.Horizontal)
        level_toolbar.setFloatable(False)

        level_toolbar.addWidget(self.spinner_panel)
        level_toolbar.addWidget(self.object_dropdown)
        level_toolbar.addWidget(self.level_size_bar)
        level_toolbar.addWidget(self.enemy_size_bar)
        level_toolbar.addWidget(splitter)

        level_toolbar.setAllowedAreas(Qt.LeftToolBarArea | Qt.RightToolBarArea)

        self.addToolBar(Qt.RightToolBarArea, level_toolbar)

        self.object_toolbar = ObjectToolBar(self)
        self.object_toolbar.object_selected.connect(
            self._on_placeable_object_selected)

        object_toolbar = QToolBar("Object Toolbar", self)
        object_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        object_toolbar.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        object_toolbar.setFloatable(False)

        object_toolbar.addWidget(self.object_toolbar)
        object_toolbar.setAllowedAreas(Qt.LeftToolBarArea
                                       | Qt.RightToolBarArea)

        self.addToolBar(Qt.LeftToolBarArea, object_toolbar)

        menu_toolbar = QToolBar("Menu Toolbar", self)
        menu_toolbar.setOrientation(Qt.Horizontal)
        menu_toolbar.setIconSize(QSize(20, 20))

        menu_toolbar.addAction(
            icon("settings.svg"),
            "Editor Settings").triggered.connect(show_settings)
        menu_toolbar.addSeparator()
        menu_toolbar.addAction(icon("folder.svg"),
                               "Open ROM").triggered.connect(self.on_open_rom)
        menu_toolbar.addAction(
            icon("save.svg"), "Save Level").triggered.connect(self.on_save_rom)
        menu_toolbar.addSeparator()

        self.undo_action = menu_toolbar.addAction(icon("rotate-ccw.svg"),
                                                  "Undo Action")
        self.undo_action.triggered.connect(self.level_ref.undo)
        self.undo_action.setEnabled(False)
        self.redo_action = menu_toolbar.addAction(icon("rotate-cw.svg"),
                                                  "Redo Action")
        self.redo_action.triggered.connect(self.level_ref.redo)
        self.redo_action.setEnabled(False)

        menu_toolbar.addSeparator()
        menu_toolbar.addAction(icon("play-circle.svg"),
                               "Play Level").triggered.connect(self.on_play)
        menu_toolbar.addSeparator()
        menu_toolbar.addAction(icon("zoom-out.svg"),
                               "Zoom Out").triggered.connect(
                                   self.level_view.zoom_out)
        menu_toolbar.addAction(icon("zoom-in.svg"),
                               "Zoom In").triggered.connect(
                                   self.level_view.zoom_in)
        menu_toolbar.addSeparator()
        menu_toolbar.addAction(icon("tool.svg"),
                               "Edit Level Header").triggered.connect(
                                   self.on_header_editor)
        self.jump_destination_action = menu_toolbar.addAction(
            icon("arrow-right-circle.svg"), "Go to Jump Destination")
        self.jump_destination_action.triggered.connect(
            self._go_to_jump_destination)
        menu_toolbar.addSeparator()
        # menu_toolbar.addAction(icon("help-circle.svg"), "What's this?")

        self.addToolBar(Qt.TopToolBarArea, menu_toolbar)

        self.status_bar = ObjectStatusBar(self, self.level_ref)
        self.setStatusBar(self.status_bar)

        self.delete_shortcut = QShortcut(QKeySequence(Qt.Key_Delete), self,
                                         self.remove_selected_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_X), self, self._cut_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_C), self, self._copy_objects)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_V), self, self._paste_objects)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Z), self, self.level_ref.undo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Y), self, self.level_ref.redo)
        QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Z), self,
                  self.level_ref.redo)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Plus), self,
                  self.level_view.zoom_in)
        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Minus), self,
                  self.level_view.zoom_out)

        QShortcut(QKeySequence(Qt.CTRL + Qt.Key_A), self,
                  self.level_view.select_all)

        if not self.on_open_rom(path_to_rom):
            self.deleteLater()

        self.showMaximized()
Exemplo n.º 27
0
    def set_shortcuts(self, parent):
        # Viewer Image Canvas Display On/Off
        toggle_view = QShortcut(QKeySequence(Qt.Key_Tab), parent)
        toggle_view.activated.connect(self.ui.vis_btn.animateClick)
        toggle_view_x = QShortcut(QKeySequence(Qt.Key_X), parent)
        toggle_view_x.activated.connect(self.ui.vis_btn.animateClick)

        # Increase Image Size
        size_hi = QShortcut(QKeySequence(Qt.Key_Plus), parent)
        size_hi.activated.connect(self.viewer.increase_size)
        size_hi_e = QShortcut(QKeySequence(Qt.Key_E), parent)
        size_hi_e.activated.connect(self.viewer.increase_size)
        # Decrease Image Size
        size_lo = QShortcut(QKeySequence(Qt.Key_Minus), parent)
        size_lo.activated.connect(self.viewer.decrease_size)
        size_lo_q = QShortcut(QKeySequence(Qt.Key_Q), parent)
        size_lo_q.activated.connect(self.viewer.decrease_size)

        # Increase Viewer Window Opacity
        opa_hi_w = QShortcut(QKeySequence(Qt.Key_W), parent)
        opa_hi_w.activated.connect(self.viewer.increase_window_opacity)
        opa_hi = QShortcut(QKeySequence('Ctrl++'), parent)
        opa_hi.activated.connect(self.viewer.increase_window_opacity)
        # Decrease Viewer Window Opacity
        opa_lo_s = QShortcut(QKeySequence(Qt.Key_S), parent)
        opa_lo_s.activated.connect(self.viewer.decrease_window_opacity)
        opa_lo = QShortcut(QKeySequence('Ctrl+-'), parent)
        opa_lo.activated.connect(self.viewer.decrease_window_opacity)

        # Load Next Image
        fwd = QShortcut(QKeySequence(Qt.Key_Right), parent)
        fwd.activated.connect(self.ui.fwd_btn.animateClick)
        fwd_d = QShortcut(QKeySequence(Qt.Key_D), parent)
        fwd_d.activated.connect(self.ui.fwd_btn.animateClick)
        # Load Previous Image
        bck = QShortcut(QKeySequence(Qt.Key_Left), parent)
        bck.activated.connect(self.ui.back_btn.animateClick)
        bck_a = QShortcut(QKeySequence(Qt.Key_A), parent)
        bck_a.activated.connect(self.ui.back_btn.animateClick)

        # Send DeltaGen camera data
        cam = QShortcut(QKeySequence(Qt.Key_C), parent)
        cam.activated.connect(self.ui.cam_btn.animateClick)

        # Toggle DeltaGen Viewer Sync
        dg = QShortcut(QKeySequence(Qt.Key_F), parent)
        dg.activated.connect(self.viewer.dg_toggle_sync)

        # Exit
        esc = QShortcut(QKeySequence(Qt.Key_Escape), parent)
        esc.activated.connect(self.viewer.close)
Exemplo n.º 28
0
    def initUI(self):
        """
        Initialize the user interface.

        """
        # Main window
        self.win = QWidget()

        # Figure out the GUI size
        self.AR = float(self.imageReader.width) / self.imageReader.height
        self.win.resize(self.gui_size*1.5, self.gui_size)
        L_main = QGridLayout(self.win)

        # A subwindow on the left for widgets, and a subwindow
        # on the right for the image
        self.win_right = QWidget(self.win)
        self.win_left = QWidget(self.win)
        L_right = QGridLayout(self.win_right)
        L_left = QGridLayout(self.win_left)
        L_main.addWidget(self.win_right, 0, 1, 1, 3)
        L_main.addWidget(self.win_left, 0, 0, 1, 1)

        ## IMAGES / OVERLAYS

        # ImageView, for rendering image
        self.imageView = ImageView(parent=self.win_right)
        L_right.addWidget(self.imageView, 0, 0)

        # ScatterPlotItem, for overlaying localizations
        self.scatterPlotItem = ScatterPlotItem()
        self.scatterPlotItem.setParentItem(self.imageView.imageItem)

        # GraphItem, for overlaying trajectory histories when
        # desired
        self.graphItem = GraphItem()
        self.graphItem.setParentItem(self.imageView.imageItem)

        # # Make spots clickable
        self.lastClicked = []
        self.scatterPlotItem.sigClicked.connect(self.spot_clicked)

        ## WIDGETS
        widget_align = Qt.AlignTop

        # Frame slider
        self.frame_slider = IntSlider(minimum=0, interval=1, 
            maximum=self.imageReader.n_frames-1, init_value=self.start_frame,
            name='Frame', parent=self.win_left)
        L_left.addWidget(self.frame_slider, 0, 0, rowSpan=2, 
            alignment=widget_align)
        self.frame_slider.assign_callback(self.frame_slider_callback)

        # Button to toggle spot overlays
        self.B_overlay_state = True 
        self.B_overlay = QPushButton("Overlay spots", parent=self.win_left)
        self.B_overlay.clicked.connect(self.B_overlay_callback)
        L_left.addWidget(self.B_overlay, 1, 0, alignment=widget_align)

        # Button to toggle trajectory trails
        self.B_overlay_trails_state = False 
        self.B_overlay_trails = QPushButton("Overlay histories", parent=self.win_left)
        self.B_overlay_trails.clicked.connect(self.B_overlay_trails_callback)
        L_left.addWidget(self.B_overlay_trails, 1, 1, alignment=widget_align)
        self.B_overlay_trails.stackUnder(self.B_overlay)

        # Menu to select current overlay symbol
        symbol_options = keys_to_str(symbol_sizes.keys())
        self.M_symbol = LabeledQComboBox(symbol_options, "Overlay symbol",
            init_value="o", parent=self.win_left)
        self.M_symbol.assign_callback(self.M_symbol_callback)
        L_left.addWidget(self.M_symbol, 2, 0, alignment=widget_align)

        # Menu to select how the spots are colored
        color_by_options = ["None", "Trajectory", "Quantitative attribute", "Boolean attribute"]
        self.M_color_by = LabeledQComboBox(color_by_options, 
            "Color spots by", init_value="None", parent=self.win_left)
        self.M_color_by.assign_callback(self.M_color_by_callback)
        L_left.addWidget(self.M_color_by, 3, 0, alignment=widget_align)

        # Create a new binary spot condition
        self.B_create_condition = QPushButton("Create Boolean attribute", 
            parent=self.win_left)
        self.B_create_condition.clicked.connect(self.B_create_condition_callback)
        L_left.addWidget(self.B_create_condition, 4, 0, alignment=widget_align)

        # Select the binary column that determines color when "condition"
        # is selected as the color-by attribute
        condition_options = [c for c in self.locs.columns if self.locs[c].dtype == 'bool']
        self.M_condition = LabeledQComboBox(condition_options, "Boolean attribute",
            init_value="None", parent=self.win_left)
        L_left.addWidget(self.M_condition, 3, 1, alignment=widget_align)
        self.M_condition.assign_callback(self.M_condition_callback)

        # Compare spots in a separate window that shows a grid of spots
        self.B_compare_spots = QPushButton("Compare spots", parent=self)
        L_left.addWidget(self.B_compare_spots, 2, 1, alignment=widget_align)
        self.B_compare_spots.clicked.connect(self.B_compare_spot_callback)

        # Some placeholder widgets, for better formatting
        for j in range(6, 18):
            q = QLabel(parent=self.win_left)
            L_left.addWidget(q, j, 0, alignment=widget_align)


        ## KEYBOARD SHORTCUTS - tab right/left through frames
        self.left_shortcut = QShortcut(QKeySequence(QtGui_Qt.Key_Left), self.win)
        self.right_shortcut = QShortcut(QKeySequence(QtGui_Qt.Key_Right), self.win)
        self.left_shortcut.activated.connect(self.tab_prev_frame)
        self.right_shortcut.activated.connect(self.tab_next_frame)


        ## DISPLAY
        self.update_image(autoRange=True, autoLevels=True, autoHistogramRange=True)
        self.overlay_spots()
        if "trajectory" in self.locs.columns:
            self.M_color_by.setCurrentText("Trajectory")
            self.M_color_by_callback()
        self.win.show()
Exemplo n.º 29
0
    def __init__(self, context=None, parent=None):
        super().__init__(parent)
        context = context or Context()

        self._manager = Manager(context)

        # Build top menu
        self.action_new = QAction("New", self)
        self.action_save = QAction("Save", self)
        self.action_open = QAction("Open", self)
        self.action_save_as = QAction("Save As", self)
        self.action_quit = QAction("Quit", self)
        self.action_show_artists = QAction("Artists", self)
        self.action_show_artists.setCheckable(True)
        self.action_show_artists.setChecked(True)
        self.action_show_tasks = QAction("Tasks", self)
        self.action_show_tasks.setCheckable(True)
        self.action_show_tasks.setChecked(True)
        self.action_show_taskgroups = QAction("Task Groups", self)
        self.action_show_taskgroups.setCheckable(True)
        self.action_show_settings = QAction("Settings", self)
        self.action_show_settings.setCheckable(True)
        self.action_show_scores = QAction("Score", self)
        self.action_show_scores.setCheckable(True)

        self.menubar = QMenuBar(self)
        self.menu_file = QMenu("File", self.menubar)
        self.menu_view = QMenu("View", self.menubar)
        self.menubar.addAction(self.menu_file.menuAction())
        self.menubar.addAction(self.menu_view.menuAction())
        self.menu_file.addAction(self.action_new)
        self.menu_file.addAction(self.action_open)
        self.menu_file.addAction(self.action_save)
        self.menu_file.addAction(self.action_save_as)
        self.menu_file.addSeparator()
        self.menu_view.addAction(self.action_show_artists)
        self.menu_view.addAction(self.action_show_tasks)
        self.menu_view.addAction(self.action_show_taskgroups)
        self.menu_view.addAction(self.action_show_settings)
        self.menu_view.addAction(self.action_show_scores)
        self.setMenuBar(self.menubar)

        # Build dock widgets
        self.widget_artists = ArtistsWidget(self, self._manager)
        self.widget_tasks = TasksWidget(self, self._manager)
        self.widget_settings = SettingsWidget(self, self._manager)
        self.widget_scores = ScoresWidget(self)
        self.widget_tasksgroups = TasksGroupsWidget(self, self._manager,
                                                    self.widget_tasks)
        self.widget_gantt = GanttWidget(
            self,
            self._manager,
            self.widget_artists.model,
            self.widget_tasks.model,
            self.widget_artists.table.selectionModel(),
            self.widget_tasks.table.selectionModel(),
        )
        self.widget_footer = FooterBarWidget(self, self._manager)

        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_artists)
        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_tasks)
        self.addDockWidget(Qt.RightDockWidgetArea, self.widget_tasksgroups)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_gantt)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_scores)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.widget_settings)
        self.addToolBar(Qt.BottomToolBarArea, self.widget_footer)

        # Connect events
        self.widget_footer.actionPlay.connect(self._manager.play)
        self.widget_footer.actionStop.connect(self._manager.stop)
        self.widget_footer.actionLiveModeToggle.connect(
            self.on_autosolve_changed)
        self._manager.onSolutionFound.connect(self.on_solution_found)
        self._manager.onContextChanged.connect(self.on_context_changed)
        self._manager.onDirty.connect(self.on_dirty)
        self.action_new.triggered.connect(self.file_new)
        self.action_open.triggered.connect(self.file_open)
        self.action_save.triggered.connect(self.file_save)
        self.action_save_as.triggered.connect(self.file_save_as)
        self.widget_artists.artistDeleted.connect(self._on_artist_deleted)
        self.widget_tasks.taskDeleted.connect(self._on_task_deleted)

        for action, widget in (
            (self.action_show_artists, self.widget_artists),
            (self.action_show_tasks, self.widget_tasks),
            (self.action_show_taskgroups, self.widget_tasksgroups),
            (self.action_show_settings, self.widget_settings),
            (self.action_show_scores, self.widget_scores),
        ):
            widget.setVisible(action.isChecked())
            action.toggled.connect(widget.setVisible)

        self.shortcut = QShortcut(QKeySequence("Space"), self)
        self.shortcut.activated.connect(self._manager.toogle)

        self._manager.restore_autosave()
        self._update_window_title()
Exemplo n.º 30
0
    def __init__(self, ui):
        super(Widget, self).__init__()

        self.ui = ui
        self.directory = QDir.currentPath()
        self.file_name = ""

        self.pixmap = None

        self.num_columns = 5
        self.num_colours = 8
        self.ladder_threshold = 5
        self.sample_threshold = 3

        self.ladder_bands = 0
        self.coords = []
        self.calibration_values = []
        self.results = []

        QObject.connect(ui.selectFile, SIGNAL('clicked()'), self.select_file)
        QObject.connect(ui.loadImage, SIGNAL('clicked()'), self.load_image)
        QObject.connect(ui.saveImage, SIGNAL('clicked()'), self.save_image)
        QObject.connect(ui.sendEmail, SIGNAL('clicked()'), self.show_dialog)

        self.ui.columns.setMinimum(2)
        self.ui.columns.setValue(self.num_columns)
        self.ui.colours.setMinimum(4)
        self.ui.colours.setValue(self.num_colours)
        self.ui.ladderThreshold.setMinimum(1)
        self.ui.ladderThreshold.setMaximum(self.num_colours)
        self.ui.ladderThreshold.setValue(self.ladder_threshold)
        self.ui.sampleThreshold.setMinimum(1)
        self.ui.sampleThreshold.setMaximum(self.num_colours)
        self.ui.sampleThreshold.setValue(self.sample_threshold)

        QObject.connect(self.ui.columns, SIGNAL('valueChanged(int)'),
                        self.set_columns)
        QObject.connect(self.ui.colours, SIGNAL('valueChanged(int)'),
                        self.set_colours)
        QObject.connect(self.ui.ladderThreshold, SIGNAL('valueChanged(int)'),
                        self.set_ladder_threshold)
        QObject.connect(self.ui.sampleThreshold, SIGNAL('valueChanged(int)'),
                        self.set_sample_threshold)

        self.ui.calibrationText.setText("No ladder bands detected.")

        self.model = ResultsModel()
        self.ui.results.setModel(self.model)
        self.ui.results.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.ui.results.show()

        QObject.connect(self.ui.findContours, SIGNAL('clicked()'),
                        self.find_contours)
        QObject.connect(self.ui.findContours, SIGNAL('clicked()'),
                        self.update_calibration_text)
        QObject.connect(self.ui.calibrate, SIGNAL('clicked()'),
                        self.parse_calibration_base_pairs)

        ui_file = QFile(os.path.join(os.getcwd(), 'src', 'dialog.ui'))
        ui_file.open(QFile.ReadOnly)
        loader = QUiLoader()
        ui = loader.load(ui_file)
        ui_file.close()

        self.dialog = Dialog(ui)
        QObject.connect(self.dialog.ui, SIGNAL('accepted()'), self.send_email)

        quit_shortcut = QShortcut(QKeySequence.Quit, self.ui)
        close_shortcut = QShortcut(QKeySequence.Close, self.ui)
        QObject.connect(quit_shortcut, SIGNAL('activated()'), self.ui.close)
        QObject.connect(close_shortcut, SIGNAL('activated()'), self.ui.close)

        if include_camera:
            QObject.connect(self.ui.takePicture, SIGNAL('clicked()'),
                            self.take_picture)
            self.ui.whiteBalance.addItems(camera.MODES)
            QObject.connect(self.ui.whiteBalance,
                            SIGNAL('currentIndexChanged(int)'),
                            self.select_white_balance)