Hey guys I am new here, I starting programming and I got stuck on this problem.
When I choose the segments i create a form using the segment_index to switch the view and the form is showed normally but when I select the others segment the form created by the other segment remains.
When I try to remove_subview it’s tells me that doesn’t have any view. Can u guys help me ?

import ui
import sqlite3 as sql
import functools

class MyView(ui.View):

def reg_feitas():
    pass

def reg_seihin():

    seihin_label = ui.Label()
    seihin_label.text = 'Seihin'
    seihin_label.font = ('Arial', 30)
    seihin_label.x = 5
    seihin_label.y = 60
    view.add_subview(seihin_label)


    seihin_n = ui.TextField()
    seihin_n.autocorrection_type = False
    seihin_n.x = 100
    seihin_n.y = 95
    seihin_n.width = 140
    seihin_n.height = 30
    seihin_n.bring_to_front = False
    view.add_subview(seihin_n)

    seihin_price = ui.Label()
    seihin_price.text = 'Preço'
    seihin_price.font = ('Arial', 30)
    seihin_price.x = 5
    seihin_price.y = 105
    view.add_subview(seihin_price)


    seihin_p = ui.TextField()
    seihin_p.autocorrection_type = False
    seihin_p.x = 100
    seihin_p.y = 140
    seihin_p.width = 140
    seihin_p.height = 30
    seihin_p.bring_to_front = False
    view.add_subview(seihin_p)

    bt_reg = ui.Button(title='Registrar')
    bt_reg.x, bt_reg.y = (270, 120)
    bt_reg.border_color = '#808080'
    bt_reg.border_width = 3
    bt_reg.width = 80
    view.add_subview(bt_reg)


def animation():
    alpha = 0.0 # fade out


def seg_default():
    seg0 = ui.Label()

    seg0.text = 'Salário calculado até agora...'
    seg0.title = 'seg0'
    seg0.background_color = '#ff61e8'
    seg0.width = 360
    seg0.height = 30
    seg0.x = 5
    seg0.y = 60
    view.add_subview(seg0)

def aba_ctrl(aba):
    seg = aba.segments
    seg_index = aba.selected_index
    aba_dic = {0: 'default', 1: 'teste'}


    if seg_index == 0:
        MyView.seg_default()

    elif seg_index == 1:

        MyView.reg_feitas()

        seg1 = ui.Label()
        seg1.text = 'Adicionar dia de trabalho...'
        seg1.background_color = '#008000'
        seg1.width = 360
        seg1.height = 30
        seg1.x = 5
        seg1.y = 60
        view.add_subview(seg1)


    elif seg_index == 2:

        MyView.reg_seihin()

        seg2 = ui.Label()
        seg2.text = 'Adicionar novo seihin ...'
        seg2.name = 'teste'
        seg2.text_color = 'white'
        seg2.background_color = 'black'
        seg2.width = 360
        seg2.height = 30
        seg2.x = 5
        seg2.y = 60
        view.add_subview(seg2)


def remove(sender):
    label = view["seihin_label"]
    if label:
        view.remove_subview(label)
        view.labelcounter -= 1



def registra_seihin():
    pass

view = ui.load_view()
v = MyView()
MyView.seg_default()

view.present('fullscreen', animated=True, hide_close_button=False)