예제 #1
0
    def show_login_window(self):

        # declaring variables

        main = Main()
        main.__init__()

        lroot = Tk()
        lroot.grid()
        lroot.title = "Login"
        lroot.wm_title("Login")

        def login():
            name = usrname.get()
            passwd = usrpasswd.get()

            if self.login_attempts < self.max_login_attempts:
                if self.check(name, passwd):
                    print("User " + name + " logged in successfully")
                    lroot.destroy()
                    main.show_main()
                    print(self.login_attempts)
                else:
                    self.login_attempts += 1
                    print("User " + name + " cannot be logged in: Wrong username/password")
            else:
                print("User " + name + " cannot be logged in: Too much login attempts. Login blocked")

                # Adding elements to window

                # input fields

                # username

        lbusrname = Label(lroot, text="Username:"******"Passwort:")
        lbusrpasswd.grid(pady=1, padx=1, row=1, column=0)

        usrpasswd = Entry(lroot, show="*")
        usrpasswd.grid(pady=1, padx=1, row=1, column=1)

        # buttons

        # login
        btlogin = Button(lroot, text="Login", command=login)
        btlogin.grid(pady=1, padx=1, row=2, column=1, sticky="E")

        # closing the window
        btquit = QuitButton(lroot)
        btquit["text"] = "Schließen"
        btquit.grid(pady=1, padx=1, row=2, column=1, sticky="W")

        lroot.mainloop()
예제 #2
0
	def __init__(self):
		# creating the window
		pat = Tk()
		pat.geometry()
		pat.wm_title("Neuer Patient")
		pat.configure(width=855, height=500)

		# define variables
		sanis = []
		v_san1 = StringVar(pat)
		v_san2 = StringVar(pat)
		v_san3 = StringVar(pat)
		v_san4 = StringVar(pat)

		# methods

		def get_filename():
			filename = ""
			date = time.strftime("%Y%m%d_%H%M%S")

			filename += date
			filename += "_"

			for c in pat_name.get():
				if c.isalpha():
					filename += c

			filename += ".json"
			return filename

		def save_protocol():
			with open("__template.json") as json_data:
				data = json.load(json_data)
				json_data.close()

			data['Patient']['Name'] = pat_name.get()
			data['Patient']['Klasse'] = pat_class.get()
			data['Patient']['Beginn'] = time_arrive.get()
			data['Patient']['Ende'] = time_leave.get()
			data['Sanis']['Sani1'] = v_san1.get()
			data['Sanis']['Sani2'] = v_san2.get()
			data['Sanis']['Sani3'] = v_san3.get()
			data['Sanis']['Sani4'] = v_san4.get()
			with open(get_filename(), 'w') as f:
				json.dump(data, f, sort_keys=True)
				f.close()

			print("Protokoll unter ", get_filename(), " gespeichert.")

		def receive_message():
			# receive sent message from other instance of program and from unit in schools office
			print("Nachricht von [IP] empfangen")
			chat.insert(END, "[IP]: empfangene Nachricht")

		def send_message():
			print("Nachricht " + message.get() + " gesendet")
			chat.insert(END, "[Ich]: " + message.get() + "\n")
			# clear entry field with title message
			# write message into chat window: done

		def get_sanis():
			sanis.clear()
			with open("__sanis.json") as json_data:
				data = json.load(json_data)
				json_data.close()

			for a in data['Sanis']:
				sanis.append(a)

			sanis.sort()

			return sanis

		get_sanis()

		def sanchange(index, value, op):
			get_sanis()
			if v_san1.get() in sanis:
				sanis.remove(v_san1.get())
			if v_san2.get() in sanis:
				sanis.remove(v_san2.get())
			if v_san3.get() in sanis:
				sanis.remove(v_san3.get())
			if v_san4.get() in sanis:
				sanis.remove(v_san4.get())

			san1['values'] = sanis
			san2['values'] = sanis
			san3['values'] = sanis
			san4['values'] = sanis
			print(sanis)

		# window elements

		# inputs

		# name
		lbpat_name = Label(pat, text="Name:")
		lbpat_name.place(x=2, y=2)

		pat_name = Entry(pat)
		pat_name.place(x=44, y=2, width=200)

		# class
		lbpat_class = Label(pat, text="Klasse/Stufe:")
		lbpat_class.place(x=257, y=25)

		pat_class = Entry(pat)
		pat_class.place(x=338, y=25, width=223)

		# stayed time
		lbtime = Label(pat, text="Behandlungszeit (HH:MM):")
		lbtime.place(x=257, y=2)

		time_arrive = Entry(pat)
		time_arrive.place(x=424, y=2, width=50)

		lbbis = Label(pat, text="bis")
		lbbis.place(x=482, y=2)

		time_leave = Entry(pat)
		time_leave.place(x=512, y=2, width=50)

		# info field
		lbinfo = Label(pat, text="Informationen")
		lbinfo.place(x=577, y=2)

		info = Text(pat)
		info.place(x=577, y=25, width=275, height=150)

		# chat window
		lbchat = Label(pat, text="Kommunikation")
		lbchat.place(x=577, y=180)

		chat = Text(pat)
		chat.place(x=577, y=203, width=275, height=210)

		lbmessage = Label(pat, text="Nachricht:")
		lbmessage.place(x=577, y=421)

		message = Entry(pat)
		message.place(x=577, y=444, width=200)

		# first responsers

		lbsan1 = Label(pat, text="Sanitäter 1:")
		lbsan1.place(x=2, y=25)

		# san1 = Entry(pat)
		# san1.place(x=77, y=25)

		san1 = ttk.Combobox(pat, values=sanis, textvar=v_san1)
		san1.place(x=77, y=25)

		lbsan2 = Label(pat, text="Sanitäter 2:")
		lbsan2.place(x=2, y=48)

		# san2 = Entry(pat)
		# san2.place(x=77, y=48)

		san2 = ttk.Combobox(pat, values=sanis, textvar=v_san2)
		san2.place(x=77, y=48)

		lbsan3 = Label(pat, text="Sanitäter 3:")
		lbsan3.place(x=2, y=71)

		# san3 = Entry(pat)
		# san3.place(x=77, y=71)

		san3 = ttk.Combobox(pat, values=sanis, textvar=v_san3)
		san3.place(x=77, y=71)

		lbsan4 = Label(pat, text="Sanitäter 4:")
		lbsan4.place(x=2, y=94)

		# san4 = Entry(pat)
		# san4.place(x=77, y=94)

		san4 = ttk.Combobox(pat, values=sanis, textvar=v_san4)
		san4.place(x=77, y=94)

		# buttons

		# button for saving current protocol
		btpat_save = Button(pat, text="Protokoll speichern", command=save_protocol)
		btpat_save.place(x=709, y=467)

		# button for closing the window
		btpat_quit = QuitButton(pat)
		btpat_quit['text'] = "Schließen"
		btpat_quit.place(x=619, y=467)

		# button for sending chat message
		btsenden = Button(pat, text=">>", command=send_message)
		btsenden.place(x=780, y=444, width=72, height=20)

		# calling callback functions on change

		v_san1.trace('w', sanchange)
		v_san2.trace('w', sanchange)
		v_san3.trace('w', sanchange)
		v_san4.trace('w', sanchange)
