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_url.input_address.text = self.url_address self.settingsDialog.open()
def showSettingsUI(self, parentWidget): self.parentWidget = parentWidget self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget) self.settingsDialog.group_server.combo_auth.connect( "currentIndexChanged(QString)", self.authMethodChanged) self.settingsDialog.group_server.button_browse.connect( "clicked()", self.browseForKeyfile) self.settingsDialog.group_location.input_name.connect( "textChanged(QString)", self.nameFormatEdited) self.settingsDialog.connect("accepted()", self.saveSettings) self.loadSettings() self.updateUi() 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_keyfile.text = self.keyfile self.settingsDialog.group_server.input_passphrase.text = self.passphrase self.settingsDialog.group_location.input_folder.text = self.folder self.settingsDialog.group_location.input_url.text = self.url self.settingsDialog.group_location.input_name.text = self.nameFormat self.settingsDialog.group_server.combo_auth.setCurrentIndex( self.settingsDialog.group_server.combo_auth.findText( self.authMethod)) self.settingsDialog.open()
def upload(self, screenshot, name): self.loadSettings() #Make sure we have a up to date token if not self.uploadAnon: try: self.imgur.refresh_access_token() except Exception as e: ScreenCloud.setError("Failed to refresh imgur access token. " + e.message) return False #Save to a temporary file 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()) #Upload! try: uploaded_image = self.imgur.upload_image( tmpFilename, title=ScreenCloud.formatFilename(name, False)) except Exception as e: ScreenCloud.setError("Failed to upload to imgur. " + e.message) return False if self.copyLink: if self.copyDirectLink: ScreenCloud.setUrl(uploaded_image.link) else: ScreenCloud.setUrl("https://imgur.com/" + uploaded_image.id) return True
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()) 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 showSettingsUI(self, parentWidget): self.parentWidget = parentWidget self.settingsDialog = self.uil.load(QFile(workingDir + '/settings.ui'), parentWidget) self.settingsDialog.group_url.check_copylink.connect( 'stateChanged(int)', self.updateUI) self.settingsDialog.group_screenshot.input_name.connect( 'textChanged(QString)', self.nameFormatEdited) self.settingsDialog.group_screenshot.check_savefile.connect( 'stateChanged(int)', self.updateUI) self.settingsDialog.group_screenshot.button_browse.connect( 'clicked()', self.browseForDirectory) self.settingsDialog.connect('accepted()', self.saveSettings) self.loadSettings() self.settingsDialog.group_url.input_url.text = self.dav_address self.settingsDialog.group_url.input_username.text = self.username self.settingsDialog.group_url.input_password.text = self.password self.settingsDialog.group_url.check_copylink.checked = self.copy_link self.settingsDialog.group_url.input_public.text = self.host_address self.settingsDialog.group_screenshot.input_name.text = self.name_format self.settingsDialog.group_screenshot.check_savefile.checked = self.save_file self.settingsDialog.group_screenshot.input_directory.text = self.save_path self.updateUI() self.settingsDialog.open()
def upload(self, screenshot, name): self.loadSettings() if self.loggedIn: self.client.auth_provider.refresh_token() #Save to temporary file 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()) #Workaround to get id of app folder import requests, json endpoint = "https://api.onedrive.com/v1.0/drives/me/special/approot" headers = { "Authorization": "Bearer " + self.client.auth_provider.access_token } response = requests.get(endpoint, headers=headers).json() appfolder_id = response["id"] #Upload uploaded_item = self.client.item(drive='me', id=appfolder_id).children[ ScreenCloud.formatFilename(name)].upload(tmpFilename) print(uploaded_item, " ".join(dir(uploaded_item)), str(uploaded_item), uploaded_item.id, uploaded_item.image) if self.copyLink: permission = self.client.item( id=uploaded_item.id).create_link("view").post() ScreenCloud.setUrl(permission.link.web_url) return True
def showSettingsUI(self, parentWidget): self.settingsDialog = QUiLoader().load(QFile(workingDir + "/settings.ui"), parentWidget) # Inject the image title format. self.settingsDialog.group_upload.input_name.connect("textChanged(QString)", self.nameFormatEdited) self.settingsDialog.connect("accepted()", self.saveSettings) # Inject the upload stream self.settingsDialog.group_upload.input_stream.text = self.Stream # Inject default values. self.loadSettings() self.settingsDialog.group_upload.input_name.text = self.Format self.settingsDialog.group_account.input_username.text = self.Username self.settingsDialog.group_account.input_password.text = self.Password self.settingsDialog.group_clipboard.radio_direct.setChecked(not self.copyDirect) self.settingsDialog.group_clipboard.radio_nothing.setChecked(not self.copyNothing) # Wait for login/out button activation. self.settingsDialog.group_account.widget_loggedIn.connect("clicked()", self.Logout) self.settingsDialog.group_account.button_authenticate.connect("clicked()", self.Login) self.updateUi() self.settingsDialog.open()
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
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.files_upload( f, '/' + ScreenCloud.formatFilename(name)) f.close() os.remove(tmpFilename) if self.copy_link: share = self.client.sharing_create_shared_link( '/' + ScreenCloud.formatFilename(name), short_url=True) ScreenCloud.setUrl(share.url) return True
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 = r.getUiSceneManager() # 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.") 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
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_puush.input_api_key.text = self.apiKey self.settingsDialog.open()
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 upload(self, screenshot, name): self.loadSettings() f = QFile(self.folder + "/" + ScreenCloud.formatFilename(name)) f.open(QIODevice.WriteOnly) if not f.isWritable(): ScreenCloud.setError("File " + f.fileName() + " is not writable!") return False screenshot.save(f, ScreenCloud.getScreenshotFormat()) f.close() return True
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 showSettingsUI(self, parentWidget): self.parentWidget = parentWidget self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget) self.settingsDialog.group_name.input_name.connect( "textChanged(QString)", self.nameFormatEdited) self.settingsDialog.connect("accepted()", self.saveSettings) self.updateUi() self.settingsDialog.open()
def upload(self, screenshot, name): self.loadSettings() #Save to a temporary file 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()) #Connect to server try: transport = paramiko.Transport((self.host, self.port)) except Exception as e: ScreenCloud.setError(e.message) return False if self.authMethod == "Password": try: transport.connect(username=self.username, password=self.password) except paramiko.AuthenticationException: ScreenCloud.setError("Authentication failed (password)") return False else: try: private_key = paramiko.RSAKey.from_private_key_file( self.keyfile, password=self.passphrase) transport.connect(username=self.username, pkey=private_key) except paramiko.AuthenticationException: ScreenCloud.setError("Authentication failed (key)") return False except paramiko.SSHException as e: ScreenCloud.setError("Error while connecting to " + self.host + ":" + str(self.port) + ". " + e.message) return False except Exception as e: ScreenCloud.setError("Unknown error: " + e.message) return False sftp = paramiko.SFTPClient.from_transport(transport) try: sftp.put(tmpFilename, self.folder + "/" + ScreenCloud.formatFilename(name)) except IOError: ScreenCloud.setError("Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions.") return False sftp.close() transport.close() if self.url: ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name)) return True
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 requestExtIcon(self, filename): self.nwmc_exti[filename] = QNetworkAccessManager() self.nwmc_exti[filename].connect("finished(QNetworkReply*)", self.loadExtIcon) self.tmpfile[filename] = QFile() self.tmpfile[filename].setFileName(path.join(self.icons, filename)) self.tmpfile[filename].open(QIODevice.WriteOnly) url = "https://raw.githubusercontent.com/R4P3-NET/CustomBadges/master/img/{}".format( filename) self.nwmc_exti[filename].get(QNetworkRequest(QUrl(url)))
def save(self, screenshot, name, path=None): path = QStandardPaths.writableLocation(QStandardPaths.TempLocation) path = os.path.join(path, name) try: screenshot.save(QFile(path), ScreenCloud.getScreenshotFormat()) except Exception as e: raise return path
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_url.token.text = self.token self.settingsDialog.group_url.host.text = self.host self.settingsDialog.open()
def upload(self, screenshot, name): self.loadSettings() f = QFile(self.folder + "/" + ScreenCloud.formatFilename(name)) f.open(QIODevice.WriteOnly) if not f.isWritable(): ScreenCloud.setError("File " + f.fileName() + " is not writable!") return False screenshot.save(f, ScreenCloud.getScreenshotFormat()) f.close() return True
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
def onNetworkReply( self, reply ): #http://stackoverflow.com/questions/41712636/qnetworkrequest-for-generated-images try: print("Error: %s (%s)" % (reply.error(), reply.errorString())) print("Content-Type: %s" % reply.header(QNetworkRequest.ContentTypeHeader)) try: print("Content: %s" % reply.readAll()) except: pass #if reply.header(QNetworkRequest.ContentTypeHeader) == "image/jpeg": imgraw = reply.readAll() #.data()#.decode('utf-8') temp_dir = gettempdir() filename = self.generateAvatarFileName(self.schid) tmp = path.join(temp_dir, filename) fn = QFile(tmp) fn.open(QIODevice.WriteOnly) fn.write(imgraw) fn.close #with open(tmp, 'wb') as f: f.write(imgraw) ts3lib.logMessage("Uploading %s as new avatar." % tmp, ts3defines.LogLevel.LogLevel_INFO, "PyTSon Script", 0) self.uploadAvatar(self.schid, tmp, filename) except: from traceback import format_exc try: ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon Script", 0) except: print(format_exc()) reply.deleteLater()
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_url.input_url.text = self.remote_url self.settingsDialog.group_url.check_copylink.checked = self.copy_link self.settingsDialog.open()
def showSettingsUI(self, parentWidget): self.parentWidget = parentWidget self.settingsDialog = self.uil.load(QFile(workingDir + "/settings.ui"), parentWidget) self.settingsDialog.group_name.input_name.connect( "textChanged(QString)", self.nameFormatEdited) self.settingsDialog.group_location.button_browse.connect( "clicked()", self.browseForFolder) self.settingsDialog.connect("accepted()", self.saveSettings) self.loadSettings() self.settingsDialog.group_name.input_name.setText(self.nameFormat) self.settingsDialog.group_location.input_folder.setText(self.folder) self.settingsDialog.open()
def upload(self, screenshot, name): Headers = {"User-Agent": "ScreenCloud-Cloudup"} try: FilePath = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(time.time())) screenshot.save(QFile(FilePath), ScreenCloud.getScreenshotFormat()) # Has a stream been specified or should we create on? if self.Stream: Stream = self.Stream else: # Create stream s = requests.post("https://api.cloudup.com/1/streams?access_token=" + self.Key, data = {"title": name}, headers = Headers) c = s.json() Stream = c["id"] # Create item inside the stream i = requests.post("https://api.cloudup.com/1/items?access_token=" + self.Key, data = {"filename": FilePath, "stream_id": Stream}, headers = Headers) j = json.loads(i.text) # Upload requests.post(j["s3_url"], files = {"file": open(FilePath, "rb")}, data = { "key": j["s3_key"], "acl": "public-read", "policy": j["s3_policy"], "signature": j["s3_signature"], "AWSAccessKeyId": j["s3_access_key"], "Content-Type": "image/png", "Content-Length": os.path.getsize(FilePath) }, headers = Headers) # Completion signal requests.patch("https://api.cloudup.com/1/items/" + j["id"] + "?access_token=" + self.Key, json.dumps({u"complete": True}), headers = { "Content-Type": "application/json", "User-Agent": "ScreenCloud-Cloudup" }) # Does the user want the Cloudup item link? if self.copyCloudup: ScreenCloud.setUrl(j["url"]) # Does the user want the direct link? if self.copyDirect: ScreenCloud.setUrl(j["direct_url"]) except requests.exceptions.RequestException as E: ScreenCloud.setError("Failued to upload to Cloudup: " + E.message) return False return True
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 upload(self, screenshot, name): temp = QDesktopServices.storageLocation(QDesktopServices.TempLocation) file = temp + '/' + name screenshot.save(QFile(file), ScreenCloud.getScreenshotFormat()) ns = NoelShack() try: url = ns.upload(file) except NoelShackError as e: ScreenCloud.setError(str(e)) return False ScreenCloud.setUrl(url) return True
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()) try: oc = nextcloud.Client(self.url) oc.login(self.username, self.password) remotePath = "" if self.remotePath: remotePath = self.remotePath try: oc.file_info(remotePath) except Exception: oc.mkdir(remotePath) uploaded_image = oc.put_file( remotePath + "/" + ScreenCloud.formatFilename(name, False), tmpFilename) if self.copyLink: link_info = oc.share_file_with_link( remotePath + "/" + ScreenCloud.formatFilename(name, False)) share_link = link_info.get_link() if self.copyDirectLink: share_link = share_link + "/download" ScreenCloud.setUrl(share_link) return True except Exception as e: ScreenCloud.setError("Failed to upload to NextCloud. " + e.message) return False
def save(self, screenshot, name, path=None): if self.save_file and len(self.save_path) > 0: if os.path.isdir(self.save_path): path = self.save_path # else: # TODO: warn the user that the file could not be saved locally if not path: path = QStandardPaths.writableLocation(QStandardPaths.TempLocation) path = os.path.join(path, name) try: screenshot.save(QFile(path), ScreenCloud.getScreenshotFormat()) except Exception as e: raise return path
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))
def setupUi(obj, uipath, *, widgets=None, seticons=True, iconpack=None, pluginicons=None, extraWidgets=None): """ Loads a Qt designer file (.ui), creates the widgets defined in and adds them as property to a given object. This internally calls retrieveWidgets, so signals from widgets are connected by name to obj. @param obj: The object which will act as parent of the loaded ui (this object will receive a new layout) @type obj: QWidget @param uipath: the path to the Qt designer file @type uipath: str @param widgets: optional argument; a recursive (parent-relation of widgets) list of tuples, defining which widgets should be added as attributes to obj. See retrieveWidgets for details. If you omit this or pass None, recursively all child widgets will be stored @type widgets: list[tuple(str, bool, list(...))] or None @param seticons: if True, widgets containing a string-property called 'pytsonicon' will get the icon of a soundpack (value of property = variable in soundpack) @type seticons: bool @param iconpack: if set, the iconpack will be used, if None, the current iconpack is used @type iconpack: ts3client.IconPack @param pluginicons: callable which gets a string and either returns the path to the image file or returns a QPixmap to set the icon property to; defaults to None @type pluginicons: Callable(str) -> str or QIcon @param extraWidgets: list of extra classes to be created, there must be a constructor which takes only the parent object @type extraWidgets: list(QWidget type) """ root = False if seticons and not iconpack: try: iconpack = ts3client.IconPack.current() iconpack.open() root = True except Exception as e: iconpack = None seticons = False ts3print(pytson.tr("pytsonui", "Error loading iconpack: " "{exception}").format(exception=e), ts3defines.LogLevel.LogLevel_ERROR, "pytsonui.setupUi.%s" % obj.objectName, 0) if os.path.isfile(uipath): f = QFile(uipath) if f.open(QIODevice.ReadOnly): loader = UiLoader(obj, extraWidgets=extraWidgets) ui = loader.load(f) f.close() if not ui: raise Exception("Error creating widget from uifile: %s" % loader.errorString()) else: raise Exception("Could not open uifile") else: raise Exception("Could not find uifile") if widgets: retrieveWidgets(obj, ui, widgets, seticons, iconpack, pluginicons) else: retrieveAllWidgets(obj, ui, seticons, iconpack, pluginicons) if hasattr(obj, "parent") and obj.parent(): par = obj.parent() obj.move(par.window().frameGeometry.topLeft() + par.window().rect.center() - obj.rect.center()) if root: iconpack.close()