The Shell and Gui user API¶
shell¶
- class gdesk.core.shellmod.Shell(workspace=None)
- edit(object)
Edit source file of object with external editor
- Parameters
objects – object from which the source code will be opened in an editor
- Returns
None
- edit_dbase(filename)
Edit a SQLite file with an external editor.
- edit_file(filename, lineno=0)
Edit the file with an external editor at a certain lineno.
- execfile(filepath, globals=None, locals=None)
Execute a Python file
- execfilews(filepath, wsname='__execfilews__')
Execute a Python file in a new workspace. Place the workspace in shell
- static get_sys_paths(customs_only=True)
List the sys.paths.
- Parameters
customs_only (bool) – List only paths not part of the python.exe directory.
- getcodefile(object)
Find out which source or compiled file an object was defined in.
- info()
Print info about the current process
- magic(cmd)
Magic commands like in IPython.
- pprint(var)
Do a pretty print of var. The user can also use var!! to call this function.
- static set_sys_paths(new_sys_paths)
Set new content for sys.path.
- this_interpreter()
Return the interpreter related to this thread.
gui¶
- class gdesk.core.gui_proxy.GuiProxy(qapp=None, master_call_queue=None, master_return_queue=None, process_ready_call=None)
Communication channel to the gui Master and Slave Across Procecess and Threads
- static exit()
Exit Gamma Hawk
- static get_panel_ids(category)
Returns all current panal ids of a category. The last one is the selected one.
- Returns
current panal ids
- Return type
list
- static history(count=20)
The command history
- Parameters
count (int) – Show the last count elements
- Returns
Command history as list
- Return type
list
- static menu_trigger(category, pandid, action_names, *args, **kwargs)
Trigger a menu action of a panel.
- Parameters
category (str) – Example ‘image’
id (int) – Example 1
action_names (list) – Example [‘File’, ‘New…’]
- static pull()
Pull and object from the gui data stack
- Returns
The object
- static push(obj)
Push an object on the gui data stack
- Parameters
obj (object) – A pickable object
- property qapp
The QApplication instance. Is only visible in the gui thread.
- show(*args, **argv)
Shows a object in an suitable panel
You can give more then one object to display, multiple viewers will be created.
- Parameters
select (int) – selects which viewer shows the object (start with 1! 0 in GH1) negative numbers stands for last selected, or the selected before that, or before that
- property vr
The roi sliced numpy array of the current image viewer
- property vs
The shared array on the current image viewer Note that the data is on shared memory.
vs[:]
orvs.ndarray
to view it as a real numpy array
Proxy Base¶
- class gdesk.core.gui_proxy.GuiProxyBase
- classmethod close(panid=- 1)
Close the selected panel of the category
- classmethod menu(action_names, *args, **kwargs)
Call a certain menu item of the panel
- Parameters
action_names (list) – Example [‘File’, ‘New…’]
*args – Positional arguments of the menu call
**kwargs – Keyword arguments of the menu call
- classmethod selected()
Return the panel id of the selected panel if this category.
gui.img¶
- class gdesk.panels.imgview.proxy.ImageGuiProxy
- static get_roi()
Get the region of interest of the current viewport as a tuple of integers.
- Return tuple(int, int, int, int)
x0, y0, width, height.
- static get_roi_slices()
Get the current region of interest as a tupple of slice objects
- static jump_to(x, y)
Select a certain pixel and zoom to it
- static select(panid=- 1)
Select or create an image panel with id image_id or auto id
- static set_roi(x0, y0, width=1, height=1)
Set the region of interest on the current viewport.
- Parameters
x0 (int) – first column of the roi
y0 (int) – first row of the roi
width (int) – width of the roi
height (int) – height of the roi
- static set_roi_slices(slices, yonfirst=True)
Set the region of interest on the current viewport.
- Parameters
slices (tuple) – Tuple of slices accross the dimensions.
yonfirst (bool) – True if first slice is the y direction.
- show(array, cmap=None)
Show array in the image viewer.
- Parameters
array (ndarray) –
cmap (str) – ‘grey’, ‘jet’ or ‘turbo’
- static zoom_fit()
Zoom the image to fitting the image viewer area. Snap on the default zooming values.
- static zoom_full()
Zoom the image to fully fitting the image viewer area.
- static zoom_region(x, y, width, height)
Zoom the image to a certain region.
gui.plot¶
- class gdesk.panels.matplot.plotproxy.PlotGuiProxy
- static new(figure_id=None)
Create a new figure.
Links to pylab.figure
- static save(file)
Save the selected figure to a file
- static select(panid=- 1, args=())
If panid < 0, -1: select the active panel, -2: selected before that, … panid == None: new panel panid >= 0: select the panel if exists, otherwise a new with that number
- static show_figure_box(figurebox, hold=False)
Display the figure in the figurebox. The figure has to be added to the current pyplot backend.
- Parameters
hold (bool) – Replace the figure in the current selected panel by the new figure
gui.dialog¶
- class gdesk.panels.dialog.proxy.DialogGuiProxy
- 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 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