def getPixmap(self):
     image = None
     if self.icon:                
         if type(self.icon) == str:
             image = QPixmap()
             image.loadFromData(self.icon)
         elif type(self.icon) == list:
             image = QPixmap(self.icon)
     return image
 def btnRefresh_clicked(self):
     if str(self.editUrl.text()):
         try:
             img = urllib2.urlopen(str(self.editUrl.text())).read()
             pic = QPixmap()
             pic.loadFromData(img)
             if not str(self.editWidth.text()):
                 self.editWidth.setText(str(pic.width()))
             if not str(self.editHeight.text()):
                 self.editHeight.setText(str(pic.height()))
             self.previewImage.setPixmap(pic)
         except:
             QMessageBox.warning(self, "Warning", "Cannot open the image url!")
Beispiel #3
0
 def btnRefresh_clicked(self):
     if str(self.editUrl.text()):
         try:
             img = urllib2.urlopen(str(self.editUrl.text())).read()
             pic = QPixmap()
             pic.loadFromData(img)
             if not str(self.editWidth.text()):
                 self.editWidth.setText(str(pic.width()))
             if not str(self.editHeight.text()):
                 self.editHeight.setText(str(pic.height()))
             self.previewImage.setPixmap(pic)
         except:
             QMessageBox.warning(self, "Warning",
                                 "Cannot open the image url!")
Beispiel #4
0
 def _setupTray(app, wnd):
     try:
         icons = KIconLoader()
         systray = KSystemTray(wnd["Class"])
         p = QPixmap()
         p.loadFromData(icon)
         systray.setPixmap(p)
         QToolTip.add(systray, "PyQLogger - Blogger GUI")
         systray.show()
         wnd["Impl"].systray = systray
     except Exception, inst:
         sys.stderr.write(
             "setupKDE: cannot set tray, exception: %s\n" %
             inst)
 def SimpleButton(parent, title, handler, page=None, image=None):
     tabpage = parent.getPage(page)
     button = QPushButton(tabpage)
     if image:
         bi = QPixmap()
         bi.loadFromData(image, "PNG")
         button.setIconSet(QIconSet(bi))
         w = bi.width() + 3
         h = bi.height() + 3
         if w < 32:
             w = 32
         if h < 32:
             h = 32
         button.setMaximumSize(QSize(w, h))
     else:
         button.setText(title)
     QToolTip.add(button, title)
     parent.connect(button, SIGNAL("clicked()"), handler)
     button.show()
     p = ToolbarPlugin(parent)
     p.getWidget = lambda: button
 def SimpleButton(parent, title, handler, page=None, image=None):
     tabpage = parent.getPage(page)
     button = QPushButton(tabpage)
     if image : 
         bi = QPixmap()
         bi.loadFromData(image, "PNG")
         button.setIconSet(QIconSet(bi))
         w = bi.width()+3
         h = bi.height()+3
         if w < 32:
             w = 32
         if h < 32:
             h = 32
         button.setMaximumSize(QSize(w, h))
     else:
         button.setText(title)
     QToolTip.add(button, title)
     parent.connect(button, SIGNAL("clicked()"), handler)
     button.show()
     p = ToolbarPlugin(parent)
     p.getWidget = lambda: button
Beispiel #7
0
 def __open(self, txt, btn):
     filename = str(QFileDialog.getOpenFileName(None , \
         "Images (*.png *.jpg *.gif)", \
         self, \
         "open image file", \
         "Choose a file to open" ))
     txt.setText(filename)
     ok = False
     try:
         pic = QPixmap()
         if pic.loadFromData(open(filename, "rb").read()):
             ok = True
             if not str(self.editWidth.text()):
                 self.editWidth.setText(str(pic.width()))
             if not str(self.editHeight.text()):
                 self.editHeight.setText(str(pic.height()))
             self.previewImage.setPixmap(pic)
             btn.setEnabled(True)
     except:
         ok = False
     if not ok:
         QMessageBox.warning(self, "Warning", "Cannot open the image file!")
         self.previewImage.setPixmap(QPixmap())
         btn.setEnabled(False)
 def __open(self, txt, btn):
     filename = str(
         QFileDialog.getOpenFileName(
             None, "Images (*.png *.jpg *.gif)", self, "open image file", "Choose a file to open"
         )
     )
     txt.setText(filename)
     ok = False
     try:
         pic = QPixmap()
         if pic.loadFromData(open(filename, "rb").read()):
             ok = True
             if not str(self.editWidth.text()):
                 self.editWidth.setText(str(pic.width()))
             if not str(self.editHeight.text()):
                 self.editHeight.setText(str(pic.height()))
             self.previewImage.setPixmap(pic)
             btn.setEnabled(True)
     except:
         ok = False
     if not ok:
         QMessageBox.warning(self, "Warning", "Cannot open the image file!")
         self.previewImage.setPixmap(QPixmap())
         btn.setEnabled(False)