예제 #1
0
 def openMultiChartEvent(self):
     """Open oroboros chart file."""
     tr = self.tr
     path = unicode(
         QFileDialog.getOpenFileName(self, tr('Open chart'),
                                     os.path.expanduser(cfg.charts_dir),
                                     tr('Oroboros (*.xml)')))
     if path != '':
         cht = Chart(path)
         app.appendMultiChart(cht)
예제 #2
0
 def openMultiChartSkifEvent(self):
     """Open skylendar chart file."""
     tr = self.tr
     path = unicode(
         QFileDialog.getOpenFileName(self, tr('Import Skylendar chart'),
                                     os.path.expanduser(cfg.charts_dir),
                                     tr('Skylendar (*.skif)')))
     if path != '':
         cht = skylendar.load(path)
         cht.calc()
         app.appendMultiChart(cht)
예제 #3
0
 def openMultiChartA32Event(self):
     """Open astrolog32 chart file."""
     tr = self.tr
     path = unicode(
         QFileDialog.getOpenFileName(self, tr('Import Astrolog32 chart'),
                                     os.path.expanduser(cfg.charts_dir),
                                     tr('Astrolog32 (*.dat)')))
     if path != '':
         cht = astrolog32.load(path)
         cht.calc()
         app.appendMultiChart(cht)
예제 #4
0
 def hereNowMultiChartEvent(self):
     """Create a default here-now chart."""
     app.appendMultiChart(Chart())
예제 #5
0
	def accept(self):
		tr = self.tr
		# name
		name = unicode(self.nameEdit.text())
		if name == '':
			QMessageBox.critical(self, tr('Missing Name'),
				tr('Please set chart name.'))
			self.nameEdit.setFocus()
			return
		# datetime
		dt = self.datetimeEdit.dateTime().toPyDateTime()
		# calendar
		if self.calendarEdit.currentIndex() == 0:
			cal = 'gregorian'
		else:
			cal = 'julian'
		# location
		loc = unicode(self.locationEdit.text())
		# country
		cty = unicode(self.countryEdit.text())
		# latitude
		lat = self.latitudeEdit.latitude()
		# longitude
		lon = self.longitudeEdit.longitude()
		# altitude
		alt = self.altitudeEdit.altitude()
		# zoneinfo
		tz = self.zoneinfoEdit.currentIndex()
		if tz == 0:
			tz = ''
		else:
			tz = pytz.all_timezones[tz - 1]
		# dst
		dst = self.dstEdit.currentIndex()
		if dst == 0: ## not needed
			dst = ''
		elif dst == 1:
			dst = True
		else:
			dst = False
		# timezone
		tzone = self.timezoneEdit.currentIndex()
		if tzone == 0:
			tzone = ''
		else:
			tzone = timezone.all_timezones[tzone - 1]
		# utcoffset
		utcof = self.utcoffsetEdit.value()
		if utcof == -25: ## not needed
			utcof = ''
		# comment
		cmt = unicode(self.commentEdit.toPlainText())
		# keywords
		kw = unicode(self.keywordsEdit.toPlainText()).replace('\n', ';')
		# set chart
		self._chart.set(name=name, datetime=dt, calendar=cal, location=loc,
			country=cty, latitude=lat, longitude=lon, altitude=alt, zoneinfo=tz,
			dst=dst, utcoffset=utcof, timezone=tzone, comment=cmt, keywords=kw)
		# check ambiguous datetime
		try:
			self._chart.local_datetime
		except TypeError: ## unable to get local time
			QMessageBox.critical(self, tr('Ambiguous datetime!'),
				tr('Please set DST.'))
			self.dstEdit.setFocus()
			return
		# recalc and close
		self._chart.calc()
		if __name__ != '__main__': ## update app
			if self._idx == -1:
				app.appendMultiChart(self._chart)
			else:
				app.replaceChart(self._idx, self._num, self._chart)
		# done
		self.done(QDialog.Accepted)