__init__.py 1.96 KB
Newer Older
marc's avatar
marc committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget, QApplication
from ui_createpointings import Ui_FormCreatePoinings
from astropy import units as u
from astropy.coordinates import SkyCoord
import sys
import logging

'''
Setup logging
'''
logger = logging.getLogger('root')
FORMAT = "[%(asctime)s%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s,filename='dtobsgui.log',filemode='w'"
logging.basicConfig(format=FORMAT)
logger.setLevel(logging.DEBUG)

class CreatePointings(Ui_FormCreatePoinings):
    def __init__(self, formCreatePointings):
        logging.info('CreatePointings Intialized')
        Ui_FormCreatePoinings.__init__(self)
        self.setupUi(formCreatePointings)
marc's avatar
marc committed
22
23
24
25
26
27
28
29
30
31
32
        self.target = SkyCoord(0 * u.radian,0 * u.radian)
        try:
            #self.target = SkyCoord.from_name(self.comboBox.currentText())
            (self.raStr, self.decStr)  = self.target.to_string('hmsdms').split()
            self.lineEditRA.setText(self.raStr)
            self.lineEditDec.setText(self.decStr)
        except socket.gaierror as e:
            raise URLError("Could not connect to Internet" + str(e))
            raise NameError("Could not connect to Internet" + str(e))
            self.target = Null
                    
marc's avatar
marc committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
        '''
        Define slot and connections for GUI
        '''
        self.comboBox.currentIndexChanged.connect(self.updateRADEC)
        logging.debug('Target changed')
    
    def updateRADEC(self):
        logging.debug('Target changed')
        self.target = SkyCoord.from_name(self.comboBox.currentText())
        (self.raStr, self.decStr)  = self.target.to_string('hmsdms').split()
        self.lineEditRA.setText(self.raStr)
        self.lineEditDec.setText(self.decStr)
        logging.info('New target is: {}'.format(self.target))
    
if __name__ == '__main__':
    app = QApplication(sys.argv)
    formCreatePointings = QWidget()
    myForm = CreatePointings(formCreatePointings)
    formCreatePointings.show()
    sys.exit(app.exec_())