Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.logger = logger
if settings is None:
settings = Settings.SettingGroup(logger=self.logger)
self.settings = settings
self.settings.add_defaults(use_opengl=False)
self.window_list = []
self.window_dict = {}
self.wincnt = 0
if self.settings.get('use_opengl', False):
# ensure we are using correct version of opengl
# NOTE: On MacOSX w/Qt it is necessary to set the default OpenGL
# profile BEFORE creating the QApplication object, because it
# shares the OpenGL context
QtHelp.set_default_opengl_context()
if have_pyqt4:
QtGui.QApplication.setGraphicsSystem('raster')
app = QtGui.QApplication([])
# app.lastWindowClosed.connect(lambda *args: self._quit())
self._qtapp = app
_app = self
# Get screen size
desktop = self._qtapp.desktop()
rect = desktop.availableGeometry()
size = rect.size()
self.screen_wd = size.width()
self.screen_ht = size.height()
# Get screen resolution
fr.layout().addWidget(nb, stretch=1, alignment=QtCore.Qt.AlignLeft)
vbox.addWidget(fr, stretch=0, alignment=QtCore.Qt.AlignTop)
vbox2 = QtHelp.VBox()
captions = (('Zoom', 'label', 'Contour Zoom', 'label'),
('Object_X', 'label', 'Object_Y', 'label'),
('RA', 'label', 'DEC', 'label'),
('Equinox', 'label', 'Background', 'label'),
('Sky Level', 'label', 'Brightness', 'label'),
('FWHM X', 'label', 'FWHM Y', 'label'),
('FWHM', 'label', 'Star Size', 'label'),
('Sample Area', 'label', 'Default Region', 'button'),
)
w, b = QtHelp.build_info(captions)
self.w.update(b)
b.zoom.setText(self.fv.scale2text(di.get_scale()))
self.wdetail = b
b.default_region.clicked.connect(self.reset_region)
b.default_region.setToolTip("Reset region size to default")
vbox2.addWidget(w, stretch=1)
# Pick field evaluation status
label = QtGui.QLabel()
self.w.eval_status = label
## w.layout().addWidget(label, stretch=0, alignment=QtCore.Qt.AlignLeft)
vbox2.addWidget(label, stretch=0)
# Pick field evaluation progress bar and stop button
hbox = QtHelp.HBox()
def start_drag(self):
if QtHelp.have_pyqt5:
self._drag.exec_(QtCore.Qt.MoveAction)
else:
self._drag.start(QtCore.Qt.MoveAction)
#("Load", 'button', 'fits_open_48', "Open an image file"),
("Prev", 'button', 'prev_48', "Go to previous image"),
("Next", 'button', 'next_48', "Go to next image"),
("Zoom In", 'button', 'zoom_in_48', "Zoom in"),
("Zoom Out", 'button', 'zoom_out_48', "Zoom out"),
("Zoom Fit", 'button', 'zoom_fit_48', "Zoom to fit window size"),
("Zoom 1:1", 'button', 'zoom_100_48', "Zoom to 100% (1:1)"),
#("Quit", 'button', 'exit', "Quit the program"),
):
btn = self.fv.make_button(*tup)
name = tup[0]
if tup[3]:
btn.setToolTip(tup[3])
bw[QtHelp._name_mangle(name, pfx='btn_')] = btn
layout.addWidget(btn, stretch=0)
#self.w.btn_load.connect("clicked", lambda w: self.gui_load_file())
bw.btn_prev.clicked.connect(self.fv.prev_img)
bw.btn_next.clicked.connect(self.fv.next_img)
bw.btn_zoom_in.clicked.connect(self.fv.zoom_in)
bw.btn_zoom_out.clicked.connect(self.fv.zoom_out)
bw.btn_zoom_fit.clicked.connect(self.fv.zoom_fit)
bw.btn_zoom_1_1.clicked.connect(self.fv.zoom_1_to_1)
vbox.addWidget(btns, stretch=0)
#widget.show()
sw.setWidget(widget)
return sw, b
index = 0
for name in self.imap_names:
options.append(name)
combobox.addItem(name)
index += 1
imap_name = self.magimap
try:
index = self.imap_names.index(imap_name)
except Exception:
index = self.imap_names.index('ramp')
combobox.setCurrentIndex(index)
combobox.activated.connect(self.set_imap_cb)
self.btn['imap'] = combobox
btns.addWidget(combobox, stretch=0, alignment=QtCore.Qt.AlignRight)
combobox = QtHelp.ComboBox()
options = []
index = 0
for name, fn in self.operation_table:
options.append(name)
combobox.addItem(name)
index += 1
combobox.setCurrentIndex(0)
combobox.activated.connect(self.do_operation_cb)
self.btn['oprn'] = combobox
btns.addWidget(combobox, stretch=0, alignment=QtCore.Qt.AlignRight)
btn = QtGui.QPushButton("Do it")
btns.addWidget(btn, stretch=0, alignment=QtCore.Qt.AlignRight)
vbox.addWidget(btns, stretch=0, alignment=QtCore.Qt.AlignTop)
def build_gui(self, container):
nb = QtHelp.StackedWidget()
self.nb = nb
cw = container.get_widget()
cw.layout().addWidget(nb, stretch=0)
vbox.setSpacing(14)
widget.setLayout(vbox)
self.w.thumbs = vbox
self.w.thumbs_w = widget
#widget.show()
sw.setWidget(widget)
self.w.thumbs_scroll = sw
#self.w.thumbs_scroll.connect("size_allocate", self.thumbpane_resized_cb)
# TODO: should this even have it's own scrolled window?
cw = container.get_widget()
cw.addWidget(sw, stretch=1)
sw.show()
captions = (('Auto scroll', 'checkbutton', 'Clear', 'button'),)
w, b = QtHelp.build_info(captions)
self.w.update(b)
b.auto_scroll.setToolTip("Scroll the thumbs window when new images arrive")
b.clear.setToolTip("Remove all current thumbnails")
b.clear.clicked.connect(self.clear)
auto_scroll = self.settings.get('auto_scroll', True)
b.auto_scroll.setChecked(auto_scroll)
cw.addWidget(w, stretch=0)
self.gui_up = True
def __init__(self, title=''):
super(Expander, self).__init__()
# Qt doesn't seem to like it (segfault) if we actually construct
# these icons in the class variable declarations
if Expander.r_arrow is None:
Expander.r_arrow = QtHelp.get_icon(
os.path.join(icondir, 'triangle-right-48.png'), size=(12, 12))
if Expander.d_arrow is None:
Expander.d_arrow = QtHelp.get_icon(
os.path.join(icondir, 'triangle-down-48.png'), size=(12, 12))
self.widget = QtGui.QWidget()
vbox = QtGui.QVBoxLayout()
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
self.layout = vbox
self.toggle = QtGui.QPushButton(Expander.r_arrow, title)
self.toggle.setStyleSheet(Expander.widget_style)
# self.toggle.setCheckable(True)
self.toggle.clicked.connect(self._toggle_widget)
def build_gui(self, container):
sw = QtGui.QScrollArea()
twidget = QtHelp.VBox()
sp = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
QtGui.QSizePolicy.Fixed)
twidget.setSizePolicy(sp)
vbox1 = twidget.layout()
vbox1.setContentsMargins(4, 4, 4, 4)
vbox1.setSpacing(2)
sw.setWidgetResizable(True)
sw.setWidget(twidget)
msgFont = self.fv.getFont("sansFont", 14)
tw = QtGui.QLabel()
tw.setFont(msgFont)
tw.setWordWrap(True)
self.tw = tw
fr = QtHelp.Frame("Instructions")
def _build_gui(self, container):
self.mframe = container
vbox = QtHelp.VBox()
# create the table
table = QtGui.QTableView()
self.table = table
table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
table.setShowGrid(False)
vh = table.verticalHeader()
# Hack to make the rows in a TableView all have a
# reasonable height for the data
if QtHelp.have_pyqt5:
# NOTE: this makes a terrible hit on performance--DO NOT USE!
#vh.setSectionResizeMode(QtGui.QHeaderView.ResizeToContents)
vh.setSectionResizeMode(QtGui.QHeaderView.Fixed)
else:
# NOTE: this makes a terrible hit on performance--DO NOT USE!
#vh.setResizeMode(QtGui.QHeaderView.ResizeToContents)
vh.setResizeMode(QtGui.QHeaderView.Fixed)
vh.setDefaultSectionSize(18)
# Hide vertical header
vh.setVisible(False)
vbox.addWidget(table, stretch=1)
self.cbar = ColorBar.ColorBar(self.logger)
self.cbar.set_cmap(self.cmap)
self.cbar.set_imap(self.imap)