コード例 #1
0
 def httpDone(self, error):
     qs = QString(self.http.readAll())
     match = self.imgre.search(unicode(qs))
     if error:
         QMessageBox.warning(self, "Warning",
                             "Cannot upload! Error:" + self.http.error())
     else:
         if match:
             self.image = match.group(1)
             if self.thumbfile:  # do second upload
                 if self.chkShack.isChecked():
                     self.BeginImageUpload(self.thumbfile,
                                           self.ImageShackPostData,
                                           self.http2)
                 elif self.chkArk.isChecked():
                     self.BeginImageUpload(self.thumbfile,
                                           self.ImageArkPostData,
                                           self.http2)
             else:  # no need to upload second
                 QMessageBox.information(self, "Info",
                                         "Image successfully uploaded!")
                 self.editUrl.setText(self.image)
         else:
             if self.thumbfile:
                 os.unlink(thumbfile)
             QMessageBox.warning(self, "Warning",
                                 "Cannot upload the image file!")
     self.http.closeConnection()
コード例 #2
0
 def http2Done(self, error):
     qs = QString(self.http2.readAll())
     match = self.imgre.search(unicode(qs))
     if error:
         QMessageBox.warning(self, "Warning",
                             "Cannot upload! Error:" + self.http2.error())
     else:
         if match:
             self.editUrl.setText(self.image)
             self.editThumb.setText(match.group(1))
             QMessageBox.information(self, "Info",
                                     "Image successfully uploaded!")
         else:
             QMessageBox.warning(self, "Warning",
                                 "Cannot upload the thumbnail image file!")
     self.http2.closeConnection()
コード例 #3
0
ファイル: wall.py プロジェクト: pars-linux/uludag
def setWallpaper(path):
    "Changes current wallpaper with the new one"
    # Copy file to wallpapers dir:
    wallpapersdir = os.path.expanduser("~/.kde/share/wallpapers")
    if not (os.path.isdir(wallpapersdir)):
        os.makedirs(wallpapersdir)
    newpath = os.path.join(wallpapersdir, os.path.basename(path))
    shutil.copyfile(path, newpath)
    # Create a dcop object:
    client = DCOPClient()
    if not client.attach():
        raise WallpaperError, "Wallpaper cannot be changed"
    # Set Wallpaper:
    background = DCOPObj("kdesktop", client, "KBackgroundIface")
    ok, wallpaper = background.setWallpaper(QString(unicode(newpath)), 6)     # 6: Scaled
    if not ok:
        raise WallpaperError, "Wallpaper cannot be changed"
コード例 #4
0
ファイル: uniqstring2.py プロジェクト: pars-linux/projects
#
# uniqstring2.py - coercing Python strings into and from QStrings
#
from qt import QString

s = "A string that contains just ASCII characters"
u = u"\u0411\u0412 - a string with a few Cyrillic characters"

qs = QString(s)
qu = QString(u)

aQCString = qu.utf8()
aPythonString = str(aQCString)
aPythonUnicodeObject = unicode(aPythonString, "utf-8")

print qs
print aPythonUnicodeObject.encode("utf-8")
コード例 #5
0
def qstr(text):
    return QString(unicode(text))
コード例 #6
0
 def __init__(self, text, icon, ttip, whatsit):
     KGuiItem.__init__(self, QString(text), QString(icon), QString(ttip),
                       QString(whatsit))