leoapp32.png).def runAskOkCancelStringDialog(self,c,title,message,cancelButtonText=None,
okButtonText=None, icon=None,default=""):
"""Create and run askOkCancelString dialog ."""
if g.unitTesting: return None
d = QtWidgets.QInputDialog()
d.setWindowTitle(title)
d.setLabelText(message)
d.setTextValue(default)
if icon:
d.setWindowIcon(icon)
else:
d.setWindowIcon(g.app.gui.getIconImage ('leoapp32.png'))
if cancelButtonText:
d.setCancelButtonText(cancelButtonText)
if okButtonText:
d.setOkButtonText(okButtonText)
ok = d.exec_()
return str(d.textValue()) if ok else None
I just realize that it only work for g.app.gui.runAskOkCancelStringDialog and g.app.gui.runAskOkCancelNumberDialog
but not for runOpenFileDialog, runOpenDirectoryDialog & runSaveFileDialog...
I've to say that I've no idea why this difference...
Does anyone have any clue ?
Various dialogs work differently and return different values. Look at the code: these g.app.gui methodscall different Qt dialog methods, as would be expected.
Leo Log Window
Leo 5.0-final, build 20141214175420, Sun Dec 14 17:54:20 CST 2014
Git repo info: branch = master, commit = 861bce9f9855
Python 2.7.6, PyQt version 4.8.6
linux2
I use Linux Mint 17 KDE (Ubuntu based).
Chris
runAboutLeoDialog
runAskDateTimeDialog
runAskOkDialog
runAskYesNoCancelDialog
runAskYesNoDialog
alert
runAskLeoIDDialog
runOpenDirectoryDialog
runOpenFileDialog
runSaveFileDialog
runAskOkCancelNumberDialog
runAskOkCancelStringDialog
from leo.core.leoQt import QtWidgets
b = QtWidgets.QMessageBox
def independantBox():
"""This box is independant from Leo
You can keep working without closing it
It have its own tab on your desktop app panel"""
# For no new app tab
box=b()
#Equivalent to
#box=b(None)
#box=b(parent=None)
box.setWindowIcon(g.app.gui.appIcon)
box.exec_()
def childBox():
"""This box is attached to Leo
Leo is frozen until you close it
It have no tab on your panel"""
box=b(c.frame.top)
#Equivalent to
#box=b(parent=c.frame.top)
# Set tabs icon
box.exec_()
from leo.core.leoQt import QtWidgets
def onDirEntered():
g.es("Entered in a new directory")
dialog = QtWidgets.QFileDialog(None, 'Select directory')
dialog.setDirectory(os.getenv('HOME'))
dialog.setFileMode(QtWidgets.QFileDialog.Directory)
dialog.directoryEntered.connect(onDirEntered)
# Try with and without this option :
dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog)
dialog.setWindowIcon(g.app.gui.appIcon)
dialog.exec_()