本文整理汇总了Python中PyQt4.Qt.QPushButton.setObjectName方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setObjectName方法的具体用法?Python QPushButton.setObjectName怎么用?Python QPushButton.setObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setObjectName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MovieRewindDialog
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
class MovieRewindDialog(QDialog):
def __init__(self, movie):
self.movie = movie
QDialog.__init__(self, None)
self.setObjectName("movie_warning")
self.text_browser = QTextBrowser(self)
self.text_browser.setObjectName("movie_warning_textbrowser")
self.text_browser.setMinimumSize(400, 40)
self.setWindowTitle('Rewind your movie?')
self.text_browser.setPlainText(
"You may want to rewind the movie now. If you save the part without " +
"rewinding the movie, the movie file will become invalid because it " +
"depends upon the initial atom positions. The atoms move as the movie " +
"progresses, and saving the part now will save the final positions, " +
"which are incorrect for the movie you just watched.")
self.ok_button = QPushButton(self)
self.ok_button.setObjectName("ok_button")
self.ok_button.setText("Rewind movie")
self.cancel_button = QPushButton(self)
self.cancel_button.setObjectName("cancel_button")
self.cancel_button.setText("No thanks")
layout = QGridLayout(self)
layout.addWidget(self.text_browser,0,0,0,1)
layout.addWidget(self.ok_button,1,0)
layout.addWidget(self.cancel_button,1,1)
self.connect(self.ok_button,SIGNAL("clicked()"),self.rewindMovie)
self.connect(self.cancel_button,SIGNAL("clicked()"),self.noThanks)
def rewindMovie(self):
self.movie._reset()
self.accept()
def noThanks(self):
self.accept()
示例2: windowTitle
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
class windowTitle(QFrame):
def __init__(self, parent, closeButton=True):
QFrame.__init__(self, parent)
self.setMaximumSize(QSize(9999999,22))
self.setObjectName("windowTitle")
self.hboxlayout = QHBoxLayout(self)
self.hboxlayout.setSpacing(0)
self.hboxlayout.setContentsMargins(0,0,4,0)
self.label = QLabel(self)
self.label.setObjectName("label")
self.label.setStyleSheet("padding-left:4px; font:bold 11px; color: #FFFFFF;")
self.hboxlayout.addWidget(self.label)
spacerItem = QSpacerItem(40,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
self.hboxlayout.addItem(spacerItem)
if closeButton:
self.pushButton = QPushButton(self)
self.pushButton.setFocusPolicy(Qt.NoFocus)
self.pushButton.setObjectName("pushButton")
self.pushButton.setStyleSheet("font:bold;")
self.pushButton.setText("X")
self.hboxlayout.addWidget(self.pushButton)
self.dragPosition = None
self.mainwidget = self.parent()
self.setStyleSheet("""
QFrame#windowTitle {background-color:#222222;color:#FFF;}
""")
# Initial position to top left
self.dragPosition = self.mainwidget.frameGeometry().topLeft()
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.dragPosition = event.globalPos() - self.mainwidget.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self, event):
if event.buttons() & Qt.LeftButton:
self.mainwidget.move(event.globalPos() - self.dragPosition)
event.accept()
示例3: _MovieRewindDialog
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
class _MovieRewindDialog(QDialog):
"""
Warn the user that a given movie is not rewound,
explain why that matters, and offer to rewind it
(by calling its _reset method).
"""
def __init__(self, movie):
self.movie = movie
QDialog.__init__(self, None)
self.setObjectName("movie_warning")
self.text_browser = QTextBrowser(self)
self.text_browser.setObjectName("movie_warning_textbrowser")
self.text_browser.setMinimumSize(400, 40)
self.setWindowTitle('Rewind your movie?')
self.text_browser.setPlainText( #bruce 080827 revised text
"You may want to rewind the movie now. The atoms move as the movie "
"progresses, and saving the part without rewinding will save the "
"current positions, which is sometimes useful, but will make the "
"movie invalid, because .dpb files only store deltas relative to "
"the initial atom positions, and don't store the initial positions "
"themselves." )
self.ok_button = QPushButton(self)
self.ok_button.setObjectName("ok_button")
self.ok_button.setText("Rewind movie")
self.cancel_button = QPushButton(self)
self.cancel_button.setObjectName("cancel_button")
self.cancel_button.setText("Exit command without rewinding") #bruce 080827 revised text
# Note: this is not, in fact, a cancel button --
# there is no option in the caller to prevent exiting the command.
# There is also no option to "forward to final position",
# though for a minimize movie, that might be most useful.
# [bruce 080827 comment]
layout = QGridLayout(self)
layout.addWidget(self.text_browser, 0, 0, 0, 1)
layout.addWidget(self.ok_button, 1, 0)
layout.addWidget(self.cancel_button, 1, 1)
self.connect(self.ok_button, SIGNAL("clicked()"), self.rewindMovie)
self.connect(self.cancel_button, SIGNAL("clicked()"), self.noThanks)
def rewindMovie(self):
self.movie._reset()
self.accept()
def noThanks(self):
self.accept()
pass
示例4: PermissionDialog
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
class PermissionDialog(QDialog, threading.Thread):
# Politely explain what we're doing as clearly as possible. This will be the
# user's first experience of the sponsorship system and we want to use the
# Google axiom of "Don't be evil".
text = ("We would like to use your network connection to update a list of our " +
"sponsors. This enables us to recoup some of our development costs " +
"by putting buttons with sponsor logos on some dialogs. If you click " +
"on a sponsor logo button, you will get a small window with some " +
"information about that sponsor. May we do this? Otherwise we'll " +
"just use buttons with our own Nanorex logo.")
def __init__(self, win):
self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml')
self.win = win
self.needToAsk = False
self.downloadSponsors = False
threading.Thread.__init__(self)
if not self.refreshWanted():
return
if env.prefs[sponsor_permanent_permission_prefs_key]:
# We have a permanent answer so no need for a dialog
if env.prefs[sponsor_download_permission_prefs_key]:
self.downloadSponsors = True
return
self.needToAsk = True
QDialog.__init__(self, None)
self.setObjectName("Permission")
self.setModal(True) #This fixes bug 2296. Mitigates bug 2297
layout = QGridLayout()
self.setLayout(layout)
layout.setMargin(0)
layout.setSpacing(0)
layout.setObjectName("PermissionLayout")
self.text_browser = QTextBrowser(self)
self.text_browser.setObjectName("text_browser")
layout.addWidget(self.text_browser,0,0,1,4)
self.text_browser.setMinimumSize(400, 80)
self.setWindowTitle('May we use your network connection?')
self.setWindowIcon(geticon('ui/border/MainWindow.png'))
self.text_browser.setPlainText(self.text)
self.accept_button = QPushButton(self)
self.accept_button.setObjectName("accept_button")
self.accept_button.setText("Always OK")
self.accept_once_button = QPushButton(self)
self.accept_once_button.setObjectName("accept_once_button")
self.accept_once_button.setText("OK now")
self.decline_once_button = QPushButton(self)
self.decline_once_button.setObjectName("decline_once_button")
self.decline_once_button.setText("Not now")
self.decline_always_button = QPushButton(self)
self.decline_always_button.setObjectName("decline_always_button")
self.decline_always_button.setText("Never")
layout.addWidget(self.accept_button,1,0)
layout.addWidget(self.accept_once_button,1,1)
layout.addWidget(self.decline_once_button,1,2)
layout.addWidget(self.decline_always_button,1,3)
self.connect(self.accept_button,SIGNAL("clicked()"),self.acceptAlways)
self.connect(self.accept_once_button,SIGNAL("clicked()"),self.acceptJustOnce)
self.connect(self.decline_once_button,SIGNAL("clicked()"),self.declineJustOnce)
self.connect(self.decline_always_button,SIGNAL("clicked()"),self.declineAlways)
def acceptAlways(self):
env.prefs[sponsor_download_permission_prefs_key] = True
env.prefs[sponsor_permanent_permission_prefs_key] = True
self.downloadSponsors = True
self.close()
def acceptJustOnce(self):
env.prefs[sponsor_permanent_permission_prefs_key] = False
self.downloadSponsors = True
self.close()
def declineAlways(self):
env.prefs[sponsor_download_permission_prefs_key] = False
env.prefs[sponsor_permanent_permission_prefs_key] = True
self.close()
def declineJustOnce(self):
env.prefs[sponsor_permanent_permission_prefs_key] = False
self.close()
def run(self):
#
# Implements superclass's threading.Thread.run() function
#
if self.downloadSponsors:
_download_xml_file(self.xmlfile)
self.finish()
env.prefs[sponsor_md5_mismatch_flag_key] = self.md5Mismatch()
def refreshWanted(self):
if not os.path.exists(self.xmlfile):
return True
#.........这里部分代码省略.........
示例5: LetsShareBooksDialog
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
class LetsShareBooksDialog(QDialog):
def __init__(self, gui, icon, do_user_config, qaction, us):
QDialog.__init__(self, gui)
self.gui = gui
self.do_user_config = do_user_config
self.qaction = qaction
self.us = us
self.clip = QApplication.clipboard()
self.main_gui = calibre_main()
self.urllib_thread = UrlLibThread(self.us)
self.kill_servers_thread = KillServersThread(self.us)
self.us.check_finished = True
self.pxmp = QPixmap()
self.pxmp.load('images/icon_connected.png')
self.icon_connected = QIcon(self.pxmp)
self.setStyleSheet("""
QDialog {
background-color: white;
}
QPushButton {
font-size: 16px;
border-style: solid;
border-color: red;
font-family:'BitstreamVeraSansMono',Consolas,monospace;
text-transform: uppercase;
}
QPushButton#arrow {
border-width: 16px;
border-right-color:white;
padding: -10px;
color:red;
}
QPushButton#url {
background-color: red;
min-width: 460px;
color: white;
text-align: left;
}
QPushButton#url:hover {
background-color: white;
color: red;
}
QPushButton#share {
background-color: red;
color: white;
margin-right: 10px;
}
QPushButton#share:hover {
background-color: white;
color: red;
}
QPushButton#url2 {
color: #222;
text-align: left;
}
QPushButton#url2:hover {
color: red;
}
""")
self.ll = QVBoxLayout()
#self.ll.setSpacing(1)
self.l = QHBoxLayout()
self.l.setSpacing(0)
self.l.setMargin(0)
#self.l.setContentsMargins(0,0,0,0)
self.w = QWidget()
self.w.setLayout(self.l)
self.setLayout(self.ll)
self.setWindowIcon(icon)
self.lets_share_button = QPushButton()
self.lets_share_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
self.lets_share_button.setObjectName("share")
self.lets_share_button.clicked.connect(self.lets_share)
self.stop_share_button = QPushButton()
self.stop_share_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
self.stop_share_button.setObjectName("share")
self.stop_share_button.clicked.connect(self.stop_share)
self.l.addWidget(self.lets_share_button)
self.l.addWidget(self.stop_share_button)
if self.us.button_state == "start":
self.lets_share_button.show()
self.stop_share_button.hide()
#.........这里部分代码省略.........
示例6: LetsShareBooksDialog
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
#.........这里部分代码省略.........
QLineEdit#edit {
background-color: white;
color: black;
font-size: 16px;
border-style: solid;
border-color: red;
font-family:'BitstreamVeraSansMono',Consolas,monospace;
text-transform: uppercase;
}
""")
self.ll = QVBoxLayout()
#self.ll.setSpacing(1)
self.l = QHBoxLayout()
self.l.setSpacing(0)
self.l.setMargin(0)
#self.l.setContentsMargins(0,0,0,0)
self.w = QWidget()
self.w.setLayout(self.l)
self.setLayout(self.ll)
self.setWindowIcon(icon)
self.debug_label = QLabel()
self.ll.addWidget(self.debug_label)
self.debug_label.show()
self.lets_share_button = QPushButton()
self.lets_share_button.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
self.lets_share_button.setObjectName("share")
#self.lets_share_button.clicked.connect(self.lets_share)
self.l.addWidget(self.lets_share_button)
self.url_label = QPushButton()
self.url_label.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
self.url_label.setObjectName("url")
#self.url_label.clicked.connect(self.open_url)
self.l.addWidget(self.url_label)
self.arrow_button = QPushButton("_____")
self.arrow_button.setObjectName("arrow")
self.l.addWidget(self.arrow_button)
self.ll.addWidget(self.w)
self.ll.addSpacing(5)
self.libranon_layout = QHBoxLayout()
self.libranon_layout.setSpacing(0)
self.libranon_layout.setMargin(0)
#self.l.setContentsMargins(0,0,0,0)
self.libranon_container = QWidget()
self.libranon_container.setLayout(self.libranon_layout)
self.edit = QLineEdit()
self.edit.setObjectName("edit")
self.edit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.edit.setToolTip("Change your librarian name")
self.edit.setText(self.librarian)
#self.edit.textChanged.connect(self.handle_text_changed)
self.save_libranon = QPushButton("librarian:")
示例7: RddtDataExtractorGUI
# 需要导入模块: from PyQt4.Qt import QPushButton [as 别名]
# 或者: from PyQt4.Qt.QPushButton import setObjectName [as 别名]
#.........这里部分代码省略.........
elif (self._rddtDataExtractor.downloadType is DownloadType.SUBREDDIT_CONTENT):
self.allSubBtn.setChecked(True)
icon = QIcon()
icon.addPixmap(QPixmap("RedditDataExtractor/images/logo.png"), QIcon.Normal, QIcon.Off)
self.setWindowIcon(icon)
def stopDownload(self):
try:
self.redditorValidator.stop()
except AttributeError: # the redditorValidator object hasn't been made
pass
try:
self.subredditValidator.stop()
except AttributeError: # the subredditValidator object hasn't been made
pass
try:
self.downloader.stop()
except AttributeError: # the downloader object hasn't been made
pass
# Try to save the current downloads, just in case it never stops the download (rare cases of network problems)
self._rddtDataExtractor.currentlyDownloading = False
self._rddtDataExtractor.saveState()
self._rddtDataExtractor.currentlyDownloading = True
self.stopBtn.setEnabled(False)
@pyqtSlot()
def reactivateBtns(self):
try:
self.gridLayout.removeWidget(self.stopBtn)
self.stopBtn.deleteLater()
except:
pass
self.downloadBtn = QPushButton(self.centralwidget)
self.downloadBtn.setObjectName("downloadBtn")
self.downloadBtn.setText("Download!")
self.downloadBtn.clicked.connect(self.beginDownload)
self.gridLayout.addWidget(self.downloadBtn, 6, 0, 1, 2)
self.addUserBtn.setEnabled(True)
self.addSubredditBtn.setEnabled(True)
self.deleteUserBtn.setEnabled(True)
self.deleteSubredditBtn.setEnabled(True)
self._rddtDataExtractor.currentlyDownloading = False
def enterDownloadMode(self):
self._rddtDataExtractor.currentlyDownloading = True
self.logTextEdit.clear()
self.stopBtn = QPushButton(self.centralwidget)
self.stopBtn.setObjectName("stopBtn")
self.stopBtn.setText("Downloading... Press here to stop the download (In progress downloads will continue until done).")
self.stopBtn.clicked.connect(self.stopDownload)
try:
self.gridLayout.removeWidget(self.downloadBtn)
self.downloadBtn.deleteLater()
except:
pass
self.gridLayout.addWidget(self.stopBtn, 6, 0, 1, 2)
self.addUserBtn.setEnabled(False)
self.addSubredditBtn.setEnabled(False)
self.deleteUserBtn.setEnabled(False)
self.deleteSubredditBtn.setEnabled(False)
@pyqtSlot()
def beginDownload(self):
self.enterDownloadMode()
if self._rddtDataExtractor.downloadType is DownloadType.USER_SUBREDDIT_CONSTRAINED:
# need to validate both subreddits and redditors, start downloading user data once done