예제 #1
0
    def __init__(self, qapp, name, parentWinName=None):
        super(MainWindow, self).__init__()

        self.qapp = qapp
        self.name = name

        self.panels = qapp.panels
        self.dragState = DragState.placed
        self.qapp.panels.ezm

        if not parentWinName is None:
            self.setParent(self.qapp.windows[parentWinName])
            self.setWindowFlags(self.windowFlags() | Qt.Tool)
            #self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)

        self.container = self.qapp.panels.ezm.new_container(self, self.name)
        self.setCentralWidget(self.container)

        self.setWindowTitle(f'[{self.name}]')

        self.createMenus()
        self.createStatusBar()

        #Hiding panelsDialog will disable all shortcuts
        sc = QShortcut(
            QKeySequence("Ctrl+Shift+Alt+F12"), self, lambda: self.qapp.
            panelsDialog.setVisible(not self.qapp.panelsDialog.isVisible()))
        sc.setContext(Qt.ApplicationShortcut)

        self.moveQueued.connect(self.moveWindow, Qt.QueuedConnection)

        self.activeCategory = None
        self.activePanId = None
        self.priorHoverButton = None
예제 #2
0
    def __init__(self, parent, term_url='http://127.0.0.1:8070'):
        """Webview main constructor."""
        WebView.__init__(self, parent)
        self.parent = parent
        self.copy_action = create_action(self,
                                         _("Copy text"),
                                         icon=ima.icon('editcopy'),
                                         triggered=self.copy,
                                         shortcut='Ctrl+Alt+C')
        self.paste_action = create_action(self,
                                          _("Paste text"),
                                          icon=ima.icon('editpaste'),
                                          triggered=self.paste,
                                          shortcut='Ctrl+Alt+V')
        self.term_url = QUrl(term_url)
        self.load(self.term_url)
        copy_shortcut = QShortcut(QKeySequence("Ctrl+Alt+C"), self, self.copy)
        copy_shortcut.setContext(Qt.WidgetWithChildrenShortcut)

        paste_shortcut = QShortcut(QKeySequence("Ctrl+Alt+V"), self,
                                   self.paste)
        paste_shortcut.setContext(Qt.WidgetWithChildrenShortcut)

        if WEBENGINE:
            self.document = self.page()
        else:
            self.document = self.page().mainFrame()

        self.initial_y_pos = 0
예제 #3
0
def fixed_shortcut(keystr, parent, action):
    """
    DEPRECATED: This function will be removed in Spyder 4.0

    Define a fixed shortcut according to a keysequence string
    """
    sc = QShortcut(QKeySequence(keystr), parent, action)
    sc.setContext(Qt.WidgetWithChildrenShortcut)
    return sc
예제 #4
0
파일: gui.py 프로젝트: cfanpc/spyder
def fixed_shortcut(keystr, parent, action):
    """
    DEPRECATED: This function will be removed in Spyder 4.0

    Define a fixed shortcut according to a keysequence string
    """
    sc = QShortcut(QKeySequence(keystr), parent, action)
    sc.setContext(Qt.WidgetWithChildrenShortcut)
    return sc
예제 #5
0
    def __init__(self, parent):
        """Widget constructor."""
        SpyderPluginWidget.__init__(self, parent)
        self.tab_widget = None
        self.menu_actions = None
        self.port = select_port(default_port=8070)
        self.server = subprocess.Popen([
            sys.executable,
            osp.join(LOCATION, 'server', 'main.py'), '--port',
            str(self.port)
        ],
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
        time.sleep(0.5)
        self.main = parent

        self.terms = []
        self.untitled_num = 0
        self.initialize_plugin()

        layout = QVBoxLayout()
        new_term_btn = create_toolbutton(self,
                                         icon=ima.icon('project_expanded'),
                                         tip=_('Open a new terminal'),
                                         triggered=self.create_new_term)
        menu_btn = create_toolbutton(self,
                                     icon=ima.icon('tooloptions'),
                                     tip=_('Options'))
        self.menu = QMenu(self)
        menu_btn.setMenu(self.menu)
        menu_btn.setPopupMode(menu_btn.InstantPopup)
        add_actions(self.menu, self.menu_actions)
        # if self.get_option('first_time', True):
        # self.setup_shortcuts()
        # self.shortcuts = self.create_shortcuts()
        corner_widgets = {Qt.TopRightCorner: [new_term_btn, menu_btn]}
        self.tabwidget = Tabs(self,
                              menu=self.menu,
                              actions=self.menu_actions,
                              corner_widgets=corner_widgets)
        if hasattr(self.tabwidget, 'setDocumentMode') \
           and not sys.platform == 'darwin':
            # Don't set document mode to true on OSX because it generates
            # a crash when the console is detached from the main window
            # Fixes Issue 561
            self.tabwidget.setDocumentMode(True)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)

        self.tabwidget.set_close_function(self.close_term)

        layout.addWidget(self.tabwidget)
        self.setLayout(layout)

        paste_shortcut = QShortcut(QKeySequence("Ctrl+Shift+T"), self,
                                   self.create_new_term)
        paste_shortcut.setContext(Qt.WidgetWithChildrenShortcut)
