Hab mir die letzte Version mal angesehen.
Die Interessanteste Datei darin ist net_io_main.py
Auf dessen Grundlage hab ich mal schnell das folgende zusammen gehackt:
Code: Alles auswählen
import tkinter as tk
class Outputs(tk.LabelFrame):
def __init__(self, master, **kwargs):
tk.LabelFrame.__init__(self, master, text="LCD-Ausgabe")
self.grid(**kwargs)
self._lbl = tk.Label(self, text="Foo", anchor="e")
self._lbl.grid(column=0, row=0, sticky="e")
self._var = tk.StringVar()
self._entry = tk.Entry(self, textvariable=self._var)
self._entry.grid(column=1, row=0, sticky="nse")
self._btn = tk.Button(self, text="Zeile löschen")
self._btn.grid(column=3, row=0, sticky="nse")
class Inputs(tk.LabelFrame):
def __init__(self, master, **kwargs):
tk.LabelFrame.__init__(self, master, text="Eingabe")
self.grid(**kwargs)
self._lbl = tk.Label(self, text="Foo", anchor="e")
self._lbl.grid(column=0, row=0, sticky="e")
self._var = tk.StringVar()
self._entry = tk.Entry(self, textvariable=self._var)
self._entry.grid(column=1, row=0, sticky="nse")
self._btn = tk.Button(self, text="Zeile löschen")
self._btn.grid(column=3, row=0, sticky="nse")
class Buttons(tk.LabelFrame):
def __init__(self, master, **kwargs):
tk.LabelFrame.__init__(self, master, text="Ein paar Buttons")
self.grid(**kwargs)
for no, txt in enumerate(["bla blub", "foo bar"]):
self._btn = tk.Button(self, text=txt)
self._btn.grid(column=no, row=0, sticky="nse")
for no, txt in enumerate(["noch einer", "ende"]):
self._btn = tk.Button(self, text=txt)
self._btn.grid(column=no, row=1, sticky="nse")
class App(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.title("Foo Bar")
self.add_Widgets()
self.mainloop()
def add_Widgets(self):
padding = 5
defaults = {
"ipadx": padding, # add internal padding in x direction
"ipady": padding, # add internal padding in y direction
"padx": padding, # add padding in x direction
"pady": padding, # add padding in y direction
"sticky": tk.NSEW, # stick to the cell boundary
}
self.outputs = Outputs(self, column=0, row=0, **defaults)
self.inputs = Inputs(self, column=0, row=1, **defaults)
self.actions = Buttons(self, column=1, row=0, rowspan=2, **defaults)
if __name__ == '__main__':
App()
Ich finde diese Aufteilung eigentlich ganz nett. Wie sieht ihr das? Brauchbar, vom Prinzip her?!?