def __init__(self, userId): Gtk.Window.__init__(self, title="Endereço", window_position="center") self.set_resizable(False) session = SbSession() if session.check_level() != 3: UiDialog( 'Erro de permissão!', 'Somente usuários com o nível 3 podem inserir e/ou alterar endereços.' ) return self.destroy() grid = Gtk.Grid(margin=20) grid.set_row_spacing(10) grid.set_column_spacing(10) self.add(grid) # Título label = Gtk.Label(margin_bottom=30, halign="start") label.set_markup("<span size='20000'>Endereço</span>") grid.attach(label, 1, 1, 1, 1) # CEP label = Gtk.Label(halign="start") label.set_label("CEP:") self.cep = Gtk.Entry(max_length=10) self.cep.set_input_purpose(Gtk.InputPurpose.NUMBER) grid.attach(label, 1, 2, 1, 1) grid.attach(self.cep, 1, 3, 1, 1) # Rua label = Gtk.Label(halign="start") label.set_markup("Logradouro<span color='red'>*</span>:") self.street = Gtk.Entry(max_length=120) grid.attach(label, 1, 4, 1, 1) grid.attach(self.street, 1, 5, 3, 1) # Complemento label = Gtk.Label(halign="start") label.set_label("Complemento:") self.complement = Gtk.Entry(width_request=300) grid.attach(label, 1, 6, 1, 1) grid.attach(self.complement, 1, 7, 2, 1) # Número da casa label = Gtk.Label(halign="start") label.set_label("Número da casa:") self.house = Gtk.Entry(max_length=5) self.house.set_input_purpose(Gtk.InputPurpose.NUMBER) grid.attach(label, 3, 6, 1, 1) grid.attach(self.house, 3, 7, 1, 1) # Bairro label = Gtk.Label(halign="start") label.set_markup("Bairro/Distrito<span color='red'>*</span>:") self.bairro = Gtk.Entry(max_length=120) grid.attach(label, 1, 8, 1, 1) grid.attach(self.bairro, 1, 9, 2, 1) # Cidade label = Gtk.Label(halign="start") label.set_markup("Cidade<span color='red'>*</span>:") self.city = Gtk.Entry(max_length=120) grid.attach(label, 3, 8, 1, 1) grid.attach(self.city, 3, 9, 1, 1) # Estado label = Gtk.Label(halign="start") label.set_label("Estado:") liststore = Gtk.ListStore(str) listStates = [ "Acre", "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceará", "Distrito Federal", "Espírito Santo", "Goiás", "Maranhão", "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Pará", "Paraíba", "Paraná", "Pernambuco", "Piauí", "Rio de Janeiro", "Rio Grande do Norte", "Rio Grande do Sul", "Rondônia", "Roraima", "Santa Catarina", "São Paulo", "Sergipe", "Tocantins" ] for item in listStates: liststore.append([item]) entrycompletion = Gtk.EntryCompletion() entrycompletion.set_model(liststore) entrycompletion.set_text_column(0) entrycompletion.set_inline_completion(True) self.state = Gtk.Entry(max_length=120) self.state.set_completion(entrycompletion) self.state.set_text("Espírito Santo") grid.attach(label, 1, 10, 1, 1) grid.attach(self.state, 1, 11, 1, 1) # Separator separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin_top=20, margin_bottom=20) grid.attach(separator, 1, 12, 3, 1) # Enviar submit = Gtk.Button(label="Enviar", height_request=40) submit.connect("clicked", self.submit_address, userId) grid.attach(submit, 1, 13, 2, 1) # Cancelar button = Gtk.Button(label="Fechar", height_request=40) button.connect("clicked", self.destroy_window) grid.attach(button, 3, 13, 1, 1)
def __init__(self): Gtk.Window.__init__(self, title="Cadastro de usuário", window_position="center") self.set_resizable(False) session = SbSession() if session.check_level() != 3: UiDialog( 'Erro de permissão!', 'Somente usuários com o nível 3 podem criar novos usuários.') return self.destroy() grid = Gtk.Grid(margin=20) grid.set_row_spacing(10) grid.set_column_spacing(10) self.add(grid) # Título label = Gtk.Label(margin_bottom=20, halign="start") label.set_markup("<span size='20000'>Cadastro de usuário</span>") grid.attach(label, 1, 1, 1, 1) # Nome label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>Nome completo:</span><span color='red'>*</span>" ) self.name = Gtk.Entry(max_length=120) grid.attach(label, 1, 2, 2, 1) grid.attach(self.name, 1, 3, 2, 1) # Username label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>Username:</span><span color='red'>*</span>") self.username = Gtk.Entry(max_length=120) self.username.set_input_purpose(Gtk.InputPurpose.NUMBER) grid.attach(label, 3, 2, 1, 1) grid.attach(self.username, 3, 3, 1, 1) # PIN label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>PIN:</span><span color='red'>*</span> (4 números)" ) self.pin = Gtk.Entry(max_length=4) grid.attach(label, 3, 4, 1, 1) grid.attach(self.pin, 3, 5, 1, 1) # Nível de permisão label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>Nível de permisão:</span><span color='red'>*</span>" ) grid.attach(label, 1, 4, 2, 1) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) grid.attach(box, 1, 5, 2, 1) self.level = 1 radiobutton1 = Gtk.RadioButton(label="Nível 1") radiobutton1.connect("toggled", self.on_radio_button_toggled) box.pack_start(radiobutton1, True, True, 0) radiobutton2 = Gtk.RadioButton(label="Nível 2", group=radiobutton1) radiobutton2.connect("toggled", self.on_radio_button_toggled) box.pack_start(radiobutton2, True, True, 0) radiobutton3 = Gtk.RadioButton(label="Nível 3", group=radiobutton1) radiobutton3.connect("toggled", self.on_radio_button_toggled) box.pack_start(radiobutton3, True, True, 0) # Separator separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin_top=10, margin_bottom=10) grid.attach(separator, 1, 6, 3, 1) # E-mail label = Gtk.Label(halign="start") label.set_markup("<span font='bold'>E-mail:</span>") self.email = Gtk.Entry(max_length=200) self.email.set_input_purpose(Gtk.InputPurpose.EMAIL) grid.attach(label, 1, 7, 1, 1) grid.attach(self.email, 1, 8, 1, 1) # Telefone label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>Telefone:</span><span color='red'>*</span>") self.phone = Gtk.Entry(max_length=20) self.phone.set_input_purpose(Gtk.InputPurpose.PHONE) grid.attach(label, 2, 7, 1, 1) grid.attach(self.phone, 2, 8, 1, 1) # Aniversário label = Gtk.Label(halign="start") label.set_markup( "<span font='bold'>Aniversário:</span><span color='red'>*</span>") self.birthday = Gtk.Entry(max_length=10) grid.attach(label, 3, 7, 1, 1) grid.attach(self.birthday, 3, 8, 1, 1) # Separator separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin_top=10, margin_bottom=10) grid.attach(separator, 1, 9, 3, 1) # Enviar submit = Gtk.Button(label="Próximo", height_request=40) submit.connect("clicked", self.submit_user) grid.attach(submit, 1, 10, 3, 1)