Facebook
From kod, 5 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 120
  1. from kivy.app import App
  2. from kivy.uix.boxlayout import BoxLayout
  3. from kivy.uix.gridlayout import GridLayout
  4. from kivy.uix.label import Label
  5. from kivy.uix.textinput import TextInput
  6. from kivy.uix.button import Button
  7.  
  8. class ContactApp(App):
  9.     def build(self):
  10.         root = BoxLayout(orientation='horizontal', spacing=10)
  11.  
  12.         # Lewa strona - etykiety (Imię, Nazwisko, Numer telefonu)
  13.         left_column = GridLayout(cols=1, spacing=10)
  14.         left_column.add_widget(Label(text='Imię'))
  15.         left_column.add_widget(Label(text='Nazwisko'))
  16.         phone_label = Label(text='Numer telefonu')
  17.         left_column.add_widget(phone_label)
  18.  
  19.         # Prawa strona - pola do wprowadzania danych
  20.         right_column = GridLayout(cols=1, spacing=10)
  21.         name_input = TextInput(background_color=(0.7, 0.7, 1, 1))  # Ustal jasnoniebieski kolor tła dla pól
  22.         last_name_input = TextInput(background_color=(0.7, 0.7, 1, 1))
  23.         phone_input = TextInput(background_color=(0.7, 0.7, 1, 1))
  24.         right_column.add_widget(name_input)
  25.         right_column.add_widget(last_name_input)
  26.         right_column.add_widget(phone_input)
  27.  
  28.         # Dodaj pole wyniku na dole po prawej
  29.         result_label = Label(text='DANE: Imię - Nazwisko - Numer telefonu')
  30.         right_column.add_widget(result_label)
  31.  
  32.         # Dodaj obie kolumny do głównego layoutu
  33.         root.add_widget(left_column)
  34.         root.add_widget(right_column)
  35.  
  36.         # Funkcja obsługująca przycisk "Zapisz dane"
  37.         def save_data(instance):
  38.             result_label.text = f'DANE: {name_input.text} - {last_name_input.text} - {phone_input.text}'
  39.  
  40.         # Podłącz przycisk do funkcji obsługującej zapis danych
  41.         save_button = Button(text='Wyslij', background_color=(0.2, 0.7, 0.3, 1))  # Ustal zielony kolor tła przycisku
  42.         save_button.bind(on_press=save_data)
  43.         left_column.add_widget(save_button)
  44.  
  45.         # Ustaw kolory tła dla lewej kolumny (etkiet) i prawej kolumny (pola i wynik)
  46.         left_column.background_color = (0.8, 0.8, 0.8, 1)
  47.         right_column.background_color = (0.9, 0.9, 0.9, 1)
  48.  
  49.         return root
  50.  
  51. if __name__ == '__main__':
  52.     ContactApp().run()
  53.