misc¶
General utility routines, especially simple GUI dialogs for different applications
Functions¶
misc.askquestion()
… GUI-dialog for y/n selectionmisc.get_file()
… GUI-dialog for file-selectionmisc.get_dir()
… GUI-dialog for directory-selectionmisc.progressbar()
… console-based progressbar, to indicate the level of completenessmisc.save_file()
… GUI-dialog for saving file
Details¶
Miscellaneous user interface utilities for
selecting files or directories. If nothing or a non-existing file/direcoty is selected, the return is “None”. Otherwise the file/directory is returned.
waitbar
- misc.askquestion(dialog_title: str = 'Interactive Selection', Question: str = 'Are we done yet?') bool [source]¶
Ask the user a yes/no question
- Parameters:
dialog_title (Window title) –
Question (Question to the user) –
- Returns:
yes_no
- Return type:
Selected answer
Examples
>>> my_wish = sksound.misc.askquestion('Work or Play', 'Do you want to go home?')
- misc.get_dir(dialog_title: str = 'Select Directory', default_name: str = '.') PathLike | None [source]¶
Select a directory
- Parameters:
dialog_title (Window title) –
default_name (Can be a directory AND filename) –
- Returns:
directory
- Return type:
Selected directory
Examples
>>> myDir = skinematics.ui.getdir('c:\temp', 'Pick your directory')
- misc.get_file(filter_spec: str = '*', dialog_title: str = 'Select File: ', default_name: str = '') PathLike | None | str [source]¶
Selecting an existing file.
- Parameters:
filter_spec (File filters) –
dialog_title (Window title) –
default_name (Can be a directory AND filename) –
- Returns:
filename – If no file is selected, ‘None’ is returned
- Return type:
selected existing file (partent + name)
Examples
>>> my_file = skinematics.ui.getfile('*.py', 'Testing file-selection', 'c:\temp\test.py')
- misc.progressbar(it: ndarray | range, prefix: str = '', size: int = 60) Generator [source]¶
Shows a progress-bar on the commandline. This has the advantage that you don’t need to bother with windows managers. Nifty coding!
- Parameters:
it (index variable (integer)) –
prefix (Text preceding the progress-bar) –
size (Length of progress-bar) –
Examples
>>> import time >>> for ii in progressbar(range(50), 'Computing ', 25): >>> #print(ii) >>> time.sleep(0.05)
- misc.save_file(filter_spec: str = '*', dialog_title: str = 'Save File: ', default_name: str = '') PathLike | None [source]¶
Selecting an existing or new file:
- Parameters:
filter_spec (string) – File filters.
dialog_title (string) – Window title.
default_name (string) – Can be a directory AND filename.
- Returns:
selected_file
- Return type:
Selected file (parent + name)
Examples
>>> selected_file = skinematics.ui.savefile('*.py', 'Testing file-selection', 'c:\temp\test.py')