Zapisując tak kod
ip_input = tkinter.Entry(okno, width=20) #pole tekstowe
ip_input.place(x=0, y=30)
button = tkinter.Button(okno, command=ekran_poczatkowy, height=1, width=10, text="prześlij") #przycisk
button.place(x=0, y=70)
serwer_ip = ip_input.get()
okno.mainloop()
dane z ip_input są "pobierane" w trakcie "tworzenia" okienka aplikacji, zanim użytkownik zdąży cokolwiek wpisać, chyba nie o to Tobie chodziło
Tak jak @Whiskey_Taster napisał Tobie, musisz dodać "akcję" do przycisku, która to po kliknięciu "pobierze" wartość z ip_input
przykład (pozwoliłem sobie nieco uporządkować Twój kod )
import tkinter as tk
import socket
serwer_ip = 'localhost'
########## okno z ip serwera ##########
class komunikator(tk.Tk):
def __init__(self):
super().__init__()
top = tk.Frame(self)
top.pack(side='top')
self.title('Komunikator')
self.geometry('500x600')
padding = 5
self.text = tk.Label(self, text='Podaj adres ip serwera:')
self.text.place(x=padding, y=padding)
self.ip_input = tk.Entry(self, width=20)
self.ip_input.place(x=padding, y=30)
self.ip_input.insert(0, serwer_ip) # domyślny tekst w polu
self.button = tk.Button(self, command=self.uzyskaj_adres_ip_serwera, width=10, text='Prześlij')
self.button.place(x=padding, y=60)
def uzyskaj_adres_ip_serwera(self):
serwer_ip = self.ip_input.get()
print(serwer_ip)
if __name__ == '__main__':
komunikator().mainloop()