当前位置: 首页 > news >正文

windows2008 iis网站 指定域名宁波人流

windows2008 iis网站 指定域名,宁波人流,弹簧东莞网站建设,网站广东省备案PyQt5图片浏览器 实现方式功能实现具体代码 界面实现pillow源码修改ImageQt错误主页面布局 项目开源地址 分享一个图片浏览器 实现方式 qt本身有一个QGraphicsView类用来当做视图框架。 具体参考#xff1a;如何在pyqt中使用 QGraphicsView 实现图片查看器 不过大佬给的例子… PyQt5图片浏览器 实现方式功能实现具体代码 界面实现pillow源码修改ImageQt错误主页面布局 项目开源地址 分享一个图片浏览器 实现方式 qt本身有一个QGraphicsView类用来当做视图框架。 具体参考如何在pyqt中使用 QGraphicsView 实现图片查看器 不过大佬给的例子功能有点少因此需要添加一下其他的功能 功能实现 图片旋转顺时针/逆时针设置 1:1 大小缩放以适应 代码示例 def setOriginalSize(self):设置 1:1 大小:return:self.resetTransform()self.setSceneRect(QRectF(self.pixmap.rect()))self.__setDragEnabled(self.__isEnableDrag())self.zoomInTimes self.getZoomInTimes(self.pixmap.width())def setAdaptation(self):缩放以适应:return:self.setSceneRect(QRectF(self.pixmap.rect()))self.fitInView(self.pixmapItem, Qt.KeepAspectRatio)self.__setDragEnabled(False)self.zoomInTimes 0def rotationAngle(self):return self._rotationAngledef rotateClockwise(self, stepSize: int 90):顺时针旋转:param stepSize: 步长旋转角度:return:if self.pixmap.fileName() is None:returnself._rotationAngle self._rotationAngle stepSizeself.__rotation(self._rotationAngle)def __rotation(self, stepSize: int):指定图片中心并旋转:return:self.pixmapItem.setTransformOriginPoint(self.pixmapItem.boundingRect().center()) # 指定图片旋转中心点self.pixmapItem.setRotation(stepSize)self.setAdaptation()具体代码 # coding:utf-8 from PyQt5.QtCore import QRectF, QSize, Qt from PyQt5.QtGui import QPainter, QPixmap, QWheelEvent, QResizeEvent from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsPixmapItem, QGraphicsItemclass Pixmap(QPixmap):def __init__(self, fileName: str, *args, **kwargs):super().__init__(fileName, *args, **kwargs)self._fileName fileNamedef fileName(self):return self._fileNameclass ImageGraphicsView(QGraphicsView):图片查看器def __init__(self, fileName: str None, parentNone):super().__init__(parent)self._rotationAngle 0self.zoomInTimes 0self.maxZoomInTimes 22self.pixmap Pixmap(fileName)self.pixmapItem QGraphicsPixmapItem()self.graphicsScene QGraphicsScene()self.displayedImageSize QSize(0, 0)self.__initWidget()def __initWidget(self):初始化小部件:return:self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) # 隐藏水平滚动条self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) # 隐藏垂直滚动条self.setTransformationAnchor(QGraphicsView.ViewportAnchor.AnchorUnderMouse) # 以鼠标所在位置为锚点进行缩放self.pixmapItem.setTransformationMode(Qt.TransformationMode.SmoothTransformation) # 平滑转型self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) # 平滑像素图变换self.pixmapItem.setPixmap(self.pixmap)self.graphicsScene.addItem(self.pixmapItem)self.setScene(self.graphicsScene)self.setStyleSheet(background-color: #ffffff;)def setImage(self, fileName: str):设置显示的图片:param fileName::return:self.resetTransform()del self.pixmapself.pixmap Pixmap(fileName)self.pixmapItem.setPixmap(self.pixmap)self.zoomInTimes 0# 调整图片大小self.setSceneRect(QRectF(self.pixmap.rect()))ratio self.__getScaleRatio()self.displayedImageSize self.pixmap.size() * ratioif ratio 1:self.fitInView(self.pixmapItem, Qt.KeepAspectRatio)self.pixmapItem.setTransformOriginPoint(self.pixmapItem.boundingRect().center())def setOriginalSize(self):设置 1:1 大小:return:self.resetTransform()self.setSceneRect(QRectF(self.pixmap.rect()))self.__setDragEnabled(self.__isEnableDrag())self.zoomInTimes self.getZoomInTimes(self.pixmap.width())def setAdaptation(self):缩放以适应:return:self.setSceneRect(QRectF(self.pixmap.rect()))self.fitInView(self.pixmapItem, Qt.KeepAspectRatio)self.__setDragEnabled(False)self.zoomInTimes 0def rotationAngle(self):return self._rotationAngledef rotateClockwise(self, stepSize: int 90):顺时针旋转:param stepSize: 步长旋转角度:return:if self.pixmap.fileName() is None:returnself._rotationAngle self._rotationAngle stepSizeself.__rotation(self._rotationAngle)def __rotation(self, stepSize: int):指定图片中心并旋转:return:self.pixmapItem.setTransformOriginPoint(self.pixmapItem.boundingRect().center()) # 指定图片旋转中心点self.pixmapItem.setRotation(stepSize)self.setAdaptation()def __isEnableDrag(self):根据图片的尺寸决定是否启动拖拽功能:return:v self.verticalScrollBar().maximum() 0h self.horizontalScrollBar().maximum() 0return v or hdef __setDragEnabled(self, isEnabled: bool):设置拖拽是否启动:param isEnabled: bool:return:if isEnabled:self.setDragMode(QGraphicsView.DragMode.ScrollHandDrag)else:self.setDragMode(QGraphicsView.DragMode.NoDrag)def __getScaleRatio(self):获取显示的图像和原始图像的缩放比例:return:if self.pixmap.isNull():return 1pw self.pixmap.width()ph self.pixmap.height()rw min(1, self.width() / pw)rh min(1, self.height() / ph)return min(rw, rh)def enlargePicture(self, anchorQGraphicsView.AnchorUnderMouse):放大图片:return:if self.zoomInTimes self.maxZoomInTimes:returnself.setTransformationAnchor(anchor)self.zoomInTimes 1self.scale(1.1, 1.1)self.__setDragEnabled(self.__isEnableDrag())# 还原 anchorself.setTransformationAnchor(self.AnchorUnderMouse)def shrinkPicture(self, anchorQGraphicsView.AnchorUnderMouse):缩小图片:return:if self.zoomInTimes 0 and not self.__isEnableDrag():returnself.setTransformationAnchor(anchor)self.zoomInTimes - 1# 原始图像的大小pw self.pixmap.width()ph self.pixmap.height()# 实际显示的图像宽度w self.displayedImageSize.width() * 1.1 ** self.zoomInTimesh self.displayedImageSize.height() * 1.1 ** self.zoomInTimesif pw self.width() or ph self.height():# 在窗口尺寸小于原始图像时禁止继续缩小图像比窗口还小if w self.width() and h self.height():self.fitInView(self.pixmapItem)else:self.scale(1 / 1.1, 1 / 1.1)else:# 在窗口尺寸大于图像时不允许缩小的比原始图像小if w pw:self.resetTransform()else:self.scale(1 / 1.1, 1 / 1.1)self.__setDragEnabled(self.__isEnableDrag())# 还原 anchorself.setTransformationAnchor(self.AnchorUnderMouse)def getZoomInTimes(self, width: int, step: int 100):for i in range(0, self.maxZoomInTimes):if width - self.displayedImageSize.width() * 1.1 ** i step:return ireturn self.maxZoomInTimesdef fitInView(self, item: QGraphicsItem, modeQt.AspectRatioMode.KeepAspectRatio):缩放场景使其适应窗口大小:param item::param mode::return:super().fitInView(item, mode)self.displayedImageSize self.__getScaleRatio() * self.pixmap.size()self.zoomInTimes 0def resizeEvent(self, event: QResizeEvent):if self.zoomInTimes 0:return# 调整图片大小ratio self.__getScaleRatio()self.displayedImageSize self.pixmap.size() * ratioif ratio 1:self.fitInView(self.pixmapItem, Qt.KeepAspectRatio)else:self.resetTransform()def resetTransform(self):重置变换:return:self.zoomInTimes 0self.__setDragEnabled(False)super().resetTransform()def wheelEvent(self, e: QWheelEvent):滚动鼠标滚轮缩放图片:param e::return:if e.angleDelta().y() 0:self.enlargePicture()else:self.shrinkPicture() 该函数可以显示图片实现图片下旋转、放大、缩小等功能 界面实现 pillow源码修改 在实现图片列表时如果全部加载出来会直接爆内存因此需要借助pillow生成缩略图但是pillow最新版本没有适配PyQt5如果使用需要改源码。 在ImageQt.py中修改源码 将红框中的代码加上就行了。 ImageQt错误 如果你使用了pillow这个库直接转为QPixmap你就会发现很多问题。 PyQt5pillow实现缩略图代码示例 import sys from PyQt5.Qt import * import res.res_rc from PIL import Image, ImageQtclass Window(QWidget):def __init__(self, parentNone):super().__init__(parent)self.vBox QVBoxLayout(self)self.vBox.setContentsMargins(0, 0, 0, 0)self.vBox.setSpacing(0)file rG:\手机\壁纸\电脑壁纸\1689637545648.pngimg Image.open(file)img.thumbnail((200, 120))label QLabel()label.setPixmap(ImageQt.toqpixmap(img))self.vBox.addWidget(label)if __name__ __main__:QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)app QApplication(sys.argv)app.setQuitOnLastWindowClosed(True)demo Window()demo.resize(800, 600)demo.show()sys.exit(app.exec_())运行结果 运行后你会发现基本上所有图片都会变成花屏于是就直接放弃了那么只能生成本地图片然后在显示出来于是使用本地sqlite数据库为了使方便引入了SQLAlchemy来管理数据库别问为什么问就是不想写SQL这要也方便了后期拓展 def CreateThumbnail(fileName, saveFile, *, size(200, 120), **kwargs):创建缩略图img Image.open(fileName)img.thumbnail(sizesize, **kwargs)img.save(saveFile) 主页面布局 项目开源地址 https://gitee.com/chiyaun/picture-browser.git
http://www.zqtcl.cn/news/18898/

