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)
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)
def setClientId(self, clientId): """服务器与客户端之间的约定为仅设置clientId一次,否则需要修改资源管理器的行为""" self.clientId = clientId if self.clientId != -1: EventManager.bind('Client.replyReady.' + self.clientId, self.addReply) application.addResource([], self.clientId)
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)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.createModelAndView() #self.createOp() mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) mainLayout.addWidget(self.treeView) self.setLayout(mainLayout) self.setStyleSheet('QLineEdit{padding: 0;}') EventManager.bind('Message.addVms', self.addVms) EventManager.bind('Message.updateVm', self.resetVm)
def __init__(self, port, parent=None): QThread.__init__(self, parent) self.port = port self.serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.serverSocket.bind(('', self.port)) self.serverSocket.listen(5) self.serverSocket.setblocking(False) self.dispatcher = Dispatcher(self) #clients --> {clientId: Socket object} self.clients = {} EventManager.bind('Message.broadcast', self.broadcast)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.createModelAndView() #self.createOp() mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) mainLayout.addWidget(self.treeView) self.setLayout(mainLayout) self.setStyleSheet( 'QLineEdit{padding: 0;}' ) EventManager.bind('Message.addVms', self.addVms) EventManager.bind('Message.updateVm', self.resetVm)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.tabWidget = QTabWidget() self.tabWidget.setTabsClosable(True) self.tabWidget.setMovable(True) self.tabWidget.tabCloseRequested.connect(self.closeTab) mainLayout = QHBoxLayout() mainLayout.addWidget(self.tabWidget) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(0) self.setLayout(mainLayout) self.tabWidget.currentChanged.connect(self.resetCurrentWebchat) EventManager.bind('Message.vmStarted', self.syncVideoOfVm) EventManager.bind('Message.vmStartFail', self.closeWebchat)
def __init__(self, title=None, parent=None): QWidget.__init__(self, parent) self._id = uuid.uuid4().hex self.label = QLabel() self.label.setAlignment(Qt.AlignCenter) if title: self.setTitle(title) self.indicator = StatusIndicator() self.indicatorReference = 0 mainLayout = QHBoxLayout() mainLayout.addWidget(self.label, 0, Qt.AlignVCenter | Qt.AlignLeading) mainLayout.addWidget(self.indicator, 0, Qt.AlignVCenter | Qt.AlignLeft) mainLayout.addStretch() mainLayout.setContentsMargins(4, 4, 4, 4) mainLayout.setSpacing(5) self.setLayout(mainLayout) self.hideIndicator() EventManager.bind('ToolBar.changeState.' + self._id, self.changeIndicatorStatus) print 'ToolBar.changeState.' + self._id
def __init__(self, parent=None): QWidget.__init__(self, parent) self.restart = QPushButton(u'重启') self.detect = QPushButton(u'探测输入框') l1 = QHBoxLayout() l1.addWidget(self.restart) l1.addWidget(self.detect) l1.setContentsMargins(0, 0, 0, 0) w1 = QWidget() w1.setLayout(l1) self.readable = QLineEdit() self.readable.setPlaceholderText(u'详细位置') self.setLocation = QPushButton(u'设置位置') self.lat = QLineEdit() self.lat.setPlaceholderText(u'纬度') self.lng = QLineEdit() self.lng.setPlaceholderText(u'经度') for edit in (self.readable, self.lat, self.lng): edit.setReadOnly(True) l2 = QHBoxLayout() l2.addWidget(self.lng) l2.addWidget(self.lat) l3 = QHBoxLayout() l3.addWidget(self.readable) l3.addWidget(self.setLocation) locationLayout = QVBoxLayout() locationLayout.addLayout(l2) locationLayout.addLayout(l3) locationLayout.setContentsMargins(0, 0, 0, 0) w2 = QWidget() w2.setLayout(locationLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(w1) mainLayout.addWidget(w2) mainLayout.setContentsMargins(2, 10, 2, 6) self.setLayout(mainLayout) EventManager.bind('Map.locationChanged', self.syncLocationToMap)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.gpsModel = singleton.getGpsModel() self.gpsTable = QTableView() self.gpsTable.setModel(self.gpsModel) self.gpsTable.setSelectionBehavior(QTableView.SelectRows) self.gpsTable.setFocusPolicy(Qt.NoFocus) self.gpsTable.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel) selectionModel = QItemSelectionModel(self.gpsModel) self.gpsTable.setSelectionModel(selectionModel) selectionModel.currentRowChanged.connect(self.loadCurrentPosition) header = self.gpsTable.horizontalHeader() #在针对某个section设置resizeMode前务必保证已经设置了model,否则view不知道有多少列,导致程序崩溃 #header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setStretchLastSection(True) header.setSectionsClickable(False) mainLayout = QVBoxLayout() mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.addWidget(self.gpsTable) self.setLayout(mainLayout) self.createContextMenu() self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.showContextMenu) self.gpsModel.dataChanged.connect(self.editLocation) EventManager.bind('Message.addGps', self.addGpsItems) EventManager.bind('Message.updateGps', self.resetGps) EventManager.bind('Message.deleteGps', self.deleteGpsItems)
def __init__(self, parent=None): QObject.__init__(self, parent) self.workThread = QThread() self.worker = self.Worker() self.worker.moveToThread(self.workThread) self.workThread.start() self.controller = self.Controller() self.controller.dataCenterSetup.connect(self.worker.setupDatabase) self.controller.dataCenterSetup.emit() self.controller.addVM.connect(self.worker.addServer) self.controller.delVM.connect(self.worker.delServer) self.controller.loadAllVMs.connect(self.worker.loadAllServers) EventManager.bind('DataCenter.addServer', self.addServer) EventManager.bind('DataCenter.delServer', self.delServer) EventManager.bind('DataCenter.loadAllServers', self.loadAllServers)
def __init__(self, server, parent=None): Dispatcher.__init__(self, server, parent) self.vm = VmManager() self.vm.loadAllMachines() #externalToVm --> {clientId: [(vmId, vmInfo),]} self.externalToVm = {} self.callbacks = { Message.CMD_START_VM: self.startVM, Message.CMD_CLOSE_VM: self.closeVM, Message.CMD_RESET_VM: self.resetVM, Message.CMD_QUERY_VMS: self.queryVms, Message.CMD_QUERY_GPS: self.queryGPS, Message.CMD_UPDATE_VM: self.updateVm, Message.CMD_UPDATE_GPS: self.updateGps, Message.CMD_ADD_GPS: self.addGps, Message.CMD_DELETE_GPS: self.deleteGps, Message.CMD_ADD_ACCOUNT: self.addAccount, Message.CMD_QUERY_ACCOUNT: self.queryAccount, Message.CMD_DELETE_ACCOUNT: self.deleteAccount, } self.server.clientDisconnected.connect(self.clearVmForClient) EventManager.bind('DataCenter.gpsLoaded', self._sendGpsData) EventManager.bind('DataCenter.gpsUpdated', self._updateGpsData) EventManager.bind('DataCenter.gpsAdded', self._addGpsData) EventManager.bind('DataCenter.gpsDeleted', self._deleteGpsData) EventManager.bind('DataCenter.accountAdded', self._addAccountData) EventManager.bind('DataCenter.accountLoaded', self._sendAccountData) EventManager.bind('DataCenter.accountDeleted', self._deleteAccountData)
def __init__(self, parent=None): QObject.__init__(self, parent) self.workThread = QThread() self.worker = self.Worker() self.worker.moveToThread(self.workThread) self.workThread.start() self.controller = self.Controller() self.controller.dataCenterSetup.connect(self.worker.setupDatabase) self.controller.dataCenterSetup.emit() self.controller.wantToAddGps.connect(self.worker.addGps) self.controller.wantAllGps.connect(self.worker.loadAllGps) self.controller.updateGps.connect(self.worker.updateGps) self.controller.deleteGps.connect(self.worker.deleteGps) self.controller.addAccount.connect(self.worker.addAccount) self.controller.loadAllAccount.connect(self.worker.loadAllAccount) self.controller.deleteAccount.connect(self.worker.deleteAccount) EventManager.bind('DataCenter.addGps', self.addGps) EventManager.bind('DataCenter.loadAllGps', self.loadAllGps) EventManager.bind('DataCenter.updateGps', self.updateGps) EventManager.bind('DataCenter.deleteGps', self.deleteGps) EventManager.bind('DataCenter.addAccount', self.addAccount) EventManager.bind('DataCenter.loadAllAccount', self.loadAllAccount) EventManager.bind('DataCenter.deleteAccount', self.deleteAccount)
def test(self): EventManager.bind('DataCenter.settingLoaded.geo', self.callback) EventManager.trigger(Event('DataCenter.saveSetting', 'geo', '我们')) EventManager.trigger(Event('DataCenter.loadSetting', 'geo'))