本文整理汇总了Python中PyQt5.QtNetwork.QLocalSocket.waitForReadyRead方法的典型用法代码示例。如果您正苦于以下问题:Python QLocalSocket.waitForReadyRead方法的具体用法?Python QLocalSocket.waitForReadyRead怎么用?Python QLocalSocket.waitForReadyRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtNetwork.QLocalSocket
的用法示例。
在下文中一共展示了QLocalSocket.waitForReadyRead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainForm
# 需要导入模块: from PyQt5.QtNetwork import QLocalSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QLocalSocket import waitForReadyRead [as 别名]
#.........这里部分代码省略.........
def itemClicked(self):
sender = self.sender()
if sender.item.folder:
self.setCurrentItem(sender.item)
self.refresh(False)
else:
flags = ['f', 'F', 'u', 'U', 'd', 'D', 'n', 'N', 'i', 'k', 'v', 'm']
command = sender.item.command
for i in flags:
command = command.replace('%' + i, '')
# %c needs a proper value in some cases
command = command.replace('%c', '"%s"' % sender.item.name)
working = sender.item.working
if not os.path.isdir(working):
working = None
# Need to redirect stdout and stderr so if the process writes something it won't fail
with open(os.path.devnull, 'w') as devnull:
Popen(command + '&', stdout=devnull, stderr=devnull, shell=True, cwd=working)
self.hideOrClose()
def backClicked(self):
if self.currentItem:
self.setCurrentItem(self.currentItem.parent)
self.refresh(False)
def setCurrentItem(self, item):
self.currentItem = item
if item != None:
self.currentLabel.setText(item.name)
if item.parent != None:
self.backButton.setText(item.parent.name)
else:
self.backButton.setText('Favorites')
else:
self.currentLabel.setText('')
self.backButton.setText('Favorites')
def settingsClicked(self):
form = SettingsForm(self)
form.quitCheck.setChecked(self.settings['quit'])
theme = self.settings.get('iconTheme')
if theme:
form.themeCombo.setCurrentIndex(form.themeCombo.findText(theme))
self.holdOpen = True
form.exec_()
self.checkMouse()
self.holdOpen = False
if form.accepted:
self.settings['quit'] = form.quitCheck.isChecked()
def firstRun(self):
QMessageBox.information(self, 'First Time?', 'Your menu is currently empty. It is recommended that you import an existing menu file.')
self.settingsClicked()
def connectToRunning(self):
self.socket = QLocalSocket()
self.socket.connectToServer('nemuSocket')
self.socket.waitForConnected(1000)
if self.socket.state() == QLocalSocket.ConnectedState:
print 'Server found'
if self.socket.waitForReadyRead(3000):
line = self.socket.readLine()
print line
else:
print self.socket.errorString()
sys.exit()
else:
print 'No server running'
def handleConnection(self):
import datetime
print "Got connection", datetime.datetime.now()
connection = self.server.nextPendingConnection()
connection.write('connected')
del connection
self.setCurrentItem(None)
self.filterBox.setText('')
self.refresh(False)
self.show()
print "Showed", datetime.datetime.now()
return
# Call periodically to keep data resident in memory (hopefully)
def keepalive(self):
if self.isHidden():
self.refresh(False)