default close window key combo

180 views
Skip to first unread message

john lunzer

unread,
Feb 18, 2015, 11:29:24 AM2/18/15
to pyqt...@googlegroups.com
I always thought it was odd that pyqtgraph didn't have any default behavior to close its plot windows. I wrote a support function so I didn't have to add the code to every program I write.

def add_close(window=None):
    '''
    adds close keyboard short for any of the following: \n
    Ctrl+w \n
    Ctrl+F4 \n
    Ctrl+q \n
    \n
    `(for PyQtGraph)`    
    '''
    import pyqtgraph as pg

    if window == None:
        pass
    else:
        #Create close shortcut
        cl_keyseq = pg.QtGui.QKeySequence("Ctrl+w")
        cl_short = pg.QtGui.QShortcut(cl_keyseq,window,window.close)
        
        cl_keyseq_alt = pg.QtGui.QKeySequence("Ctrl+F4")
        cl_short_alt = pg.QtGui.QShortcut(cl_keyseq_alt,window,window.close)
        
        cl_keyseq_alt2 = pg.QtGui.QKeySequence("Ctrl+q")
        cl_short_alt2 = pg.QtGui.QShortcut(cl_keyseq_alt2,window,window.close)
    return

Is there a better way to do this? Or perhaps someway to get it built into pyqtgraph?

Luke Campagnola

unread,
Feb 18, 2015, 11:50:26 AM2/18/15
to pyqt...@googlegroups.com
I would be in favor of adding a single keyboard shortcut (ctrl+w) to the classes in `pyqtgraph/graphicsWindows.py`. You could assign the shortcut in the `__init__()` methods and use a global config parameter to allow the user to change or disable the shortcut (see CONFIG_OPTIONS in pyqtgraph/__init__.py). Would you like to make a PR for this?

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/21cce40a-bbcf-4e49-8e98-4451319762db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

john lunzer

unread,
Feb 18, 2015, 1:56:02 PM2/18/15
to pyqt...@googlegroups.com
I would like to. I'll need to find some time to make the change myself.
Reply all
Reply to author
Forward
0 new messages