Python PyQt4.QtGui 模块,QShortcut() 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用PyQt4.QtGui.QShortcut()

项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def init_shortcuts (self):
        """Configure application shortcuts."""
        def selectUrl():
            """Highlight URL input textbox."""
            self.urlinput.setFocus()
            self.urlinput.selectAll()
        shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+L"), self)
        shortcut.activated.connect(selectUrl)
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, parent ,curveList,plot):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.connect(QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Escape), self), QtCore.SIGNAL('activated()'), self.close)
        self.connect(QtGui.QShortcut(QtGui.QKeySequence(plotSave._translate("MainWindow", "Ctrl+P", None)), self), QtCore.SIGNAL('activated()'), self.printImage)
        self.connect(QtGui.QShortcut(QtGui.QKeySequence(plotSave._translate("MainWindow", "Ctrl+C", None)), self), QtCore.SIGNAL('activated()'), self.copyToClipboard)

        self.table.setColumnWidth(0,200)
        colnum=0;labels=[]
        self.maxRows=0
        self.maxCols=0
        for a in curveList:
            x,y = a.getData()
            name = a.name()
            if x!=None and y!=None:
                self.setColumn(colnum,x);colnum+=1
                self.setColumn(colnum,y);colnum+=1
                labels.append('%s(X)'%(name));labels.append('%s(Y)'%(name));
        self.table.setHorizontalHeaderLabels(labels)        

        self.plot = plot
        if plot:
            self.imageWidthBox.setEnabled(True)
            self.saveImageButton.setEnabled(True)
            self.imageWidthBox.setValue(self.plot.plotItem.width())
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def __init__(self, scene, zoom=.8):
        QtGui.QGraphicsView.__init__(self, scene)
        self.zoom = zoom
        QtGui.QShortcut(QtGui.QKeySequence('pgdown'), self, self.zoomIn)
        QtGui.QShortcut(QtGui.QKeySequence('pgup'), self, self.zoomOut)
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl++'), self, self.zoomIn)
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl+-'), self, self.zoomOut)
    #     self.scene = scene
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self._drag_start = None
        self.setMouseTracking(True)

        self._shown = set()
        self._show_places = set(xrange(1, 10))
        self._station_to_move = None
        self._move_station = False
        self._move_grid = False
        self._grid_start = None
        self._grid_line = None
        self._grid_coord = None
        self.ruler_items = []
        self.legend_items = []
        self.legend_pos = None
        self.trace_items = []

