added convenience shortcut creation
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import QWidget, QLineEdit, QPushButton, QHBoxLayout, QStyle, QShortcut
|
||||
from PyQt5.QtWidgets import QWidget, QLineEdit, QPushButton, QHBoxLayout, QStyle
|
||||
|
||||
from ..shortcut import shortcut
|
||||
|
||||
|
||||
class SearchBox(QWidget):
|
||||
@ -28,8 +29,7 @@ class SearchBox(QWidget):
|
||||
btn.clicked.connect(self.txt.clear)
|
||||
|
||||
#TODO: where should this go? probably top level MainWindow...
|
||||
shortcut = QShortcut(QKeySequence("Ctrl+F"), self)
|
||||
shortcut.activated.connect(txt.setFocus)
|
||||
shortcut(self, "Ctrl+F", txt.setFocus)
|
||||
|
||||
|
||||
# behave like encapsulated QLineEdit
|
||||
|
@ -1,6 +1,5 @@
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import QMainWindow, QSplitter, QShortcut
|
||||
from PyQt5.QtWidgets import QMainWindow, QSplitter
|
||||
|
||||
from . import assets
|
||||
from .dictlist import DictList
|
||||
@ -8,6 +7,7 @@ from .mdi import MDIArea, MDISubPlot, MDISubMultiPlot
|
||||
from .rpc import RPCServerThread
|
||||
from .plotdesc import PlotDescription
|
||||
from .menus import BarMenu
|
||||
from .shortcut import shortcut
|
||||
from .exampledata import exampledata
|
||||
|
||||
|
||||
@ -29,8 +29,7 @@ class MainWindow(QMainWindow):
|
||||
lst_menu.addSeparator()
|
||||
lst_menu.addAction("Plot selected", self.on_plot_selected)
|
||||
|
||||
plot_shortcut = QShortcut(QKeySequence("Ctrl+P"), self)
|
||||
plot_shortcut.activated.connect(self.on_plot_selected)
|
||||
shortcut(self, "Ctrl+P", self.on_plot_selected)
|
||||
|
||||
bar = self.menuBar()
|
||||
|
||||
|
12
grum/shortcut.py
Normal file
12
grum/shortcut.py
Normal file
@ -0,0 +1,12 @@
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import QShortcut
|
||||
|
||||
|
||||
def shortcut(parent, key_sequence, triggered):
|
||||
key_sequence = QKeySequence(key_sequence)
|
||||
shortcut = QShortcut(key_sequence, parent)
|
||||
shortcut.activated.connect(triggered)
|
||||
return shortcut
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user