本文整理汇总了Python中ginga.misc.Widgets.wrap方法的典型用法代码示例。如果您正苦于以下问题:Python Widgets.wrap方法的具体用法?Python Widgets.wrap怎么用?Python Widgets.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ginga.misc.Widgets
的用法示例。
在下文中一共展示了Widgets.wrap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_channel
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def add_channel(self, viewer, chinfo):
panimage = self._create_pan_image()
chname = chinfo.name
iw = panimage.get_widget()
# wrap widget
iw = Widgets.wrap(iw)
self.nb.add_widget(iw)
index = self.nb.index_of(iw)
paninfo = Bunch.Bunch(panimage=panimage, widget=iw,
pancompass=None, panrect=None,
nbindex=index)
self.channel[chname] = paninfo
# Extract RGBMap object from main image and attach it to this
# pan image
fitsimage = chinfo.fitsimage
rgbmap = fitsimage.get_rgbmap()
panimage.set_rgbmap(rgbmap, redraw=False)
rgbmap.add_callback('changed', self.rgbmap_cb, panimage)
fitsimage.copy_attributes(panimage, ['cutlevels'])
fitsimage.add_callback('image-set', self.new_image_cb, chinfo, paninfo)
fitsimage.add_callback('redraw', self.panset, chinfo, paninfo)
fitssettings = fitsimage.get_settings()
pansettings = panimage.get_settings()
zoomsettings = ['zoom_algorithm', 'zoom_rate',
'scale_x_base', 'scale_y_base']
fitssettings.shareSettings(pansettings, zoomsettings)
for key in zoomsettings:
pansettings.getSetting(key).add_callback('set', self.zoom_cb,
fitsimage, chinfo, paninfo)
xfrmsettings = ['flip_x', 'flip_y', 'swap_xy', 'rot_deg']
fitssettings.shareSettings(pansettings, xfrmsettings)
for key in xfrmsettings:
pansettings.getSetting(key).add_callback('set', self.redraw_cb,
fitsimage, chinfo, paninfo, 0)
fitssettings.shareSettings(pansettings, ['cuts'])
pansettings.getSetting('cuts').add_callback('set', self.redraw_cb,
fitsimage, chinfo, paninfo, 1)
self.logger.debug("channel %s added." % (chinfo.name))
示例2: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
vbox, sw, orientation = Widgets.get_oriented_box(container,
scrolled=False)
vbox.set_border_width(4)
vbox.set_spacing(2)
width, height = 300, 300
# Uncomment to debug; passing parent logger generates too
# much noise in the main logger
#zi = CanvasTypes.ImageViewCanvas(logger=self.logger)
zi = CanvasTypes.ImageViewCanvas(logger=None)
zi.set_desired_size(width, height)
zi.enable_autozoom('off')
zi.enable_autocuts('off')
#zi.set_scale_limits(0.001, 1000.0)
zi.zoom_to(self.default_zoom, redraw=False)
settings = zi.get_settings()
settings.getSetting('zoomlevel').add_callback('set',
self.zoomset, zi)
zi.set_bg(0.4, 0.4, 0.4)
zi.show_pan_mark(True, redraw=False)
# for debugging
zi.set_name('zoomimage')
self.zoomimage = zi
bd = zi.get_bindings()
bd.enable_zoom(False)
bd.enable_pan(False)
bd.enable_cmap(False)
iw = Widgets.wrap(zi.get_widget())
vpaned = Widgets.Splitter(orientation=orientation)
vpaned.add_widget(iw)
vpaned.add_widget(Widgets.Label(''))
vbox.add_widget(vpaned, stretch=1)
vbox2 = Widgets.VBox()
captions = (("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'),
("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
vbox2.add_widget(w, stretch=0)
self.w.zoom_radius.set_limits(1, 300, incr_value=1)
self.w.zoom_radius.set_value(self.zoom_radius)
self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb)
self.w.zoom_radius.set_tracking(True)
self.w.zoom_amount.set_limits(-20, 30, incr_value=1)
self.w.zoom_amount.set_value(self.zoom_amount)
self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb)
self.w.zoom_amount.set_tracking(True)
captions = (("Zoom:", 'label', 'Zoom', 'label'),
("Relative Zoom", 'checkbutton'),
("Refresh Interval", 'label',
'Refresh Interval', 'spinbutton'),
("Defaults", 'button'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w.update(b)
b.zoom.set_text(self.fv.scale2text(zi.get_scale()))
b.relative_zoom.set_state(not self.t_abszoom)
b.relative_zoom.add_callback("activated", self.set_absrel_cb)
b.defaults.add_callback("activated", lambda w: self.set_defaults())
b.refresh_interval.set_limits(0, 200, incr_value=1)
b.refresh_interval.set_value(int(self.refresh_interval * 1000))
b.refresh_interval.add_callback('value-changed', self.set_refresh_cb)
row = Widgets.HBox()
row.add_widget(w, stretch=0)
row.add_widget(Widgets.Label(''), stretch=1)
vbox2.add_widget(row, stretch=0)
# stretch
spacer = Widgets.Label('')
vbox2.add_widget(spacer, stretch=1)
vbox.add_widget(vbox2, stretch=0)
vbox.add_widget(Widgets.Label(''), stretch=1)
container.add_widget(sw, stretch=1)
示例3: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
assert iqcalc.have_scipy == True, \
Exception("Please install python-scipy to use this plugin")
self.pickcenter = None
vtop = Widgets.VBox()
vpaned = Widgets.Splitter(orientation='vertical')
nb = Widgets.TabWidget(tabpos='bottom')
#nb.set_scrollable(True)
self.w.nb1 = nb
vpaned.add_widget(nb)
cm, im = self.fv.cm, self.fv.im
di = CanvasTypes.ImageViewCanvas(logger=self.logger)
width, height = 200, 200
di.set_desired_size(width, height)
di.enable_autozoom('off')
di.enable_autocuts('off')
di.zoom_to(3, redraw=False)
settings = di.get_settings()
settings.getSetting('zoomlevel').add_callback('set',
self.zoomset, di)
di.set_cmap(cm, redraw=False)
di.set_imap(im, redraw=False)
di.set_callback('none-move', self.detailxy)
di.set_bg(0.4, 0.4, 0.4)
# for debugging
di.set_name('pickimage')
self.pickimage = di
bd = di.get_bindings()
bd.enable_pan(True)
bd.enable_zoom(True)
bd.enable_cuts(True)
iw = Widgets.wrap(di.get_widget())
nb.add_widget(iw, title="Image")
if have_mpl:
self.plot1 = Plot.Plot(logger=self.logger,
width=2, height=3, dpi=72)
self.w.canvas = self.plot1.canvas
self.w.fig = self.plot1.fig
self.w.ax = self.w.fig.add_subplot(111, axisbg='black')
self.w.ax.set_aspect('equal', adjustable='box')
self.w.ax.set_title('Contours')
#self.w.ax.grid(True)
canvas = self.w.canvas
connect = canvas.mpl_connect
# These are not ready for prime time...
# connect("motion_notify_event", self.plot_motion_notify)
# connect("button_press_event", self.plot_button_press)
connect("scroll_event", self.plot_scroll)
nb.add_widget(Widgets.wrap(canvas), title="Contour")
self.plot2 = Plot.Plot(logger=self.logger,
width=2, height=3, dpi=72)
self.w.canvas2 = self.plot2.canvas
self.w.fig2 = self.plot2.fig
self.w.ax2 = self.w.fig2.add_subplot(111, axisbg='white')
#self.w.ax2.set_aspect('equal', adjustable='box')
self.w.ax2.set_ylabel('brightness')
self.w.ax2.set_xlabel('pixels')
self.w.ax2.set_title('FWHM')
self.w.ax.grid(True)
canvas = self.w.canvas2
nb.add_widget(Widgets.wrap(canvas), title="FWHM")
sw = Widgets.ScrollArea()
vbox = Widgets.VBox()
sw.set_widget(vbox)
self.msgFont = self.fv.getFont("sansFont", 12)
tw = Widgets.TextArea(wrap=True, editable=False)
tw.set_font(self.msgFont)
self.tw = tw
fr = Widgets.Frame("Instructions")
fr.set_widget(tw)
vbox.add_widget(fr, stretch=0)
fr = Widgets.Frame("Pick")
nb = Widgets.TabWidget(tabpos='bottom')
self.w.nb2 = nb
fr.set_widget(nb)
vbox.add_widget(fr, stretch=0)
# Build report panel
captions = (('Zoom:', 'label', 'Zoom', 'llabel',
'Contour Zoom:', 'label', 'Contour Zoom', 'llabel'),
('Object_X', 'label', 'Object_X', 'llabel',
'Object_Y', 'label', 'Object_Y', 'llabel'),
('RA:', 'label', 'RA', 'llabel',
'DEC:', 'label', 'DEC', 'llabel'),
('Equinox:', 'label', 'Equinox', 'llabel',
#.........这里部分代码省略.........
示例4: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
top = Widgets.VBox()
top.set_border_width(4)
# Make the cuts plot
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_margins(4, 4, 4, 4)
vbox.set_spacing(2)
msgFont = self.fv.getFont("sansFont", 12)
tw = Widgets.TextArea(wrap=True, editable=False)
tw.set_font(msgFont)
self.tw = tw
fr = Widgets.Frame("Instructions")
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
vbox.add_widget(fr, stretch=0)
self.plot = Plot.Cuts(self.logger, width=2, height=3, dpi=100)
ax = self.plot.add_axis()
ax.grid(True)
# for now we need to wrap this native widget
w = Widgets.wrap(self.plot.get_widget())
vbox.add_widget(w, stretch=1)
hbox = Widgets.HBox()
hbox.set_spacing(4)
hbox.set_border_width(4)
# control for selecting a cut
combobox = Widgets.ComboBox()
for tag in self.tags:
combobox.append_text(tag)
if self.cutstag == None:
combobox.set_index(0)
else:
combobox.show_text(self.cutstag)
combobox.add_callback('activated', self.cut_select_cb)
self.w.cuts = combobox
combobox.set_tooltip("Select a cut")
hbox.add_widget(combobox)
btn = Widgets.Button("Delete")
btn.add_callback('activated', self.delete_cut_cb)
btn.set_tooltip("Delete selected cut")
hbox.add_widget(btn)
btn = Widgets.Button("Delete All")
btn.add_callback('activated', self.delete_all_cb)
btn.set_tooltip("Clear all cuts")
hbox.add_widget(btn)
combobox = Widgets.ComboBox()
for cuttype in self.cuttypes:
combobox.append_text(cuttype)
self.w.cuts_type = combobox
index = self.cuttypes.index(self.cuttype)
combobox.set_index(index)
combobox.add_callback('activated', self.set_cutsdrawtype_cb)
combobox.set_tooltip("Choose the cut type")
hbox.add_widget(combobox)
vbox2 = Widgets.VBox()
vbox2.add_widget(hbox, stretch=0)
vbox2.add_widget(Widgets.Label(''), stretch=1)
vbox.add_widget(vbox2, stretch=0)
top.add_widget(sw, stretch=1)
btns = Widgets.HBox()
btns.set_border_width(4)
btns.set_spacing(3)
btn = Widgets.Button("Close")
btn.add_callback('activated', lambda w: self.close())
btns.add_widget(btn, stretch=0)
btns.add_widget(Widgets.Label(''), stretch=1)
top.add_widget(btns, stretch=0)
container.add_widget(top, stretch=1)
self.gui_up = True
示例5: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
top = Widgets.VBox()
top.set_border_width(4)
# Make the cuts plot
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_border_width(4)
vbox.set_spacing(2)
msgFont = self.fv.getFont("sansFont", 12)
tw = Widgets.TextArea(wrap=True, editable=False)
tw.set_font(msgFont)
self.tw = tw
fr = Widgets.Frame("Instructions")
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
vbox.add_widget(fr, stretch=0)
self.plot = Plot.Plot(self.logger, width=2, height=3, dpi=100)
ax = self.plot.add_axis()
ax.grid(True)
# for now we need to wrap this native widget
w = Widgets.wrap(self.plot.get_widget())
vbox.add_widget(w, stretch=1)
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())
b.auto_levels.add_callback('activated', lambda w: self.auto_levels())
b.log_histogram.set_state(self.plot.logy)
b.log_histogram.add_callback('activated', self.log_histogram_cb)
b.plot_by_cuts.set_state(self.xlimbycuts)
b.plot_by_cuts.add_callback('activated', self.plot_by_cuts_cb)
b.numbins.add_callback('activated', lambda w: self.set_numbins_cb())
b.full_image.add_callback('activated', lambda w: self.full_image_cb())
vbox.add_widget(w, stretch=0)
## spacer = Widgets.Label('')
## vbox.add_widget(spacer, stretch=1)
top.add_widget(sw, stretch=1)
btns = Widgets.HBox()
btns.set_border_width(4)
btns.set_spacing(3)
btn = Widgets.Button("Close")
btn.add_callback('activated', lambda w: self.close())
btns.add_widget(btn, stretch=0)
btns.add_widget(Widgets.Label(''), stretch=1)
top.add_widget(btns, stretch=0)
container.add_widget(top, stretch=1)
self.gui_up = True
示例6: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
top = Widgets.VBox()
top.set_border_width(4)
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_margins(4, 4, 4, 4)
vbox.set_spacing(2)
self.msgFont = self.fv.getFont("sansFont", 12)
tw = Widgets.TextArea(wrap=True, editable=False)
tw.set_font(self.msgFont)
self.tw = tw
fr = Widgets.Expander("Instructions")
vbox2 = Widgets.VBox()
vbox2.add_widget(tw)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr.set_widget(vbox2)
vbox.add_widget(fr, stretch=0)
self.plot = Plot.Plot(self.logger, width=2, height=4, dpi=100)
ax = self.plot.add_axis()
ax.grid(False)
w = Widgets.wrap(self.plot.get_widget())
vbox.add_widget(w, stretch=0)
fr = Widgets.Frame("Axes controls")
self.hbox_axes = Widgets.HBox()
self.hbox_axes.set_border_width(4)
self.hbox_axes.set_spacing(1)
fr.set_widget(self.hbox_axes)
vbox.add_widget(fr, stretch=0)
btns = Widgets.HBox()
btns.set_border_width(4)
btns.set_spacing(4)
# control for selecting a mark
cbox2 = Widgets.ComboBox()
for tag in self.marks:
cbox2.append_text(tag)
if self.mark_selected is None:
cbox2.set_index(0)
else:
cbox2.show_text(self.mark_selected)
cbox2.add_callback('activated', self.mark_select_cb)
self.w.marks = cbox2
cbox2.set_tooltip("Select a mark")
btns.add_widget(cbox2, stretch=0)
btn1 = Widgets.CheckBox("Pan to mark")
btn1.set_state(self.pan2mark)
btn1.add_callback('activated', self.pan2mark_cb)
btn1.set_tooltip("Pan follows selected mark")
btns.add_widget(btn1)
btns.add_widget(Widgets.Label(''), stretch=1)
btn2 = Widgets.Button("Delete")
self.del_btn = btn2
btn2.add_callback('activated', lambda w: self.clear_mark_cb())
btn2.set_tooltip("Delete selected mark")
btn2.set_enabled(False)
btns.add_widget(btn2, stretch=0)
btn3 = Widgets.Button("Delete All")
self.del_all_btn = btn3
btn3.add_callback('activated', lambda w: self.clear_all())
btn3.set_tooltip("Clear all marks")
btn3.set_enabled(False)
btns.add_widget(btn3, stretch=0)
vbox2 = Widgets.VBox()
vbox2.add_widget(btns, stretch=0)
vbox2.add_widget(Widgets.Label(''), stretch=1)
fr = Widgets.Frame("Mark controls")
fr.set_widget(vbox2)
vbox.add_widget(fr, stretch=1)
# scroll bars will allow lots of content to be accessed
top.add_widget(sw, stretch=1)
# A button box that is always visible at the bottom
btns = Widgets.HBox()
btns.set_spacing(3)
# Add a close button for the convenience of the user
btn = Widgets.Button("Close")
btn.add_callback('activated', lambda w: self.close())
btns.add_widget(btn, stretch=0)
btns.add_widget(Widgets.Label(''), stretch=1)
top.add_widget(btns, stretch=0)
# Add our GUI to the container
container.add_widget(top, stretch=1)
self.gui_up = True
self.build_axes()
示例7: build_gui
# 需要导入模块: from ginga.misc import Widgets [as 别名]
# 或者: from ginga.misc.Widgets import wrap [as 别名]
def build_gui(self, container):
vpaned = Widgets.Splitter(orientation="vertical")
width, height = 300, 300
# Uncomment to debug; passing parent logger generates too
# much noise in the main logger
# zi = CanvasTypes.ImageViewCanvas(logger=self.logger)
zi = CanvasTypes.ImageViewCanvas(logger=None)
zi.set_desired_size(width, height)
zi.enable_autozoom("off")
zi.enable_autocuts("off")
# zi.set_scale_limits(0.001, 1000.0)
zi.zoom_to(self.default_zoom, redraw=False)
settings = zi.get_settings()
settings.getSetting("zoomlevel").add_callback("set", self.zoomset, zi)
zi.set_bg(0.4, 0.4, 0.4)
zi.show_pan_mark(True, redraw=False)
# for debugging
zi.set_name("zoomimage")
self.zoomimage = zi
bd = zi.get_bindings()
bd.enable_zoom(False)
bd.enable_pan(False)
bd.enable_cmap(False)
iw = Widgets.wrap(zi.get_widget())
vpaned.add_widget(iw)
vbox = Widgets.VBox()
captions = (
("Zoom Radius:", "label", "Zoom Radius", "hscale"),
("Zoom Amount:", "label", "Zoom Amount", "hscale"),
)
w, b = Widgets.build_info(captions)
self.w.update(b)
vbox.add_widget(w, stretch=0)
self.w.zoom_radius.set_limits(1, 300, incr_value=1)
self.w.zoom_radius.set_value(self.zoom_radius)
self.w.zoom_radius.add_callback("value-changed", self.set_radius_cb)
self.w.zoom_radius.set_tracking(True)
self.w.zoom_amount.set_limits(-20, 30, incr_value=1)
self.w.zoom_amount.set_value(self.zoom_amount)
self.w.zoom_amount.add_callback("value-changed", self.set_amount_cb)
self.w.zoom_amount.set_tracking(True)
captions = (
("Zoom:", "label", "Zoom", "label"),
("Relative Zoom", "checkbutton"),
("Refresh Interval", "label", "Refresh Interval", "spinbutton"),
("Defaults", "button"),
)
w, b = Widgets.build_info(captions)
self.w.update(b)
b.zoom.set_text(self.fv.scale2text(zi.get_scale()))
b.relative_zoom.set_state(not self.t_abszoom)
b.relative_zoom.add_callback("activated", self.set_absrel_cb)
b.defaults.add_callback("activated", lambda w: self.set_defaults())
b.refresh_interval.set_limits(0, 200, incr_value=1)
b.refresh_interval.set_value(int(self.refresh_interval * 1000))
b.refresh_interval.add_callback("value-changed", self.set_refresh_cb)
row = Widgets.HBox()
row.add_widget(w, stretch=0)
row.add_widget(Widgets.Label(""), stretch=1)
vbox.add_widget(row, stretch=0)
# vertical stretch
vbox.add_widget(Widgets.Label(""), stretch=1)
sw = Widgets.ScrollArea()
sw.set_widget(vbox)
vpaned.add_widget(sw)
container.add_widget(vpaned, stretch=1)