相关文章:

  • 郑州便宜网站建设360建筑网官网查询
  • 哪个装修公司比较好seo顾问赚钱吗
  • 咸宁网站建设价格嵌入式开发难学吗
  • 万众城网站建设小程序交易买卖平台
  • 视频播放网站怎么做郑州商城app制作
  • 亚马逊网站网址东莞微信网站建设信息
  • 免费解析网站网站怎么推广
  • 网站自定义链接怎么做的黄冈建设工程信息网
  • 网站规划html网站建设类课题的研究方法
  • 重庆网站制作天电商网站开发思路模版
  • 萍乡网站建设哪家好哦上海网页设计是什么
  • 在线做网站大概多少钱百度seo外包
  • 2017年做网站好难改版百度不收录网站
  • 团购网站开发网络热词
  • 青岛专业网站推广设计公司网站建设翻译谁提供
  • sql注入网站源码网站建设的市场规模
  • 局网站建设方案网站建设业务的途径
  • 网站备案信息找回建站 wordpress
  • destoon 网站后台网站设计做什么的
  • 目前国内家教做的好的网站公司网页设计图
  • 如何搭建o2o网站wordpress本地ftp
  • 高清视频素材下载网站做么做好网站运营
  • 深圳网站制作要多少钱微信红包制作官网
  • 小白如何建设网站邯郸网站设计注册
  • 网站建设十佳佛山做礼物的网站
  • 公司优化是什么意思论坛与网站做优化哪个更好
  • 源码制作网站网站首页被k多久恢复
  • 离职删除做的网站网站开发好难呀
  • 微信营销推广软件百度seo收费
  • 做任务网站排行榜当今做网站的流行趋势