예제 #6
0
def _config_shortcut(action, context, name, keystr, parent):
    """
    Create a Shortcut namedtuple for a widget.

    The data contained in this tuple will be registered in our shortcuts
    preferences page.
    """
    qsc = QShortcut(QKeySequence(keystr), parent, action)
    qsc.setContext(Qt.WidgetWithChildrenShortcut)
    sc = Shortcut(data=(qsc, context, name))
    return sc
예제 #7
0
파일: gui.py 프로젝트: cfanpc/spyder
def config_shortcut(action, context, name, parent):
    """
    Create a Shortcut namedtuple for a widget
    
    The data contained in this tuple will be registered in
    our shortcuts preferences page
    """
    keystr = get_shortcut(context, name)
    qsc = QShortcut(QKeySequence(keystr), parent, action)
    qsc.setContext(Qt.WidgetWithChildrenShortcut)
    sc = Shortcut(data=(qsc, context, name))
    return sc
예제 #8
0
 def register_plugin(self):
     """Register plugin in Spyder's main window."""
     try:
         # Spyder 3 compatibility
         super(Vim, self).register_plugin()
     except NotImplementedError:
         pass
     self.focus_changed.connect(self.main.plugin_focus_changed)
     self.vim_cmd.editor_widget.layout().addWidget(self.vim_cmd)
     sc = QShortcut(QKeySequence("Esc"),
                    self.vim_cmd.editor_widget.editorsplitter,
                    self.vim_cmd.commandline.setFocus)
     sc.setContext(Qt.WidgetWithChildrenShortcut)
예제 #9
0
    def __init__(self, main_window, shortcut):
        self.shortcut = shortcut
        self.main_window = main_window
        shortcut_ = QShortcut(self.shortcut, main_window)
        shortcut_.setContext(Qt.ApplicationShortcut)

        def ShowStyleSheetEditor():
            style_sheet_inspector_class = GetStyleSheetInspectorClass()
            style_sheet_inspector = [
                c for c in self.main_window.children()
                if isinstance(c, style_sheet_inspector_class)
            ]
            if style_sheet_inspector:
                style_sheet_inspector = style_sheet_inspector[0]
            else:
                style_sheet_inspector = style_sheet_inspector_class(
                    self.main_window)
                style_sheet_inspector.setFixedSize(600, 400)
            style_sheet_inspector.show()

        shortcut_.activated.connect(ShowStyleSheetEditor)
예제 #10
0
    def __init__(self, parent):
        """Widget constructor."""
        SpyderPluginWidget.__init__(self, parent)
        self.tab_widget = None
        self.menu_actions = None
        self.server_retries = 0
        self.server_ready = False
        self.port = select_port(default_port=8071)

        self.cmd = 'bash'
        if WINDOWS:
            self.cmd = 'cmd'

        self.server_stdout = subprocess.PIPE
        self.server_stderr = subprocess.PIPE
        self.stdout_file = osp.join(getcwd(), 'spyder_terminal_out.log')
        self.stderr_file = osp.join(getcwd(), 'spyder_terminal_err.log')
        if DEV:
            self.server_stdout = open(self.stdout_file, 'w')
            self.server_stderr = open(self.stderr_file, 'w')

        self.server = subprocess.Popen(
            [sys.executable, '-m', 'spyder_terminal.server',
             '--port', str(self.port), '--shell', self.cmd],
            stdout=self.server_stdout,
            stderr=self.server_stderr)

        self.main = parent

        self.terms = []
        self.untitled_num = 0

        self.project_path = None
        self.current_file_path = None
        self.current_cwd = getcwd()

        self.initialize_plugin()

        layout = QVBoxLayout()
        new_term_btn = create_toolbutton(self,
                                         icon=ima.icon('project_expanded'),
                                         tip=_('Open a new terminal'),
                                         triggered=self.create_new_term)
        menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'),
                                     tip=_('Options'))
        self.menu = QMenu(self)
        menu_btn.setMenu(self.menu)
        menu_btn.setPopupMode(menu_btn.InstantPopup)
        add_actions(self.menu, self.menu_actions)
        # if self.get_option('first_time', True):
        # self.setup_shortcuts()
        # self.shortcuts = self.create_shortcuts()
        corner_widgets = {Qt.TopRightCorner: [new_term_btn, menu_btn]}
        self.tabwidget = Tabs(self, menu=self.menu, actions=self.menu_actions,
                              corner_widgets=corner_widgets, rename_tabs=True)

        if hasattr(self.tabwidget, 'setDocumentMode') \
           and not sys.platform == 'darwin':
            # Don't set document mode to true on OSX because it generates
            # a crash when the console is detached from the main window
            # Fixes Issue 561
            self.tabwidget.setDocumentMode(True)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)

        self.tabwidget.set_close_function(self.close_term)

        layout.addWidget(self.tabwidget)
        self.setLayout(layout)

        new_term_shortcut = QShortcut(QKeySequence("Ctrl+Alt+Shift+T"),
                                      self, self.create_new_term)
        new_term_shortcut.setContext(Qt.WidgetWithChildrenShortcut)

        self.__wait_server_to_start()
