def __init__(self, parent, phil=None):
        BasePanel.__init__(self, parent=parent)

        self.regenerate_params(phil)

        # Title box
        self.project_title = ct.InputCtrl(self,
                                          label='Project Title: ',
                                          label_size=(140, -1))
        # Output file box
        self.out_box = ct.InputCtrl(self,
                                    label='Project folder: ',
                                    label_size=(140, -1),
                                    label_style='bold',
                                    value=os.path.abspath(os.curdir),
                                    buttons=True)
        # Input file box
        self.inp_box = FileListCtrl(self)

        # Options
        opt_box = wx.FlexGridSizer(2, 3, 10, 10)
        self.opt_chk_useref = wx.CheckBox(self,
                                          label='Use reference in refinement')
        self.opt_chk_useref.Disable()
        self.opt_spc_nres = ct.SpinCtrl(self,
                                        label='No. of Residues: ',
                                        label_size=(160, -1),
                                        ctrl_size=(100, -1),
                                        ctrl_value=500,
                                        ctrl_min=10,
                                        ctrl_max=100000)
        procs = multiprocessing.cpu_count()
        self.opt_spc_nproc = ct.SpinCtrl(self,
                                         label='No. of Processors: ',
                                         label_size=(160, -1),
                                         ctrl_max=procs,
                                         ctrl_min=1,
                                         ctrl_value=str(int(procs / 2)))
        self.opt_btn = wx.Button(self, label='Advanced Options...')
        opt_box.AddMany([(self.opt_chk_useref), (0, 0), (self.opt_spc_nres),
                         (self.opt_btn), (0, 0), (self.opt_spc_nproc)])
        opt_box.AddGrowableCol(1)

        # Add to sizers
        self.main_sizer.Add(self.project_title, flag=f.expand, border=10)
        self.main_sizer.Add(self.out_box, flag=f.expand, border=10)
        self.main_sizer.Add(self.inp_box,
                            1,
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(wx.StaticLine(self), flag=wx.EXPAND)
        self.main_sizer.Add(opt_box, flag=wx.ALL | wx.EXPAND, border=10)

        # Button bindings
        self.out_box.btn_browse.Bind(wx.EVT_BUTTON, self.onOutputBrowse)
        self.opt_btn.Bind(wx.EVT_BUTTON, self.onAdvancedOptions)
Exemplo n.º 2
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent=parent)
        self.parent = parent
        self.chart_sash_position = 0

        self.main_sizer = wx.GridBagSizer(10, 10)

        # Status box
        self.info_panel = wx.Panel(self)
        self.info_sizer = wx.FlexGridSizer(1, 4, 0, 10)
        self.info_sizer.AddGrowableCol(3)
        self.info_panel.SetSizer(self.info_sizer)

        self.count_box = wx.StaticBox(self.info_panel, label='Hits')
        self.count_box_sizer = wx.StaticBoxSizer(self.count_box, wx.HORIZONTAL)
        self.count_txt = wx.StaticText(self.info_panel, label='')
        self.count_box_sizer.Add(self.count_txt,
                                 flag=wx.ALL | wx.ALIGN_CENTER,
                                 border=10)

        self.idx_count_box = wx.StaticBox(self.info_panel, label='Indexed')
        self.idx_count_box_sizer = wx.StaticBoxSizer(self.idx_count_box,
                                                     wx.HORIZONTAL)
        self.idx_count_txt = wx.StaticText(self.info_panel, label='')
        self.idx_count_box_sizer.Add(self.idx_count_txt,
                                     flag=wx.ALL | wx.ALIGN_CENTER,
                                     border=10)

        self.pg_box = wx.StaticBox(self.info_panel, label='Lattice')
        self.pg_box_sizer = wx.StaticBoxSizer(self.pg_box, wx.HORIZONTAL)
        self.pg_txt = wx.StaticText(self.info_panel, label='')
        self.pg_box_sizer.Add(self.pg_txt,
                              flag=wx.ALL | wx.ALIGN_CENTER,
                              border=10)

        self.uc_box = wx.StaticBox(self.info_panel, label='Unit Cell')
        self.uc_box_sizer = wx.StaticBoxSizer(self.uc_box, wx.HORIZONTAL)
        self.uc_txt = wx.StaticText(self.info_panel, label='')
        self.uc_box_sizer.Add(self.uc_txt,
                              flag=wx.ALL | wx.ALIGN_CENTER,
                              border=10)

        font = wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        self.count_txt.SetFont(font)
        self.idx_count_txt.SetFont(font)
        font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        self.pg_txt.SetFont(font)
        self.uc_txt.SetFont(font)

        self.info_sizer.Add(self.count_box_sizer, flag=wx.EXPAND)
        self.info_sizer.Add(self.idx_count_box_sizer, flag=wx.EXPAND)
        self.info_sizer.Add(self.pg_box_sizer, flag=wx.EXPAND)
        self.info_sizer.Add(self.uc_box_sizer, flag=wx.EXPAND)

        # Put chart and image list into splitter window
        self.chart_splitter = wx.SplitterWindow(
            self, style=wx.SP_LIVE_UPDATE | wx.SP_3DSASH | wx.SP_NOBORDER)

        # Put in chart
        self.graph_panel = wx.Panel(self.chart_splitter)
        self.graph_sizer = wx.GridBagSizer(5, 5)

        self.chart = TrackChart(self.graph_panel, main_window=parent)
        self.min_bragg = ct.SpinCtrl(self.graph_panel,
                                     label='Min. Bragg spots',
                                     label_size=wx.DefaultSize,
                                     ctrl_size=(100, -1),
                                     ctrl_value=10,
                                     ctrl_min=0)
        self.chart_window = ct.SpinCtrl(self.graph_panel,
                                        label_size=wx.DefaultSize,
                                        checkbox=True,
                                        checkbox_state=False,
                                        checkbox_label='Finite chart window',
                                        ctrl_size=(100, -1),
                                        ctrl_value=100,
                                        ctrl_min=10,
                                        ctrl_step=10)
        # self.spf_options = wx.Button(self.graph_panel,
        #                              label='Spotfinding Options...')
        self.chk_uc_cluster = wx.CheckBox(self.graph_panel,
                                          label='Unit cell clustering')
        self.graph_sizer.Add(self.chart,
                             flag=wx.EXPAND,
                             pos=(0, 0),
                             span=(1, 3))
        self.graph_sizer.Add(self.min_bragg, flag=wx.ALIGN_LEFT, pos=(1, 0))
        self.graph_sizer.Add(self.chart_window,
                             flag=wx.ALIGN_CENTER,
                             pos=(1, 1))
        self.graph_sizer.Add(self.chk_uc_cluster,
                             flag=wx.ALIGN_CENTER,
                             pos=(1, 2))
        #self.graph_sizer.Add(self.spf_options, flag=wx.ALIGN_RIGHT, pos=(1, 2))

        self.graph_sizer.AddGrowableRow(0)
        self.graph_sizer.AddGrowableCol(1)
        self.graph_panel.SetSizer(self.graph_sizer)

        # List of images
        self.image_list_panel = wx.Panel(self.chart_splitter)
        self.image_list_sizer = wx.BoxSizer(wx.VERTICAL)
        self.image_list = ImageList(self.image_list_panel)
        self.btn_view_sel = wx.Button(self.image_list_panel,
                                      label='View Selected')
        self.btn_view_all = wx.Button(self.image_list_panel, label='View All')
        self.btn_wrt_file = wx.Button(self.image_list_panel,
                                      label='Write to File')
        self.btn_view_sel.Disable()
        self.btn_wrt_file.Disable()
        self.btn_view_all.Disable()

        btn_sizer = wx.FlexGridSizer(1, 3, 0, 5)
        btn_sizer.Add(self.btn_wrt_file, flag=wx.ALIGN_LEFT)
        btn_sizer.Add(self.btn_view_all, flag=wx.ALIGN_RIGHT)
        btn_sizer.Add(self.btn_view_sel, flag=wx.ALIGN_RIGHT)
        btn_sizer.AddGrowableCol(0)

        self.image_list_sizer.Add(self.image_list, 1, flag=wx.EXPAND)
        self.image_list_sizer.Add(btn_sizer, flag=wx.ALIGN_RIGHT | wx.EXPAND)
        self.image_list_panel.SetSizer(self.image_list_sizer)

        # Add all to main sizer
        self.main_sizer.Add(self.info_panel,
                            pos=(0, 0),
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(self.chart_splitter,
                            pos=(1, 0),
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        # self.main_sizer.Add(self.graph_panel, pos=(1, 0),
        #                     flag=wx.EXPAND | wx.LEFT | wx.BOTTOM, border=10)
        # self.main_sizer.Add(self.image_list_panel, pos=(1, 1),
        #                     flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT,
        #                     border=10)
        self.main_sizer.AddGrowableCol(0)
        self.main_sizer.AddGrowableRow(1)
        self.SetSizer(self.main_sizer)
        self.chart_splitter.SplitVertically(self.graph_panel,
                                            self.image_list_panel)
        self.chart_splitter.Unsplit()
Exemplo n.º 3
0
  def __init__(self, parent, phil=None, *args, **kwargs):
    BaseDialog.__init__(self, parent, *args, **kwargs)

    self.pparams = phil.extract()
    self.pref_phil = None

    main_sizer = wx.BoxSizer(wx.VERTICAL)

    main_box = wx.StaticBox(self, label='PRIME Preferences')
    vbox = wx.StaticBoxSizer(main_box, wx.VERTICAL)

    self.SetSizer(main_sizer)

    q_choices = ['psanaq', 'psnehq', 'psfehq'] + ['custom']
    self.queues = ct.ChoiceCtrl(self,
                                label='Queue:',
                                label_size=(120, -1),
                                label_style='bold',
                                ctrl_size=wx.DefaultSize,
                                choices=q_choices)
    vbox.Add(self.queues, flag=wx.ALL, border=10)

    self.custom_queue = ct.OptionCtrl(self,
                                      items=[('cqueue', '')],
                                      label='Custom Queue:',
                                      label_size=(120, -1),
                                      label_style='normal',
                                      ctrl_size=(150, -1))
    self.custom_queue.Disable()
    vbox.Add(self.custom_queue, flag=wx.ALL, border=10)

    self.nodes = ct.SpinCtrl(self,
                             label='No. of nodes',
                             label_size=(120, -1),
                             ctrl_value=12,
                             ctrl_size=(80, -1),
                             ctrl_min=1,
                             ctrl_max=5000)
    self.nodes.Disable()
    vbox.Add(self.nodes, flag=wx.ALL, border=10)

    mp_choices = ['multiprocessing', 'bsub']
    self.mp_methods = ct.ChoiceCtrl(self,
                                    label='Method:',
                                    label_size=(120, -1),
                                    label_style='bold',
                                    ctrl_size=wx.DefaultSize,
                                    choices=mp_choices)
    vbox.Add(self.mp_methods, flag=wx.ALL, border=10)

    main_sizer.Add(vbox, flag=wx.EXPAND | wx.ALL, border=10)

    # Dialog control
    dialog_box = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)
    main_sizer.Add(dialog_box,
                   flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL,
                   border=10)

    self.Bind(wx.EVT_CHOICE, self.onQueue, self.queues.ctr)
    self.Bind(wx.EVT_CHOICE, self.onMethod, self.mp_methods.ctr)
    self.Bind(wx.EVT_BUTTON, self.onOK, id=wx.ID_OK)

    self.set_choices()
Exemplo n.º 4
0
  def __init__(self, parent, phil=None, *args, **kwargs):

    BaseBackendDialog.__init__(self, parent,
                               backend_name='PRIME',
                               phil=phil,
                               phil_size=(500, 500),
                               opt_size=(500, 500),
                               *args, **kwargs)

    self.prime_phil = phil
    self.new_prime_phil = None
    self.pparams = self.prime_phil.extract()

    self.splitter.SplitVertically(self.options, self.phil_panel)

    # Target file input
    self.phil = ct.PHILBox(self.phil_panel,
                           btn_import=True,
                           btn_import_label='Import PHIL',
                           btn_export=False,
                           btn_default=False,
                           btn_pos='bottom',
                           ctr_size=(-1, 300),
                           ctr_value='')
    self.phil_sizer.Add(self.phil, 1, flag=wx.EXPAND | wx.ALL, border=5)

    # PRIME Options (there is some redundancy with the PHIL textbox)
    self.prm_options = wx.Panel(self.options)
    opt_box = wx.StaticBox(self.prm_options, label='Advanced Options')
    opt_box_sizer = wx.StaticBoxSizer(opt_box, wx.VERTICAL)
    self.prm_options.SetSizer(opt_box_sizer)

    # Resolution
    self.scale_res = ct.OptionCtrl(self.prm_options,
                                   label='Scale Resolution: ',
                                   label_size=(120, -1),
                                   label_style='normal',
                                   ctrl_size=wx.DefaultSize,
                                   items=[('low', 50),
                                          ('high', 1.5)])
    opt_box_sizer.Add(self.scale_res, flag=f.stack, border=10)

    self.merge_res = ct.OptionCtrl(self.prm_options,
                                   label='Merge Resolution: ',
                                   label_size=(120, -1),
                                   label_style='normal',
                                   ctrl_size=wx.DefaultSize,
                                   items=[('low', 50),
                                          ('high', 1.5)])
    opt_box_sizer.Add(self.merge_res, flag=f.stack, border=10)

    self.p_scale_res = ct.OptionCtrl(self.prm_options,
                                     label='Postref Scale Res.: ',
                                     label_size=(120, -1),
                                     label_style='normal',
                                     ctrl_size=wx.DefaultSize,
                                     items=[('low', 50),
                                            ('high', 1.5)])
    opt_box_sizer.Add(self.p_scale_res, flag=f.stack, border=10)

    self.p_cryst_res = ct.OptionCtrl(self.prm_options,
                                     checkbox=True,
                                     checkbox_label='Crystal Orientation: ',
                                     label_size=(120, -1),
                                     label_style='normal',
                                     ctrl_size=wx.DefaultSize,
                                     items=[('low', 50),
                                            ('high', 1.5)])
    opt_box_sizer.Add(self.p_cryst_res, flag=f.stack, border=10)

    self.p_rrange_res = ct.OptionCtrl(self.prm_options,
                                      checkbox=True,
                                      checkbox_label='Reflecting Range: ',
                                      label_size=(120, -1),
                                      label_style='normal',
                                      ctrl_size=wx.DefaultSize,
                                      items=[('low', 50),
                                             ('high', 1.5)])
    opt_box_sizer.Add(self.p_rrange_res, flag=f.stack, border=10)

    self.p_uc_res = ct.OptionCtrl(self.prm_options,
                                  checkbox=True,
                                  checkbox_label='Unit Cell: ',
                                  label_size=(120, -1),
                                  label_style='normal',
                                  ctrl_size=wx.DefaultSize,
                                  items=[('low', 50),
                                         ('high', 1.5)])
    opt_box_sizer.Add(self.p_uc_res, flag=f.stack, border=10)

    self.p_all_res = ct.OptionCtrl(self.prm_options,
                                   checkbox=True,
                                   checkbox_label='All Parameters: ',
                                   label_size=(120, -1),
                                   label_style='normal',
                                   ctrl_size=wx.DefaultSize,
                                   items=[('low', 50),
                                          ('high', 1.5)])
    opt_box_sizer.Add(self.p_all_res, flag=f.stack, border=10)

    self.btn_synch_res = wx.Button(self.prm_options,
                                   label="Set Res. Limits to Postref. Scale")
    opt_box_sizer.Add(self.btn_synch_res, flag=f.stack, border=10)


    # Target space group
    self.sg = ct.OptionCtrl(self.prm_options,
                            label='Space Group: ',
                            label_size=(120, -1),
                            label_style='normal',
                            ctrl_size=(100, -1),
                            items=[('spacegroup','P212121')])
    opt_box_sizer.Add(self.sg, flag=f.stack, border=10)

    # Target unit cell
    self.uc = ct.OptionCtrl(self.prm_options,
                            label='Unit Cell: ',
                            label_size=(120, -1),
                            label_style='normal',
                            ctrl_size=(300, -1),
                            items=[('unit_cell', '72 120 134 90 90 90')])
    self.anom = wx.CheckBox(self.prm_options, label='Anomalous')
    self.anom.SetValue(False)
    opt_box_sizer.Add(self.uc, flag=f.stack, border=10)
    opt_box_sizer.Add(self.anom, flag=f.stack, border=10)

    # CC cutoff
    self.cc = ct.OptionCtrl(self.prm_options,
                            label='CC cutoff: ',
                            label_size=(120, -1),
                            label_style='normal',
                            ctrl_size=(100, -1),
                            items=[('cc_cutoff', 0.25)])
    opt_box_sizer.Add(self.cc, flag=f.stack, border=10)

    # Pixel size
    self.pix = ct.OptionCtrl(self.prm_options,
                             label='Pixel size: ',
                             label_size=(120, -1),
                             label_style='normal',
                             ctrl_size=(100, -1),
                             items=[('pixel_size', 0.172)])
    opt_box_sizer.Add(self.pix, flag=wx.RIGHT | wx.LEFT | wx.TOP, border=10)

    self.cycles = ct.SpinCtrl(self.prm_options,
                              label='No. of Cycles:',
                              label_size=(120, -1),
                              label_style='normal',
                              ctrl_size=(60, -1))
    opt_box_sizer.Add(self.cycles, flag=wx.ALL, border=10)

    # self.options_sizer.Add(self.phil_sizer, 1, flag=wx.EXPAND | wx.ALL, border=10)
    self.options_sizer.Add(self.prm_options, 1, flag=wx.EXPAND | wx.ALL, border=10)

    # Button bindings
    self.Bind(wx.EVT_BUTTON, self.onImportPHIL, self.phil.btn_import)
    self.Bind(wx.EVT_BUTTON, self.onOK, id=wx.ID_OK)
    self.Bind(wx.EVT_BUTTON, self.onHideScript, self.btn_hide_script)
    self.Bind(wx.EVT_BUTTON, self.onResSynchronize, self.btn_synch_res)
    self.Bind(wx.EVT_CHOICE, self.onAdvanced, self.dlg_ctr.choice)

    self.show_hide_script()
    self.show_hide_advanced(show=False)
    self.Layout()
    self.options.SetupScrolling()
    self.read_param_phil()
Exemplo n.º 5
0
    def __init__(self,
                 parent,
                 phil=None,
                 label_style='bold',
                 content_style='normal',
                 *args,
                 **kwargs):

        BaseDialog.__init__(self,
                            parent,
                            label_style=label_style,
                            content_style=content_style,
                            size=(600, 300),
                            *args,
                            **kwargs)

        # Create options panel (all objects should be called as self.options.object)
        self.options = ScrolledPanel(self, size=(-1, 300))
        options_sizer = wx.BoxSizer(wx.VERTICAL)
        self.options.SetSizer(options_sizer)

        phil_box = wx.StaticBox(self, label='PRIME Input')
        phil_box_sizer = wx.StaticBoxSizer(phil_box, wx.VERTICAL)

        # Target file input
        self.phil = ct.PHILBox(self,
                               btn_import=False,
                               btn_export=False,
                               btn_default=False,
                               ctr_size=(500, 200),
                               ctr_value='')
        phil_box_sizer.Add(self.phil, 1, flag=wx.EXPAND | wx.ALL, border=10)

        # PRIME Options (there is some redundancy with the PHIL textbox)
        opt_box = wx.StaticBox(self.options, label='Advanced Options')
        opt_box_sizer = wx.StaticBoxSizer(opt_box, wx.VERTICAL)

        # Resolution
        self.res_override = wx.CheckBox(self.options,
                                        label='Resolution override')
        self.res = ct.OptionCtrl(self.options,
                                 label='Resolution: ',
                                 label_size=(120, -1),
                                 label_style='normal',
                                 ctrl_size=wx.DefaultSize,
                                 items=[('high', 50), ('low', 1.5)])
        opt_box_sizer.Add(self.res_override, flag=f.stack, border=10)
        opt_box_sizer.Add(self.res, flag=f.stack, border=10)

        # Target space group
        self.sg = ct.OptionCtrl(self.options,
                                label='Space Group: ',
                                label_size=(120, -1),
                                label_style='normal',
                                ctrl_size=(100, -1),
                                items=[('spacegroup', 'P212121')])
        opt_box_sizer.Add(self.sg, flag=f.stack, border=10)

        # Target unit cell
        self.uc = ct.OptionCtrl(self.options,
                                label='Unit Cell: ',
                                label_size=(120, -1),
                                label_style='normal',
                                ctrl_size=(300, -1),
                                items=[('unit_cell', '72 120 134 90 90 90')])
        self.anom = wx.CheckBox(self.options, label='Anomalous')
        self.anom.SetValue(False)
        opt_box_sizer.Add(self.uc, flag=f.stack, border=10)
        opt_box_sizer.Add(self.anom, flag=f.stack, border=10)

        # CC cutoff
        self.cc = ct.OptionCtrl(self.options,
                                label='CC cutoff: ',
                                label_size=(120, -1),
                                label_style='normal',
                                ctrl_size=(100, -1),
                                items=[('cc_cutoff', 0.25)])
        opt_box_sizer.Add(self.cc, flag=f.stack, border=10)

        # Pixel size
        self.pix = ct.OptionCtrl(self.options,
                                 label='Pixel size: ',
                                 label_size=(120, -1),
                                 label_style='normal',
                                 ctrl_size=(100, -1),
                                 items=[('pixel_size', 0.172)])
        opt_box_sizer.Add(self.pix,
                          flag=wx.RIGHT | wx.LEFT | wx.TOP,
                          border=10)

        self.cycles = ct.SpinCtrl(self.options,
                                  label='No. of Cycles:',
                                  label_size=(120, -1),
                                  label_style='normal',
                                  ctrl_size=(60, -1))
        opt_box_sizer.Add(self.cycles, flag=wx.ALL, border=10)

        # Dialog controls
        dialog_box = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)

        options_sizer.Add(opt_box_sizer, 1, flag=f.expand, border=10)
        self.main_sizer.Add(phil_box_sizer,
                            1,
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(self.options,
                            1,
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(dialog_box,
                            flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL,
                            border=10)

        self.options.SetupScrolling()
Exemplo n.º 6
0
    def __init__(self, parent):
        BasePanel.__init__(self, parent=parent)

        self.parent = parent
        self.img_filename = None
        self.input_phil = None
        self.sparams = None
        self.coord_filename = None
        self.mtz_filename = None
        self.stol_filename = None
        self.ref_img_filename = None
        self.dblclick = False

        self.project_folder = ct.InputCtrl(self,
                                           label='Project Folder: ',
                                           label_size=(150, -1),
                                           label_style='bold',
                                           value=os.path.abspath(os.curdir),
                                           buttons=True)

        self.project_title = ct.InputCtrl(self,
                                          label='Description',
                                          label_size=(150, -1),
                                          label_style='normal')

        self.splitter = wx.SplitterWindow(self,
                                          style=wx.SP_LIVE_UPDATE
                                          | wx.SP_3DSASH | wx.SP_NOBORDER)
        self.file_panel = wx.Panel(self.splitter, size=(-1, 200))
        self.file_sizer = wx.BoxSizer(wx.VERTICAL)
        self.file_panel.SetSizer(self.file_sizer)
        self.preview_panel = wx.Panel(self.splitter, size=(-1, 500))
        self.preview_sizer = wx.BoxSizer(wx.VERTICAL)
        self.preview_panel.SetSizer(self.preview_sizer)
        self.splitter.SplitHorizontally(self.file_panel, self.preview_panel,
                                        200)

        self.input = FileListCtrl(self.file_panel)
        self.file_sizer.Add(self.input, 1, flag=wx.ALL | wx.EXPAND, border=10)

        # Image preview box w/ options
        prev_box = wx.GridBagSizer(5, 15)

        # self.opt_knb_start = ct.KnobCtrl(self.preview_panel,
        #                                  label='start',
        #                                  label_size=(40, -1),
        #                                  spin_ctr_size=(50, -1),
        #                                  knob_size=(120, 120),
        #                                  values_start=0,
        #                                  values_end=360,
        #                                  values_step=1,
        #                                  value=0)
        #
        # self.opt_knb_end = ct.KnobCtrl(self.preview_panel,
        #                                label='end',
        #                                label_size=(40, -1),
        #                                spin_ctr_size=(50, -1),
        #                                knob_size=(120, 120),
        #                                values_start=0,
        #                                values_end=360,
        #                                values_step=1,
        #                                value=360)

        self.opt_spc_start = ct.SpinCtrl(self.preview_panel,
                                         label='start:',
                                         label_size=(50, -1),
                                         ctrl_size=(60, -1),
                                         ctrl_value='0',
                                         ctrl_max=360,
                                         ctrl_min=0,
                                         ctrl_step=0.1,
                                         ctrl_digits=1)

        self.opt_spc_end = ct.SpinCtrl(self.preview_panel,
                                       label='finish:',
                                       label_size=(50, -1),
                                       ctrl_size=(60, -1),
                                       ctrl_value='360',
                                       ctrl_max=360,
                                       ctrl_min=0,
                                       ctrl_step=0.1,
                                       ctrl_digits=1)

        self.opt_spc_osc = ct.SpinCtrl(self.preview_panel,
                                       label='step:',
                                       label_size=(50, -1),
                                       ctrl_size=(60, -1),
                                       ctrl_value='1.0',
                                       ctrl_max=360,
                                       ctrl_min=0,
                                       ctrl_step=0.1,
                                       ctrl_digits=2)

        self.opt_btn_prev = wx.Button(self.preview_panel,
                                      label='PREVIEW IMAGE')

        self.opt_chk_bkg = wx.CheckBox(self.preview_panel,
                                       label='Add Background')
        self.opt_chk_bkg.SetValue(True)
        self.opt_chk_noise = wx.CheckBox(self.preview_panel, label='Add Noise')
        self.opt_chk_noise.SetValue(True)
        self.opt_chk_rand = wx.CheckBox(self.preview_panel,
                                        label='Randomize Orientation')
        self.opt_chk_rand.SetValue(True)

        self.opt_spc_scale = ct.SpinCtrl(self.preview_panel,
                                         label='Crystal size (um): ',
                                         label_size=(120, -1),
                                         ctrl_size=(100, -1),
                                         ctrl_min=1,
                                         ctrl_max=1000,
                                         ctrl_step=1,
                                         ctrl_value=30)

        self.img_figure = Figure(figsize=(3, 3))
        self.img_axes = self.img_figure.add_subplot(111)

        self.img_axes.set_frame_on(False)
        self.img_axes.axis('off')
        self.img_axes.set_aspect('equal')

        self.img_figure.patch.set_visible(False)
        self.img_canvas = FigureCanvas(self.preview_panel, -1, self.img_figure)

        prev_box.Add(self.opt_spc_start, pos=(0, 0))
        prev_box.Add(self.opt_spc_end, pos=(0, 1))
        prev_box.Add(self.opt_spc_osc, pos=(1, 0))
        prev_box.Add(self.opt_chk_bkg, flag=wx.EXPAND, pos=(4, 0), span=(1, 2))
        prev_box.Add(self.opt_chk_noise,
                     flag=wx.EXPAND,
                     pos=(5, 0),
                     span=(1, 2))
        prev_box.Add(self.opt_chk_rand,
                     flag=wx.EXPAND,
                     pos=(6, 0),
                     span=(1, 2))
        prev_box.Add(self.opt_spc_scale,
                     flag=wx.EXPAND,
                     pos=(7, 0),
                     span=(1, 2))
        prev_box.Add(self.opt_btn_prev,
                     flag=wx.EXPAND,
                     pos=(8, 0),
                     span=(1, 2))
        prev_box.Add(self.img_canvas, pos=(0, 2), span=(9, 1), flag=wx.EXPAND)
        prev_box.AddGrowableCol(2)
        prev_box.AddGrowableRow(8)

        self.preview_sizer.Add(prev_box, 1, flag=wx.EXPAND | wx.ALL, border=10)

        self.main_sizer.Add(self.project_title,
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(self.project_folder,
                            flag=wx.EXPAND | wx.ALL,
                            border=10)
        self.main_sizer.Add(self.splitter, 1, flag=wx.EXPAND)

        # Button bindings
        self.Bind(wx.EVT_BUTTON, self.onRunPreview, self.opt_btn_prev)

        # Thread bindings
        self.Bind(thr.EVT_NBDONE, self.onFinishedSimThread)

        # Image bindings
        xid = self.img_canvas.mpl_connect('button_press_event',
                                          self.on_button_press)
        xid = self.img_canvas.mpl_connect('button_release_event',
                                          self.on_button_release)