Módulo commonsdialog¶
Funciones principales¶
-
msgbox(message[, title="", meesageType=IDEA, root=None])¶ Shows a message dialog with ok button only.
Parámetros: - message (str) – text to present in the dialog
- title (str) – title of the dialog
- messageType (int) – type of icon to use.
- root (DefaultFrame or None) – Frame reference
-
inputbox(message[, title="", messageType=IDEA, initialValue="", root=None])¶ Shows a input dialog.
Parámetros: - message (str) – text to present in the dialog
- title (str) – title of the dialog
- messageType (int) – type of icon to use.
- initialValue (str) – Initial value of the inputbox
- root (DefaultFrame or None) – Frame reference
Devuelve: Return text in the input box
Tipo del valor devuelto: str
-
confirmDialog(message[, title="", optionType=YES_NO, messageType=IDEA, root=None])¶ Create a message dialog with options button
Parámetros: - message (str) – text to present in the dialog
- title (str) – title of the dialog
- optionType (int) – bottons to show
- messageType (int) – type of icon to use.
-
filechooser(option[, title="", initialPath=None, multiselection=False, filter = None, fileHidingEnabled=True, root=None])¶ - Allows configuration parameters to filechooser dialogs
Parámetros: - option (int) – file chooser selection mode. Allowed values: OPEN_FILE, OPEN_DIRECTORY, SAVE_FILE
- title (str) – Window title
- initialPath (str) – Initial path to the directory to open in the dialog
- multiselection (boolean) – Allow select more than one object.
- filter (List of Strings) – list of acepted extension files (“jpg”, “png”, “gif”)
- fileHidingEnabled (boolean) – True if hidden files are not displayed
Devuelve: Selected path or list of paths
-
openFileDialog([title='', initialPath=None, root=None])¶ - Shows a window dialog to choose one file.
Parámetros: - title (str) – Window title. Default ‘’
- initialPath (str) – Initial path to open in window dialog
-
openFolderDialog([title='', initialPath=None, root=None])¶ Shows a window dialog to choose one folder.
Parámetros: - title (str) – Window title. Default ‘’
- initialPath (str) – Initial path to open in window dialog
-
saveFileDialog([title='', initialPath=None, root=None])¶ Shows a window dialog to choose one file.
Parámetros: - title (str) – Window title. Default ‘’
- initialPath (str) – Initial path to open in window dialog
-
getJavaFile(path)¶ - Returns a java File using parameter path. If path doesn’t exists looks for user home folder and if can not find it, returns path will be gvSIG instance directory.
Devuelve: Tipo del valor devuelto: java.io.File
Constantes en la libreria¶
messageType options FORBIDEN = 0 IDEA= 1 WARNING= 2 QUESTION= 3
Confirmdialog optionType Options YES_NO = 0 YES_NO_CANCEL = 1 ACEPT_CANCEL = 2
YES = 0 NO = 1 CANCEL = 2
filechooser options OPEN_FILE = 0 OPEN_DIRECTORY = 1 SAVE_FILE = 2
filechooser selectionMode FILES_ONLY = JFileChooser.FILES_ONLY DIRECTORIES_ONLY = JFileChooser.DIRECTORIES_ONLY
Uso¶
En el módulo de commonsdialog gestiona las ventanas emergentes que aparecen en gvSIG. Por ejemplo, si queremos mostrar un avisa al usuario usaremos msgbox(): o si queremos preguntar por algún valor al usuario que ejecute el script, podemos usar la función inputbox() la cual devolverá el texto que escriba el usuario en la caja de texto que aparecerá en pantalla.
Para importar la librería lo haremos mediante:
import gvsig.commonsdialog
o:
from gvsig import commonsdialog
o:
from gvsig.commonsdialog import *
Por ejemplo:
from gvsig import commonsdialog
def main(*args):
commonsdialog.msgbox("Bienvenido a gvSig","Welcome", commonsdialog.IDEA)
El tipo de mensaje lo establecemos en el parámetro meesageType como podemos ver en msgbox() y estos tipos se encuentras almacenados en constantes dentro del módulo commonsdialog.
O depende de cómo lo importemos:
from gvsig.commonsdialog import *
def main(*args):
msgbox("Bienvenido a gvSIG", "Welcome", IDEA)
Dando como resultado una ventana:
Depende del tipo de aviso que seleccionemos mostrará diferentes iconos en la ventana:
WARNING:
FORBIDEN:
QUESTION: