mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
Remove redundant code
This commit is contained in:
parent
7f6c28488d
commit
7cca099699
86
prefs.py
86
prefs.py
@ -532,89 +532,3 @@ class PreferencesDialog(tk.Toplevel):
|
||||
except:
|
||||
AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})
|
||||
self.parent.event_generate('<<Quit>>', 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("<Return>", 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('<Return>', 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user