gdesk.panels.dialog.proxy module¶
- class gdesk.panels.dialog.proxy.DialogGuiProxy¶
Bases:
gdesk.core.gui_proxy.GuiProxyBase
- attach(gui)¶
- category = 'values'¶
- static fedit(*args, **kwargs)¶
Create form dialog and return result (if Cancel button is pressed, return None)
- Parameters
data (tuple) – datalist, datagroup (see below)
title (str) – form title
comment (str) – header comment
icon (QIcon) – dialog box icon
parent (QWidget) – parent widget
ok (str) – customized ok button label
cancel (str) – customized cancel button label
apply (function) – (label, function) customized button label and callback
apply – function taking two arguments (result, widgets)
result (str) – result serialization (‘list’, ‘dict’, ‘OrderedDict’, ‘JSON’ or ‘XML’)
outfile (str) – write result to the file outfile.[py|json|xml]
type (str) – layout type (‘form’ or ‘questions’)
scrollbar (bool) – vertical scrollbar
background_color (str) – color of the background
widget_color (str) – color of the widgets
- Returns
Serialized result (data type depends on result parameter)
datalist: list/tuple of (field_name, field_value) datagroup: list/tuple of (datalist or datagroup, title, comment)
- Tips:
one field for each member of a datalist
one tab for each member of a top-level datagroup
one page (of a multipage widget, each page can be selected with a combo box) for each member of a datagroup inside a datagroup
- Supported types for field_value:
int, float, str, unicode, bool
- colors: in Qt-compatible text form, i.e. in hex format or name (red,…)
(automatically detected from a string)
- list/tuple:
the first element will be the selected index (or value)
the other elements can be couples (key, value) or only values
- static filterlist(items=None, selection=None, filter=None)¶
Open a items filter dialog. The user have to select items from it.
- selection = Noneselect nothing
= one_item : select the one item = []: use checkable items = [str1, str2] : check items on string value
- filter = None: check nothing
= False: check everything =
\w*01\w*
: use re to match string
- static getdir(startpath=None, title='select a Directory')¶
Show a directory dialog to choose a dir
- Returns
The directory
- Return type
str
- static getfile(filter='*.*', title='open', file=None)¶
Show a file dialog to open a file. Return a string tuple of file path and choosen filter
- Parameters
filter (str) – a filter of the form *.tif
title (str) – the window title
file (str) – default file path
- Returns
The file path and choosen filter
- Return type
tuple(str, str)
- static getfilename(filter='*.*', title='open', file=None)¶
- static getfilenames(filter='*.*', title='open', file=None)¶
Multi file selection version of getfilename
- static getfiles(filter='*.*', title='open', file=None)¶
Multi file selection version of getfile
- static getpath(startpath=None, title='select a Directory')¶
Show a directory dialog to choose a dir :return: The directory :rtype: pathlib.Path
- static getstring(prompt='', default='', title='Input', echo='Normal', timeout=None)¶
Show a popup-window to ask the user some textual input.
Makes use of QtWidgets.QInputDialog.getText; see https://srinikom.github.io/pyside-docs/PySide/QtGui/QInputDialog.html#PySide.QtGui.PySide.QtGui.QInputDialog.getText
- Parameters
prompt (str) – The explanation that is visible just above the text input field.
default (str) – The text that is already present in the editable input field.
title (str) – The name of the pop-window (shown in its title bar).
echo (str) – ‘Normal’ for normal text entry; ‘Password’ for password entry. See http://doc.qt.io/qt-4.8/qlineedit.html#EchoMode-enum
- static inputdlg(prompt='', default='', title='Input', masked=False, timeout=None)¶
Open a input dialog. The user can enter a string.
- Parameters
prompt (str) – The prompt
default (str) – The default string
title (str) – The title of the dialog
masked (bool) – Mask the string as stars ******
timeout (None or float) – After time, continue the flow. Expressed in miliseconds
- Returns
The user string
- Return type
str
Timeout can not be combined with mask.
- static msgbox(message, title='', icon='none')¶
Creates a message box
- Parameters
message (str) – the message
title (str) – the title
icon (str) – ‘none’, ‘help, ‘info’, ‘warn’, ‘error’
- static putfile(filter='*.*', title='save', file=None, defaultfilter='')¶
Open a save file dialog and return a file name selected by the user. The file does not have to exist.
- Parameters
filter (str) – File type filter, filters are seperated by
;;
e.g.: *.tif, Image (*.tif *.png), Text(*.txt);;Image (*.tif *.png)title (str) – Title of the dialog
file (str or None) – Propose of file name
defaultfilter (str) – Default filter to use
- Returns
The filename and used filter
- Return type
str, str
Example
>>> filename, filter = gui.putfile('Text(*.txt);;Image (*.tif *.png)', "Give it a filename", r"C:\temp\default.tif", "Image (*.tif *.png)")
- static putfilename(filter='*.*', title='save', file=None, defaultfilter='')¶
Open a save file dialog and return a file name selected by the user. The file does not have to exist.
- Parameters
filter (str) – File type filter, filters are seperated by
;;
e.g.: *.tif, Image (*.tif *.png), Text(*.txt);;Image (*.tif *.png)title (str) – Title of the dialog
file (str or None) – Propose of file name
defaultfilter (str) – Default filter to use
- Returns
The filename
- Return type
str
Example
>>> filename = gui.putfile('Text(*.txt);;Image (*.tif *.png)', "Give it a filename", r"C:\temp\default.tif", "Image (*.tif *.png)")
- static question(question='Do you press the No Button?', title='Question')¶
Yes/No question
- static selectfile(filter='*.*', title='Select', default_path=None)¶