本文整理汇总了Python中PyQt4.QtCore.QSignalMapper类的典型用法代码示例。如果您正苦于以下问题:Python QSignalMapper类的具体用法?Python QSignalMapper怎么用?Python QSignalMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSignalMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LEDDialog
class LEDDialog(QDialog):
rowwidth = 20
def __init__(self, strip, parent=None):
super(LEDDialog,self).__init__(parent)
self.strip = strip
self.buttons = []
layout = QVBoxLayout()
btnlayout = QGridLayout()
self.btnmapper = QSignalMapper()
for i in xrange(int(self.strip.config['nleds'])):
p = QPushButton()
p.setFixedWidth(40)
p.setFlat(True)
p.setAutoFillBackground(True)
self.btnmapper.setMapping( p, i)
p.clicked.connect( self.btnmapper.map)
self.buttons += [[p,QColor()]]
btnlayout.addWidget(p, i/self.rowwidth, i%self.rowwidth)
self.btnmapper.mapped['int'].connect(self.chooseColor)
layout.addLayout(btnlayout)
ctrllayout = QHBoxLayout()
p = QPushButton("Refresh")
p.clicked.connect(self.refresh)
ctrllayout.addWidget(p)
p = QPushButton("Set")
p.clicked.connect(self.set)
ctrllayout.addWidget(p)
p = QPushButton("Close")
p.clicked.connect(self.close)
ctrllayout.addWidget(p)
layout.addLayout(ctrllayout)
self.setLayout( layout)
self.refresh()
def refresh(self):
tmp = self.strip.state()
for i in xrange(len(self.buttons)):
c = QColor(int(tmp[i*3+0]),int(tmp[i*3+1]),int(tmp[i*3+2]))
pal = self.buttons[i][0].palette()
pal.setBrush( QPalette.Button, QColor(c.red(),c.green(),c.blue()))
self.buttons[i][0].setPalette(pal)
self.buttons[i][1] = c
def set(self):
leds = []
for b,c in self.buttons:
leds += [ c.red(), c.green(), c.blue() ]
self.strip.setState(leds)
time.sleep(0.1)
self.refresh()
def chooseColor(self, i):
if not i < len(self.buttons): return
initial = self.buttons[i][1]
c = QColorDialog.getColor(initial,self)
if initial == c: return
pal = self.buttons[i][0].palette()
pal.setBrush( QPalette.Button, QColor(c.red(),c.green(),c.blue()))
self.buttons[i][0].setPalette(pal)
self.buttons[i][1] = c
示例2: ProviderToolBar
class ProviderToolBar(QToolBar):
'''
Widget to display the vehicles/objects status and position
'''
triggered = pyqtSignal(str)
def __init__(self, parent=None):
super(ProviderToolBar, self).__init__(parent)
self.signalMapper = QSignalMapper(self)
self.setMovable(True)
self.setFloatable(True)
self.upToDate = False
self.actions = []
self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
self.signalMapper.mapped[str].connect(self.triggered)
def createAction(self, provider):
icon = QIcon(':/plugins/PosiView/ledgreen.png')
icon.addFile(':/plugins/PosiView/ledgrey.png', QSize(), QIcon.Disabled, QIcon.Off)
action = QAction(icon, provider.name, None)
button = QToolButton()
button.setDefaultAction(action)
action.setEnabled(False)
provider.deviceConnected.connect(action.setEnabled)
provider.deviceDisconnected.connect(action.setDisabled)
self.signalMapper.setMapping(action, provider.name)
action.triggered.connect(self.signalMapper.map)
self.addAction(action)
self.actions.append(action)
示例3: contextMenuEvent
def contextMenuEvent(self, event):
menu = QtGui.QMenu()
last_pos = event.pos()
cursor = self.cursorForPosition(last_pos)
pos = cursor.positionInBlock()
line = cursor.blockNumber()
keywords = self.words_at_pos(line, pos)
if len(keywords) > 0:
keyword_mapper = QSignalMapper(self)
actions = []
for keyword in keywords:
action_text = "Copy \"%s\"" % keyword[0].meaning
actions.append(QtGui.QAction(action_text, None))
# We can only send strings with the signal mapper, so pickle our data.
data = pickle.dumps(keyword[0])
data = QtCore.QString.fromAscii(data)
self.connect(actions[-1], QtCore.SIGNAL("triggered()"), keyword_mapper, QtCore.SLOT("map()"))
keyword_mapper.setMapping(actions[-1], data)
self.connect(keyword_mapper, QtCore.SIGNAL("mapped(QString)"), self.copy_keyword)
menu.addActions(actions)
menu.addSeparator()
default_menu = self.createStandardContextMenu()
menu.addActions(default_menu.actions())
menu.exec_(event.globalPos())
示例4: __init__
def __init__(self, auth, conversation_id, settings, version, parent = None):
QDialog.__init__(self, parent)
self.ui = cg.Ui_Dialog()
self.ui.setupUi(self)
self.settings = settings
self.auth = auth
self.version = version
# Initialize signal mappers for buttons and lists for buttons pointers
self.context_buttons_mapper = QSignalMapper(self)
self.context_buttons_list = []
self.destroy_buttons_mapper = QSignalMapper(self)
self.destroy_buttons_list = []
self.redent_buttons_mapper = QSignalMapper(self)
self.redent_buttons_list = []
self.like_buttons_mapper = QSignalMapper(self)
self.like_buttons_list = []
self.dentid_buttons_mapper = QSignalMapper(self)
self.dentid_buttons_list = []
self.ui.context.setSortingEnabled(True)
self.ui.context.sortByColumn(2, Qt.DescendingOrder)
for column in range(2, 6):
self.ui.context.setColumnHidden(column, True)
self.ui.context.setColumnWidth(0, 65)
self.ui.context.itemActivated.connect(self.reply_to_dent)
conversation = self.auth.get_conversation(conversation_id)
self.list_handler = list_handler.List_Handler(self.callback)
self.list_item = list_item.list_item()
self.list_handler.add_data("conversation", conversation, self.settings["server"])
self.connect_buttons()
示例5: __init__
def __init__(self, parent, tester):
"""Construct a new dockwindow following the tester """
self.tester = tester
QtGui.QDockWidget.__init__(self, tester.testname, parent)
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
if not self.widget():
self.setWidget(QtGui.QWidget(self))
vl = QtGui.QVBoxLayout(self.widget())
#self.widget().setLayout(vl)
panel = QtGui.QFrame(self)
vl.addWidget(panel)
self.login = QtGui.QLineEdit(self)
self.login.textEdited.connect(self.check_logpass)
self.password = QtGui.QLineEdit(self)
self.password.setEchoMode(QtGui.QLineEdit.Password)
self.password.textEdited.connect(self.check_logpass)
self.tests = []
fl = QtGui.QFormLayout(panel)
fl.addRow('&Login:',self.login)
fl.addRow('&Password:',self.password)
panel.setLayout(fl)
panel = QtGui.QFrame(self)
panel.setFrameShadow(QtGui.QFrame.Sunken)
panel.setFrameShape(QtGui.QFrame.Panel)
vl.addWidget(panel)
vl2 = QtGui.QVBoxLayout(panel)
signalmapper = QSignalMapper(self)
signalmapper.mapped[int].connect(self.test)
for i,test in enumerate(self.tester.tests):
btn = QtGui.QPushButton("Test {}: {}".format(i+1,test.name),panel)
btn.setStyleSheet(self.btn_default_stylesheet)
btn.setEnabled(False)
vl2.addWidget(btn)
self.tests.append(btn)
signalmapper.setMapping(btn,i)
btn.clicked.connect(signalmapper.map)
panel.setLayout(vl2)
self.text = QtGui.QLabel("Enter your Coursera login and assignments password and push one of the test buttons above to run the test and submit the results to Coursera.")
self.text.setWordWrap(True)
vl.addWidget(self.text)
self.text.setFrameShadow(QtGui.QFrame.Sunken)
self.text.setFrameShape(QtGui.QFrame.Panel)
self.text.setMargin(5)
#vl.setStretch(2,1)
vl.addStretch(1)
示例6: __init__
def __init__ (self, collaggr=None, songs=None, view=None):
QAbstractTableModel.__init__ (self, view)
# TODO: different delegate for editing tags: one with completion
self.view_= view
self.playlist= view.playlist
self.edited= False
if songs is None:
self.collaggr= collaggr
self.collections= self.collaggr.collections
self.signalMapper= QSignalMapper ()
for collNo, collection in enumerate (self.collections):
collection.newSongs.connect (self.signalMapper.map)
self.signalMapper.setMapping (collection, collNo)
self.signalMapper.mapped.connect (self.addRows)
else:
self.collaggr= CollectionAggregator (self, songs=songs)
self.attrNames= ('artist', 'year', 'collection', 'diskno', 'album', 'trackno', 'title', 'length', 'filepath')
self.headers= (u'Artist', u'Year', u'Collection', u'CD', u'Album', u'Track', u'Title', u'Length', u'Path')
# FIXME: kinda hacky
self.fontMetrics= QFontMetrics (KGlobalSettings.generalFont ())
# FIXME: (even more) hackish
self.columnWidths= ("M"*15, "M"*4, "M"*15, "M"*3, "M"*20, "M"*3, "M"*25, "M"*5, "M"*200)
logger.debug ("QPLM: ", self)
示例7: __init__
def __init__(self, strip, parent=None):
super(LEDDialog,self).__init__(parent)
self.strip = strip
self.buttons = []
layout = QVBoxLayout()
btnlayout = QGridLayout()
self.btnmapper = QSignalMapper()
for i in xrange(int(self.strip.config['nleds'])):
p = QPushButton()
p.setFixedWidth(40)
p.setFlat(True)
p.setAutoFillBackground(True)
self.btnmapper.setMapping( p, i)
p.clicked.connect( self.btnmapper.map)
self.buttons += [[p,QColor()]]
btnlayout.addWidget(p, i/self.rowwidth, i%self.rowwidth)
self.btnmapper.mapped['int'].connect(self.chooseColor)
layout.addLayout(btnlayout)
ctrllayout = QHBoxLayout()
p = QPushButton("Refresh")
p.clicked.connect(self.refresh)
ctrllayout.addWidget(p)
p = QPushButton("Set")
p.clicked.connect(self.set)
ctrllayout.addWidget(p)
p = QPushButton("Close")
p.clicked.connect(self.close)
ctrllayout.addWidget(p)
layout.addLayout(ctrllayout)
self.setLayout( layout)
self.refresh()
示例8: __init__
def __init__(self, current_case):
QWidget.__init__(self)
self.__model = PlotCaseModel()
self.__signal_mapper = QSignalMapper(self)
self.__case_selectors = {}
self.__case_selectors_order = []
layout = QVBoxLayout()
add_button_layout = QHBoxLayout()
self.__add_case_button = QToolButton()
self.__add_case_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.__add_case_button.setText("Add case to plot")
self.__add_case_button.setIcon(resourceIcon("ide/small/add"))
self.__add_case_button.clicked.connect(self.addCaseSelector)
add_button_layout.addStretch()
add_button_layout.addWidget(self.__add_case_button)
add_button_layout.addStretch()
layout.addLayout(add_button_layout)
self.__case_layout = QVBoxLayout()
self.__case_layout.setContentsMargins(0, 0, 0, 0)
layout.addLayout(self.__case_layout)
self.addCaseSelector(disabled=True, current_case=current_case)
layout.addStretch()
self.setLayout(layout)
self.__signal_mapper.mapped[QWidget].connect(self.removeWidget)
示例9: __init__
def __init__(self, current_case):
QWidget.__init__(self)
self.__model = PlotCaseModel()
self.__signal_mapper = QSignalMapper(self)
self.__case_selectors = {}
self.__case_selectors_order = []
layout = QVBoxLayout()
add_button_layout = QHBoxLayout()
button = QPushButton(util.resourceIcon("ide/small/add"), "Add case to plot")
button.clicked.connect(self.addCaseSelector)
add_button_layout.addStretch()
add_button_layout.addWidget(button)
add_button_layout.addStretch()
layout.addLayout(add_button_layout)
self.__case_layout = QVBoxLayout()
self.__case_layout.setMargin(0)
layout.addLayout(self.__case_layout)
self.addCaseSelector(disabled=True, current_case=current_case)
layout.addStretch()
self.setLayout(layout)
self.__signal_mapper.mapped[QWidget].connect(self.removeWidget)
示例10: __init__
def __init__ (self, parent, collections=None, songs=None, busName=None, busPath=None):
SatyrObject.__init__ (self, parent, busName, busPath)
self.configValues= (
('collsNo', int, 0),
)
self.loadConfig ()
self.signalMapper= QSignalMapper ()
self.collections= []
if songs is None:
self.songs= []
self.count= 0
else:
self.songs= songs
self.count= len (songs)
# if collections is not None we it means the may have changed
if self.collsNo>0 and collections is None:
logger.info ("loading collections from config", self.collsNo)
for index in xrange (self.collsNo):
collection= Collection (self, busName=busName, busPath="/collection_%04d" % index)
self.append (collection)
else:
if collections is not None:
for collection in collections:
self.append (collection)
self.signalMapper.mapped.connect (self.addSongs)
示例11: _init_translators
def _init_translators(self):
translator_menu = QMenu(self)
self._trans_widget_mgr = TranslatorWidgetManager(self)
self._trans_signal_mapper = QSignalMapper(self)
for trans_name, config in ValueTranslatorConfig.translators.iteritems():
trans_action = QAction( u'{}...'.format(trans_name),
translator_menu
)
self._trans_signal_mapper.setMapping(trans_action, trans_name)
trans_action.triggered.connect(self._trans_signal_mapper.map)
translator_menu.addAction(trans_action)
if len(translator_menu.actions()) == 0:
self.btn_add_translator.setEnabled(False)
else:
self.btn_add_translator.setMenu(translator_menu)
self._trans_signal_mapper.mapped[str].connect(self._load_translator_dialog)
self.btn_edit_translator.setEnabled(False)
self.btn_delete_translator.setEnabled(False)
self.btn_edit_translator.clicked.connect(self._on_edit_translator)
self.btn_delete_translator.clicked.connect(self._on_delete_translator)
示例12: __init__
def __init__(self, parent=None, columns=4, buttonSize=None,
iconSize=None, toolButtonStyle=Qt.ToolButtonTextUnderIcon):
QFrame.__init__(self, parent)
if buttonSize is not None:
buttonSize = QSize(buttonSize)
if iconSize is not None:
iconSize = QSize(iconSize)
self.__columns = columns
self.__buttonSize = buttonSize or QSize(50, 50)
self.__iconSize = iconSize or QSize(26, 26)
self.__toolButtonStyle = toolButtonStyle
self.__gridSlots = []
self.__buttonListener = ToolButtonEventListener(self)
self.__buttonListener.buttonRightClicked.connect(
self.__onButtonRightClick)
self.__buttonListener.buttonEnter.connect(
self.__onButtonEnter)
self.__mapper = QSignalMapper()
self.__mapper.mapped[QObject].connect(self.__onClicked)
self.__setupUi()
示例13: __init__
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.setWindowFlags(Qt.Window)
self._mdi_area = QMdiArea()
self._mdi_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self._mdi_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setCentralWidget(self._mdi_area)
# set the size of mid_area and DocumentViewManager based on the
# screen size.
screen = QDesktopWidget().availableGeometry()
self._mdi_area.resize(screen.width() - 30, screen.height() - 80)
self.resize(self._mdi_area.size())
self._mdi_area.subWindowActivated.connect(self.update_actions)
self._viewer_mapper = QSignalMapper(self)
self._viewer_mapper.mapped[QWidget].connect(self.set_active_sub_window)
win_title = QApplication.translate(
"DocumentViewManager",
"Document Viewer"
)
self.setWindowTitle(win_title)
self.setUnifiedTitleAndToolBarOnMac(True)
self.statusBar().showMessage(
QApplication.translate(
"DocumentViewManager",
"Ready"
)
)
self._doc_viewers = {}
self._create_menu_actions()
self.update_actions()
示例14: setup_file_locs
def setup_file_locs(self):
# Because the default margins are ugly as h*ck.
self.ui.tabLocs.layout().setContentsMargins(0, 0, 0, 0)
# Map our buttons to functions that retrieve the necessary data.
cfg_mapper = QSignalMapper(self)
for i, item in enumerate(FILE_LOCATIONS):
self.connect(self.ui.__dict__[item[BTN]], QtCore.SIGNAL("clicked()"), cfg_mapper, QtCore.SLOT("map()"))
cfg_mapper.setMapping(self.ui.__dict__[item[BTN]], i)
self.connect(cfg_mapper, QtCore.SIGNAL("mapped(int)"), self.__get_cfg_item)
# Load in all our info from the config file.
for item in FILE_LOCATIONS:
self.ui.__dict__[item[TEXT]].setText(common.editor_config.get_pref(item[CFG]))
示例15: __init__
def __init__(self, *args, **kwargs):
QGraphicsScene.__init__(self, *args, **kwargs)
self.scheme = None
self.registry = None
# All node items
self.__node_items = []
# Mapping from SchemeNodes to canvas items
self.__item_for_node = {}
# All link items
self.__link_items = []
# Mapping from SchemeLinks to canvas items.
self.__item_for_link = {}
# All annotation items
self.__annotation_items = []
# Mapping from SchemeAnnotations to canvas items.
self.__item_for_annotation = {}
# Is the scene editable
self.editable = True
# Anchor Layout
self.__anchor_layout = AnchorLayout()
self.addItem(self.__anchor_layout)
self.__channel_names_visible = True
self.__node_animation_enabled = True
self.user_interaction_handler = None
self.activated_mapper = QSignalMapper(self)
self.activated_mapper.mapped[QObject].connect(
lambda node: self.node_item_activated.emit(node)
)
self.hovered_mapper = QSignalMapper(self)
self.hovered_mapper.mapped[QObject].connect(
lambda node: self.node_item_hovered.emit(node)
)
self.position_change_mapper = QSignalMapper(self)
self.position_change_mapper.mapped[QObject].connect(
self._on_position_change
)
log.info("'%s' intitialized." % self)