本文整理汇总了Python中PyKDE4.kdeui.KMessageBox.warningYesNo方法的典型用法代码示例。如果您正苦于以下问题:Python KMessageBox.warningYesNo方法的具体用法?Python KMessageBox.warningYesNo怎么用?Python KMessageBox.warningYesNo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyKDE4.kdeui.KMessageBox
的用法示例。
在下文中一共展示了KMessageBox.warningYesNo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import warningYesNo [as 别名]
def __init__( self ):
bus = dbus.SessionBus()
try:
app_proxy = bus.get_object( 'org.kde.amarok', '/' )
self.app = dbus.Interface( app_proxy, 'org.freedesktop.MediaPlayer' )
player_proxy = bus.get_object( 'org.kde.amarok', '/Player' )
self.player = dbus.Interface( player_proxy, 'org.freedesktop.MediaPlayer' )
tList_proxy = bus.get_object( 'org.kde.amarok', '/TrackList')
self.trackList = dbus.Interface( tList_proxy, 'org.freedesktop.MediaPlayer' )
except dbus.exceptions.DBusException:
import sys
from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
from PyKDE4.kdeui import KMainWindow, KMessageBox, KApplication
about = KAboutData("msgbox", "msgbox", ki18n ("TAmarok"), "0.1", ki18n(""), KAboutData.License_GPL,
ki18n ( "(c) 2009 Thomas Eichinger" ), ki18n(""), "", "")
KCmdLineArgs.init(sys.argv, about)
app = KApplication()
win = KMainWindow()
if KMessageBox.warningYesNo(win, "Oops, found no Amarok instance.\n Start Amarok now?" ) == 3 :
import subprocess
self.out = ""
subprocess.Popen("amarok")
import time
time.sleep(3)
app_proxy = bus.get_object( 'org.kde.amarok', '/' )
self.app = dbus.Interface( app_proxy, 'org.freedesktop.MediaPlayer' )
player_proxy = bus.get_object( 'org.kde.amarok', '/Player' )
self.player = dbus.Interface( player_proxy, 'org.freedesktop.MediaPlayer' )
tList_proxy = bus.get_object( 'org.kde.amarok', '/TrackList')
self.trackList = dbus.Interface( tList_proxy, 'org.freedesktop.MediaPlayer' )
else:
print "*E* Sorry no Amarok running"
quit()
示例2: license_accepted
# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import warningYesNo [as 别名]
def license_accepted(license):
"""asks to accept a license"""
return KMessageBox.Yes == KMessageBox.warningYesNo(kate.mainWindow(),
i18nc('@info:status', '''<p>
Additionally to free software licenses like GPL and MIT,
this functionality requires you to accept the following conditions:
</p><p>%1</p><p>
Do you want to accept and download the functionality?
</p>''', license),
i18nc('@title:window', 'Accept license?'))
示例3: __kdeWarning
# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import warningYesNo [as 别名]
def __kdeWarning(parent, title, text,
buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
"""
Function to show a modal warning message box.
@param parent parent widget of the message box
@param title caption of the message box
@param text text to be shown by the message box
@param buttons flags indicating which buttons to show
(QMessageBox.StandardButtons)
@param defaultButton flag indicating the default button
(QMessageBox.StandardButton)
@return button pressed by the user (QMessageBox.StandardButton)
"""
if __nrButtons(buttons) == 1:
KMessageBox.sorry(parent, text, title)
return buttons
if __nrButtons(buttons) == 2:
if defaultButton == QMessageBox.NoButton:
defaultButton = __getLowestFlag(buttons)
noButton = defaultButton
noItem = __getGuiItem(noButton)
yesButton = int(buttons & ~noButton)
yesItem = __getGuiItem(yesButton)
res = KMessageBox.warningYesNo(parent, text, title, yesItem, noItem)
if res == KMessageBox.Yes:
return yesButton
else:
return noButton
if __nrButtons(buttons) == 3:
if defaultButton == QMessageBox.NoButton:
defaultButton = __getLowestFlag(buttons)
yesButton = defaultButton
yesItem = __getGuiItem(yesButton)
buttons = buttons & ~yesButton
noButton = __getLowestFlag(buttons)
noItem = __getGuiItem(noButton)
cancelButton = int(buttons & ~noButton)
cancelItem = __getGuiItem(cancelButton)
res = KMessageBox.warningYesNoCancel(parent, text, title,
yesItem, noItem, cancelItem)
if res == KMessageBox.Yes:
return yesButton
elif res == KMessageBox.No:
return noButton
else:
return cancelButton
raise RuntimeError("More than three buttons are not supported.")
示例4: doExport
# 需要导入模块: from PyKDE4.kdeui import KMessageBox [as 别名]
# 或者: from PyKDE4.kdeui.KMessageBox import warningYesNo [as 别名]
def doExport(self, exporter):
filePath = exporter.getFilePath()
if filePath != None:
# if a path is set, than it is configurable
fileTypes = exporter.getFileTypes()
if fileTypes:
filterStr = ' '.join(fileTypes)
else:
filterStr = ''
# TODO make remote url work
fileDialog = KFileDialog(KUrl(filePath), filterStr, self)
fileDialog.setSelection(os.path.basename(filePath))
fileDialog.setCaption(i18n('Export Vocabulary'))
#fileDialog.setConfirmOverwrite(True)
fileDialog.setOperationMode(KFileDialog.Saving)
if fileDialog.exec_() != KFileDialog.Accepted:
return
filePath = unicode(fileDialog.selectedFile())
# TODO setConfirmOverwrite() doesn't work right now, so...
while filePath and os.path.exists(filePath) \
and KMessageBox.warningYesNo(self,
i18n('The given file "%1" already exists. Overwrite?',
os.path.basename(filePath))) == KMessageBox.No:
fileDialog.setSelection(os.path.basename(filePath))
if fileDialog.exec_() != KFileDialog.Accepted:
return
filePath = unicode(fileDialog.selectedFile())
if not filePath:
return
exporter.setFilePath(unicode(filePath))
exporter.setEntries(self.vocabularyModel.getVocabulary())
try:
if not exporter.write():
KMessageBox.error(self, i18n('Error saving file'))
except Exception, e:
KMessageBox.error(self, i18n('Error saving file: %1', unicode(e)))
print unicode(e).encode(locale.getpreferredencoding())