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 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 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()