--- title: Widgets keywords: fastai sidebar: home_sidebar summary: "This module contains widgets to perform selected tasks such as viewing/modifying plots interactively. Use Jupyterlab>=3, Notebook or VS Code, Google Colab may not work! For troubleshooting plotly's FigureWidget see Plotly's help" description: "This module contains widgets to perform selected tasks such as viewing/modifying plots interactively. Use Jupyterlab>=3, Notebook or VS Code, Google Colab may not work! For troubleshooting plotly's FigureWidget see Plotly's help" nb_path: "Widgets.ipynb" ---
full_box,files_w = get_files_gui(theme_colors=light_colors,height=400)
va = VasprunApp()
# va.cache_data = False
# va.evr_kws['try_pwsh'] = False
# va.evr_kws['elim'] = [-2,2]
# va.show()
va.set_theme_colors({'next_bg': 'whitesmoke',
'hover_bg': 'skyblue',
'accent': 'black',
'main_bg': 'white',
'main_fg': 'black'})
Note: If you used pivotpy.sio.get_kpath for generating KPOINTS file, your kticks will be automatically filled. If not, you can still add this example string at end of first line of first KPOINTS file with your own values, (not required in all KPOINST files, one time fill is enough if whole project is based on same kpath) [Do not modify names of variables!].
HSK-INDS = [0, 29, -1], LABELS = ['M', 'Γ|M', 'L'], SEG-INDS = [21, 29]
Let's va = VasprunApp(), then:
va.input is dictionary which is unpacked in plot arguments.va.idos_kws and va.ibands_kws can be modified for other arguments not present in self.input.va.cache_data is boolean to turn caching ON and OFF. Caching helps in faster load in subsequent requests.va.result is what you see in table. va.data is output of export_vasprun. You can tweak va.evr_kws that are passed to export_vasprun. va.fig is current figure. va.set_theme_colors could be used to change theme, e.g va.set_theme_colors(pp.dark_colors) will change theme to Dark. This is useful to create new themes, you can edit color values in dark_colors/light_colors and apply back. Do not modify keys, just values!. va.InGui is instance of InputGui class and va.InGui.out is used as va.input. va.html is used to observe self.__updata_input internally.va.iplot and va.splot give current figure(detached) and its matplotlib figure respectively. Their kwargs correspond to current figure's command e.g if Bands figure is there, kwargs are passed to iplot_rgb_lines for va.iplot and to splot_rgb_lines for va.splot. Almost every other attribute is a gui or collection of widgets. E.g. va.dds is dictionary that contains all dropdowns in app. Make sure to not change any key in any dictionary, if done by mistake use, dictionary.pop(key,None).
You can set va.set_theme_colors(<va.theme_colors after edit>) and then apply Custom from theme dropdown to display theme of your choice. Used CSS-compatible color values only.
Load Graph) You can extend app as you choose, see how it saves a figure on button(within app) click.
import pivotpy as pp
import ipywidgets as ipw, os
va = pp.VasprunApp()
va.show()
#Create Additional Functionality
out = ipw.Output()
@out.capture(clear_output=True, wait=True)
def update_mpl(change):
if change:
va.splot(colorbar=False)
path = os.path.join(os.path.dirname(va.files_dd.value),'mpl_plot.png')
pp.savefig(path,transparent=True,dpi=600) #Prevents overwiting existing files
pp._show()
print(va.data.sys_info.incar)
va.buttons['load_graph'].on_click(update_mpl)
out
#ka.show()
Navigate to ipyslides or do pip install ipyslides to create beautiful data driven presentation in Jupyter Notebook.