From 7cca099699c94ae5a1d250c36980c7b153dc66c2 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Sat, 5 Jan 2019 17:35:16 +0000 Subject: [PATCH] Remove redundant code --- prefs.py | 86 -------------------------------------------------------- 1 file changed, 86 deletions(-) diff --git a/prefs.py b/prefs.py index 71079a89..45ad41fa 100644 --- a/prefs.py +++ b/prefs.py @@ -532,89 +532,3 @@ class PreferencesDialog(tk.Toplevel): except: AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True}) self.parent.event_generate('<>', when="tail") - - -class AuthenticationDialog(tk.Toplevel): - - def __init__(self, parent, callback): - tk.Toplevel.__init__(self, parent) - - self.parent = parent - self.callback = callback - self.title('Authentication') - - if parent.winfo_viewable(): - self.transient(parent) - - # position over parent - if platform!='darwin' or parent.winfo_rooty()>0: # http://core.tcl.tk/tk/tktview/c84f660833546b1b84e7 - self.geometry("+%d+%d" % (parent.winfo_rootx(), parent.winfo_rooty())) - - # remove decoration - self.resizable(tk.FALSE, tk.FALSE) - if platform=='win32': - self.attributes('-toolwindow', tk.TRUE) - elif platform=='darwin': - # http://wiki.tcl.tk/13428 - parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility') - - frame = ttk.Frame(self) - frame.grid(sticky=tk.NSEW) - frame.columnconfigure(0, weight=3) - frame.columnconfigure(2, weight=1) - - ttk.Label(frame, text=_('A verification code has now been sent to the{CR}email address associated with your Elite account.') + # Use same text as E:D Launcher's verification dialog - - '\n' + - _('Please enter the code into the box below.'), anchor=tk.W, justify=tk.LEFT).grid(columnspan=4, sticky=tk.NSEW) # Use same text as E:D Launcher's verification dialog - ttk.Label(frame).grid(row=1, column=0) # spacer - self.code = ttk.Entry(frame, width=8, validate='key', validatecommand=(self.register(self.validatecode), '%P', '%d', '%i', '%S')) - self.code.grid(row=1, column=1) - self.code.focus_set() - ttk.Label(frame).grid(row=1, column=2) # spacer - self.button = ttk.Button(frame, text=_('OK'), command=self.apply, state=tk.DISABLED) - self.button.bind("", lambda event:self.apply()) - self.button.grid(row=1, column=3, sticky=tk.E) - - for child in frame.winfo_children(): - child.grid_configure(padx=5, pady=5) - - self.protocol("WM_DELETE_WINDOW", self._destroy) - - # wait for window to appear on screen before calling grab_set - self.parent.wm_attributes('-topmost', 0) # needed for dialog to appear ontop of parent on OSX & Linux - self.wait_visibility() - self.grab_set() - - # Ensure fully on-screen - if platform == 'win32': - position = RECT() - GetWindowRect(GetParent(self.winfo_id()), position) - if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()), - SIZE(position.right - position.left, position.bottom - position.top), - 0x10000, None, position): - self.geometry("+%d+%d" % (position.left, position.top)) - - self.bind('', self.apply) - - - def validatecode(self, newval, ins, idx, diff): - self.code.selection_clear() - self.code.delete(0, tk.END) - self.code.insert(0, newval.upper()) - self.code.icursor(int(idx) + (int(ins)>0 and len(diff) or 0)) - self.after_idle(lambda: self.code.config(validate='key')) # http://tcl.tk/man/tcl8.5/TkCmd/entry.htm#M21 - self.button['state'] = len(newval.strip())==5 and tk.NORMAL or tk.DISABLED - return True - - def apply(self, event=None): - code = self.code.get().strip() - if len(code) == 5: - self.parent.wm_attributes('-topmost', config.getint('always_ontop') and 1 or 0) - self.destroy() - if self.callback: self.callback(code) - - def _destroy(self): - self.parent.wm_attributes('-topmost', config.getint('always_ontop') and 1 or 0) - self.destroy() - if self.callback: self.callback(None)