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!")
Ejemplo n.º 2
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!")
 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
Ejemplo n.º 5
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)