55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import tkinter as tk
|
|
from tkinter import ttk
|
|
|
|
from generic import sanitize, type_hosts_listed, type_hosts_organized
|
|
|
|
class App(tk.Tk):
|
|
def __init__(self, *args, **kwargs):
|
|
tk.Tk.__init__(self, *args, **kwargs)
|
|
self.wm_title("Testing out classing my application")
|
|
|
|
container = tk.Frame(self, height=400, width=600)
|
|
container.pack(side="top", fill="both", expand=True)
|
|
|
|
container.grid_rowconfigure(0, weight=1)
|
|
container.grid_columnconfigure(0, weight=1)
|
|
self.var = tk.Variable()
|
|
|
|
# I think this goes wrong for my purposes: I'm not switching frames in place, but keeping them besides each other. Find a simpler setup maybe?
|
|
self.frames = {}
|
|
for F in (InputFrame, LookupFrame):
|
|
frame = F(container, self)
|
|
frame.grid(row=0, column=0, sticky='nsew')
|
|
|
|
class InputFrame(tk.Frame):
|
|
def __init__(self, parent, controller):
|
|
tk.Frame.__init__(self, parent)
|
|
label = tk.Label(self, text="Input URL, IP, email address")
|
|
label.pack(padx=10, pady=10)
|
|
self.var = tk.Variable()
|
|
|
|
self.entry = ttk.Entry(self)
|
|
self.entry.focus()
|
|
self.entry.pack(padx=10, pady=10)
|
|
self.entry.bind("<Return>", self.key_handler_function)
|
|
|
|
def key_handler_function(self, event) -> None:
|
|
inputs = self.entry.get()
|
|
sanitized = sanitize.strip_and_list(inputs)
|
|
typed = type_hosts_organized.type_hosts(sanitized)
|
|
self.var.set(typed)
|
|
|
|
class LookupFrame(tk.Frame):
|
|
def __init__(self, parent, controller):
|
|
tk.Frame.__init__(self, parent)
|
|
label = tk.Label(self, text="Lookup information")
|
|
label.pack(padx=10, pady=10)
|
|
var = controller.var.get()
|
|
print(var)
|
|
|
|
if __name__ == "__main__":
|
|
testObj = App()
|
|
testObj.mainloop()
|
|
|
|
|