Status Liste mit tkinter
Verfasst: Sonntag 14. November 2021, 12:35
Hallo,
ich lerne gerade die Python Sprache (natürlich in der aktuellen Version). Möchte daher eine Status liste mit Python3 und tkinter erstellen. Das 1. Grundgerüst steht schonmal und dies wurde auf 2 Seiten (tk.notebook) verteilt. Klicke ich aber auf ein Button auf der seite 1, hat dies auf der 2. Seite und dem 1. Button.
Ich weiss nicht, was ich da falsch mache... Habe das gefühl, das der inhalt im Reiter nicht neu gezeichnet werden, oder das kann man irgendwo aktivieren?
ich lerne gerade die Python Sprache (natürlich in der aktuellen Version). Möchte daher eine Status liste mit Python3 und tkinter erstellen. Das 1. Grundgerüst steht schonmal und dies wurde auf 2 Seiten (tk.notebook) verteilt. Klicke ich aber auf ein Button auf der seite 1, hat dies auf der 2. Seite und dem 1. Button.
Code: Alles auswählen
try:
# Python2
import Tkinter as tk
import ttk
except ImportError:
# Python3
import tkinter as tk
import tkinter.font as tkFont
import tkinter.ttk as ttk
root = tk.Tk()
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (1400, 700, 1, 1))
root.title('Auftragsliste')
# Font
ebrima = tkFont.Font(family='Ebrima', size=12, weight=tkFont.BOLD)
nb = ttk.Notebook(root)
nb.pack(fill='both', expand='yes')
# create a child frame for each page
f1 = tk.Frame(bg='#444444')
f2 = tk.Frame(bg='#444444')
f3 = tk.Frame(bg='#444444')
# create the pages, text goes on the tabs
nb.add(f1, text=' Seite 1 ')
nb.add(f2, text=' Seite 2 ')
nb.add(f3, text=' FUTURE ')
# Frame f1
Labelh1 = tk.Label(f1, text='Auftrag ', width='84', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh1.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh1.place(x='0', y='5')
Labelh2 = tk.Label(f1, text='Zahlen', width='10', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh2.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh2.place(x='850', y='5')
Labelh3 = tk.Label(f1, text='Kommentar', width='50', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh3.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh3.place(x='960', y='5')
# Nr1
Labelr1 = tk.Label(f1, text='Abteilung 1', width='20', bg='#888888', fg='#eeeeee', font=ebrima)
Labelr1.pack(side='left', anchor='nw', padx=3, pady=5)
Labelr1.place(x='0', y='35')
Labelr1a = tk.Label(f1, text='TEL', width='5', bg='#888888', fg='#eeeeee', font=ebrima)
Labelr1a.pack(side='left', anchor='nw', padx=3, pady=5)
Labelr1a.place(x='210', y='35')
GCheckBox_RIDE1a = tk.Checkbutton(f1)
GCheckBox_RIDE1a["borderwidth"] = "0px"
GCheckBox_RIDE1a["font"] = ebrima
GCheckBox_RIDE1a["fg"] = "#000000"
GCheckBox_RIDE1a["justify"] = "left"
GCheckBox_RIDE1a["text"] = "erhalten"
GCheckBox_RIDE1a.place(x=280, y=36, width=120, height=26)
GCheckBox_RIDE1a["offvalue"] = "0"
GCheckBox_RIDE1a["onvalue"] = "1"
GCheckBox_RIDE1a["indicatoron"] = "0"
GCheckBox_RIDE1a["selectcolor"] = "#00ee00"
GCheckBox_RIDE1a["bg"] = "#ee0000"
#GCheckBox_RIDE1a["command"] = self.GCheckBox_RIDE1a_command
GCheckBox_RIDE1b = tk.Checkbutton(f1)
GCheckBox_RIDE1b["borderwidth"] = "0px"
GCheckBox_RIDE1b["font"] = ebrima
GCheckBox_RIDE1b["fg"] = "#000000"
GCheckBox_RIDE1b["justify"] = "left"
GCheckBox_RIDE1b["text"] = "weitergeleitet"
GCheckBox_RIDE1b.place(x=410, y=36, width=120, height=26)
GCheckBox_RIDE1b["offvalue"] = "0"
GCheckBox_RIDE1b["onvalue"] = "1"
GCheckBox_RIDE1b["indicatoron"] = "0"
GCheckBox_RIDE1b["selectcolor"] = "#00ee00"
GCheckBox_RIDE1b["bg"] = "#ee0000"
#GCheckBox_RIDE1b["command"] = self.GCheckBox_RIDE1b_command
GCheckBox_RIDE1c = tk.Checkbutton(f1)
GCheckBox_RIDE1c["borderwidth"] = "0px"
GCheckBox_RIDE1c["font"] = ebrima
GCheckBox_RIDE1c["fg"] = "#000000"
GCheckBox_RIDE1c["justify"] = "center"
GCheckBox_RIDE1c["text"] = "erledigt"
GCheckBox_RIDE1c.place(x=595, y=36, width=120, height=26)
GCheckBox_RIDE1c["offvalue"] = "0"
GCheckBox_RIDE1c["onvalue"] = "1"
GCheckBox_RIDE1c["indicatoron"] = "0"
GCheckBox_RIDE1c["selectcolor"] = "#00ee00"
GCheckBox_RIDE1c["bg"] = "#ee0000"
#GCheckBox_RIDE1c["command"] = self.GCheckBox_RIDE1c_command
GCheckBox_RIDE1d = tk.Checkbutton(f1)
GCheckBox_RIDE1d["borderwidth"] = "0px"
GCheckBox_RIDE1d["font"] = ebrima
GCheckBox_RIDE1d["fg"] = "#000000"
GCheckBox_RIDE1d["justify"] = "center"
GCheckBox_RIDE1d["text"] = "eingetragen"
GCheckBox_RIDE1d.place(x=725, y=36, width=120, height=26)
GCheckBox_RIDE1d["offvalue"] = "0"
GCheckBox_RIDE1d["onvalue"] = "1"
GCheckBox_RIDE1d["indicatoron"] = "0"
GCheckBox_RIDE1d["selectcolor"] = "#00ee00"
GCheckBox_RIDE1d["bg"] = "#ee0000"
#GCheckBox_RIDE1d["command"] = self.GCheckBox_RIDE1d_command
GLineEdit_RIDE1a = tk.Entry(f1)
GLineEdit_RIDE1a["borderwidth"] = "0px"
GLineEdit_RIDE1a["font"] = ebrima
GLineEdit_RIDE1a["fg"] = "#333333"
GLineEdit_RIDE1a["justify"] = "center"
GLineEdit_RIDE1a["text"] = "0"
GLineEdit_RIDE1a["textvariable"] = "Ride1aVar"
GLineEdit_RIDE1a.place(x=851, y=36, width=105, height=25)
GLineEdit_RIDE1b = tk.Entry(f1)
GLineEdit_RIDE1b["borderwidth"] = "0px"
GLineEdit_RIDE1b["font"] = ebrima
GLineEdit_RIDE1b["fg"] = "#333333"
GLineEdit_RIDE1b["justify"] = "center"
GLineEdit_RIDE1b["text"] = "Entry"
GLineEdit_RIDE1b["textvariable"] = "Ride1bVar"
GLineEdit_RIDE1b.place(x=960, y=36, width=505, height=25)
# Frame 2 Page 2
# Frame f2
Labelh1 = tk.Label(f2, text='Auftrags Nr. 20', width='84', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh1.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh1.place(x='0', y='5')
Labelh2 = tk.Label(f2, text='Zahlen', width='10', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh2.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh2.place(x='850', y='5')
Labelh3 = tk.Label(f2, text='Kommentar', width='50', bg='#888888', fg='#eeeeee', font=ebrima)
Labelh3.pack(side='left', anchor='nw', padx=3, pady=5)
Labelh3.place(x='960', y='5')
# Eintrag
Labelr1 = tk.Label(f2, text='Auftrag Nr. xx', width='20', bg='#888888', fg='#eeeeee', font=ebrima)
Labelr1.pack(side='left', anchor='nw', padx=3, pady=5)
Labelr1.place(x='0', y='35')
Labelr1a = tk.Label(f2, text='TEL', width='5', bg='#888888', fg='#eeeeee', font=ebrima)
Labelr1a.pack(side='left', anchor='nw', padx=3, pady=5)
Labelr1a.place(x='210', y='35')
GCheckBox_RIDE21a = tk.Checkbutton(f2)
GCheckBox_RIDE21a["borderwidth"] = "0px"
GCheckBox_RIDE21a["font"] = ebrima
GCheckBox_RIDE21a["fg"] = "#000000"
GCheckBox_RIDE21a["justify"] = "left"
GCheckBox_RIDE21a["text"] = "erhalten"
GCheckBox_RIDE21a.place(x=280, y=36, width=120, height=26)
GCheckBox_RIDE21a["offvalue"] = "0"
GCheckBox_RIDE21a["onvalue"] = "1"
GCheckBox_RIDE21a["indicatoron"] = "0"
GCheckBox_RIDE21a["selectcolor"] = "#00ee00"
GCheckBox_RIDE21a["bg"] = "#ee0000"
#GCheckBox_RIDE21a["command"] = self.GCheckBox_RIDE21a_command
GCheckBox_RIDE21b = tk.Checkbutton(f2)
GCheckBox_RIDE21b["borderwidth"] = "0px"
GCheckBox_RIDE21b["font"] = ebrima
GCheckBox_RIDE21b["fg"] = "#000000"
GCheckBox_RIDE21b["justify"] = "left"
GCheckBox_RIDE21b["text"] = "weitergeleitet"
GCheckBox_RIDE21b.place(x=410, y=36, width=120, height=26)
GCheckBox_RIDE21b["offvalue"] = "0"
GCheckBox_RIDE21b["onvalue"] = "1"
GCheckBox_RIDE21b["indicatoron"] = "0"
GCheckBox_RIDE21b["selectcolor"] = "#00ee00"
GCheckBox_RIDE21b["bg"] = "#ee0000"
#GCheckBox_RIDE21b["command"] = self.GCheckBox_RIDE21b_command
GCheckBox_RIDE21c = tk.Checkbutton(f2)
GCheckBox_RIDE21c["borderwidth"] = "0px"
GCheckBox_RIDE21c["font"] = ebrima
GCheckBox_RIDE21c["fg"] = "#000000"
GCheckBox_RIDE21c["justify"] = "center"
GCheckBox_RIDE21c["text"] = "erledigt"
GCheckBox_RIDE21c.place(x=595, y=36, width=120, height=26)
GCheckBox_RIDE21c["offvalue"] = "0"
GCheckBox_RIDE21c["onvalue"] = "1"
GCheckBox_RIDE21c["indicatoron"] = "0"
GCheckBox_RIDE21c["selectcolor"] = "#00ee00"
GCheckBox_RIDE21c["bg"] = "#ee0000"
#GCheckBox_RIDE21c["command"] = self.GCheckBox_RIDE21c_command
GCheckBox_RIDE21d = tk.Checkbutton(f2)
GCheckBox_RIDE21d["borderwidth"] = "0px"
GCheckBox_RIDE21d["font"] = ebrima
GCheckBox_RIDE21d["fg"] = "#000000"
GCheckBox_RIDE21d["justify"] = "center"
GCheckBox_RIDE21d["text"] = "eingetragen"
GCheckBox_RIDE21d.place(x=725, y=36, width=120, height=26)
GCheckBox_RIDE21d["offvalue"] = "0"
GCheckBox_RIDE21d["onvalue"] = "1"
GCheckBox_RIDE21d["indicatoron"] = "0"
GCheckBox_RIDE21d["selectcolor"] = "#00ee00"
GCheckBox_RIDE21d["bg"] = "#ee0000"
#GCheckBox_RIDE21d["command"] = self.GCheckBox_RIDE21d_command
GLineEdit_RIDE21a = tk.Entry(f2)
GLineEdit_RIDE21a["borderwidth"] = "0px"
GLineEdit_RIDE21a["font"] = ebrima
GLineEdit_RIDE21a["fg"] = "#333333"
GLineEdit_RIDE21a["justify"] = "center"
GLineEdit_RIDE21a["text"] = "0"
GLineEdit_RIDE21a["textvariable"] = "RIDE21aVar"
GLineEdit_RIDE21a.place(x=851, y=36, width=105, height=25)
GLineEdit_RIDE21b = tk.Entry(f2)
GLineEdit_RIDE21b["borderwidth"] = "0px"
GLineEdit_RIDE21b["font"] = ebrima
GLineEdit_RIDE21b["fg"] = "#333333"
GLineEdit_RIDE21b["justify"] = "center"
GLineEdit_RIDE21b["text"] = "Entry"
GLineEdit_RIDE21b["textvariable"] = "RIDE21bVar"
GLineEdit_RIDE21b.place(x=960, y=36, width=505, height=25)
root.mainloop()