本文整理汇总了Python中application.EventManager类的典型用法代码示例。如果您正苦于以下问题:Python EventManager类的具体用法?Python EventManager怎么用?Python EventManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatchRequest
def dispatchRequest(self, request):
cmd = request.getCMD()
if not cmd:
Log.i('缺少cmd参数')
identifier = request.getParam('identifier')
EventManager.trigger(Event('Socket.addReply.' + identifier,
request))
示例2: closeTab
def closeTab(self, index):
widget = self.tabWidget.widget(index)
msgBox = QMessageBox()
msgBox.setText(u'是否真的要关闭: ' + self.tabWidget.tabText(index))
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msgBox.setDefaultButton(QMessageBox.No)
msgBox.setWindowTitle(u'关闭tab页')
info = widget.information()
if info:
try:
accounts = info['accounts']
text = u'该tab页已登陆帐号:\n'
for account in accounts:
text += account + '\n'
text.rstrip('\n')
msgBox.setInformativeText(unicode(text))
except KeyError:
pass
result = msgBox.exec_()
if result == QMessageBox.Yes:
for webChat in widget.webchats:
vmId = webChat.vmId()
clientId = application.lookUpClientIdByResourceId(vmId)
message = Message(cmd=Message.CMD_CLOSE_VM)
message['vmId'] = vmId
EventManager.trigger(Event('Client.replyReady.' + clientId, message))
self.tabWidget.removeTab(index)
示例3: _sendAccountData
def _sendAccountData(self, data, clientId):
accounts = []
for account in data:
accounts.append({'id': account[1], 'desc': account[2], 'username': account[3], 'password': account[4]})
message = Message(cmd=Message.CMD_QUERY_ACCOUNT_OK)
message['accounts'] = accounts
EventManager.trigger(Event('Socket.addReply.' + clientId, message))
示例4: __init__
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.controlInfo = ControlInfo()
self.accountEdit = AccountEdit()
self.accountList = AccountList()
accountLayout = QVBoxLayout()
accountLayout.setContentsMargins(0, 2, 0, 0)
accountLayout.addWidget(self.accountEdit)
accountLayout.addWidget(self.accountList)
w = QWidget()
w.setLayout(accountLayout)
self.splitter = QSplitter(Qt.Vertical)
self.splitter.setHandleWidth(1)
self.splitter.setChildrenCollapsible(False)
self.splitter.addWidget(self.controlInfo)
self.splitter.addWidget(w)
mainLayout = QVBoxLayout()
mainLayout.setContentsMargins(0, 0, 0, 0)
mainLayout.setSpacing(0)
mainLayout.addWidget(self.splitter)
self.setLayout(mainLayout)
self.setStyleSheet(
'InfoPanel {border-bottom: 1px solid #818A9A}'
'QTableView{border-top: 1px solid #818A9A}'
)
self.currentWebchat = None
EventManager.bind('Webchat.currentChanged', self.setCurrentWebchat)
self.accountEdit.wantSaveAccount.connect(self.accountList.addItem)
示例5: _addGpsData
def _addGpsData(self, params, clientId):
message = Message(cmd=Message.CMD_ADD_GPS_OK, id=params['id'])
EventManager.trigger(Event('Socket.addReply.' + clientId, message))
message = Message(cmd=Message.CMD_GPS_ADDED)
gps = [{'id': params['id'], 'desc': params['desc'], 'lng': params['lng'], 'lat': params['lat']}]
message['gps'] = gps
EventManager.trigger(Event('Message.broadcast', message, (clientId,)))
示例6: _sendGpsData
def _sendGpsData(self, data, clientId):
gps_ = []
for gps in data:
gps_.append({'id': gps[1], 'desc': gps[2], 'lng': gps[3], 'lat': gps[4]})
message = Message(cmd=Message.CMD_QUERY_GPS_OK)
message['gps'] = gps_
EventManager.trigger(Event('Socket.addReply.' + clientId, message))
示例7: deleteSelectedItems
def deleteSelectedItems(self):
selection = self.gpsTable.selectionModel()
indexes = selection.selectedRows()
#uuids: {clientId: [uuid,]}
uuids = {}
for index in indexes:
uuid_ = self.gpsModel.gpsItems[index.row()].id()
clientId = application.lookUpClientIdByResourceId(uuid_)
if clientId in uuids:
uuids[clientId].append(uuid_)
else:
uuids[clientId] = [uuid_]
if len(uuids) == 0:
return
for clientId in uuids:
message = Message(cmd=Message.CMD_DELETE_GPS)
message['ids'] = uuids[clientId]
EventManager.trigger(Event('Client.replyReady.' + clientId, message))
self.deleteGpsItems(uuids[clientId])
for uuid_ in uuids[clientId]:
toolBarId = application.lookUpToolBarIdByResourceId(uuid_)
if toolBarId:
EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True))
else:
Log.e(u'未找到对应的ToolBar')
示例8: registerCurrentLocation
def registerCurrentLocation(self, *args):
if len(args) == 1 and isinstance(args[0], dict):
current = args[0]
elif len(args) == 3:
current = {'desc': args[2], 'lng': args[0], 'lat': args[1]}
else:
raise ValueError(u'参数个数不合法')
EventManager.trigger(Event('Map.locationChanged', current))
示例9: loadVms
def loadVms(self, request):
vms = request['vms']
clientId = request['clientId']
pureVms = vms['vms']
for name in pureVms:
application.addResource(pureVms[name]['vmId'], clientId)
application.addItemToToolBar(pureVms[name]['vmId'], 0, 0)
EventManager.trigger(Event('Message.addVms', vms))
示例10: __init__
def __init__(self, inSocket, identifier, parent=None):
QObject.__init__(self, parent)
self.socket = inSocket
self.replies = Queue()
self.requests = Queue()
self.identifier = identifier
self.buf = bytes()
EventManager.bind('Socket.addReply.' + self.identifier, self.addReply)
示例11: _addAccountData
def _addAccountData(self, params, clientId):
message = Message(cmd=Message.CMD_ADD_ACCOUNT_OK, id=params['id'])
EventManager.trigger(Event('Socket.addReply.' + clientId, message))
message = Message(cmd=Message.CMD_ACCOUNT_ADDED)
accounts = [{'id': params['id'], 'desc': params['desc'], 'username': params['username'],
'password': params['password']}]
message['accounts'] = accounts
EventManager.trigger(Event('Message.broadcast', message, (clientId,)))
示例12: startNewVm
def startNewVm(self, info):
webchat = WebChat(info['vmId'], info['vmType'], info['desc'])
index, tab = self.tabContainer.lookUpVmSpace()
tab.addWebchat(webchat)
self.tabContainer.adjustTabName(tab)
self.tabContainer.setCurrentWidget(tab, index)
message = Message(cmd=Message.CMD_START_VM, vmId=info['vmId'])
EventManager.trigger(Event('Client.replyReady.' + info['serverId'], message))
示例13: setupDatabase
def setupDatabase(self):
from collections import OrderedDict
self.db = Database('chat-advance.db')
if not self.db.createConnection():
EventManager.trigger(Event('Database.databaseConnectionFail'))
return
if not self.db.isTableExist(DataCenter.TABLE_FRIENDS):
self.db.createTable(DataCenter.TABLE_SERVERS, OrderedDict([('name', Database.TYPE_TEXT),
('url', Database.TYPE_TEXT), ('port', Database.TYPE_TEXT)]))
示例14: queryAccount
def queryAccount(self, request):
clientId = request.getParam('clientId')
if not clientId:
Log.e('ExternalDispatcher.queryAccount: 权限不足')
return
if clientId not in self.server.clients:
Log.e('ExternalDispatcher.queryAccount: 该客户端在服务器中不存在')
return
EventManager.trigger(Event('DataCenter.loadAllAccount', clientId))
示例15: updateGps
def updateGps(self, request):
clientId = request.getParam('clientId')
if not clientId:
Log.e('ExternalDispatcher.updateGps: 权限不足')
return
if clientId not in self.server.clients:
Log.e('ExternalDispatcher.updateGps: 该客户端在服务器中不存在')
return
EventManager.trigger(Event('DataCenter.updateGps', request['id'], request['desc'], clientId))