From 6807afe5bec851fd9af60cfba81dc19e88925cde Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Tue, 25 Dec 2018 00:48:54 +0800 Subject: [PATCH] hotplaylist --- .../Data/pic_v.png | Bin .../HotPlaylist.py | 4 +- {QGridLayout, => QFlowLayout}/README.en.md | 0 QFlowLayout/README.md | 18 ++ .../ScreenShot/HotPlaylist.gif | Bin QGridLayout/Data/pic_v.png | Bin 0 -> 7015 bytes .../HotPlaylist.py | 2 +- .../README.md => QGridLayout/README.en.md | 0 QGridLayout/README.md | 18 ++ .../ScreenShot/HotPlaylist.gif | Bin QListWidget/Data/pic_v.png | Bin 0 -> 7015 bytes ...ieHotPlay_ListWidget.py => HotPlaylist.py} | 2 +- QListWidget/HotPlaylist/README.md | 29 ---- QListWidget/HotPlaylist/flowlayout.py | 161 ------------------ QListWidget/README.md | 25 ++- .../3.gif => ScreenShot/HotPlaylist.gif} | Bin 16 files changed, 64 insertions(+), 195 deletions(-) rename {QListWidget/HotPlaylist => QFlowLayout}/Data/pic_v.png (100%) rename QListWidget/HotPlaylist/TencentMovieHotPlay_Flow.py => QFlowLayout/HotPlaylist.py (99%) rename {QGridLayout, => QFlowLayout}/README.en.md (100%) create mode 100644 QFlowLayout/README.md rename QListWidget/HotPlaylist/ScreenShot/2.gif => QFlowLayout/ScreenShot/HotPlaylist.gif (100%) create mode 100644 QGridLayout/Data/pic_v.png rename QListWidget/HotPlaylist/TencentMovieHotPlay.py => QGridLayout/HotPlaylist.py (99%) rename QGridLayout,/README.md => QGridLayout/README.en.md (100%) create mode 100644 QGridLayout/README.md rename QListWidget/HotPlaylist/ScreenShot/1.gif => QGridLayout/ScreenShot/HotPlaylist.gif (100%) create mode 100644 QListWidget/Data/pic_v.png rename QListWidget/{HotPlaylist/TencentMovieHotPlay_ListWidget.py => HotPlaylist.py} (99%) delete mode 100644 QListWidget/HotPlaylist/README.md delete mode 100644 QListWidget/HotPlaylist/flowlayout.py rename QListWidget/{HotPlaylist/ScreenShot/3.gif => ScreenShot/HotPlaylist.gif} (100%) diff --git a/QListWidget/HotPlaylist/Data/pic_v.png b/QFlowLayout/Data/pic_v.png similarity index 100% rename from QListWidget/HotPlaylist/Data/pic_v.png rename to QFlowLayout/Data/pic_v.png diff --git a/QListWidget/HotPlaylist/TencentMovieHotPlay_Flow.py b/QFlowLayout/HotPlaylist.py similarity index 99% rename from QListWidget/HotPlaylist/TencentMovieHotPlay_Flow.py rename to QFlowLayout/HotPlaylist.py index 0566d73..6f8f68d 100644 --- a/QListWidget/HotPlaylist/TencentMovieHotPlay_Flow.py +++ b/QFlowLayout/HotPlaylist.py @@ -21,7 +21,7 @@ from PyQt5.QtSvg import QSvgWidget from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QLabel,\ QHBoxLayout, QSpacerItem, QSizePolicy, QScrollArea, QAbstractSlider -from flowlayout import FlowLayout # @UnresolvedImport +from Lib.flowlayout import FlowLayout # @UnresolvedImport from lxml.etree import HTML # @UnresolvedImport @@ -259,7 +259,7 @@ class GridWidget(QWidget): li.xpath(".//div[@class='figure_count']/span/text()") or [""])[0] path = "cache/{0}.jpg".format( os.path.splitext(os.path.basename(video_url))[0]) - cover_path = "pic_v.png" + cover_path = "Data/pic_v.png" if os.path.isfile(path): cover_path = path iwidget = ItemWidget(cover_path, figure_info, figure_title, diff --git a/QGridLayout,/README.en.md b/QFlowLayout/README.en.md similarity index 100% rename from QGridLayout,/README.en.md rename to QFlowLayout/README.en.md diff --git a/QFlowLayout/README.md b/QFlowLayout/README.md new file mode 100644 index 0000000..944d88b --- /dev/null +++ b/QFlowLayout/README.md @@ -0,0 +1,18 @@ +# QListView + +## 1、腾讯视频热播列表 +[运行](HotPlaylist.py) + +简单思路说明: + + - 利用`QScrollArea`滚动显示,自定义的`QFlowLayout`做布局来放置自定义的Widget + - `QNetworkAccessManager`异步下载网页和图片 + - `QScrollArea`滚动到底部触发下一页加载 + +自定义控件说明: + + - 主要是多个layout和控件的结合,其中图片`QLabel`为自定义,通过`setPixmap`设置图片,重写`paintEvent`绘制底部渐变矩形框和白色文字 + - 字体颜色用qss设置 + - 图标利用了`QSvgWidget`显示,可以是svg 动画(如圆形加载图) + +![HotPlaylist](ScreenShot/HotPlaylist.gif) \ No newline at end of file diff --git a/QListWidget/HotPlaylist/ScreenShot/2.gif b/QFlowLayout/ScreenShot/HotPlaylist.gif similarity index 100% rename from QListWidget/HotPlaylist/ScreenShot/2.gif rename to QFlowLayout/ScreenShot/HotPlaylist.gif diff --git a/QGridLayout/Data/pic_v.png b/QGridLayout/Data/pic_v.png new file mode 100644 index 0000000000000000000000000000000000000000..516b3c20882871820c475ae9b670d8015ff195e5 GIT binary patch literal 7015 zcmc&&XFOcnyWUEYK`^=y!4OGA8{I@_7@g632BVJ=M(;IB)F?r8(Sn2sqK1ePU7|!M zddVP41j&{2|DSX3@7{avhx6s`4{NWr_wzjO^SI}ZWg-OtfLsNkh`hLW z0ssLu=<>y^pw4#(07w-a6cn^o6cpH8-LSR}&S(Jep32tsGJ1SWFFk*ZrZkYB+^tS` z4gnw>6`&rlaRE3PK!t;;W#30cks8p_Q9VWIcZQCUBC?~F@@_ZS$;CvO#Oj-ge`TF1 zc^%-3-`P2xIBi~gx^_0`Gej9oMa`A8THpvsAR{DUldK6^h|b=YU_v^?0x=tSwXehO z(t7~dCGznO#J!X`BY1%Y2m#kIK2GZH#b05K+FXVJTN1DUpWUbI#Hg$Xxl=W zrE5e3f&h5impYKHHY!BhkUGrdwZFTt#J<$wTrH1cxC6E&S%y4K&*Gp#tP!aXUIhTA zlacnH;xdVAtILb4wrkG#gZBkLop!MhY4*MOpUsa5i2<|EyTF4?*^J7!g<MWohS&AKbE`<&kfekCA`r7#-x1Y`rh@jhZA zO9H@l!h$}>0Pwi&BtiBr0WgqW^aTK#*BQ-9QyA2{Kmeea7sCBg?#k76+KRUnPup3V z-!c%QE-T7j<$Nm%mcP6le4R9(F-`88-dort@#~jFOnFq9i{RRJs5trB0<~GlmMg>M z`;0j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encentMovieHotPlay.py b/QGridLayout/HotPlaylist.py similarity index 99% rename from QListWidget/HotPlaylist/TencentMovieHotPlay.py rename to QGridLayout/HotPlaylist.py index 457dbe2..41c25e2 100644 --- a/QListWidget/HotPlaylist/TencentMovieHotPlay.py +++ b/QGridLayout/HotPlaylist.py @@ -275,7 +275,7 @@ class GridWidget(QWidget): li.xpath(".//div[@class='figure_count']/span/text()") or [""])[0] path = "cache/{0}.jpg".format( os.path.splitext(os.path.basename(video_url))[0]) - cover_path = "pic_v.png" + cover_path = "Data/pic_v.png" if os.path.isfile(path): cover_path = path iwidget = ItemWidget(cover_path, figure_info, figure_title, diff --git a/QGridLayout,/README.md b/QGridLayout/README.en.md similarity index 100% rename from QGridLayout,/README.md rename to QGridLayout/README.en.md diff --git a/QGridLayout/README.md b/QGridLayout/README.md new file mode 100644 index 0000000..58eee65 --- /dev/null +++ b/QGridLayout/README.md @@ -0,0 +1,18 @@ +# QListView + +## 1、腾讯视频热播列表 +[运行](HotPlaylist.py) + +简单思路说明: + + - 利用`QScrollArea`滚动显示,`QGridLayout`做布局来放置自定义的Widget + - `QNetworkAccessManager`异步下载网页和图片 + - `QScrollArea`滚动到底部触发下一页加载 + +自定义控件说明: + + - 主要是多个layout和控件的结合,其中图片`QLabel`为自定义,通过`setPixmap`设置图片,重写`paintEvent`绘制底部渐变矩形框和白色文字 + - 字体颜色用qss设置 + - 图标利用了`QSvgWidget`显示,可以是svg 动画(如圆形加载图) + +![HotPlaylist](ScreenShot/HotPlaylist.gif) \ No newline at end of file diff --git a/QListWidget/HotPlaylist/ScreenShot/1.gif b/QGridLayout/ScreenShot/HotPlaylist.gif similarity index 100% rename from QListWidget/HotPlaylist/ScreenShot/1.gif rename to QGridLayout/ScreenShot/HotPlaylist.gif diff --git a/QListWidget/Data/pic_v.png b/QListWidget/Data/pic_v.png new file mode 100644 index 0000000000000000000000000000000000000000..516b3c20882871820c475ae9b670d8015ff195e5 GIT binary patch literal 7015 zcmc&&XFOcnyWUEYK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ov%gDF{OYBI+>b=*DY`U>27Mj2qW{!#~Fc|zP$zs@cDO{@B8W8ai; zih`4Meb%yXTB`(+bVBkQL`&M~TVm2y6d(TOjv|MrFE0HLgF>tuCRu6!B#;M8*`;{yd|$s<2XR%kRMkFI#6( zZCTBd`|;VCn+KI~Mn1gqQ~BX7{PD=AGGgu4R(sV?YXc|X*`4O~3oIwQx6W6x=&&#Zk)JSR<7Vq@wukO`-kUXpAwKFUpBA^( zHD$$r-zriK-p?U4o9oUc3OY2=`l%chQ5f!NQ*i?k-)-$hpLuH8e$8tlH|Xcd@vFIf zMQ@SaHF(~OU~nv)WOlB++TTpfBH`?4^I0_4-IQ`M4L?Jw#*j9bru0g^@CK)%(qBPD z;R|CQYTKqeX3U=p(SsL9KYyJC=Uir%_ebXJui{mbiH&niTWk6=^(t%bC3qj)vZNwl zZ{R+eBeb#t|%LYN80H|DRZ>(*Yw5#@_md=apBQw6gQIlYz`zXjcFK!k%HwD+-S zm|~~5Ab8MYxGJ$|-Rp%ZzwAev;6{Kwu$A%pP7vP=jtXE0z=Z#3_(!BaV*PXG1^pko h{cp_s!oNrafK$RmsyW;6;NSl$RN$J5Rr2>k{{z`zHj@AV literal 0 HcmV?d00001 diff --git a/QListWidget/HotPlaylist/TencentMovieHotPlay_ListWidget.py b/QListWidget/HotPlaylist.py similarity index 99% rename from QListWidget/HotPlaylist/TencentMovieHotPlay_ListWidget.py rename to QListWidget/HotPlaylist.py index e1031d4..5abfc6e 100644 --- a/QListWidget/HotPlaylist/TencentMovieHotPlay_ListWidget.py +++ b/QListWidget/HotPlaylist.py @@ -274,7 +274,7 @@ class Window(QListWidget): li.xpath(".//div[@class='figure_count']/span/text()") or [""])[0] path = "cache/{0}.jpg".format( os.path.splitext(os.path.basename(video_url))[0]) - cover_path = "pic_v.png" + cover_path = "Data/pic_v.png" if os.path.isfile(path): cover_path = path iwidget = ItemWidget(cover_path, figure_info, figure_title, diff --git a/QListWidget/HotPlaylist/README.md b/QListWidget/HotPlaylist/README.md deleted file mode 100644 index 8580067..0000000 --- a/QListWidget/HotPlaylist/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# 腾讯视频热播列表 - -简单思路说明: - - - 利用QScrollArea滚动显示,QGridLayout或者FlowLayout做布局来放置自定义的Widget - - QNetworkAccessManager异步下载网页和图片 - - QScrollArea滚动到底部触发下一页加载 - -自定义控件说明: - - - 主要是多个layout和控件的结合,其中图片QLabel为自定义,通过setPixmap设置图片,重写paintEvent绘制底部渐变矩形框和白色文字 - - 字体颜色用qss设置 - - 图标利用了QSvgWidget显示,可以是svg 动画(如圆形加载图) - - -# 截图 - -使用QGridLayout 固定列数效果图 - -![截图1](ScreenShot/1.gif) - -使用自定义布局FlowLayout 自动列数效果图 -![截图2](ScreenShot/2.gif) - -使用QListWidget 配合setFlow(QListWidget.LeftToRight)和 -setWrapping(True)和 -setResizeMode(QListWidget.Adjust)达到类似FlowLayout的效果 - -![截图3](ScreenShot/3.gif) \ No newline at end of file diff --git a/QListWidget/HotPlaylist/flowlayout.py b/QListWidget/HotPlaylist/flowlayout.py deleted file mode 100644 index ef1d54e..0000000 --- a/QListWidget/HotPlaylist/flowlayout.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python - - -############################################################################# -## -# Copyright (C) 2013 Riverbank Computing Limited. -# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -## -# This file is part of the examples of PyQt. -## -# $QT_BEGIN_LICENSE:BSD$ -# You may use this file under the terms of the BSD license as follows: -## -# "Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -# the names of its contributors may be used to endorse or promote -# products derived from this software without specific prior written -# permission. -## -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -# $QT_END_LICENSE$ -## -############################################################################# - - -from PyQt5.QtCore import QPoint, QRect, QSize, Qt -from PyQt5.QtWidgets import (QApplication, QLayout, QPushButton, QSizePolicy, - QWidget) - - -class Window(QWidget): - def __init__(self): - super(Window, self).__init__() - - flowLayout = FlowLayout() - flowLayout.addWidget(QPushButton("Short")) - flowLayout.addWidget(QPushButton("Longer")) - flowLayout.addWidget(QPushButton("Different text")) - flowLayout.addWidget(QPushButton("More text")) - flowLayout.addWidget(QPushButton("Even longer button text")) - self.setLayout(flowLayout) - - self.setWindowTitle("Flow Layout") - - -class FlowLayout(QLayout): - def __init__(self, parent=None, margin=0, spacing=-1): - super(FlowLayout, self).__init__(parent) - - if parent is not None: - self.setContentsMargins(margin, margin, margin, margin) - - self.setSpacing(spacing) - - self.itemList = [] - - def __del__(self): - item = self.takeAt(0) - while item: - item = self.takeAt(0) - - def addItem(self, item): - self.itemList.append(item) - - def count(self): - return len(self.itemList) - - def itemAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList[index] - - return None - - def takeAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList.pop(index) - - return None - - def expandingDirections(self): - return Qt.Orientations(Qt.Orientation(0)) - - def hasHeightForWidth(self): - return True - - def heightForWidth(self, width): - height = self.doLayout(QRect(0, 0, width, 0), True) - return height - - def setGeometry(self, rect): - super(FlowLayout, self).setGeometry(rect) - self.doLayout(rect, False) - - def sizeHint(self): - return self.minimumSize() - - def minimumSize(self): - size = QSize() - - for item in self.itemList: - size = size.expandedTo(item.minimumSize()) - - margin, _, _, _ = self.getContentsMargins() - - size += QSize(2 * margin, 2 * margin) - return size - - def doLayout(self, rect, testOnly): - x = rect.x() - y = rect.y() - lineHeight = 0 - - for item in self.itemList: - wid = item.widget() - spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, - QSizePolicy.PushButton, Qt.Horizontal) - spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, - QSizePolicy.PushButton, Qt.Vertical) - nextX = x + item.sizeHint().width() + spaceX - if nextX - spaceX > rect.right() and lineHeight > 0: - x = rect.x() - y = y + lineHeight + spaceY - nextX = x + item.sizeHint().width() + spaceX - lineHeight = 0 - - if not testOnly: - item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) - - x = nextX - lineHeight = max(lineHeight, item.sizeHint().height()) - - return y + lineHeight - rect.y() - - -if __name__ == '__main__': - - import sys - - app = QApplication(sys.argv) - mainWin = Window() - mainWin.show() - sys.exit(app.exec_()) diff --git a/QListWidget/README.md b/QListWidget/README.md index b02e844..02ee0ec 100644 --- a/QListWidget/README.md +++ b/QListWidget/README.md @@ -13,4 +13,27 @@ ## 2、自定义可拖拽Item [运行](DragDrop.py) -![CustomWidgetSortItem](ScreenShot/DragDrop.gif) \ No newline at end of file +![CustomWidgetSortItem](ScreenShot/DragDrop.gif) + +## 3、腾讯视频热播列表 +[运行](HotPlaylist.py) + +简单思路说明: + + - 利用`QListWidget`设置一些特殊的参数达到可以横向自动显示 + - `QNetworkAccessManager`异步下载网页和图片 + - 滚动到底部触发下一页加载 + +自定义控件说明: + + - 主要是多个layout和控件的结合,其中图片`QLabel`为自定义,通过`setPixmap`设置图片,重写`paintEvent`绘制底部渐变矩形框和白色文字 + - 字体颜色用qss设置 + - 图标利用了`QSvgWidget`显示,可以是svg 动画(如圆形加载图) + +`QListWidget`的参数设置 + +1. `setFlow(QListWidget.LeftToRight)` +2. `setWrapping(True)` +3. `setResizeMode(QListWidget.Adjust)` + +![HotPlaylist](ScreenShot/HotPlaylist.gif) \ No newline at end of file diff --git a/QListWidget/HotPlaylist/ScreenShot/3.gif b/QListWidget/ScreenShot/HotPlaylist.gif similarity index 100% rename from QListWidget/HotPlaylist/ScreenShot/3.gif rename to QListWidget/ScreenShot/HotPlaylist.gif