Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def build_gui(self, container):
vbox = Widgets.VBox()
fr = Widgets.Frame("Remote Control")
captions = [
("Addr:", 'label', "Addr", 'llabel', 'Restart', 'button'),
("Set Addr:", 'label', "Set Addr", 'entry')]
w, b = Widgets.build_info(captions)
self.w.update(b)
addr = self.host + ':' + str(self.port)
b.addr.set_text(addr)
b.restart.set_tooltip("Restart the server")
b.restart.add_callback('activated', self.restart_cb)
b.set_addr.set_length(100)
b.set_addr.set_text(addr)
b.set_addr.set_tooltip("Set address to run remote control server")
b.set_addr.add_callback('activated', self.set_addr_cb)
fr.set_widget(w)
vbox.add_widget(fr, stretch=0)
# stretch
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
b.channel_name.set_tooltip('Channel for locating images to save')
b.channel_name.add_callback('activated', self.select_channel_cb)
mod_only = self.settings.get('modified_only', True)
b.modified_only.set_state(mod_only)
b.modified_only.add_callback('activated', lambda *args: self.redo())
b.modified_only.set_tooltip("Show only locally modified images")
container.add_widget(w, stretch=0)
captions = (('Path:', 'llabel', 'OutDir', 'entry', 'Browse', 'button'),
('Suffix:', 'llabel', 'Suffix', 'entry'))
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
b.outdir.set_text(self.outdir)
b.outdir.set_tooltip('Output directory')
b.outdir.add_callback('activated', lambda w: self.set_outdir())
b.browse.set_tooltip('Browse for output directory')
b.browse.add_callback('activated', lambda w: self.browse_outdir())
b.suffix.set_text(self.suffix)
b.suffix.set_tooltip('Suffix to append to filename')
b.suffix.add_callback('activated', lambda w: self.set_suffix())
container.add_widget(w, stretch=0)
self.treeview = Widgets.TreeView(auto_expand=True,
# for statistics line
self.w.stats1 = Widgets.Label('')
vbox.add_widget(self.w.stats1)
captions = (('Cut Low:', 'label', 'Cut Low', 'entry'),
('Cut High:', 'label', 'Cut High', 'entry',
'Cut Levels', 'button'),
('Auto Levels', 'button'),
('Log Histogram', 'checkbutton',
'Plot By Cuts', 'checkbutton'),
('NumBins:', 'label', 'NumBins', 'entry'),
('Full Image', 'button'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
b.cut_levels.set_tooltip("Set cut levels manually")
b.auto_levels.set_tooltip("Set cut levels by algorithm")
b.cut_low.set_tooltip("Set low cut level (press Enter)")
b.cut_high.set_tooltip("Set high cut level (press Enter)")
b.log_histogram.set_tooltip("Use the log of the pixel values for the "
"histogram (empty bins map to 10^-1)")
b.plot_by_cuts.set_tooltip("Only show the part of the histogram "
"between the cuts")
b.numbins.set_tooltip("Number of bins for the histogram")
b.full_image.set_tooltip("Use the full image for calculating the "
"histogram")
b.numbins.set_text(str(self.numbins))
b.cut_low.add_callback('activated', lambda w: self.cut_levels())
b.cut_high.add_callback('activated', lambda w: self.cut_levels())
b.cut_levels.add_callback('activated', lambda w: self.cut_levels())
def _setup_params(self, obj, container):
params = obj.getParams()
captions = []
paramList = sorted(params.values(), key=lambda b: b.order)
for bnch in paramList:
text = bnch.name
if 'label' in bnch:
text = bnch.label
#captions.append((text, 'entry'))
captions.append((text + ':', 'label', bnch.name, 'entry'))
# TODO: put RA/DEC first, and other stuff not in random orders
w, b = Widgets.build_info(captions)
# remove old widgets
container.remove_all()
# add new widgets
container.add_widget(w)
return b
def build_gui(self, container):
top = Widgets.VBox()
top.set_border_width(4)
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_border_width(4)
vbox.set_spacing(2)
fr = Widgets.Frame("Crosshair")
captions = (('Format:', 'label', 'Format', 'combobox'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w = b
combobox = b.format
for name in self.formats:
combobox.append_text(name)
index = self.formats.index(self.format)
combobox.set_index(index)
combobox.add_callback('activated', lambda w, idx: self.set_format())
fr.set_widget(w)
vbox.add_widget(fr, stretch=0)
spacer = Widgets.Label('')
vbox.add_widget(spacer, stretch=1)
top.add_widget(sw, stretch=1)
def gui_add_channel(self, chname=None):
chpfx = "Image"
ws = self.get_current_workspace()
if ws is not None:
chpfx = ws.extdata.get('chpfx', chpfx)
if not chname:
chname = self.make_channel_name(chpfx)
captions = (('New channel name:', 'label', 'channel_name', 'entry'),
('In workspace:', 'label', 'workspace', 'combobox'),
)
w, b = Widgets.build_info(captions, orientation='vertical')
# populate values
b.channel_name.set_text(chname)
names = self.ds.get_wsnames()
try:
idx = names.index(self._lastwsname)
except:
idx = 0
for name in names:
b.workspace.append_text(name)
b.workspace.set_index(idx)
# build dialog
dialog = Widgets.Dialog(title="Add Channel",
flags=0,
buttons=[['Cancel', 0], ['Ok', 1]],
# Add plot to its tab
vbox_plot = Widgets.VBox()
vbox_plot.add_widget(self.plot, stretch=1)
nb.add_widget(vbox_plot, title='Plot')
captions = (('X:', 'label', 'x_combo', 'combobox'),
('Y:', 'label', 'y_combo', 'combobox'),
('Log X', 'checkbutton', 'Log Y', 'checkbutton',
'Show Marker', 'checkbutton'),
('X Low:', 'label', 'x_lo', 'entry'),
('X High:', 'label', 'x_hi', 'entry'),
('Y Low:', 'label', 'y_lo', 'entry'),
('Y High:', 'label', 'y_hi', 'entry'),
('Save', 'button'))
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
# Controls for X-axis column listing
combobox = b.x_combo
combobox.add_callback('activated', self.x_select_cb)
self.w.xcombo = combobox
combobox.set_tooltip('Select a column to plot on X-axis')
# Controls for Y-axis column listing
combobox = b.y_combo
combobox.add_callback('activated', self.y_select_cb)
self.w.ycombo = combobox
combobox.set_tooltip('Select a column to plot on Y-axis')
b.log_x.set_state(self.tab_plot.logx)
b.log_x.add_callback('activated', self.log_x_cb)
self.slit_plot = plots.Plot(logger=self.logger,
width=400, height=400)
if plots.MPL_GE_2_0:
kwargs = {'facecolor': 'black'}
else:
kwargs = {'axisbg': 'black'}
self.slit_plot.add_axis(**kwargs)
self.plot2 = Plot.PlotWidget(self.slit_plot)
self.plot2.resize(400, 400)
captions = (('Cut:', 'label', 'Cut', 'combobox',
'New Cut Type:', 'label', 'Cut Type', 'combobox'),
('Delete Cut', 'button', 'Delete All', 'button'),
('Save', 'button'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
# control for selecting a cut
combobox = b.cut
for tag in self.tags:
combobox.append_text(tag)
combobox.show_text(self.cutstag)
combobox.add_callback('activated', self.cut_select_cb)
self.w.cuts = combobox
combobox.set_tooltip("Select a cut to redraw or delete")
# control for selecting cut type
combobox = b.cut_type
for cuttype in self.cuttypes:
combobox.append_text(cuttype)
self.w.cuts_type = combobox
top.set_border_width(4)
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_border_width(4)
vbox.set_spacing(2)
fr = Widgets.Frame("WCS Match")
captions = (('Reference Channel:', 'label',
'ref channel', 'combobox'),
('Match Pan', 'checkbutton',
'Match Scale', 'checkbutton'),
('Match Transforms', 'checkbutton',
'Match Rotation', 'checkbutton'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w = b
b.ref_channel.add_callback('activated', self.set_reference_channel_cb)
self.w.match_pan.set_state(self._match['pan'])
self.w.match_pan.set_tooltip("Match pan position of reference image")
self.w.match_pan.add_callback('activated',
self.set_match_cb, 'pan')
self.w.match_scale.set_state(self._match['scale'])
self.w.match_scale.add_callback('activated',
self.set_match_cb, 'scale')
self.w.match_scale.set_tooltip("Match scale of reference image")
self.w.match_transforms.set_state(self._match['transforms'])
self.w.match_transforms.add_callback('activated',
self.set_match_cb, 'transforms')
self.w.match_transforms.set_tooltip("Match transforms of reference image")
self.w.match_rotation.set_state(self._match['rotation'])
b.suffix.set_text(self.suffix)
b.suffix.set_tooltip('Suffix to append to filename')
b.suffix.add_callback('activated', lambda w: self.set_suffix())
container.add_widget(w, stretch=0)
self.treeview = Widgets.TreeView(auto_expand=True,
sortable=True,
selection='multiple',
use_alt_row_color=True)
self.treeview.setup_table(self.columns, 1, 'IMAGE')
self.treeview.add_callback('selected', self.toggle_save_cb)
container.add_widget(self.treeview, stretch=1)
captions = (('Status', 'llabel'), )
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
b.status.set_text('')
b.status.set_tooltip('Status message')
container.add_widget(w, stretch=0)
btns = Widgets.HBox()
btns.set_border_width(4)
btns.set_spacing(3)
btn = Widgets.Button('Save')
btn.set_tooltip('Save selected image(s)')
btn.add_callback('activated', lambda w: self.save_images())
btn.set_enabled(False)
btns.add_widget(btn, stretch=0)
self.w.save = btn