so ich habe jetzt mal versucht deine Tastatur in mein Programm zu intigrieren genauso wie ich probiert habe das "from TKInter import *" in eine "import tkinter as tk"
zu ändern.
.... jetzt geht gar nichts mehr das Problem ist durch YouTube Videos lernt man echt nicht gut und wenn dann nur diese eine gezeigte Nische.
könnt ihr bitte bitte mal drüber schauen wo mein Fehler ist und mir bitte erklären warum und wie dieser Fehler ist. und ja ich weiss ich habe noch viel was an dem code verbesserd werden muss zb alle entry und alle... alles andere.
Ja ich weiß ich habe versucht eine code von einem Profi in einem Code von einem Noob (mir) zu intigrieren, aber das muss ich ja auch erst alles verstehen und lernen
Code: Alles auswählen
import tkinter as tk
from tkinter import ttk
from functools import partial
#from gpiozero import LED
from time import *
import tester
#############################################
############### useradd Fenster #############
def useradd_funk():
keyboard=Toplevel(root)
keyboard.title("useradd_keyboard")
keyboard.geometry("600x800")
KEYS= [
('a', 40, 60),
('b', 230, 110),
('c', 130, 110),
('d', 140, 60),
('e', 130, 10),
('f', 190, 60),
('g', 240, 60),
('h', 290, 60),
('i', 380, 10),
('j', 340, 60),
('k', 390, 60),
('l', 440, 60),
('m', 330, 110),
('n', 280, 110),
('o', 430, 10),
('p', 480, 10),
('q', 30, 10),
('r', 180, 10),
('s', 90, 60),
('t', 230, 10),
('u', 330, 10),
('v', 180, 110),
('w', 80, 10),
('x', 80, 110),
('y', 30, 110),
('z', 280, 10),
('ä', 530, 10),
('ö', 490, 60),
('ü', 540, 60)
]
class Keyboard(tk.useradd_funk):
def __init__(self, root):
tk.useradd_funk.__init__(self, root, width=600, height=160)
self.focused_widget = None
for letter, x, y in KEYS:
key = tk.Button(self, text=letter, command=partial(self.type, letter), width="3", height="1", bg="grey", font=("AcmeFont",15))
key.place(x=x, y=y)
keyspace = tk.Button(self,text="Space", command=partial(self.type, " "), width="9", height="1", bg="grey", font=("AcmeFont",15))
keyspace.place(x=380, y=110)
keyback = tk.Button(self,text="<-- ", command=self.backspace, width="6", height="1", bg="grey", font=("AcmeFont",15))
keyback.place(x=503, y=110)
def type(self, letter):
if self.focused_widget:
self.focused_widget.insert(tk.END, letter)
def backspace(self):
if self.focused_widget:
self.focused_widget.delete(1, tk.END)
def set_focus(self, event):
self.focused_widget = event.widget
def release_focus(self, event):
self.focused_widget = None
def main():
root = tk.Tk()
name_field = tk.Entry(root, width="30", font=("AcmeFont",15))
name_field.pack()
name_field = tk.Entry(root, width="30", font=("AcmeFont",15))
name_field.pack()
keyboard = Keyboard(root)
keyboard.pack()
root.bind("<FocusIn>", keyboard.set_focus)
root.bind("<FocusOut>", keyboard.release_focus)
root.mainloop()
if __name__ == '__main__':
main()
def checkbox_check():
if Checkbox_checkt.get():
infinity_open_check["text"]="Unbegrenzter Zugang"
montag_h_min.config(state="disable")
montag_m_min.config(state="disable")
montag_h_max.config(state="disable")
montag_m_max.config(state="disable")
dienstag_h_min.config(state="disable")
dienstag_m_min.config(state="disable")
dienstag_h_max.config(state="disable")
dienstag_m_max.config(state="disable")
mittwoch_h_min.config(state="disable")
mittwoch_m_min.config(state="disable")
mittwoch_h_max.config(state="disable")
mittwoch_m_max.config(state="disable")
donnerstag_h_min.config(state="disable")
donnerstag_m_min.config(state="disable")
donnerstag_h_max.config(state="disable")
donnerstag_m_max.config(state="disable")
freitag_h_min.config(state="disable")
freitag_m_min.config(state="disable")
freitag_h_max.config(state="disable")
freitag_m_max.config(state="disable")
samstag_h_min.config(state="disable")
samstag_m_min.config(state="disable")
samstag_h_max.config(state="disable")
samstag_m_max.config(state="disable")
sonntag_h_min.config(state="disable")
sonntag_m_min.config(state="disable")
sonntag_h_max.config(state="disable")
sonntag_m_max.config(state="disable")
montag_menu.config(state="disable")
dienstag_menu.config(state="disable")
mittwoch_menu.config(state="disable")
donnerstag_menu.config(state="disable")
freitag_menu.config(state="disable")
samstag_menu.config(state="disable")
sonntag_menu.config(state="disable")
label_montag.config(state="disable")
label_dienstag.config(state="disable")
label_mittwoch.config(state="disable")
label_donnerstag.config(state="disable")
label_freitag.config(state="disable")
label_samstag.config(state="disable")
label_sonntag.config(state="disable")
label_string_1.config(state="disable")
label_string_2.config(state="disable")
label_string_3.config(state="disable")
label_string_4.config(state="disable")
label_string_5.config(state="disable")
label_string_6.config(state="disable")
label_string_7.config(state="disable")
else:
infinity_open_check["text"]="Begrenzter Zugang"
montag_h_min.config(state="normal")
montag_m_min.config(state="normal")
montag_h_max.config(state="normal")
montag_m_max.config(state="normal")
dienstag_h_min.config(state="normal")
dienstag_m_min.config(state="normal")
dienstag_h_max.config(state="normal")
dienstag_m_max.config(state="normal")
mittwoch_h_min.config(state="normal")
mittwoch_m_min.config(state="normal")
mittwoch_h_max.config(state="normal")
mittwoch_m_max.config(state="normal")
donnerstag_h_min.config(state="normal")
donnerstag_m_min.config(state="normal")
donnerstag_h_max.config(state="normal")
donnerstag_m_max.config(state="normal")
freitag_h_min.config(state="normal")
freitag_m_min.config(state="normal")
freitag_h_max.config(state="normal")
freitag_m_max.config(state="normal")
samstag_h_min.config(state="normal")
samstag_m_min.config(state="normal")
samstag_h_max.config(state="normal")
samstag_m_max.config(state="normal")
sonntag_h_min.config(state="normal")
sonntag_m_min.config(state="normal")
sonntag_h_max.config(state="normal")
sonntag_m_max.config(state="normal")
montag_menu.config(state="normal")
dienstag_menu.config(state="normal")
mittwoch_menu.config(state="normal")
donnerstag_menu.config(state="normal")
freitag_menu.config(state="normal")
samstag_menu.config(state="normal")
sonntag_menu.config(state="normal")
label_montag.config(state="normal")
label_dienstag.config(state="normal")
label_mittwoch.config(state="normal")
label_donnerstag.config(state="normal")
label_freitag.config(state="normal")
label_samstag.config(state="normal")
label_sonntag.config(state="normal")
label_string_1.config(state="normal")
label_string_2.config(state="normal")
label_string_3.config(state="normal")
label_string_4.config(state="normal")
label_string_5.config(state="normal")
label_string_6.config(state="normal")
label_string_7.config(state="normal")
return
Checkbox_checkt=IntVar()
day_options = ["keinzugang","Unbegrenzt","benutzerdefiniert"]
monvar= StringVar()
monvar.set("keinzugang")
dievar= StringVar()
dievar.set("keinzugang")
mitvar= StringVar()
mitvar.set("keinzugang")
donvar= StringVar()
donvar.set("keinzugang")
frevar= StringVar()
frevar.set("keinzugang")
samvar= StringVar()
samvar.set("keinzugang")
sonvar= StringVar()
sonvar.set("keinzugang")
montag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
montag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
montag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
montag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
dienstag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
dienstag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
dienstag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
dienstag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
mittwoch_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
mittwoch_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
mittwoch_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
mittwoch_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
donnerstag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
donnerstag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
donnerstag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
donnerstag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
freitag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
freitag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
freitag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
freitag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
samstag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
samstag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
samstag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
samstag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
sonntag_h_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
sonntag_m_min=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
sonntag_h_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
sonntag_m_max=tk.Entry(keyboard,width="2",font=("AcmeFont",20),state="normal")
montag_menu=tk.OptionMenu(keyboard, monvar, *day_options)
dienstag_menu=tk.OptionMenu(keyboard, dievar, *day_options)
mittwoch_menu=tk.OptionMenu(keyboard, mitvar, *day_options)
donnerstag_menu=tk.OptionMenu(keyboard, donvar, *day_options)
freitag_menu=tk.OptionMenu(keyboard, frevar, *day_options)
samstag_menu=tk.OptionMenu(keyboard, samvar, *day_options)
sonntag_menu=tk.OptionMenu(keyboard, sonvar, *day_options)
label_montag=tk.tk.Label(keyboard,text="Montag",font=("AcmeFont",15),state="normal")
label_dienstag=tk.tk.Label(keyboard,text="Dienstag",font=("AcmeFont",15),state="normal")
label_mittwoch=tk.tk.Label(keyboard,text="Mittwoch",font=("AcmeFont",15),state="normal")
label_donnerstag=tk.tk.Label(keyboard,text="Donnerstag",font=("AcmeFont",15),state="normal")
label_freitag=tk.tk.Label(keyboard,text="Freitag",font=("AcmeFont",15),state="normal")
label_samstag=tk.tk.Label(keyboard,text="Samstag",font=("AcmeFont",15),state="normal")
label_sonntag=tk.tk.Label(keyboard,text="Sonntag",font=("AcmeFont",15),state="normal")
label_string_1=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_2=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_3=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_4=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_5=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_6=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
label_string_7=tk.Label(keyboard,text="-",font=("AcmeFont",20),state="normal")
infinity_open_check=tk.Checkbutton(keyboard,text="Begrenzter Zugang",variable=Checkbox_checkt,command=checkbox_check)
name_field=tk.Entry(keyboard,width="30",font=("AcmeFont",15))
########## Keyboard ############
label_string_1.place(x=390,y=290)
label_string_2.place(x=390,y=330)
label_string_3.place(x=390,y=370)
label_string_4.place(x=390,y=410)
label_string_5.place(x=390,y=450)
label_string_6.place(x=390,y=490)
label_string_7.place(x=390,y=530)
montag_h_min.place(x=300,y=290)
montag_m_min.place(x=340,y=290)
montag_h_max.place(x=420,y=290)
montag_m_max.place(x=460,y=290)
dienstag_h_min.place(x=300,y=330)
dienstag_m_min.place(x=340,y=330)
dienstag_h_max.place(x=420,y=330)
dienstag_m_max.place(x=460,y=330)
mittwoch_h_min.place(x=300,y=370)
mittwoch_m_min.place(x=340,y=370)
mittwoch_h_max.place(x=420,y=370)
mittwoch_m_max.place(x=460,y=370)
donnerstag_h_min.place(x=300,y=410)
donnerstag_m_min.place(x=340,y=410)
donnerstag_h_max.place(x=420,y=410)
donnerstag_m_max.place(x=460,y=410)
freitag_h_min.place(x=300,y=450)
freitag_m_min.place(x=340,y=450)
freitag_h_max.place(x=420,y=450)
freitag_m_max.place(x=460,y=450)
samstag_h_min.place(x=300,y=490)
samstag_m_min.place(x=340,y=490)
samstag_h_max.place(x=420,y=490)
samstag_m_max.place(x=460,y=490)
sonntag_h_min.place(x=300,y=530)
sonntag_m_min.place(x=340,y=530)
sonntag_h_max.place(x=420,y=530)
sonntag_m_max.place(x=460,y=530)
montag_menu.place(x=170,y=290)
dienstag_menu.place(x=170,y=330)
mittwoch_menu.place(x=170,y=370)
donnerstag_menu.place(x=170,y=410)
freitag_menu.place(x=170,y=450)
samstag_menu.place(x=170,y=490)
sonntag_menu.place(x=170,y=530)
label_montag.place(x=30,y=290)
label_dienstag.place(x=30,y=330)
label_mittwoch.place(x=30,y=370)
label_donnerstag.place(x=30,y=410)
label_freitag.place(x=30,y=450)
label_samstag.place(x=30,y=490)
label_sonntag.place(x=30,y=530)
infinity_open_check.place(x=300,y=100)
name_field.place(x=50,y=150)
#############################################
############### user Fenster #############330
######### Notizen ###########
#ttk.Treeview ausprobieren
def user():
userlist=Toplevel(root) #Neues Fenster öffnen
userlist.title("Smartdoor")
userlist.geometry("600x800")
userlist.attributes('-fullscreen',False) #Vollbild
#Benutzer buttons und Funktionen
useradd = tk.Button(userlist,text="+",command=useradd_funk,width="3",height="1",bg="grey",font=("AcmeFont",50))
useradd.place(x=15,y=15)
#############################################
########## Settings Fenster #################
def settings():
settings=Toplevel(root) #Neues Fenster öffnen
settings.title("Smartdoor")
settings.geometry("600x800")
settings.attributes('-fullscreen',False) #Vollbild
#Funktionen Settings
def back():
settings.destroy()
def themes():
print("test")
#Buttons Settings
userbut = tk.Button(settings,text="Benutzer",command=user,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
themesbut = tk.Button(settings,text="Themes",command=themes,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
backbut = tk.Button(settings,text="zurück",command=back,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
userbut.pack()
themesbut.pack()
backbut.pack()
#######################################
############ root Fenster #############
root = Tk()
root.title("Smartdoor")
root.geometry("600x800")
root.attributes('-fullscreen',False) #Vollbild
#Funktionen root
def spycam():
print("ich sehe dich")
def lock():
if lockbut["text"] == "Abschließen":
lockbut["text"] = "Aufschließen"
else:
lockbut["text"] = "Abschließen"
def beenden():
root.destroy()
#Buttons root
settingsbutton=tk.Button(root,text="Einstellungen",command=settings,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
settingsbutton.pack()
lockbut=tk.Button(root,text="Abschließen",command=lambda:[lock()],height = 1,width = 20,bd=8,relief="raised",font="Times 32")
lockbut.pack()
spybut=tk.Button(root,text="Türspion",command=spycam,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
spybut.pack()
beenden=tk.Button(root,text="Schließen",command=beenden,height = 1,width = 20,bd=8,relief="raised",font="Times 32")
beenden.pack()
mainloop()