aktueller Stand mit zwei Frames die beschickt werden können
This commit is contained in:
+76
-29
@@ -1,5 +1,6 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
#from tkinter import messagebox
|
||||||
#import logging
|
#import logging
|
||||||
|
|
||||||
|
|
||||||
@@ -74,12 +75,20 @@ parent_children_mapping = {'400102196': ['400102125', '400102126', '400102130',
|
|||||||
class TreeView():
|
class TreeView():
|
||||||
def __init__(self, frame):
|
def __init__(self, frame):
|
||||||
# a treeview
|
# a treeview
|
||||||
self.tree = ttk.Treeview(frame)
|
# hier Anzahl der sichtbaren Zeilen des Baums angeben:
|
||||||
|
self.tree = ttk.Treeview(frame, height=40)
|
||||||
# TODO hier anstatt root die Statistik rein schreiben.
|
# TODO hier anstatt root die Statistik rein schreiben.
|
||||||
self.tree.heading('#0', text='root', anchor=tk.W)
|
self.tree.heading('#0', text='root', anchor=tk.W)
|
||||||
|
|
||||||
|
# add a scrollbar
|
||||||
|
scrollbar = ttk.Scrollbar(frame, orient=tk.VERTICAL, command=self.tree.yview)
|
||||||
|
self.tree.configure(yscroll=scrollbar.set)
|
||||||
|
scrollbar.grid(row=0, column=1, sticky='ns')
|
||||||
|
|
||||||
|
self.tree.bind('<<TreeviewSelect>>', self.item_selected)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.tree.clipboard_clear()
|
self.tree.delete()
|
||||||
|
|
||||||
def create(self, parent_children_mapping, red_ids):
|
def create(self, parent_children_mapping, red_ids):
|
||||||
# adding data of first column after root
|
# adding data of first column after root
|
||||||
@@ -109,6 +118,17 @@ class TreeView():
|
|||||||
self.tree.tag_configure('good', background='white')
|
self.tree.tag_configure('good', background='white')
|
||||||
self.tree.tag_configure('missing', background='red')
|
self.tree.tag_configure('missing', background='red')
|
||||||
|
|
||||||
|
def item_selected(self, event):
|
||||||
|
"""callback if an item in the tree has been selected
|
||||||
|
"""
|
||||||
|
id = self.tree.selection()[0]
|
||||||
|
# for selected_item in self.tree.selection():
|
||||||
|
# item = self.tree.item(selected_item)
|
||||||
|
# record = item['values']
|
||||||
|
# messagebox.showinfo(title='Information', message=','.join(record))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_handle(self):
|
def get_handle(self):
|
||||||
return self.tree
|
return self.tree
|
||||||
|
|
||||||
@@ -121,49 +141,76 @@ class App():
|
|||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
|
||||||
# configure the grid
|
# configure the grid
|
||||||
root.columnconfigure(0, weight=2)
|
# self.root.columnconfigure(0, weight=2)
|
||||||
root.columnconfigure(1, weight=1)
|
# self.root.columnconfigure(1, weight=1)
|
||||||
root.columnconfigure(2, weight=1)
|
# self.root.columnconfigure(2, weight=1)
|
||||||
root.columnconfigure(3, weight=1)
|
# self.root.columnconfigure(3, weight=1)
|
||||||
root.geometry('800x700')
|
# self.root.columnconfigure(4, weight=1)
|
||||||
root.resizable(0, 0)
|
#self.root.geometry('800x800')
|
||||||
|
#self.root.resizable(0, 0)
|
||||||
|
|
||||||
|
# Create left and right frames
|
||||||
|
left_frame = ttk.Frame(self.root, width=200, height=800)
|
||||||
|
left_frame.grid(row=0, column=0, padx=10, pady=5)
|
||||||
|
|
||||||
|
right_frame = ttk.Frame(self.root, width=650, height=800)
|
||||||
|
right_frame.grid(row=0, column=1, padx=10, pady=5)
|
||||||
|
|
||||||
|
|
||||||
style = ttk.Style(self.root)
|
style = ttk.Style(self.root)
|
||||||
style.theme_use('classic')
|
style.theme_use('classic')
|
||||||
|
|
||||||
|
self.tv = TreeView(left_frame)
|
||||||
|
self.tv.create(parent_children_mapping, red_ids)
|
||||||
|
gridhdl = self.tv.get_handle()
|
||||||
|
gridhdl.grid(row=0, column=0, sticky=tk.NSEW)
|
||||||
|
|
||||||
|
self.create_widgets(right_frame)
|
||||||
|
|
||||||
# style.configure('Error.TLabel', foreground='white')
|
# style.configure('Error.TLabel', foreground='white')
|
||||||
# style.configure('Error.TLabel', background='red')
|
# style.configure('Error.TLabel', background='red')
|
||||||
# style.configure('Error.TLabel', font=('Helvetica', 12))
|
# style.configure('Error.TLabel', font=('Helvetica', 12))
|
||||||
# style.configure('Error.TLabel', padding=(10, 10))
|
# style.configure('Error.TLabel', padding=(10, 10))
|
||||||
|
|
||||||
self.tv = TreeView(self.root)
|
|
||||||
self.tv.create(parent_children_mapping, red_ids)
|
|
||||||
gridhdl = self.tv.get_handle()
|
|
||||||
gridhdl.grid(row=0, column=0, rowspan=2, sticky=tk.NSEW)
|
|
||||||
|
|
||||||
# message = 'This is an error message!'
|
# message = 'This is an error message!'
|
||||||
# label = ttk.Label(right_list, text=message, style='Error.TLabel')
|
# error_label = ttk.Label(self.root, text=message, style='Error.TLabel')
|
||||||
self.create_widgets()
|
# error_label.grid(column=2, row=3, sticky=tk.E, padx=5, pady=5)
|
||||||
|
|
||||||
|
|
||||||
def create_widgets(self):
|
def create_widgets(self, frame):
|
||||||
# username
|
rownum = 0
|
||||||
username_label = ttk.Label(self.root, text="Username:")
|
col_left = 0
|
||||||
username_label.grid(column=1, row=0, sticky=tk.W, padx=5, pady=5, bg="green")
|
# pdmkategorie
|
||||||
|
pdmkategorie_label = ttk.Label(frame, text="PDM-Kategorie:" )
|
||||||
|
pdmkategorie_label.grid(column=col_left, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
pdmkategorie_entry = ttk.Entry(frame)
|
||||||
|
pdmkategorie_entry.grid(column=col_left+2, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
rownum += 1
|
||||||
|
|
||||||
username_entry = ttk.Entry(self.root)
|
# Neuaufbau
|
||||||
username_entry.grid(column=2, row=0, sticky=tk.E, padx=5, pady=5)
|
neuaufbau_label = ttk.Label(frame, text="Neuaufbau:")
|
||||||
|
neuaufbau_label.grid(column=col_left, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
|
||||||
# password
|
self.neuaufbau = None
|
||||||
password_label = ttk.Label(self.root, text="Password:")
|
neuaufbau_checkbutton = ttk.Checkbutton(frame,
|
||||||
password_label.grid(column=1, row=1, sticky=tk.W, padx=5, pady=5)
|
text='ja',
|
||||||
|
command=self.var_changed("neuaufbau"),
|
||||||
|
variable=self.neuaufbau,
|
||||||
|
onvalue=True,
|
||||||
|
offvalue=False)
|
||||||
|
neuaufbau_checkbutton.grid(column=col_left+2, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
rownum += 1
|
||||||
|
|
||||||
password_entry = ttk.Entry(self.root, show="*")
|
# Lebenszyklusstatus
|
||||||
password_entry.grid(column=2, row=1, sticky=tk.E, padx=5, pady=5)
|
lebenszyklusstatus_label = ttk.Label(frame, text="Lebenszyklusstatus:")
|
||||||
|
lebenszyklusstatus_label.grid(column=col_left, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
lebenszyklusstatus_entry = ttk.Entry(frame, show="*")
|
||||||
|
lebenszyklusstatus_entry.grid(column=col_left+2, row=rownum, sticky=tk.W, padx=5, pady=5)
|
||||||
|
rownum += 1
|
||||||
|
|
||||||
# login button
|
def var_changed(self, whichvar):
|
||||||
login_button = ttk.Button(self.root, text="Login")
|
a = whichvar
|
||||||
login_button.grid(column=2, row=2, sticky=tk.E, padx=5, pady=5)
|
b = self.neuaufbau
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
self.root.mainloop()
|
self.root.mainloop()
|
||||||
|
|||||||
Reference in New Issue
Block a user