本文整理汇总了Python中weboob.tools.application.qt.QtDo类的典型用法代码示例。如果您正苦于以下问题:Python QtDo类的具体用法?Python QtDo怎么用?Python QtDo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QtDo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ContactNotes
class ContactNotes(QWidget):
""" Widget for storing notes about a contact """
def __init__(self, weboob, contact, parent=None):
QWidget.__init__(self, parent)
self.ui = Ui_Notes()
self.ui.setupUi(self)
self.weboob = weboob
self.contact = contact
self.ui.textEdit.setEnabled(False)
self.ui.saveButton.setEnabled(False)
self.process = QtDo(self.weboob, self._getNotes_cb, self._getNotes_eb)
self.process.do('get_notes', self.contact.id, backends=(self.contact.backend,))
self.connect(self.ui.saveButton, SIGNAL('clicked()'), self.saveNotes)
def _getNotes_cb(self, backend, data):
if not backend or not data:
self.process = None
self.ui.textEdit.setEnabled(True)
self.ui.saveButton.setEnabled(True)
return
self.ui.textEdit.setText(data)
def _getNotes_eb(self, backend, error, backtrace):
if isinstance(error, NotImplementedError):
return
self.ui.textEdit.setEnabled(True)
self.ui.saveButton.setEnabled(True)
content = unicode(self.tr('Unable to load notes:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG:
content += '\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while loading notes'),
content, QMessageBox.Ok)
def saveNotes(self):
text = unicode(self.ui.textEdit.toPlainText())
self.ui.saveButton.setEnabled(False)
self.ui.textEdit.setEnabled(False)
self.process = QtDo(self.weboob, self._saveNotes_cb, self._saveNotes_eb)
self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))
def _saveNotes_cb(self, backend, data):
self.ui.saveButton.setEnabled(True)
self.ui.textEdit.setEnabled(True)
pass
def _saveNotes_eb(self, backend, error, backtrace):
self.ui.saveButton.setEnabled(True)
self.ui.textEdit.setEnabled(True)
content = unicode(self.tr('Unable to save notes:\n%s\n')) % to_unicode(error)
if logging.root.level == logging.DEBUG:
content += '\n%s\n' % to_unicode(backtrace)
QMessageBox.critical(self, self.tr('Error while saving notes'),
content, QMessageBox.Ok)
示例2: savePage
def savePage(self):
""" Saves the current page to the remote site """
if self.backend is None:
return
new_content = unicode(self.ui.contentEdit.toPlainText())
minor = self.ui.minorBox.isChecked()
if new_content != self.content.content:
self.ui.saveButton.setEnabled(False)
self.ui.saveButton.setText('Saving...')
self.ui.contentEdit.setReadOnly(True)
self.content.content = new_content
message = unicode(self.ui.descriptionEdit.text())
def finished():
self.process = None
self.ui.saveButton.setText('Saved')
self.ui.descriptionEdit.clear()
self.ui.contentEdit.setReadOnly(False)
self.process = QtDo(self.weboob,
None,
self._errorSavePage,
finished)
self.process.do('push_content',
self.content,
message,
minor=minor,
backends=self.backend)
示例3: loadHistory
def loadHistory(self):
""" Loads the page's log into the 'History' tab """
if self.backend is None:
return
self.ui.loadHistoryButton.setEnabled(False)
self.ui.loadHistoryButton.setText("Loading...")
self.ui.historyTable.clear()
self.ui.historyTable.setRowCount(0)
self.ui.historyTable.setHorizontalHeaderLabels(["Revision",
"Time",
"Author",
"Summary"])
self.ui.historyTable.setColumnWidth(3, 1000)
self.process = QtDo(self.weboob,
self._gotRevision,
self._errorHistory)
self.process.do(self.app._do_complete,
self.ui.nbRevBox.value(),
(),
'iter_revisions',
self.content.id,
backends=(self.backend,))
示例4: refreshHousingsList
def refreshHousingsList(self):
name = unicode(self.ui.queriesList.itemText(self.ui.queriesList.currentIndex()))
q = self.config.get('queries', name)
if q is None:
return q
self.ui.housingsList.clear()
self.ui.queriesList.setEnabled(False)
self.ui.bookmarksButton.setEnabled(False)
query = Query()
query.type = int(q.get('type', 0))
query.cities = []
for c in q['cities']:
city = City(c['id'])
city.backend = c['backend']
city.name = c['name']
query.cities.append(city)
query.area_min = int(q['area_min']) or None
query.area_max = int(q['area_max']) or None
query.cost_min = int(q['cost_min']) or None
query.cost_max = int(q['cost_max']) or None
query.nb_rooms = int(q['nb_rooms']) or None
self.process = QtDo(self.weboob, self.addHousing)
self.process.do('search_housings', query)
示例5: saveNotes
def saveNotes(self):
text = unicode(self.ui.textEdit.toPlainText())
self.ui.saveButton.setEnabled(False)
self.ui.textEdit.setEnabled(False)
self.process = QtDo(self.weboob, self._saveNotes_cb, self._saveNotes_eb)
self.process.do('save_notes', self.contact.id, text, backends=(self.contact.backend,))
示例6: _sendPressed
def _sendPressed(self):
if not self.ui.replyWidget.isVisible():
return
text = unicode(self.ui.replyEdit.toPlainText())
title = unicode(self.ui.titleEdit.text())
self.ui.backendsList.setEnabled(False)
self.ui.threadsList.setEnabled(False)
self.ui.messagesTree.setEnabled(False)
self.ui.replyButton.setEnabled(False)
self.ui.replyWidget.setEnabled(False)
self.ui.sendButton.setText(self.tr('Sending...'))
flags = 0
if self.ui.htmlBox.currentIndex() == 0:
flags = Message.IS_HTML
m = Message(thread=self.thread,
id=0,
title=title,
sender=None,
receivers=None,
content=text,
parent=self.message,
flags=flags)
self.process_reply = QtDo(self.weboob, self._postReply_cb, self._postReply_eb)
self.process_reply.do('post_message', m, backends=self.thread.backend)
示例7: searchCity
def searchCity(self):
pattern = unicode(self.ui.cityEdit.text())
self.ui.resultsList.clear()
self.ui.cityEdit.clear()
self.ui.cityEdit.setEnabled(False)
self.search_process = QtDo(self.weboob, self.addResult, fb=self.addResultEnd)
self.search_process.do('search_city', pattern)
示例8: MiniVideo
class MiniVideo(QFrame):
def __init__(self, weboob, backend, video, parent=None):
QFrame.__init__(self, parent)
self.ui = Ui_MiniVideo()
self.ui.setupUi(self)
self.weboob = weboob
self.backend = backend
self.video = video
self.ui.titleLabel.setText(video.title)
self.ui.backendLabel.setText(backend.name)
self.ui.durationLabel.setText(unicode(video.duration))
self.ui.authorLabel.setText(unicode(video.author))
self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
if video.rating_max:
self.ui.ratingLabel.setText('%s / %s' % (video.rating, video.rating_max))
else:
self.ui.ratingLabel.setText('%s' % video.rating)
self.process_thumbnail = QtDo(self.weboob, self.gotThumbnail)
self.process_thumbnail.do('fillobj', self.video, ['thumbnail'], backends=backend)
def gotThumbnail(self, backend, video):
if not backend:
return
if video.thumbnail and video.thumbnail.data:
img = QImage.fromData(video.thumbnail.data)
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
def enterEvent(self, event):
self.setFrameShadow(self.Sunken)
QFrame.enterEvent(self, event)
def leaveEvent(self, event):
self.setFrameShadow(self.Raised)
QFrame.leaveEvent(self, event)
def mousePressEvent(self, event):
QFrame.mousePressEvent(self, event)
video = self.backend.get_video(self.video.id)
if video:
video_widget = Video(video, self)
video_widget.show()
示例9: MetaGroup
class MetaGroup(IGroup):
def iter_contacts(self, cb):
if self.id == 'online':
status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
elif self.id == 'offline':
status = Contact.STATUS_OFFLINE
else:
status = Contact.STATUS_ALL
self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
self.process.do('iter_contacts', status, caps=ICapContact)
def cb(self, cb, backend, contact):
if contact:
cb(contact)
elif not backend:
self.process = None
cb(None)
示例10: urlClicked
def urlClicked(self):
url = unicode(self.ui.urlEdit.text())
if not url:
return
backend_name = unicode(self.ui.backendsList.currentText())
self.ui.urlButton.setEnabled(False)
self.url_process = QtDo(self.weboob, self.urlClicked_cb, self.urlClicked_eb)
self.url_process.do('get_contact', url, backends=backend_name)
示例11: retrieveContact
def retrieveContact(self, url):
backend_name = unicode(self.ui.backendsList.currentText())
self.ui.urlButton.setEnabled(False)
def finished():
self.url_process = None
self.ui.urlButton.setEnabled(True)
self.url_process = QtDo(self.weboob, self.retrieveContact_cb, self.retrieveContact_eb, finished)
self.url_process.do('get_contact', url, backends=backend_name)
示例12: refreshThreadMessages
def refreshThreadMessages(self, backend, id):
self.ui.messagesTree.clear()
self.ui.messageBody.clear()
self.ui.backendsList.setEnabled(False)
self.ui.threadsList.setEnabled(False)
self.ui.replyButton.setEnabled(False)
self.hideReply()
self.process = QtDo(self.weboob, self._gotThreadMessages)
self.process.do('get_thread', id, backends=backend)
示例13: refreshMessages
def refreshMessages(self, fillobj=False):
if self.process_msg:
return
self.ui.refreshButton.setEnabled(False)
self.process_msg = QtDo(self.weboob, self.gotThread, self.gotError)
if fillobj and self.thread:
self.process_msg.do('fillobj', self.thread, ['root'], backends=self.contact.backend)
else:
self.process_msg.do('get_thread', self.contact.id, backends=self.contact.backend)
示例14: iter_contacts
def iter_contacts(self, cb):
if self.id == 'online':
status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
elif self.id == 'offline':
status = Contact.STATUS_OFFLINE
else:
status = Contact.STATUS_ALL
self.process = QtDo(self.weboob, lambda b, d: self.cb(cb, b, d))
self.process.do('iter_contacts', status, caps=ICapContact)
示例15: MetaGroup
class MetaGroup(IGroup):
def iter_contacts(self, cb):
if self.id == 'online':
status = Contact.STATUS_ONLINE|Contact.STATUS_AWAY
elif self.id == 'offline':
status = Contact.STATUS_OFFLINE
else:
status = Contact.STATUS_ALL
self.process = QtDo(self.weboob, lambda d: self.cb(cb, d), fb=lambda: self.fb(cb))
self.process.do('iter_contacts', status, caps=CapContact)
def cb(self, cb, contact):
if contact:
cb(contact)
def fb(self, fb):
self.process = None
if fb:
fb(None)