#        QtGui.QShortcut(QtGui.QKeySequence('t'), self, self.toggleTotal)
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def initUI(self):
        self.grid = QtGui.QGridLayout()
        self.checkbox = []
        i = 0
        bold = QtGui.QFont()
        bold.setBold(True)
        for plot in range(len(self.plot_order)):
            if self.plot_order[plot] in self.spacers:
                label = QtGui.QLabel(self.spacers[self.plot_order[plot]])
                label.setFont(bold)
                self.grid.addWidget(label, i, 0)
                i += 1
            self.checkbox.append(QtGui.QCheckBox(self.hdrs[self.plot_order[plot]], self))
            if self.plots[self.plot_order[plot]]:
                self.checkbox[plot].setCheckState(QtCore.Qt.Checked)
            self.grid.addWidget(self.checkbox[-1], i, 0)
            i += 1
        self.grid.connect(self.checkbox[0], QtCore.SIGNAL('stateChanged(int)'), self.check_all)
        show = QtGui.QPushButton('Proceed', self)
        show.clicked.connect(self.showClicked)
        self.grid.addWidget(show, i, 0)
        frame = QtGui.QFrame()
        frame.setLayout(self.grid)
        self.scroll = QtGui.QScrollArea()
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(frame)
        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.scroll)
        commnt = QtGui.QLabel('Nearest weather files:\n' + self.comment)
        self.layout.addWidget(commnt)
        self.setWindowTitle('SIREN - Weather dialog for ' + str(self.base_year))
        QtGui.QShortcut(QtGui.QKeySequence('q'), self, self.quitClicked)
        self.show_them = False
        self.show()
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def initUI(self):
        self.chosen = []
        self.grid = QtGui.QGridLayout()
        self.checkbox = []
        self.checkbox.append(QtGui.QCheckBox('Check / Uncheck all', self))
        self.grid.addWidget(self.checkbox[-1], 0, 0)
        i = 0
        c = 0
        icons = Icons()
        for stn in sorted(self.stations, key=lambda station: station.name):
            if stn.technology[:6] == 'Fossil' and not self.actual:
                continue
            if stn.technology == 'Rooftop PV' and stn.scenario == 'Existing' and not self.gross_load:
                continue
            self.checkbox.append(QtGui.QCheckBox(stn.name, self))
            icon = icons.getIcon(stn.technology)
            if icon != '':
                self.checkbox[-1].setIcon(QtGui.QIcon(icon))
            i += 1
            self.grid.addWidget(self.checkbox[-1], i, c)
            if i > 25:
                i = 0
                c += 1
        self.grid.connect(self.checkbox[0], QtCore.SIGNAL('stateChanged(int)'), self.check_all)
        show = QtGui.QPushButton('Choose', self)
        self.grid.addWidget(show, i + 1, c)
        show.clicked.connect(self.showClicked)
        self.setLayout(self.grid)
        self.setWindowTitle('SIREN - Power Stations dialog')
        QtGui.QShortcut(QtGui.QKeySequence('q'), self, self.quitClicked)
        self.show_them = False
        self.show()
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def __init__(self, scene, zoom=.8):
        QtGui.QGraphicsView.__init__(self, scene)
        self.zoom = zoom
        QtGui.QShortcut(QtGui.QKeySequence('pgdown'), self, self.zoomIn)
        QtGui.QShortcut(QtGui.QKeySequence('pgup'), self, self.zoomOut)
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl++'), self, self.zoomIn)
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl+-'), self, self.zoomOut)
        self._rectangle = None
        self._drag_start = None
        self.setMouseTracking(True)
        self.ruler_items = []
        self.legend_items = []
        self.legend_pos = None
        self.rect_items = []
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self,parent=None):
        QtGui.QTableWidget.__init__(self,parent)
        # initially construct the visible table
        self.setRowCount(512)
        self.setColumnCount(2)
        # set the shortcut ctrl+v for paste
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl+v'),self).activated.connect(self._handlePaste)

    # paste the value
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self,parent=None):
        QtGui.QTableWidget.__init__(self,parent)
        # initially construct the visible table
        self.setRowCount(512)
        self.setColumnCount(2)
        # set the shortcut ctrl+v for paste
        QtGui.QShortcut(QtGui.QKeySequence('Ctrl+v'),self).activated.connect(self._handlePaste)
        self.setHorizontalHeaderLabels(['State','Time(uS)'])

        self.setTextElideMode(QtCore.Qt.ElideRight)
        self.setGridStyle(QtCore.Qt.DashLine)
        self.setRowCount(200)
        self.setColumnCount(2)
        self.horizontalHeader().setDefaultSectionSize(70)
        self.horizontalHeader().setMinimumSectionSize(70)
        self.horizontalHeader().setSortIndicatorShown(False)
        self.horizontalHeader().setStretchLastSection(True)
        self.verticalHeader().setStretchLastSection(True)

        for a in range(200):
            item =self.item(a,1)
            if item==None:
                item = QtGui.QTableWidgetItem()
                self.setItem(a,0,item)
            item.setText(['ON','OFF'][a%2])

    # paste the value
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def enableShortcuts(self):
        """
        Enable the following shortcuts :

        * CTRL-S : Opens the saveData window for saving trace data . It will load the coordinate data from all curves created using :func:`addCurve`

        """

        self.saveSignal = QtGui.QShortcut(QtGui.QKeySequence(QtCore.QCoreApplication.translate("MainWindow", "Ctrl+S", None)), self)
        self.saveSignal.activated.connect(self.saveData)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def qui_key(self, key_name, key_combo, func):
        self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
        self.hotkey[key_name].activated.connect( func )
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)


    # ---- user response list ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ----
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def initUI(self):
        fields = []
        label = []
        self.edit = []
        self.field_type = []
        metrics = []
        widths = [0, 0]
        heights = 0
        i = -1
        grid = QtGui.QGridLayout()
        self.web = QtGui.QTextEdit()
        if os.path.exists(self.anobject):
            htf = open(self.anobject, 'r')
            html = htf.read()
            htf.close()
            self.web.setHtml(QtCore.QString(html))
        else:
            html = self.anobject
            if self.anobject[:5] == '<html':
                self.anobject = self.anobject.replace('[VERSION]', credits.fileVersion())
                self.web.setHtml(QtCore.QString(self.anobject))
            else:
                self.web.setPlainText(QtCore.QString(self.anobject))
        metrics.append(self.web.fontMetrics())
        try:
            widths[0] = metrics[0].boundingRect(self.web.text()).width()
            heights = metrics[0].boundingRect(self.web.text()).height()
        except:
            bits = html.split('\n')
            for lin in bits:
                if len(lin) > widths[0]:
                    widths[0] = len(lin)
            heights = len(bits)
            fnt = self.web.fontMetrics()
            widths[0] = (widths[0]) * fnt.maxWidth()
            heights = (heights) * fnt.height()
            screen = QtGui.QDesktopWidget().availableGeometry()
            if widths[0] > screen.width() * .67:
                heights = int(heights / .67)
                widths[0] = int(screen.width() * .67)
        self.web.setReadOnly(True)
        i = 1
        grid.addWidget(self.web, 0, 0)
        self.set_stuff(grid, widths, heights, i)
        QtGui.QShortcut(QtGui.QKeySequence('q'), self, self.quitClicked)