class ReviewWidget(QWidget): def __init__(self, ratings_average, review, parent=None): QWidget.__init__(self, parent) self.ui_init() self.star = StarWidget('small', ratings_average, self) self.star.move(719, 42) self.ui.comment.setAlignment(Qt.AlignVCenter) self.ui.comment.setWordWrap(True) self.ui.userName.setStyleSheet("QLabel{color:#999999;font-size:12px;}") self.ui.comment.setStyleSheet("QLabel{color:#666666;font-size:12px;}") self.ui.userHead.setStyleSheet( "QLabel{background-image:url('res/userhead.png')}") self.ui.createDate.setStyleSheet( "QLabel{color:#9AA2AF;font-size:13px;}") self.ui.commentBG.setStyleSheet( "QLabel{background-image:url('res/commentbg.png')}") self.ui.userName.setText(review.user_display) self.ui.createDate.setText(review.date) # self.ui.comment.setText(review.content) # add by kobe setLongTextToElideFormat(self.ui.comment, review.content) self.ui.comment.setToolTip(review.content) def ui_init(self): self.ui = Ui_CommentWidget() self.ui.setupUi(self)
class ReviewWidget(QWidget): def __init__(self, ratings_average, review, parent=None): QWidget.__init__(self,parent) self.ui_init() self.star = StarWidget('small', ratings_average, self) self.star.move(719, 42) self.ui.comment.setAlignment(Qt.AlignVCenter) self.ui.comment.setWordWrap(True) self.ui.userName.setStyleSheet("QLabel{color:#1E66A4;font-size:14px;}") self.ui.userHead.setStyleSheet("QLabel{background-image:url('res/userhead.png')}") self.ui.createDate.setStyleSheet("QLabel{color:#9AA2AF;font-size:13px;}") self.ui.commentBG.setStyleSheet("QLabel{background-image:url('res/commentbg.png')}") self.ui.userName.setText(review.user_display) self.ui.createDate.setText(review.date) self.ui.comment.setText(review.content) def ui_init(self): self.ui = Ui_CommentWidget() self.ui.setupUi(self) self.show()
class ReviewWidget(QWidget): def __init__(self, ratings_average, review, parent=None): QWidget.__init__(self,parent) k=0 strstr="" self.ui_init() self.star = StarWidget('small', ratings_average, self) self.star.move(742, 42) self.ui.comment.setAlignment(Qt.AlignVCenter) self.ui.comment.setWordWrap(True) self.ui.comment.setAlignment(Qt.AlignTop) self.ui.userName.setStyleSheet("QLabel{color:#999999;font-size:12px;}") self.ui.comment.setStyleSheet("QLabel{color:#666666;font-size:12px;}") self.ui.userHead.setStyleSheet("QLabel{background-image:url('res/userhead.png')}") self.ui.createDate.setStyleSheet("QLabel{color:#9AA2AF;font-size:13px;}") self.ui.commentBG.setStyleSheet("QLabel{background-image:url('res/commentbg.png');border: 0px;}") self.ui.userName.setText(review.user_display) self.ui.createDate.setText(review.date) self.ui.comment.setText(review.content) # add by kobe if len(review.content)>150: setLongTextToElideFormat(self.ui.comment, review.content) self.ui.comment.setToolTip(review.content) for i in review.content: k = k + 1 strstr = strstr + i if k % 80 == 0: strstr = strstr + "\n" self.ui.comment.setToolTip(strstr) # # 函数名:初始化界面 # Function: init interface # def ui_init(self): self.ui = Ui_CommentWidget() self.ui.setupUi(self)
def ui_init(self): self.ui = Ui_CommentWidget() self.ui.setupUi(self)
def ui_init(self): self.ui = Ui_CommentWidget() self.ui.setupUi(self) self.show()