I would like to know how I can show an image brought from a url destro del qmainwindow.
this is the code:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import uic
from PyQt5.Qt import *
import cv2
import urllib.request
import numpy as np
from urllib.request import *
from PIL import Image
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("gif.ui",self)
self.table.setColumnWidth(0,200)
print(self.table.item(1,1).text())
url = 'http://www.chis.mx/boletincanaco/wp-content/uploads/2012/07/Logo-Steren-Vertical-700x406.jpg'
urlretrieve(url,'pic.jpg')
img = Image.open('pic.jpg')
img.show()
app = QApplication([])
p = Principal()
p.show()
app.exec_()
But it shows me the image using the windows viewer by default, and it does not show it destro of the qmain window
This is another file that tries to do the same but shows nothing.
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import uic
from PyQt5.Qt import *
import cv2
import urllib.request
import numpy as np
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("gif.ui",self)
self.table.setColumnWidth(0,200)
print(self.table.item(1,1).text())
self.url_to_image('http://www.chis.mx/boletincanaco/wp-content/uploads/2012/07/Logo-Steren-Vertical-700x406.jpg')
def url_to_image(sel,url):
resp = urllib.request.urlopen(url)
image = np.asarray(bytearray(resp.read()),dtype="uint8")
image = cv2.imdecode(image,cv2.IMREAD_COLOR)
print(image)
return image
app = QApplication([])
p = Principal()
p.show()
app.exec_()