def save_channel_in_database(self, name, type, selected_image): mainwindow = App.get_running_app().root #try: if Channel.select().count() > 0: selected_channel = Channel.get(Channel.selected == True) if selected_channel: selected_channel.selected = False print("tinha um canal selecionado anteriormente") self.gridchannels.channel_master = Channel.create( name=name, type=type, pin=1, note=38, threshold=10, scan=20, mask=20, retrigger=7, gain=15, curve=0, curveform=100, xtalk=0, xtalkgroup=0, image="resources/images/PNG/" + selected_image + ".png", x=0.0, y=0.0, width=0.0, height=0.0, selected=True, active=True) self.dismiss() self.gridchannels.list_channels = Channel.select().order_by(Channel.id) #adiciona canal no grid self.gridchannels.insert_channel_in_grid( self.gridchannels.channel_master) self.gridchannels.set_values_selected()