diff --git a/tomopyui/widgets/analysis.py b/tomopyui/widgets/analysis.py index 58b885f..92e87de 100644 --- a/tomopyui/widgets/analysis.py +++ b/tomopyui/widgets/analysis.py @@ -6,7 +6,6 @@ from tomopyui._sharedvars import ( tomopy_algorithm_kwargs, astra_cuda_recon_algorithm_kwargs, - extend_description_style, ) from tomopyui.backend.io import Metadata_Align, Metadata_Recon, Projections_Child @@ -16,6 +15,11 @@ BqImViewer_Projections_Child, BqImViewer_Projections_Parent, ) +from tomopyui.widgets.styles import ( + header_font_style, + button_font_style, + extend_description_style, +) class AnalysisBase(ABC): @@ -53,12 +57,6 @@ def init_attributes(self, Import, Center): key for key in astra_cuda_recon_algorithm_kwargs ] self.run_list = [] - self.header_font_style = { - "font_size": "22px", - "font_weight": "bold", - "font_variant": "small-caps", - # "text_color": "#0F52BA", - } self.accordions_open = False self.plot_output1 = Output() @@ -66,34 +64,33 @@ def init_widgets(self): """ Initializes many of the widgets in the Alignment and Recon tabs. """ - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") # -- Button to turn on tab --------------------------------------------- self.open_accordions_button = Button( icon="lock-open", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) # -- Headers for plotting ------------------------------------- self.import_plot_header = "Imported Projections" self.import_plot_header = Label( - self.import_plot_header, style=self.header_font_style + self.import_plot_header, style=header_font_style ) self.altered_plot_header = "Altered Projections" self.altered_plot_header = Label( - self.altered_plot_header, style=self.header_font_style + self.altered_plot_header, style=header_font_style ) # -- Headers for results ------------------------------------- self.before_analysis_plot_header = "Analysis Projections" self.before_analysis_plot_header = Label( - self.before_analysis_plot_header, style=self.header_font_style + self.before_analysis_plot_header, style=header_font_style ) self.after_analysis_plot_header = "Result" self.after_analysis_plot_header = Label( - self.after_analysis_plot_header, style=self.header_font_style + self.after_analysis_plot_header, style=header_font_style ) # -- Button to load metadata ---------------------------------------------- @@ -451,7 +448,7 @@ def containerize(self): # -- Methods ---------------------------------------------------------- self.tomopy_methods_hbox = VBox( [ - Label("Tomopy", style=self.header_font_style), + Label("Tomopy", style=header_font_style), VBox( self.tomopy_methods_checkboxes, layout=Layout(flex_flow="column wrap", align_content="flex-start"), @@ -462,7 +459,7 @@ def containerize(self): self.astra_methods_hbox = VBox( [ - Label("Astra", style=self.header_font_style), + Label("Astra", style=header_font_style), VBox( self.astra_cuda_methods_checkboxes, layout=Layout(flex_flow="column wrap"), diff --git a/tomopyui/widgets/center.py b/tomopyui/widgets/center.py index 31bf26e..7288710 100644 --- a/tomopyui/widgets/center.py +++ b/tomopyui/widgets/center.py @@ -14,6 +14,7 @@ from tomopyui.backend.util.center import write_center from tomopyui.widgets.helpers import ReactiveIconButton, ReactiveTextButton from tomopyui.widgets.view import BqImViewer_Center, BqImViewer_Center_Recon +from tomopyui.widgets.styles import header_font_style, button_font_style class Center: @@ -71,11 +72,6 @@ def __init__(self, Import): self.rec_viewer = BqImViewer_Center_Recon() self.rec_viewer.create_app() self.reg = None - self.header_font_style = { - "font_size": "22px", - "font_weight": "bold", - "font_variant": "small-caps", - } self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") self._init_widgets() @@ -180,21 +176,21 @@ def _init_widgets(self): ) self.projections_plot_header = "Projections" self.projections_plot_header = Label( - self.projections_plot_header, style=self.header_font_style + self.projections_plot_header, style=header_font_style ) self.reconstructions_plot_header = "Reconstructions" self.reconstructions_plot_header = Label( - self.reconstructions_plot_header, style=self.header_font_style + self.reconstructions_plot_header, style=header_font_style ) # -- Centers display ----------------------------------------------------------- - self.center_select_label = Label("Slice : Center", style=self.header_font_style) + self.center_select_label = Label("Slice : Center", style=header_font_style) self.center_select = Select( disabled=True, rows=10, ) self.all_centers_select_label = Label( - "Centers for reconstruction", style=self.header_font_style + "Centers for reconstruction", style=header_font_style ) self.all_centers_select = Select( disabled=True, @@ -205,7 +201,7 @@ def _init_widgets(self): icon="fa-minus-square", tooltip="Remove selected center.", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.buttons_to_disable = [ self.center_select, @@ -217,7 +213,7 @@ def _init_widgets(self): tooltip="Add center from reconstruction of this slice.", skip_during=True, layout=self.button_layout, - style=self.button_font, + style=button_font_style, disabled=False, ) self.add_center_button.button.disabled = True diff --git a/tomopyui/widgets/dataexplorer.py b/tomopyui/widgets/dataexplorer.py index 973920f..8d46625 100644 --- a/tomopyui/widgets/dataexplorer.py +++ b/tomopyui/widgets/dataexplorer.py @@ -212,7 +212,6 @@ def __init__(self): self.quick_path_search.observe( self.update_filechooser_from_quicksearch, names="value" ) - self.quick_path_label = Label("Quick path search") # subdirectory selector self.subdir_list = [] @@ -369,7 +368,7 @@ def load_metadata(self): def create_app(self): quickpath = VBox( [ - self.quick_path_label, + widgets.Label("Quick path search:"), self.quick_path_search, ], layout=Layout(align_items="center"), diff --git a/tomopyui/widgets/hdf_imports.py b/tomopyui/widgets/hdf_imports.py index 5e7a05c..e29c179 100644 --- a/tomopyui/widgets/hdf_imports.py +++ b/tomopyui/widgets/hdf_imports.py @@ -9,6 +9,7 @@ from tomopyui.widgets.hdf_viewer import * from tomopyui.widgets.helpers import ToggleIconButton from tomopyui.widgets.imports import UploaderBase +from tomopyui.widgets.styles import button_font_style class HDF5_GeneralUploader(UploaderBase): @@ -43,20 +44,19 @@ def init_state(self): self.turn_off_callbacks = False def init_widgets(self): - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") self.files_sel = Select() # Go faster on play button self.home_button: ipywidgets.Button = Button( icon="home", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Speed up play slider.", ) self.reset_button: ipywidgets.Button = Button( icon="redo", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Reset to original.", ) self.tree_output = Output() diff --git a/tomopyui/widgets/prep.py b/tomopyui/widgets/prep.py index b0ab8ed..8450630 100644 --- a/tomopyui/widgets/prep.py +++ b/tomopyui/widgets/prep.py @@ -20,6 +20,9 @@ from ..tomocupy.prep.alignment import shift_prj_cp, batch_cross_correlation from ..tomocupy.prep.sampling import shrink_and_pad_projections +from tomopyui.widgets.styles import header_font_style, button_font_style + + import tomopy.misc.corr as tomocorr @@ -49,12 +52,6 @@ def init_widgets(self): """ Initializes widgets in the Prep tab. """ - self.header_font_style = { - "font_size": "22px", - "font_weight": "bold", - "font_variant": "small-caps", - } - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") # -- Main viewers -------------------------------------------------------------- @@ -68,18 +65,16 @@ def init_widgets(self): # -- Headers for plotting ------------------------------------- self.import_plot_header = "Imported Projections" self.import_plot_header = Label( - self.import_plot_header, style=self.header_font_style + self.import_plot_header, style=header_font_style ) self.altered_plot_header = "Altered Projections" self.altered_plot_header = Label( - self.altered_plot_header, style=self.header_font_style + self.altered_plot_header, style=header_font_style ) # -- Header for methods ------------------------------------- self.prep_list_header = "Methods" - self.prep_list_header = Label( - self.prep_list_header, style=self.header_font_style - ) + self.prep_list_header = Label(self.prep_list_header, style=header_font_style) # -- Prep List ------------------------------------- self.prep_list_select = Select( @@ -93,21 +88,21 @@ def init_widgets(self): icon="arrow-up", tooltip="Move method up.", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.down_button = Button( disabled=True, icon="arrow-down", tooltip="Move method down.", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.remove_method_button = Button( disabled=True, icon="fa-minus-square", tooltip="Remove selected method.", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.start_button = Button( disabled=True, @@ -118,7 +113,7 @@ def init_widgets(self): ), icon="fa-running", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.preview_only_button = Button( disabled=True, @@ -129,7 +124,7 @@ def init_widgets(self): ), icon="glasses", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.save_on_button = Button( disabled=True, @@ -137,7 +132,7 @@ def init_widgets(self): tooltip=("Turn this on to save the data when you click the run button."), icon="fa-file-export", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.methods_button_box = VBox( [ @@ -191,14 +186,14 @@ def init_widgets(self): # -- Shifts uploader -------------------------------------------------------- self.shifts_uploader = ShiftsUploader(self) self.shift_x_header = "Shift in X" - self.shift_x_header = Label(self.shift_x_header, style=self.header_font_style) + self.shift_x_header = Label(self.shift_x_header, style=header_font_style) self.shifts_sx_select = Select( options=[], rows=10, disabled=True, ) self.shift_y_header = "Shift in Y" - self.shift_y_header = Label(self.shift_y_header, style=self.header_font_style) + self.shift_y_header = Label(self.shift_y_header, style=header_font_style) self.shifts_sy_select = Select( options=[], rows=10, @@ -206,7 +201,7 @@ def init_widgets(self): ) self.shifts_filechooser_label = "Filechooser" self.shifts_filechooser_label = Label( - self.shifts_filechooser_label, style=self.header_font_style + self.shifts_filechooser_label, style=header_font_style ) # -- List manipulation --------------------------------------------------------- @@ -560,7 +555,7 @@ def make_tab(self): [ VBox( [ - self.shifts_uploader.quick_path_label, + widgets.Label("Quick path search:"), self.shifts_uploader.quick_path_search, ], ), diff --git a/tomopyui/widgets/styles.py b/tomopyui/widgets/styles.py new file mode 100644 index 0000000..2c84323 --- /dev/null +++ b/tomopyui/widgets/styles.py @@ -0,0 +1,9 @@ +header_font_style = { + "font_size": "22px", + "font_weight": "bold", + "font_variant": "small-caps", +} + +button_font_style = {"font_size": "22px"} + +extend_description_style = {"description_width": "auto", "font_family": "Helvetica"} diff --git a/tomopyui/widgets/tools.py b/tomopyui/widgets/tools.py index 4cab2c1..2d08924 100644 --- a/tomopyui/widgets/tools.py +++ b/tomopyui/widgets/tools.py @@ -16,6 +16,7 @@ from tomopyui.widgets.helpers import import_module_set_env from tomopyui.widgets.imports import TwoEnergyUploader from tomopyui.widgets.view import BqImViewer_TwoEnergy_High, BqImViewer_TwoEnergy_Low +from tomopyui.widgets.styles import header_font_style, button_font_style import_module_set_env(cuda_import_dict) if os.environ["cuda_enabled"] == "True": @@ -36,17 +37,11 @@ def init_attributes(self): self.metadata = Metadata_TwoE() def init_widgets(self): - self.header_font_style = { - "font_size": "22px", - "font_weight": "bold", - "font_variant": "small-caps", - } - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") self.high_e_header = "Shifted High Energy Projections" - self.high_e_header = Label(self.high_e_header, style=self.header_font_style) + self.high_e_header = Label(self.high_e_header, style=header_font_style) self.low_e_header = "Moving Low Energy Projections" - self.low_e_header = Label(self.low_e_header, style=self.header_font_style) + self.low_e_header = Label(self.low_e_header, style=header_font_style) self.high_e_viewer = BqImViewer_TwoEnergy_High() self.low_e_viewer = BqImViewer_TwoEnergy_Low(self.high_e_viewer) self.low_e_viewer.scale_button.on_click(self.scale_low_e) @@ -59,7 +54,7 @@ def init_widgets(self): [ VBox( [ - self.high_e_uploader.quick_path_label, + widgets.Label("Quick path search:"), HBox( [ self.high_e_uploader.quick_path_search, @@ -71,7 +66,7 @@ def init_widgets(self): ), VBox( [ - self.low_e_uploader.quick_path_label, + widgets.Label("Quick path search:"), HBox( [ self.low_e_uploader.quick_path_search, @@ -250,17 +245,11 @@ def init_attributes(self): self.metadata = Metadata_TwoE() def init_widgets(self): - self.header_font_style = { - "font_size": "22px", - "font_weight": "bold", - "font_variant": "small-caps", - } - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") self.high_e_header = "Shifted High Energy Projections" - self.high_e_header = Label(self.high_e_header, style=self.header_font_style) + self.high_e_header = Label(self.high_e_header, style=header_font_style) self.low_e_header = "Moving Low Energy Projections" - self.low_e_header = Label(self.low_e_header, style=self.header_font_style) + self.low_e_header = Label(self.low_e_header, style=header_font_style) self.uploader = HDF5_MultipleEnergyUploader() self.high_e_viewer = self.uploader.viewer1 self.low_e_viewer = self.uploader.viewer2 diff --git a/tomopyui/widgets/view.py b/tomopyui/widgets/view.py index b969767..df71e6a 100644 --- a/tomopyui/widgets/view.py +++ b/tomopyui/widgets/view.py @@ -12,7 +12,9 @@ from bqplot_image_gl.interacts import MouseInteraction, keyboard_events, mouse_events from ipywidgets import * from skimage.transform import rescale # look for better option + from tomopyui._sharedvars import extend_description_style +from tomopyui.widgets.styles import button_font_style class BqImViewerBase(ABC): @@ -111,7 +113,6 @@ def _init_fig(self): def _init_widgets(self): # Styles and layouts - self.button_font = {"font_size": "22px"} self.button_layout = Layout(width="45px", height="40px") # Image index slider @@ -136,7 +137,7 @@ def _init_widgets(self): self.plus_button = Button( icon="plus", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Speed up play slider.", ) @@ -144,7 +145,7 @@ def _init_widgets(self): self.minus_button = Button( icon="minus", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Slow down play slider slider.", ) @@ -157,7 +158,7 @@ def _init_widgets(self): self.swap_axes_button = Button( icon="random", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Swap axes", ) @@ -165,7 +166,7 @@ def _init_widgets(self): self.rm_high_low_int_button = Button( icon="adjust", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Remove high and low intensities from view.", ) @@ -173,7 +174,7 @@ def _init_widgets(self): self.save_movie_button = Button( icon="file-video", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Save a movie of these images.", ) @@ -189,14 +190,14 @@ def _init_widgets(self): self.reset_button = Button( icon="redo", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Reset to original view.", ) self.rectangle_selector_button = Button( icon="far square", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Select a region of interest.", ) # Rectangle selector @@ -597,7 +598,7 @@ def __init__(self, viewer_parent): self.copy_button = Button( icon="file-import", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Copy data from 'Imported Projections'.", ) self.copy_button.on_click(self.copy_parent_projections) @@ -605,7 +606,7 @@ def __init__(self, viewer_parent): self.link_plotted_projections_button = Button( icon="unlink", layout=self.button_layout, - style=self.button_font, + style=button_font_style, disabled=True, tooltip="Link the sliders together.", ) @@ -615,7 +616,7 @@ def __init__(self, viewer_parent): self.range_from_parent_button = Button( icon="object-ungroup", layout=self.button_layout, - style=self.button_font, + style=button_font_style, disabled=True, tooltip="Get range from 'Imported Projections'.", ) @@ -956,7 +957,7 @@ def make_buttons(self): self.diff_button = Button( icon="black-tie", layout=self.button_layout, - style=self.button_font, + style=button_font_style, tooltip="Take the difference of the high and low energies.", disabled=False, ) @@ -964,7 +965,7 @@ def make_buttons(self): icon="unlink", tooltip="Link to the high energy slider.", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.link_plotted_projections_button.on_click(self.link_plotted_projections) self.plots_linked = False @@ -974,7 +975,7 @@ def make_buttons(self): button_style="", disabled=True, layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.start_button = Button( disabled=True, @@ -982,7 +983,7 @@ def make_buttons(self): tooltip="Register low energy to high energy images", icon="fa-running", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) self.save_button = Button( disabled=True, @@ -990,7 +991,7 @@ def make_buttons(self): tooltip=("Click this button to save the shifted lower energy projections."), icon="fa-file-export", layout=self.button_layout, - style=self.button_font, + style=button_font_style, ) def add_buttons(self):