예제 #11
0
def fixed_shortcut(keystr, parent, action):
    """Define a fixed shortcut according to a keysequence string"""
    sc = QShortcut(QKeySequence(keystr), parent, action)
    sc.setContext(Qt.WidgetWithChildrenShortcut)
    return sc
예제 #12
0
파일: gui.py 프로젝트: ChunHungLiu/spyder
def new_shortcut(keystr, parent, action):
    """Define a new shortcut according to a keysequence string"""
    sc = QShortcut(QKeySequence(keystr), parent, action)
    sc.setContext(Qt.WidgetWithChildrenShortcut)
    return sc
예제 #13
0
    def __init__(self, parent):
        """Widget constructor."""
        SpyderPluginWidget.__init__(self, parent)
        self.tab_widget = None
        self.menu_actions = None
        self.server_retries = 0
        self.server_ready = False
        self.port = select_port(default_port=8071)

        self.cmd = find_program(self.get_option('shell'))
        self.CONF = CONF
        self.server_stdout = subprocess.PIPE
        self.server_stderr = subprocess.PIPE
        self.stdout_file = osp.join(getcwd(), 'spyder_terminal_out.log')
        self.stderr_file = osp.join(getcwd(), 'spyder_terminal_err.log')
        if DEV:
            self.server_stdout = open(self.stdout_file, 'w')
            self.server_stderr = open(self.stderr_file, 'w')
        self.server = subprocess.Popen([
            sys.executable, '-m', 'spyder_terminal.server', '--port',
            str(self.port), '--shell', self.cmd
        ],
                                       stdout=self.server_stdout,
                                       stderr=self.server_stderr)

        self.main = parent

        self.terms = []
        self.untitled_num = 0

        self.project_path = None
        self.current_file_path = None
        self.current_cwd = getcwd()

        try:
            # Spyder 3
            self.initialize_plugin()
        except AttributeError:
            # Spyder 4
            pass

        layout = QVBoxLayout()
        new_term_btn = create_toolbutton(self,
                                         icon=ima.icon('expand_selection'),
                                         tip=_('Open a new terminal'),
                                         triggered=self.create_new_term)

        corner_widgets = {
            Qt.TopRightCorner: [new_term_btn, self.options_button]
        }
        self.tabwidget = Tabs(self,
                              menu=self._options_menu,
                              actions=self.menu_actions,
                              corner_widgets=corner_widgets,
                              rename_tabs=True)

        if hasattr(self.tabwidget, 'setDocumentMode') \
           and not sys.platform == 'darwin':
            # Don't set document mode to true on OSX because it generates
            # a crash when the console is detached from the main window
            # Fixes Issue 561
            self.tabwidget.setDocumentMode(True)
        self.tabwidget.currentChanged.connect(self.refresh_plugin)
        self.tabwidget.move_data.connect(self.move_tab)

        self.tabwidget.set_close_function(self.close_term)

        layout.addWidget(self.tabwidget)
        self.setLayout(layout)

        new_term_shortcut = QShortcut(
            CONF.get_shortcut(CONF_SECTION, 'new_term'), self,
            self.create_new_term)
        new_term_shortcut.setContext(Qt.WidgetWithChildrenShortcut)

        self.color_scheme = CONF.get('appearance', 'ui_theme')
        self.theme = CONF.get('appearance', 'selected')

        self.__wait_server_to_start()
예제 #14
0
 def on_initialize(self):
     """."""
     sc = QShortcut(QKeySequence("Esc"),
                    self.vim_cmd.editor_widget.editorsplitter,
                    self.vim_cmd.commandline.setFocus)
     sc.setContext(Qt.WidgetWithChildrenShortcut)
예제 #15
0
 def setShortCut(self, keySequence, func):
     sc = QShortcut(QKeySequence(keySequence), self.panelsDialog, func)
     sc.setContext(Qt.ApplicationShortcut)