本文整理汇总了Python中sync.Sync.moveToThread方法的典型用法代码示例。如果您正苦于以下问题:Python Sync.moveToThread方法的具体用法?Python Sync.moveToThread怎么用?Python Sync.moveToThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sync.Sync
的用法示例。
在下文中一共展示了Sync.moveToThread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SyncWindow
# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import moveToThread [as 别名]
class SyncWindow(QMainWindow):
"""
Application main window. This class is meant to handle
every widget needed by the application, as well as other
needed global objects and behavior.
"""
failedLogIn = Signal()
syncStarted = Signal()
loginRequested = Signal((str, str,))
statusChanged = Signal((str, str, int,))
def __init__(self, parent=None):
super(SyncWindow, self).__init__(parent)
# Sets up several UI aspects
self.tray = QSystemTrayIcon(self)
self.tray.setIcon(QIcon(QPixmap(':/resources/icon.png')))
self.tray.show()
self.setStyleSheet('SyncWindow {background: white}')
self.setWindowTitle('IQBox')
self.setWindowIcon(QIcon(QPixmap(':/resources/logobar.png')))
self.statusBar().setFont(View.labelsFont())
self.syncThread = None
# Initializes the window with a `LoginView` widget.
self.loginView()
def loginView(self):
"""
Initializes a `LoginView` object and sets it up as the main window's
central widget.
"""
login = LoginView()
login.login.connect(self.onLogin)
self.failedLogIn.connect(login.onFailedLogIn)
self.setCentralWidget(login)
self.setFixedSize(login.size())
self.statusBar().hide()
def syncView(self):
"""
Initializes a `SyncView` object and sets it up as the main window's
central widget.
"""
syncview = SyncView()
self.setCentralWidget(syncview)
self.setFixedSize(syncview.size())
self.statusBar().show()
self.statusChanged.connect(syncview.status.setMessage)
syncview.sync.connect(self.onSync)
@Slot(str, str, str, bool)
def onLogin(self, host, username, passwd, ssl):
"""
Slot. Triggers a log in request to the server.
:param host: Indicates the hostname of the FTP server
:param username: Username to log in into the FTP server
:param passwd: Password to log in into the FTP server
:param ssl: Indicates whether the FTP needs SSL support
"""
self.sync = Sync(host, ssl)
self.syncStarted.connect(self.sync.initQueue)
self.sync.server.downloadProgress.connect(self.onDownloadProgress)
self.sync.server.uploadProgress.connect(self.onUploadProgress)
self.sync.server.fileEvent.connect(self.onFileEvent)
self.sync.server.badFilenameFound.connect(self.badNameWarning)
self.sync.server.loginCompleted.connect(self.onLoginCompleted)
self.sync.server.fileEventCompleted.connect(self.onFileEventCompleted)
self.sync.server.ioError.connect(self.onIOError)
# Added by Si
self.sync.server.textStatus.connect(self.setStatus)
self.sync.statusChanged.connect(self.setStatus)
self.loginRequested.connect(self.sync.server.onLogin)
self.syncThread = QThread()
self.sync.moveToThread(self.syncThread)
self.syncThread.start()
QApplication.instance().lastWindowClosed.connect(self.syncThread.quit)
self.loginRequested.emit(username, passwd)
@Slot(bool, str)
def onLoginCompleted(self, ok, msg):
if not ok:
self.showMessageBox(msg)
self.failedLogIn.emit()
else:
self.syncView()
#.........这里部分代码省略.........