예제 #3
0
    def __init__(self):
        # creating the window
        san = Tk()
        san.geometry()
        san.wm_title("Sanitäter verwalten")
        san.configure(width=700, height=800)
        canvas = Canvas(san, width=700, height=800)
        canvas.place(x=0, y=0)
        canvas.create_line(180, 5, 180, 795, fill="grey", tags="line")
        canvas.create_line(5, 155, 180, 155, fill="grey", tags="line")

        def save_new_sani():
            with open("__sanis.json") as jsond:
                jdata = json.load(jsond)
                jsond.close()

            jdata["Sanis"][sanadd_name.get()] = sanadd_class.get()
            with open("__sanis.json", "w") as f:
                json.dump(jdata, f, sort_keys=True)
                f.close()

            sanis_show()
            print("Sanitäter-Datei aktualisiert.")

        def delete_sani():
            with open("__sanis.json") as jsondata:
                datajson = json.load(jsondata)
                jsondata.close()

            del datajson["Sanis"][san_del.get()]

            with open("__sanis.json", "w") as g:
                json.dump(datajson, g, sort_keys=True)
                g.close()

            sanis_show()
            print(san_del.get() + " gelöscht")

        def sanis_show():
            san_show.delete(1.0, END)
            with open("__sanis.json") as jsond:
                jdata = json.load(jsond)
                jsond.close()

            san_show.insert(END, "Name des Sanitäters\t\t\t\t\tKlasse/Stufe\n")
            san_show.insert(END, "----------------------------------------------------\n")
            for key in sorted(jdata["Sanis"].keys()):
                san_show.insert(END, key + "\t\t\t\t\t     " + jdata["Sanis"][key] + "\n")

        with open("__sanis.json") as json_data:
            data = json.load(json_data)
            json_data.close()

        sanis = []

        for a in data["Sanis"]:
            sanis.append(a)

        sanis.sort()
        print(sanis)

        # section for adding a first responder

        lbsanadd_caption = Label(san, text="Sanitäter hinzufügen", font="bald")
        lbsanadd_caption.place(x=2, y=2)

        lbsanadd_name = Label(san, text="Name: ")
        lbsanadd_name.place(x=2, y=25)

        sanadd_name = Entry(san)
        sanadd_name.place(x=2, y=48)

        lbsanadd_class = Label(san, text="Klasse: ")
        lbsanadd_class.place(x=2, y=71)

        sanadd_class = Entry(san)
        sanadd_class.place(x=2, y=94)

        btsanadd_save = Button(san, text="Speichern", command=save_new_sani)
        btsanadd_save.place(x=2, y=117)

        # section for deleting a first responder

        lbsandel_caption = Label(san, text="Sanitäter entfernen", font="bold")
        lbsandel_caption.place(x=2, y=160)

        san_del = ttk.Combobox(san, values=sanis)
        san_del.place(x=2, y=183)

        btsan_del = Button(san, text="Entfernen", command=delete_sani)
        btsan_del.place(x=2, y=206)

        # TODO: Add a combobox for displaying all first responders. Disable edit function!

        # section for editing an existing first responder

        # TODO: Add a form for editing a first responder

        # section for displaying all first responders present in the file

        lbsan_show = Label(san, text="Sanitäter anzeigen", font="bold")
        lbsan_show.place(x=190, y=2)

        san_show = Text(san)
        san_show.place(x=190, y=25, width=500, height=730)
        sanis_show()

        # quitbutton
        btsan_quit = QuitButton(san)
        btsan_quit["text"] = "Schließen"
        btsan_quit.place(x=610, y=767)