本文整理汇总了Python中PyQt4.Qt.QFrame.setObjectName方法的典型用法代码示例。如果您正苦于以下问题:Python QFrame.setObjectName方法的具体用法?Python QFrame.setObjectName怎么用?Python QFrame.setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QFrame
的用法示例。
在下文中一共展示了QFrame.setObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProgressWindow
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setObjectName [as 别名]
class ProgressWindow(QWidget):
def __init__(self, message):
QWidget.__init__(self, ctx.mainScreen)
self.setObjectName("ProgressWindow")
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setFixedHeight(50)
self.setMaximumWidth(800)
self.setStyleSheet("""
QFrame#frame { border: 1px solid rgba(255,255,255,30);
/*border-radius: 4px;*/
background-color: rgba(255,0,0,100);}
QLabel { border:none;
color:#FFFFFF;}
QProgressBar { border: 1px solid white;}
QProgressBar::chunk { background-color: #F1610D;
width: 0.5px;}
""")
self.gridlayout = QGridLayout(self)
self.frame = QFrame(self)
self.frame.setObjectName("frame")
self.horizontalLayout = QHBoxLayout(self.frame)
self.horizontalLayout.setContentsMargins(6, 0, 0, 0)
# Spinner
self.spinner = QLabel(self.frame)
self.spinner.setMinimumSize(QSize(16, 16))
self.spinner.setMaximumSize(QSize(16, 16))
self.spinner.setIndent(6)
self.movie = QMovie(':/images/working.mng')
self.spinner.setMovie(self.movie)
self.movie.start()
self.horizontalLayout.addWidget(self.spinner)
# Message
self.label = QLabel(self.frame)
self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.label)
self.gridlayout.addWidget(self.frame,0,0,1,1)
self.update(message)
def update(self, message):
self.spinner.setVisible(True)
fontMetric = self.label.fontMetrics()
textWidth = fontMetric.width(message)
self.setFixedWidth(textWidth + 100)
self.label.setText(message)
self.move(ctx.mainScreen.width()/2 - self.width()/2,
ctx.mainScreen.height() - self.height()/2 - 50)
self.show()
def refresh(self):
ctx.mainScreen.processEvents()
def show(self):
QWidget.show(self)
self.refresh()
def pop(self):
QWidget.hide(self)
self.refresh()
示例2: InformationWindow
# 需要导入模块: from PyQt4.Qt import QFrame [as 别名]
# 或者: from PyQt4.Qt.QFrame import setObjectName [as 别名]
class InformationWindow(QWidget):
def __init__(self):
QWidget.__init__(self, ctx.mainScreen)
self.setObjectName("InformationWindow")
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setFixedHeight(50)
self.setMaximumWidth(800)
self.setStyleSheet("""
QFrame#frame { border: 1px solid rgba(255,255,255,30);
/*border-radius: 4px;*/
background-color: rgba(0,0,0,100);}
QLabel { border:none;
color:#FFFFFF;}
QProgressBar { border: 1px solid white;}
QProgressBar::chunk { background-color: #F1610D;
width: 0.5px;}
""")
self.gridlayout = QGridLayout(self)
self.frame = QFrame(self)
self.frame.setObjectName("frame")
self.horizontalLayout = QHBoxLayout(self.frame)
self.horizontalLayout.setContentsMargins(10, 0, 10, 0)
# Spinner
self.spinner = QLabel(self.frame)
self.spinner.setMinimumSize(QSize(16, 16))
self.spinner.setMaximumSize(QSize(16, 16))
self.spinner.setIndent(6)
self.movie = QMovie(':/images/working.mng')
self.spinner.setMovie(self.movie)
self.movie.start()
self.horizontalLayout.addWidget(self.spinner)
# Message
self.label = QLabel(self.frame)
self.label.setAlignment(Qt.AlignCenter)
self.label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.icon = QLabel(self.frame)
self.icon.setFixedWidth(16)
self.icon.setFixedHeight(16)
self.horizontalLayout.setSpacing(10)
self.horizontalLayout.addWidget(self.icon)
self.horizontalLayout.addWidget(self.label)
self.gridlayout.addWidget(self.frame,0,0,1,1)
def update(self, message, type=None, spinner=False):
fontMetric = self.label.fontMetrics()
textWidth = fontMetric.width(message)
if type:
self.icon.show()
if type == "error":
self.icon.setPixmap(QPixmap(":/gui/pics/dialog-error.png"))
self.setStyleSheet(" QFrame#frame {background-color: rgba(255,0,0,100);} ")
elif type == "warning":
self.icon.setPixmap(QPixmap(":/gui/pics/dialog-warning.png"))
self.setStyleSheet(" QFrame#frame {background-color: rgba(0,0,0,100);} ")
self.setFixedWidth(textWidth + self.icon.width() + 50)
self.label.setText(message)
else:
self.icon.hide()
self.setStyleSheet(" QFrame#frame {background-color: rgba(0,0,0,100);} ")
self.setFixedWidth(textWidth + self.icon.width() + 100)
self.label.setText(message)
self.spinner.setVisible(spinner)
self.move(ctx.mainScreen.width()/2 - self.width()/2,
ctx.mainScreen.height() - self.height()/2 - 50)
self.show()
def refresh(self):
ctx.mainScreen.processEvents()
def show(self):
QWidget.show(self)
self.refresh()
def hide(self):
QWidget.hide(self)
self.refresh()