def to_satellite(self): name = self._sat_name.get_text() pos = round(self._sat_position.get_value(), 1) side = self._side.get_active() name = "{} ({}{})".format(name, pos, self._side.get_active_id()) pos = "{}{}{}".format("-" if side == 1 else "", *str(pos).split(".")) return Satellite(name=name, flags="0", position=pos, transponders=None)
def on_save(self): if show_dialog(DialogType.QUESTION, self._app.app_window) == Gtk.ResponseType.CANCEL: return write_satellites( (Satellite(*r) for r in self._satellite_view.get_model()), self._settings.profile_data_path + "satellites.xml")
def on_edit(self, view, force=False): """ Common edit """ paths = self.check_selection(view, "Please, select only one item!") if not paths: return model = view.get_model() row = model[paths][:] itr = model.get_iter(paths) if view is self._satellite_view: self.on_satellite(None if force else Satellite(*row), itr) elif view is self._transponder_view: self.on_transponder(None if force else Transponder(*row), itr)
def parse_data(model, path, itr, sats): if model.iter_has_child(itr): num_of_children = model.iter_n_children(itr) transponders = [] num_columns = model.get_n_columns() for num in range(num_of_children): transponder_itr = model.iter_nth_child(itr, num) transponder = model.get(transponder_itr, *[item for item in range(num_columns)]) transponders.append(Transponder(*transponder[1:-2])) sat = model.get(itr, *[item for item in range(num_columns)]) satellite = Satellite(sat[0], sat[-2], sat[-1], transponders) sats.append(satellite)
def on_edit(self, view, force=False): """ Common edit """ paths = self.check_selection(view, "Please, select only one item!") if not paths: return model = view.get_model() itr = model.get_iter(paths[0]) row = model.get(itr, *[x for x in range(view.get_n_columns())]) if row[-1]: # satellite self.on_satellite(None if force else Satellite(row[0], None, row[-1], None), itr) else: self.on_transponder(None if force else Transponder(*row[1:-2]), itr)
def get_satellite(self, sat): pos = sat[1] return Satellite(name=sat[0] + " ({})".format(pos), flags="0", position=self.get_position(pos.replace(".", "")), transponders=self.get_transponders(sat[3]))
def get_satellite(self, sat): pos = sat[1] return Satellite(name=f"{pos} {sat[0]}", flags="0", position=self.get_position(pos.replace(".", "")), transponders=self.get_transponders(sat[3]))