Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import Entry, Tk, Frame, Label
- class IpEntry(Frame):
- def __init__(self, font_size=12):
- super().__init__()
- self.font_size = font_size
- print(type(font_size))
- self.configure(
- # background='red',
- width=158,
- # height=self.font_size*4+6,
- # font=font
- )
- # print(font_size)
- font = f'Courier {font_size}'
- self.pic1 = Label(self, width=1, text='.')
- self.pic2 = Label(self, width=1, text='.')
- self.pic3 = Label(self, width=1, text='.')
- self.octet1 = Entry(self, width=3)
- self.octet2 = Entry(self, width=3)
- self.octet3 = Entry(self, width=3)
- self.octet4 = Entry(self, width=3)
- # self.lbl_ip = Label(self, text='0.0.0.0')
- # Выравниквание контроллов
- start_x = 2
- start_y = 2
- step=42
- self.pic1.place(x=start_x+step-13, y=start_y)
- self.pic2.place(x=start_x+step*2-13, y=start_y)
- self.pic3.place(x=start_x+step*3-13, y=start_y)
- self.octet1.place(x=start_x, y=start_y)
- self.octet2.place(x=start_x+step, y=start_y)
- self.octet3.place(x=start_x+step*2, y=start_y)
- self.octet4.place(x=start_x+step*3, y=start_y)
- self.octet1.bind('<KeyRelease>', self.text_verification)
- self.octet2.bind('<KeyRelease>', self.text_verification)
- self.octet3.bind('<KeyRelease>', self.text_verification)
- self.octet4.bind('<KeyRelease>', self.text_verification)
- def text_verification(self, a):
- octet = []
- octet.append(self.octet1.get())
- octet.append(self.octet2.get())
- octet.append(self.octet3.get())
- octet.append(self.octet4.get())
- self.ip = '.'.join(octet)
- def get_ip(self):
- return self.ip
- class TopFrame(Frame):
- def __init__(self):
- super().__init__()
- self.configure(
- # background='blue',
- width=265,
- height=26,
- )
- self.lbl_ip_address = Label(self, text = 'Введите ip адрес')
- self.ip = IpEntry()
- self.lbl_ip_address.place(x=5, y=2, height=25)
- self.ip.place(x=110, y=5, height=25)
- # return self
- if __name__ == '__main__':
- root = Tk()
- root.geometry('300x200')
- root.configure(background='blue' )
- root.top_frame = TopFrame()
- root.top_frame.place(x=5, y=5)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement