本文整理汇总了Python中profile.Profile.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_instance方法的具体用法?Python Profile.get_instance怎么用?Python Profile.get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profile.Profile
的用法示例。
在下文中一共展示了Profile.get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback_audio
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def callback_audio(toxav, friend_number, samples, audio_samples_per_channel, audio_channels_count, rate, user_data):
"""New audio chunk"""
print audio_samples_per_channel, audio_channels_count, rate
Profile.get_instance().call.chunk(
''.join(chr(x) for x in samples[:audio_samples_per_channel * 2 * audio_channels_count]),
audio_channels_count,
rate)
示例2: call_state
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def call_state(toxav, friend_number, mask, user_data):
"""New call state"""
print friend_number, mask
if mask == TOXAV_FRIEND_CALL_STATE['FINISHED'] or mask == TOXAV_FRIEND_CALL_STATE['ERROR']:
invoke_in_main_thread(Profile.get_instance().stop_call, friend_number, True)
else:
Profile.get_instance().call.toxav_call_state_cb(friend_number, mask)
示例3: set_avatar
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def set_avatar(self):
name = QtGui.QFileDialog.getOpenFileName(self, 'Open file', None, 'Image Files (*.png)')
print name
if name[0]:
with open(name[0], 'rb') as f:
data = f.read()
Profile.get_instance().set_avatar(data)
示例4: search
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def search(self):
Profile.get_instance().update()
text = self.search_text.text()
friend = Profile.get_instance().get_curr_friend()
if text and friend and util.is_re_valid(text):
index = friend.search_string(text)
self.load_messages(index)
示例5: callback_audio
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def callback_audio(toxav, friend_number, samples, audio_samples_per_channel, audio_channels_count, rate, user_data):
"""
New audio chunk
"""
Profile.get_instance().call.chunk(
bytes(samples[:audio_samples_per_channel * 2 * audio_channels_count]),
audio_channels_count,
rate)
示例6: unblock_user
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def unblock_user(self):
if not self.comboBox.count():
return
title = QtGui.QApplication.translate("privacySettings", "Add to friend list", None, QtGui.QApplication.UnicodeUTF8)
info = QtGui.QApplication.translate("privacySettings", "Do you want to add this user to friend list?", None, QtGui.QApplication.UnicodeUTF8)
reply = QtGui.QMessageBox.question(None, title, info, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
Profile.get_instance().unblock_user(self.comboBox.currentText(), reply == QtGui.QMessageBox.Yes)
self.close()
示例7: file_recv_control
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def file_recv_control(tox, friend_number, file_number, file_control, user_data):
"""
Friend cancelled, paused or resumed file transfer
"""
if file_control == TOX_FILE_CONTROL['CANCEL']:
invoke_in_main_thread(Profile.get_instance().cancel_transfer, friend_number, file_number, True)
elif file_control == TOX_FILE_CONTROL['PAUSE']:
invoke_in_main_thread(Profile.get_instance().pause_transfer, friend_number, file_number, True)
elif file_control == TOX_FILE_CONTROL['RESUME']:
invoke_in_main_thread(Profile.get_instance().resume_transfer, friend_number, file_number, True)
示例8: set_avatar
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def set_avatar(self):
choose = QtGui.QApplication.translate("ProfileSettingsForm", "Choose avatar", None, QtGui.QApplication.UnicodeUTF8)
name = QtGui.QFileDialog.getOpenFileName(self, choose, None, 'Images (*.png)',
options=QtGui.QFileDialog.DontUseNativeDialog)
if name[0]:
bitmap = QtGui.QPixmap(name[0])
bitmap.scaled(QtCore.QSize(128, 128), aspectMode=QtCore.Qt.KeepAspectRatio,
mode=QtCore.Qt.SmoothTransformation)
byte_array = QtCore.QByteArray()
buffer = QtCore.QBuffer(byte_array)
buffer.open(QtCore.QIODevice.WriteOnly)
bitmap.save(buffer, 'PNG')
Profile.get_instance().set_avatar(bytes(byte_array.data()))
示例9: restart_core
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def restart_core(self):
try:
settings = Settings.get_instance()
settings['ipv6_enabled'] = self.ipv.isChecked()
settings['udp_enabled'] = self.udp.isChecked()
settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0
settings['proxy_host'] = str(self.proxyip.text())
settings['proxy_port'] = int(self.proxyport.text())
settings.save()
# recreate tox instance
Profile.get_instance().reset(self.reset)
self.close()
except Exception as ex:
log('Exception in restart: ' + str(ex))
示例10: wrapped
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
profile = Profile.get_instance()
settings = Settings.get_instance()
if file_type == TOX_FILE_KIND['DATA']:
print 'file'
try:
file_name = unicode(file_name[:file_name_size].decode('utf-8'))
except:
file_name = u'toxygen_file'
invoke_in_main_thread(profile.incoming_file_transfer,
friend_number,
file_number,
size,
file_name)
if not window.isActiveWindow():
friend = profile.get_friend_by_number(friend_number)
if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
invoke_in_main_thread(tray_notification, 'File from ' + friend.name, file_name, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER'])
else: # AVATAR
print 'Avatar'
invoke_in_main_thread(profile.incoming_avatar,
friend_number,
file_number,
size)
示例11: mouseReleaseEvent
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def mouseReleaseEvent(self, event):
if self.rubberband.isVisible():
self.rubberband.hide()
rect = self.rubberband.geometry()
if rect.width() and rect.height():
p = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId(),
rect.x() + 4,
rect.y() + 4,
rect.width() - 8,
rect.height() - 8)
byte_array = QtCore.QByteArray()
buffer = QtCore.QBuffer(byte_array)
buffer.open(QtCore.QIODevice.WriteOnly)
p.save(buffer, 'PNG')
Profile.get_instance().send_screenshot(bytes(byte_array.data()))
self.close()
示例12: wrapped
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def wrapped(tox, friend_number, file_number, file_type, size, file_name, file_name_size, user_data):
profile = Profile.get_instance()
settings = Settings.get_instance()
if file_type == TOX_FILE_KIND['DATA']:
print('File')
try:
file_name = str(file_name[:file_name_size], 'utf-8')
except:
file_name = 'toxygen_file'
invoke_in_main_thread(profile.incoming_file_transfer,
friend_number,
file_number,
size,
file_name)
if not window.isActiveWindow():
friend = profile.get_friend_by_number(friend_number)
if settings['notifications'] and profile.status != TOX_USER_STATUS['BUSY'] and not settings.locked:
file_from = QtGui.QApplication.translate("Callback", "File from", None, QtGui.QApplication.UnicodeUTF8)
invoke_in_main_thread(tray_notification, file_from + ' ' + friend.name, file_name, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER'])
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(curr_directory() + '/images/icon_new_messages.png'))
else: # AVATAR
print('Avatar')
invoke_in_main_thread(profile.incoming_avatar,
friend_number,
file_number,
size)
示例13: keyPressEvent
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def keyPressEvent(self, event):
if event.matches(QtGui.QKeySequence.Paste):
mimeData = QtGui.QApplication.clipboard().mimeData()
if mimeData.hasUrls():
for url in mimeData.urls():
self.pasteEvent(url.toString())
else:
self.pasteEvent()
elif event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter):
modifiers = event.modifiers()
if modifiers & QtCore.Qt.ControlModifier or modifiers & QtCore.Qt.ShiftModifier:
self.insertPlainText('\n')
else:
if self.timer.isActive():
self.timer.stop()
self.parent.profile.send_typing(False)
self.parent.send_message()
elif event.key() == QtCore.Qt.Key_Up and not self.toPlainText():
self.appendPlainText(Profile.get_instance().get_last_message())
else:
self.parent.profile.send_typing(True)
if self.timer.isActive():
self.timer.stop()
self.timer.start(5000)
super(MessageArea, self).keyPressEvent(event)
示例14: closeEvent
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def closeEvent(self, *args, **kwargs):
settings = Settings.get_instance()
old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(bool(settings['proxy_type']))
new_data = str(self.ipv.isChecked()) + str(self.udp.isChecked()) + str(self.proxy.isChecked())
changed = old_data != new_data
if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != unicode(settings['proxy_port'])):
changed = True
if changed or self.reconn:
settings['ipv6_enabled'] = self.ipv.isChecked()
settings['udp_enabled'] = self.udp.isChecked()
settings['proxy_type'] = 2 - int(self.http.isChecked())
settings['proxy_host'] = self.proxyip.text()
settings['proxy_port'] = int(self.proxyport.text())
settings.save()
# recreate tox instance
Profile.get_instance().reset(self.reset)
示例15: friend_name
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import get_instance [as 别名]
def friend_name(tox, friend_num, name, size, user_data):
"""
Friend changed his name
"""
profile = Profile.get_instance()
print('New name friend #' + str(friend_num))
invoke_in_main_thread(profile.new_name, friend_num, name)