Commit 35ea2784 authored by tobias.dussa's avatar tobias.dussa

Merge branch 'master' into Windows

parents c5aa5566 36b22493
......@@ -4,7 +4,51 @@
from OpenSSL import crypto, SSL
from os.path import basename, dirname, isfile, splitext
from sys import exit
from tkinter import Tk, filedialog, messagebox, simpledialog
from tkinter import Button, E, Entry, Label, LEFT, Tk, W, filedialog, messagebox, simpledialog
# Define password query dialog
class _QueryPasswordDialog(simpledialog._QueryDialog):
def body(self, master):
w = Label(master, text=self.prompt, justify=LEFT)
w.grid(row=0, padx=5, sticky=W)
self.entry = Entry(master, name="entry")
self.entry.grid(row=1, padx=5, sticky=W+E)
self.toggle = Button(master, text="⚷", command=self.toggleShow)
self.toggle.grid(row=1, padx=5, column=1, sticky=W+E)
if self.initialvalue is not None:
self.entry.insert(0, self.initialvalue)
self.entry.select_range(0, END)
return self.entry
def toggleShow(self):
if self.entry["show"] == "":
self.entry["show"] = "●"
else:
self.entry["show"] = ""
class _QueryPassword(_QueryPasswordDialog):
def __init__(self, *args, **kw):
if "show" in kw:
self.__show = kw["show"]
del kw["show"]
else:
self.__show = "●"
_QueryPasswordDialog.__init__(self, *args, **kw)
def body(self, master):
entry = _QueryPasswordDialog.body(self, master)
if self.__show is not None:
entry.configure(show=self.__show)
return entry
def askpassword(title, prompt, **kw):
d = _QueryPassword(title, prompt, **kw)
return d.result
# Create and hide root window
......@@ -28,7 +72,7 @@ while True:
# Read password
while True:
password = simpledialog.askstring('Passworteingabe', 'Passwort des geheimen Schlüssels:')
password = askpassword('Passworteingabe', 'Passwort des geheimen Schlüssels:')
if password is None:
messagebox.showinfo('Abbruch', 'Die Passworteingabe wurde abgebrochen!')
exit(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment