本文整理汇总了Python中PythonQt.QtUiTools.QUiLoader.load方法的典型用法代码示例。如果您正苦于以下问题:Python QUiLoader.load方法的具体用法?Python QUiLoader.load怎么用?Python QUiLoader.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonQt.QtUiTools.QUiLoader
的用法示例。
在下文中一共展示了QUiLoader.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self, uistring, queue, endApplication, controller):
self.controller = controller
loader = QUiLoader()
uifile = QFile(uistring)
ui = loader.load(uifile)
self.gui = ui
width = ui.size.width()
height = ui.size.height()
uism = naali.ui
# uiprops = r.createUiWidgetProperty(1) #1 is ModuleWidget, shown at toolbar
# uiprops.SetMenuGroup(2) #2 is server tools group
# uiprops.widget_name_ = "Local Scene"
#uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it
#self.proxywidget = r.createUiProxyWidget(ui, uiprops)
self.proxywidget = r.createUiProxyWidget(ui)
#if not uism.AddProxyWidget(self.proxywidget):
if not uism.AddWidgetToScene(self.proxywidget):
r.logInfo("Adding the ProxyWidget to the bar failed.")
# TODO: Due to core UI API refactor AddWidgetToMenu doesn't exist anymore.
#uism.AddWidgetToMenu(self.proxywidget, "Local Scene", "Server Tools", "./data/ui/images/menus/edbutton_LSCENE_normal.png")
self.inputQueue = queue
self.endApplication = endApplication
self.tableitems = []
pass
示例2: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self):
uil = QUiLoader()
self.settingsDialog = uil.load(QFile(workingDir + "/settings.ui"))
self.settingsDialog.group_account.button_authenticate.connect("clicked()", self.startAuthenticationProcess)
self.settingsDialog.group_account.widget_loggedIn.button_logout.connect("clicked()", self.logOut)
self.settingsDialog.group_name.input_name.connect("textChanged(QString)", self.nameFormatEdited)
self.loadSettings()
示例3: ShellUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class ShellUploader():
def __init__(self):
self.uil = QUiLoader()
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.settingsDialog.group_shell.input_command.text = self.commandFormat
self.settingsDialog.open()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("shell")
self.commandFormat = settings.value("command", "")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("shell")
settings.setValue("command", self.settingsDialog.group_shell.input_command.text)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
if not self.commandFormat:
return False
return True
def getFilename(self):
timestamp = time.time()
return ScreenCloud.formatFilename(str(timestamp))
def upload(self, screenshot, name):
self.loadSettings()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
command = string.Formatter().vformat(self.commandFormat, (), defaultdict(str, s = tmpFilename))
try:
command = command.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
ScreenCloud.setError("Invalid characters in command '" + command + "'")
return False
try:
p = subprocess.Popen(command.split())
p.wait()
if p.returncode > 0:
ScreenCloud.setError("Command " + command + " did not return 0")
return False
except OSError:
ScreenCloud.setError("Failed to run command " + command)
return False
return True
示例4: ZapierUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class ZapierUploader():
def __init__(self):
self.uil = QUiLoader()
self.loadSettings()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("zapier")
self.zapier_url = settings.value("url", "")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
self.zapier_url = self.settingsDialog.group_url.widget_url.input_url.text
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("zapier")
settings.setValue("url", self.zapier_url)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
return bool(self.zapier_url.strip())
def getFilename(self):
return ScreenCloud.formatFilename("screenshot")
def showSettingsUI(self, parentWidget):
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.settingsDialog.setWindowTitle("Zapier settings");
self.settingsDialog.group_url.widget_url.input_url.setText(self.zapier_url)
self.settingsDialog.adjustSize()
self.settingsDialog.open()
def upload(self, screenshot, name):
ba = QByteArray()
buf = QBuffer(ba)
buf.open(QIODevice.WriteOnly)
screenshot.save( buf, ScreenCloud.getScreenshotFormat() ) #writes image into ba
buf.close()
json_data = json.dumps({'image': ba.toBase64().data()})
request = urllib2.Request(self.zapier_url, json_data, {"Content-Type": "application/json"})
try:
reply = urllib2.urlopen(request)
except Exception as e:
ScreenCloud.setError("Could not upload to: "+ self.zapier_url + "\n" + e.message)
return False
try:
replyText = reply.read()
ScreenCloud.setUrl(json.loads(replyText).link)
except Exception as e:
ScreenCloud.setError("Could not upload to: "+ self.zapier_url + "\n" + e.message)
return False
return True
示例5: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self):
self.sels = []
Component.__init__(self)
self.window = window.ObjectEditWindow(self)
self.resetValues()
self.worldstream = r.getServerConnection()
self.mouse_events = {
#r.LeftMouseClickPressed: self.LeftMousePressed,
r.InWorldClick: self.LeftMousePressed,
r.LeftMouseClickReleased: self.LeftMouseReleased,
r.RightMouseClickPressed: self.RightMousePressed,
r.RightMouseClickReleased: self.RightMouseReleased
}
self.shortcuts = {
#r.PyObjectEditDeselect: self.deselect,
r.PyObjectEditToggleMove: self.window.manipulator_move,#"ALT+M", #move
r.PyObjectEditToggleScale: self.window.manipulator_scale,#"ALT+S" #, #scale
r.Delete: self.deleteObject,
r.Undo: self.undo,
r.PyDuplicateDrag: self.duplicateStart,
r.ObjectLink: self.linkObjects,
r.ObjectUnlink: self.unlinkObjects,
}
self.resetManipulators()
loader = QUiLoader()
selectionfile = QFile(self.SELECTIONRECT)
self.selection_rect = loader.load(selectionfile)
rectprops = r.createUiWidgetProperty(2)
#~ print type(rectprops), dir(rectprops)
#print rectprops.WidgetType
#uiprops.widget_name_ = "Selection Rect"
#uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it
proxy = r.createUiProxyWidget(self.selection_rect, rectprops)
uism = r.getUiSceneManager()
uism.AddProxyWidget(proxy)
proxy.setWindowFlags(0) #changing it to Qt::Widget
self.selection_rect.setGeometry(0,0,0,0)
self.selection_rect_startpos = None
r.c = self #this is for using objectedit from command.py
示例6: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self):
Component.__init__(self)
loader = QUiLoader()
uism = r.getUiSceneManager()
uifile = QFile(UIFILELOC)
self.widget = loader.load(uifile)
uism.SetDemoLoginWidget(self.widget)
def make_worldlogin(w):
def worldlogin():
self.login(w)
return worldlogin
for w in self.WORLDS:
but = getattr(self.widget, w.butname)
but.connect('clicked()', make_worldlogin(w))
示例7: type
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
print text
print type(text), r.c.widgetList
print r.c.widgetList[720010]
if 0: #QtUI::UICanvas::External ?! not here...
from PythonQt.QtUiTools import QUiLoader
from PythonQt.QtCore import QFile, QIODevice
#print dir(quil)
#print dir(PythonQt.QtCore.QIODevice)
loader = QUiLoader()
canvas = r.createCanvas(0)
file = QFile("pymodules/usr/editobject.ui")
iodev = QIODevice(file)
widget = loader.load(file)
canvas.AddWidget(widget)
canvas.Show()
if 0: #collada load testing
import collada
print collada.Collada
try:
pycollada_test
except:
import pycollada_test
else:
pycollada_test = reload(pycollada_test)
if 0: #canvas size edit
box = r.c
示例8: ZapierUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class ZapierUploader():
def __init__(self):
self.uil = QUiLoader()
self.loadSettings()
def isConfigured(self):
self.loadSettings()
return bool(self.zapier_url.strip())
def getFilename(self):
return ScreenCloud.formatFilename("screenshot")
def showSettingsUI(self, parentWidget):
self.parent_widget = parentWidget
self.settings_widget = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settings_widget.connect("accepted()", self.saveSettings)
self.settings_widget.setWindowTitle("Zapier settings")
self.settings_widget.group_url.widget_url.input_url.setText(self.zapier_url)
self.settings_widget.adjustSize()
self.settings_widget.open()
def upload(self, screenshot, name):
q_byte_array = QByteArray()
q_buffer = QBuffer(q_byte_array)
q_buffer.open(QIODevice.WriteOnly)
screenshot.save(q_buffer, ScreenCloud.getScreenshotFormat()) # writes image to byte array
q_buffer.close()
json_data = json.dumps({'image': str(q_byte_array.toBase64())})
#f = open('/tmp/zapier', 'w')
#f.write("{}\n{}\n\n".format(self.zapier_url, json_data))
#f.close()
response = requests.post(url=self.zapier_url,
data=json_data,
headers={'Content-Type': 'application/json'})
try:
response.raise_for_status()
except Exception as e:
ScreenCloud.setError("Could not upload to: " + self.zapier_url + "\n" + e.message)
return False
try:
ScreenCloud.setUrl(response.json()['link'])
except Exception as e:
ScreenCloud.setError("Upload to {} worked, but response was invalid: {}\n{}".format(self.zapier_url, response.content, e.message))
return False
return True
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("zapier")
self.zapier_url = settings.value("url", "")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
self.zapier_url = self.settings_widget.group_url.widget_url.input_url.text
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("zapier")
settings.setValue("url", self.zapier_url)
settings.endGroup()
settings.endGroup()
示例9: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self):
self.sels = []
Component.__init__(self)
self.window = window.ObjectEditWindow(self)
self.resetValues()
self.worldstream = r.getServerConnection()
self.usingManipulator = False
self.useLocalTransform = False
self.cpp_python_handler = None
self.left_button_down = False
self.keypressed = False
self.shortcuts = {
(Qt.Key_Z, Qt.ControlModifier) : self.undo,
(Qt.Key_Delete, Qt.NoModifier) : self.deleteObject,
(Qt.Key_L, Qt.AltModifier) : self.linkObjects,
(Qt.Key_L, Qt.ControlModifier|Qt.ShiftModifier) : self.unlinkObjects,
}
# Connect to key pressed signal from input context
self.edit_inputcontext = naali.createInputContext("object-edit", 100)
self.edit_inputcontext.SetTakeMouseEventsOverQt(True)
self.edit_inputcontext.connect('KeyPressed(KeyEvent*)', self.on_keypressed)
# Connect to mouse events
self.edit_inputcontext.connect('MouseScroll(MouseEvent*)', self.on_mousescroll)
self.edit_inputcontext.connect('MouseLeftPressed(MouseEvent*)', self.on_mouseleftpressed)
self.edit_inputcontext.connect('MouseLeftReleased(MouseEvent*)', self.on_mouseleftreleased)
self.edit_inputcontext.connect('MouseMove(MouseEvent*)', self.on_mousemove)
self.resetManipulators()
loader = QUiLoader()
selectionfile = QFile(self.SELECTIONRECT)
self.selection_rect = loader.load(selectionfile)
#rectprops = r.createUiWidgetProperty(2)
#~ print type(rectprops), dir(rectprops)
#print rectprops.WidgetType
#uiprops.widget_name_ = "Selection Rect"
#uiprops.my_size_ = QSize(width, height) #not needed anymore, uimodule reads it
proxy = r.createUiProxyWidget(self.selection_rect)
uism = r.getUiSceneManager()
uism.AddWidgetToScene(proxy)
proxy.setWindowFlags(0) #changing it to Qt::Widget
self.selection_rect.setGeometry(0,0,0,0)
self.selection_rect_startpos = None
r.c = self #this is for using objectedit from command.py
# Get world building modules python handler
self.cpp_python_handler = r.getQWorldBuildingHandler()
if self.cpp_python_handler == None:
r.logDebug("Could not aqquire world building service to object edit")
else:
# Connect signals
self.cpp_python_handler.connect('ActivateEditing(bool)', self.on_activate_editing)
self.cpp_python_handler.connect('ManipulationMode(int)', self.on_manupulation_mode_change)
self.cpp_python_handler.connect('RemoveHightlight()', self.deselect_all)
self.cpp_python_handler.connect('RotateValuesToNetwork(int, int, int)', self.changerot_cpp)
self.cpp_python_handler.connect('ScaleValuesToNetwork(double, double, double)', self.changescale_cpp)
self.cpp_python_handler.connect('PosValuesToNetwork(double, double, double)', self.changepos_cpp)
self.cpp_python_handler.connect('CreateObject()', self.createObject)
self.cpp_python_handler.connect('DuplicateObject()', self.duplicate)
self.cpp_python_handler.connect('DeleteObject()', self.deleteObject)
# Pass widgets
self.cpp_python_handler.PassWidget("Mesh", self.window.mesh_widget)
self.cpp_python_handler.PassWidget("Animation", self.window.animation_widget)
self.cpp_python_handler.PassWidget("Sound", self.window.sound_widget)
self.cpp_python_handler.PassWidget("Materials", self.window.materialTabFormWidget)
# Check if build mode is active, required on python restarts
self.on_activate_editing(self.cpp_python_handler.IsBuildingActive())
示例10: FTPUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class FTPUploader():
def __init__(self):
self.uil = QUiLoader()
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.group_location.input_name.connect("textChanged(QString)", self.nameFormatEdited)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.settingsDialog.group_server.input_host.text = self.host
self.settingsDialog.group_server.input_port.value = self.port
self.settingsDialog.group_server.input_username.text = self.username
self.settingsDialog.group_server.input_password.text = self.password
self.settingsDialog.group_server.input_url.text = self.url
self.settingsDialog.group_location.input_folder.text = self.folder
self.settingsDialog.group_location.input_name.text = self.nameFormat
self.settingsDialog.open()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("ftp")
self.host = settings.value("host", "")
self.port = int(settings.value("port", 21))
self.username = settings.value("username", "")
self.password = settings.value("password", "")
self.url = settings.value("url", "")
self.folder = settings.value("folder", "")
self.nameFormat = settings.value("name-format", "Screenshot at %H-%M-%S")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("ftp")
settings.setValue("host", self.settingsDialog.group_server.input_host.text)
settings.setValue("port", int(self.settingsDialog.group_server.input_port.value))
settings.setValue("username", self.settingsDialog.group_server.input_username.text)
settings.setValue("password", self.settingsDialog.group_server.input_password.text)
settings.setValue("url", self.settingsDialog.group_server.input_url.text)
settings.setValue("folder", self.settingsDialog.group_location.input_folder.text)
settings.setValue("name-format", self.settingsDialog.group_location.input_name.text)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
return not(not self.host or not self.username or not self.password or not self.folder)
def getFilename(self):
self.loadSettings()
return ScreenCloud.formatFilename(self.nameFormat)
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
ftp = ftplib.FTP()
ftp.connect(self.host, self.port)
ftp.login(self.username, self.password)
f = open(tmpFilename, 'rb')
try:
ftp.cwd(self.folder)
except ftplib.error_perm as err:
ScreenCloud.setError(err.message)
return False
try:
ftp.storbinary('STOR ' + name, f)
except ftplib.error_perm as err:
ScreenCloud.setError(err.message)
return False
ftp.quit()
f.close()
if self.url:
ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
return True
def nameFormatEdited(self, nameFormat):
self.settingsDialog.group_location.label_example.setText(ScreenCloud.formatFilename(nameFormat))
示例11: OwnCloudUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class OwnCloudUploader():
def __init__(self):
self.uil = QUiLoader()
self.loadSettings()
def updateUi(self):
self.loadSettings()
if self.connectStatus:
self.settingsDialog.group_connection.widget_status.label_status.setText("Valid")
else:
self.settingsDialog.group_connection.widget_status.label_status.setText("Unknown")
self.settingsDialog.group_name.input_name.setText(self.nameFormat)
self.settingsDialog.adjustSize()
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.group_connection.button_authenticate.connect("clicked()", self.startAuthenticationProcess)
self.settingsDialog.group_name.input_name.connect("textChanged(QString)", self.nameFormatEdited)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.settingsDialog.group_account.input_url.text = self.url
self.settingsDialog.group_account.input_username.text = self.username
self.settingsDialog.group_account.input_password.text = self.password
self.settingsDialog.group_name.input_path.text = self.remotePath
self.settingsDialog.group_name.input_name.text = self.nameFormat
self.settingsDialog.group_clipboard.radio_dontcopy.setChecked(not self.copyLink)
self.settingsDialog.group_clipboard.radio_directlink.setChecked(self.copyDirectLink)
self.updateUi()
self.settingsDialog.open()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("owncloud")
self.url = settings.value("url", "")
self.username = settings.value("username", "")
self.password = settings.value("password", "")
self.remotePath = settings.value("remote-path", "")
self.connectStatus = settings.value("connect-status", "")
self.nameFormat = settings.value("name-format", "Screenshot at %H:%M:%S")
self.copyLink = settings.value("copy-link", "true") in ['true', True]
self.copyDirectLink = settings.value("copy-direct-link", "false") in ['true', True]
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("owncloud")
settings.setValue("url", self.settingsDialog.group_account.input_url.text)
settings.setValue("username", self.settingsDialog.group_account.input_username.text)
settings.setValue("password", self.settingsDialog.group_account.input_password.text)
settings.setValue("remote-path", self.settingsDialog.group_name.input_path.text)
settings.setValue("connect-status", self.connectStatus)
settings.setValue("name-format", self.settingsDialog.group_name.input_name.text)
settings.setValue("copy-link", not self.settingsDialog.group_clipboard.radio_dontcopy.checked)
settings.setValue("copy-direct-link", self.settingsDialog.group_clipboard.radio_directlink.checked)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
return self.connectStatus
def getFilename(self):
self.loadSettings()
return ScreenCloud.formatFilename(self.nameFormat)
def upload(self, screenshot, name):
return True
def startAuthenticationProcess(self):
if self.settingsDialog.group_account.input_url.text and self.settingsDialog.group_account.input_username.text and self.settingsDialog.group_account.input_password.text:
self.saveSettings()
self.loadSettings()
if match(self.url, "URI"):
try:
request = requests.get(self.url, timeout=3);
if request.status_code == 200:
oc = owncloud.Client(self.url)
oc.login(self.username, self.password)
self.connectStatus = "true"
self.saveSettings()
self.updateUi()
except requests.exceptions.RequestException as e:
QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", "The specified Server URL is invalid!")
settings = QSettings()
settings.remove("connect-status")
self.saveSettings()
self.updateUi()
except Exception as e:
errorMessage = self.formatConnectionError(e.message)
if errorMessage == "401":
self.settingsDialog.group_connection.widget_status.label_status.setText("Invalid")
else:
QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", errorMessage)
#.........这里部分代码省略.........
示例12: YASCPUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class YASCPUploader():
def __init__(self):
self.uil = QUiLoader()
self.loadSettings()
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.settingsDialog.group_server.combo_type.setCurrentIndex(self.settingsDialog.group_server.combo_type.findText(self.type))
self.settingsDialog.group_server.input_username.text = self.username
self.settingsDialog.group_server.input_password.text = self.password
self.settingsDialog.group_server.input_host.text = self.host
self.settingsDialog.group_server.input_port.text = self.port
self.settingsDialog.group_upload.input_url.text = self.url
self.settingsDialog.group_upload.input_path.text = self.path
self.settingsDialog.open()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("yascp")
self.type = settings.value("type", "SFTP")
self.username = settings.value("username", "")
self.password = settings.value("password", "")
self.host = settings.value("host", "")
if self.type == "FTP":
port = 21
elif self.type == "SFTP":
port = 22
self.port = int(settings.value("port", port))
self.url = settings.value("url", "")
self.path = settings.value("path", "")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("yascp")
settings.setValue("type", self.settingsDialog.group_server.combo_type.currentText)
settings.setValue("username", self.settingsDialog.group_server.input_username.text)
settings.setValue("password", self.settingsDialog.group_server.input_password.text)
settings.setValue("host", self.settingsDialog.group_server.input_host.text)
settings.setValue("port", self.settingsDialog.group_server.input_port.text)
settings.setValue("url", self.settingsDialog.group_upload.input_url.text)
settings.setValue("path", self.settingsDialog.group_upload.input_path.text)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
return not(not self.username or not self.password or not self.host or not self.port or not self.url or not self.path or not self.type)
def getFilename(self):
self.loadSettings()
name = uuid.uuid4().hex
return ScreenCloud.formatFilename(name[:16])
def upload(self, screenshot, name):
self.loadSettings()
f = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(name)
screenshot.save(QFile(f), ScreenCloud.getScreenshotFormat())
now = datetime.datetime.now()
date = "/%s/%02d/%02d" % (now.year, now.month, now.day)
path = "/%s/%02d/%02d/%s" % (now.year, now.month, now.day, ScreenCloud.formatFilename(name))
if self.type == "SFTP":
transport = paramiko.Transport((self.host, self.port))
transport.connect(username = self.username, password = self.password)
sftp = paramiko.SFTPClient.from_transport(transport)
try:
sftp.chdir(os.path.normpath(self.path) + date)
except IOError:
sftp.mkdir(os.path.normpath(self.path) + date)
try:
sftp.put(f, os.path.normpath(self.path) + path)
except IOError:
ScreenCloud.setError("Failed to write file")
sftp.close()
transport.close()
elif self.type == "FTP":
ftp = ftplib.FTP()
ftp.connect(self.host, self.port)
ftp.login(self.username, self.password)
if os.path.normpath(self.path) in ftp.nlst():
try:
ftp.cwd(os.path.normpath(self.path))
except ftplib.error_perm as err:
ScreenCloud.setError(err.message)
return False
#.........这里部分代码省略.........
示例13: ShellUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class ShellUploader():
def __init__(self):
self.uil = QUiLoader()
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.settingsDialog.group_shell.input_command.text = self.commandFormat
self.settingsDialog.group_shell.output_is_url.checked = self.outputIsUrl
self.settingsDialog.open()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("shell")
self.commandFormat = settings.value("command", "")
self.outputIsUrl = settings.value("copyOutput",str(False)) == "True"
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("shell")
settings.setValue("command", self.settingsDialog.group_shell.input_command.text)
settings.setValue("copyOutput", str(self.settingsDialog.group_shell.output_is_url.checked))
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
if not self.commandFormat:
return False
return True
def getFilename(self):
timestamp = time.time()
return ScreenCloud.formatFilename(str(timestamp))
def upload(self, screenshot, name):
self.loadSettings()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + name
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
command = string.Formatter().vformat(self.commandFormat, (), defaultdict(str, s = tmpFilename))
try:
command = command.encode(sys.getfilesystemencoding())
except UnicodeEncodeError:
ScreenCloud.setError("Invalid characters in command '" + command + "'")
return False
try:
if self.outputIsUrl:
pipe = subprocess.PIPE
else:
pipe = None
p = subprocess.Popen(command, shell=True, stdout=pipe)
p.wait()
if p.returncode > 0:
ScreenCloud.setError("Command %s returned %d, but 0 was expected" % (str(command), int(p.returncode)))
return False
elif self.outputIsUrl:
result = bytes.decode(p.stdout.read())
result = result.strip()
ScreenCloud.setUrl(result)
except OSError:
ScreenCloud.setError("Failed to run command " + command)
return False
return True
示例14: DropboxUploader
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
class DropboxUploader():
def __init__(self):
self.uil = QUiLoader()
self.loadSettings()
if self.access_token:
self.client = dropbox.client.DropboxClient(self.access_token)
def showSettingsUI(self, parentWidget):
self.parentWidget = parentWidget
self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget)
self.settingsDialog.group_account.widget_authorize.button_authenticate.connect("clicked()", self.startAuthenticationProcess)
self.settingsDialog.group_account.widget_loggedIn.button_logout.connect("clicked()", self.logout)
self.settingsDialog.group_name.input_nameFormat.connect("textChanged(QString)", self.nameFormatEdited)
self.settingsDialog.connect("accepted()", self.saveSettings)
self.loadSettings()
self.updateUi()
self.settingsDialog.open()
def updateUi(self):
self.loadSettings()
if not self.access_token:
self.settingsDialog.group_account.widget_loggedIn.setVisible(False)
self.settingsDialog.group_account.widget_authorize.setVisible(True)
self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(True)
self.settingsDialog.group_name.setEnabled(False)
self.settingsDialog.group_clipboard.setEnabled(False)
else:
self.settingsDialog.group_account.widget_loggedIn.setVisible(True)
self.settingsDialog.group_account.widget_authorize.setVisible(False)
self.settingsDialog.group_account.widget_loggedIn.label_user.setText(self.display_name)
self.settingsDialog.group_name.setEnabled(True)
self.settingsDialog.group_clipboard.setEnabled(True)
self.settingsDialog.group_clipboard.radio_publiclink.setChecked(self.copy_link)
self.settingsDialog.group_clipboard.radio_dontcopy.setChecked(not self.copy_link)
self.settingsDialog.group_name.input_nameFormat.setText(self.nameFormat)
self.settingsDialog.adjustSize()
def loadSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("dropbox")
self.access_token = settings.value("access-token", "")
self.user_id = settings.value("user-id", "")
self.display_name = settings.value("display-name", "")
self.copy_link = settings.value("copy-link", "true") in ['true', True]
self.nameFormat = settings.value("name-format", "Screenshot at %H-%M-%S")
settings.endGroup()
settings.endGroup()
def saveSettings(self):
settings = QSettings()
settings.beginGroup("uploaders")
settings.beginGroup("dropbox")
settings.setValue("access-token", self.access_token)
settings.setValue("user-id", self.user_id)
settings.setValue("display-name", self.display_name)
settings.setValue("copy-link", self.settingsDialog.group_clipboard.radio_publiclink.checked)
settings.setValue("name-format", self.settingsDialog.group_name.input_nameFormat.text)
settings.endGroup()
settings.endGroup()
def isConfigured(self):
self.loadSettings()
if not self.access_token:
return False
return True
def getFilename(self):
self.loadSettings()
return ScreenCloud.formatFilename(self.nameFormat)
def upload(self, screenshot, name):
self.loadSettings()
timestamp = time.time()
try:
tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
except AttributeError:
from PythonQt.QtCore import QStandardPaths #fix for Qt5
tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
f = open(tmpFilename, 'rb')
response = self.client.put_file('/' + ScreenCloud.formatFilename(name), f)
f.close()
os.remove(tmpFilename)
if self.copy_link:
share = self.client.share('/' + ScreenCloud.formatFilename(name), False)
ScreenCloud.setUrl(share['url'].replace('dl=0', 'raw=1'))
return True
def selectFolderClicked(self):
self.selectFolderDialog.exec_()
def startAuthenticationProcess(self):
self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(False)
self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect('sfacmqvdb9dn66r', 'hx8meda636xgsox')
authorize_url = QUrl(self.flow.start())
QDesktopServices.openUrl(authorize_url)
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from PythonQt.QtUiTools import QUiLoader [as 别名]
# 或者: from PythonQt.QtUiTools.QUiLoader import load [as 别名]
def __init__(self, controller, queue):
loader = QUiLoader()
loader.setLanguageChangeEnabled(True)
# uifile = QFile("pymodules/estatemanagement/estatemanagement.ui")
uifile = QFile(EstateManagementWindow.UIFILE)
self.gui = loader.load(uifile)
self.controller = controller
IncomingMessagesHandler.__init__(self, queue, self.endMethod)
uism = naali.ui
# uiprops = r.createUiWidgetProperty(1) # 1 = Qt::Dialog
# uiprops.SetMenuGroup("Server Tools")
# uiprops.name_ = "Estate Management"
self.proxywidget = r.createUiProxyWidget(self.gui)
self.proxywidget.setWindowTitle("Estate Management")
if not uism.AddWidgetToScene(self.proxywidget):
r.logInfo("Adding ProxyWidget failed.")
# TODO: Due to core UI API refactor RemoveWidgetFromMenu doesn't exist anymore.
# uism.AddWidgetToMenu(self.proxywidget, "Estate Management", "Server Tools", "./data/ui/images/menus/edbutton_ESMNG_normal.png")
self.btnLoadEstate = self.gui.findChild("QPushButton", "btnLoadEstate")
self.listWEI = self.gui.findChild("QListWidget", "listWidgetEstateInfo")
self.listWRU = self.gui.findChild("QListWidget", "listWidgetRegionUsers")
self.listWEB = self.gui.findChild("QListWidget", "listWidgetBanList")
self.listWAL = self.gui.findChild("QListWidget", "listWidgetAccessList")
self.listWEM = self.gui.findChild("QListWidget", "listWidgetEstateManagers")
self.listWSU = self.gui.findChild("QListWidget", "listWidgetSavedUsers")
self.labelEstateInfo = self.gui.findChild("QLabel", "labelEstateInfo")
self.tableEstates = self.gui.findChild("QListWidget", "tableWidgetEstates")
self.chkEstateAccess = self.gui.findChild("QCheckBox", "checkBoxEstateAccess")
self.lineCurrentEstate = self.gui.findChild("QLineEdit", "lineEditCurrentEstate")
self.listWidgetEstates = self.gui.findChild("QListWidget", "listWidgetEstates")
self.btnSetEstate = self.gui.findChild("QPushButton", "pushButtonSetEstate")
self.chkSunFixed = self.gui.findChild("QCheckBox", "checkBoxSunFixed")
# PublicAllowed
# ExternallyVisible);
self.chkAllowVoice = self.gui.findChild("QCheckBox", "checkBoxAllowVoice")
self.chkAllowDirectTeleport = self.gui.findChild("QCheckBox", "checkBoxAllowDirectTeleport")
self.chkDenyAnonymous = self.gui.findChild("QCheckBox", "checkBoxDenyAnonymous")
self.chkDenyIdentified = self.gui.findChild("QCheckBox", "checkBoxDenyIdentified")
self.chkDenyTransacted = self.gui.findChild("QCheckBox", "checkBoxDenyTransacted")
self.chkAbuseEmailToEstateOwner = self.gui.findChild("QCheckBox", "checkBoxAbuseEmailToEstateOwner")
self.chkBlockDwell = self.gui.findChild("QCheckBox", "checkBoxBlockDwell")
self.chkEstateSkipScripts = self.gui.findChild("QCheckBox", "checkBoxEstateSkipScripts")
self.chkResetHomeOnTeleport = self.gui.findChild("QCheckBox", "checkBoxResetHomeOnTeleport")
self.chkTaxFree = self.gui.findChild("QCheckBox", "checkBoxTaxFree")
self.chkDenyAgeUnverified = self.gui.findChild("QCheckBox", "checkBoxDenyAgeUnverified")
self.btnLoadEstate.connect("clicked(bool)", self.btnLoadEstateClicked)
self.btnToBan = self.gui.findChild("QPushButton", "pushButtonToBan")
self.btnToAccess = self.gui.findChild("QPushButton", "pushButtonToAccess")
self.btnToManagers = self.gui.findChild("QPushButton", "pushButtonToManagers")
self.btnSaveUserInfo = self.gui.findChild("QPushButton", "pushButtonSaveUserInfo")
self.btnRemoveBan = self.gui.findChild("QPushButton", "pushButtonRemoveBan")
self.btnRemoveAccess = self.gui.findChild("QPushButton", "pushButtonRemoveAccess")
self.btnRemoveManagers = self.gui.findChild("QPushButton", "pushButtonRemoveManager")
self.btnRemoveSaved = self.gui.findChild("QPushButton", "pushButtonRemoveSaved")
self.btnSavedToAccess = self.gui.findChild("QPushButton", "pushButtonSavedToAccess")
self.btnSavedToBan = self.gui.findChild("QPushButton", "pushButtonSavedToBan")
self.btnSavedToManagers = self.gui.findChild("QPushButton", "pushButtonSavedToManagers")
self.btnKick = self.gui.findChild("QPushButton", "pushButtonKick")
self.btnRequestGodLikePowers = self.gui.findChild("QPushButton", "pushButtonRequestGodLikePowers")
self.lineKickMessage = self.gui.findChild("QLineEdit", "lineEditKickMessage")
self.btnToBan.connect("clicked(bool)", self.btnToBanClicked)
self.btnToAccess.connect("clicked(bool)", self.btnToAccessClicked)
self.btnToManagers.connect("clicked(bool)", self.btnToManagersClicked)
self.btnSaveUserInfo.connect("clicked(bool)", self.btnSaveUserInfoClicked)
self.btnRemoveBan.connect("clicked(bool)", self.btnRemoveBanClicked)
self.btnRemoveAccess.connect("clicked(bool)", self.btnRemoveAccessClicked)
self.btnRemoveManagers.connect("clicked(bool)", self.btnRemoveManagersClicked)
self.btnRemoveSaved.connect("clicked(bool)", self.btnRemoveSavedClicked)
self.btnSavedToAccess.connect("clicked(bool)", self.btnSavedToAccessClicked)
self.btnSavedToBan.connect("clicked(bool)", self.btnSavedToBanClicked)
self.btnSavedToManagers.connect("clicked(bool)", self.btnSavedToManagersClicked)
self.btnRequestGodLikePowers.connect("clicked(bool)", self.btnRequestGodLikePowersClicked)
self.btnKick.connect("clicked(bool)", self.btnKickClicked)
self.btnSetEstate.connect("clicked(bool)", self.btnSetEstateClicked)
self.chkEstateAccess.connect("toggled(bool)", self.chkEstateAccessToggled)
# add incoming event handlers
self.addHandler("EstateUpdate", self.setEstateInfo)
self.addHandler("setEstateManagers", self.setEstateManagers)
self.addHandler("setEstateBans", self.setEstateBans)
self.addHandler("setEsteteAccessList", self.setEsteteAccessList)
#.........这里部分代码省略.........