def plugin_prefs(parent, cmdr, is_beta): """ Return a TK Frame for adding to the EDMC settings dialog. """ PADX = 5 PADY = 2 frame = nb.Frame(parent) frame.columnconfigure(1, weight=1) def select_route_file_handler(): """ Handle Select Route File button click event """ file_selection = tkFileDialog.askopenfilename(filetypes=[("Supported files","*.csv *.txt"),("CSV files","*.csv"),("Text files","*.txt"),("All files","*.*")]) if file_selection: this.route_file_location_setting.set(file_selection) load_systems() def clear_route_file_handler(): """ Handle Clear Route File button click event """ this.route_file_location_setting.set("") load_systems() nb.Label(frame, text="Route File Location: ").grid(row=0, padx=PADX, pady=PADY, sticky=tk.E) nb.Entry(frame, textvariable=this.route_file_location_setting).grid(row=0, column=1, sticky=tk.EW) nb.Button(frame, text="Select Route File", command=select_route_file_handler).grid(row=0, column=2, columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) nb.Button(frame, text="Clear Route File", command=clear_route_file_handler).grid(row=1, column=2, columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(frame, text="Route: ").grid(row=2, padx=PADX, pady=PADY, sticky=tk.NE) nb.Label(frame, textvariable=this.systems_label_text).grid(row=2, column=1, columnspan=2, sticky=tk.EW) return frame
def __populate_plugin_prefs_frame(self, frame): "Populate the frame for ``plugin_prefs``." for widget in frame.winfo_children(): # In case we're called again widget.destroy() frame.columnconfigure(0, weight=1) topline = nb.Frame(frame) topline.grid(row=0, sticky=tk.W) HyperlinkLabel(topline, text="Hutton Helper", background=nb.Label().cget('background'), url='https://hot.forthemug.com/', underline=True).grid(row=0, column=0) nb.Label(topline, text="Lite version {}".format(HH_VERSION)).grid(row=0, column=1) self.automatic_intvar = tk.IntVar(value=self.cfg_auto) nb.Checkbutton(frame, text="Update automatically", variable=self.automatic_intvar).grid(row=1, sticky=tk.W) if self.updated: nb.Label(frame, text=HH_TEXT_UPDATED).grid( row=2, sticky=tk.W) # str(self) == self.__str__() elif self.remote_version is None: nb.Label(frame, text=HH_TEXT_VERSION_CHECK_FAILED, fg='dark red').grid(row=2, sticky=tk.W) button = nb.Button( frame, text="Check Again", command=lambda: self.__again_callback(frame, button)) button.grid(row=3, sticky=tk.W) elif self.remote_version > HH_VERSION: text = HH_TEXT_UPDATE_AVAILABLE.format( remote_version=self.remote_version) nb.Label(frame, text=text, fg='dark green').grid(row=2, sticky=tk.W) button = nb.Button( frame, text="UPDATE", command=lambda: self.__upgrade_callback(frame, button)) button.grid(row=3, sticky=tk.W) else: nb.Label(frame, text="You're up to date. Fly safe!").grid(row=2, sticky=tk.W) return frame
def plugin_prefs(parent, cmdr, is_beta): frame = nb.Frame(parent) nb.Label(frame, text="Select types of location you want to visit").grid( sticky=tk.W, row=0, column=0, columnspan=2) this.settings = {} this.types = {} selected = config.get("matgrindr.selected") or [] types = config.get("matgrindr.types") or [] c = 0 debug("Types: " + str(this.mats.types())) for type in this.mats.types(): this.types[type] = tk.IntVar() this.types[type].set(1 if type in types else 0) chk = nb.Checkbutton(frame, text=type, variable=this.types[type]).grid(sticky=tk.W, row=1 + c // 2, column=c % 2, columnspan=2) c = c + 1 c = c + 2 - (c % 2) ttk.Separator(frame, orient=tk.HORIZONTAL).grid(row=1 + c // 2, columnspan=2, padx=10, pady=2, sticky=tk.EW) c = c + 2 - (c % 2) nb.Label(frame, text="Select materials you want").grid(sticky=tk.W, row=1 + c // 2, column=c % 2) c = c + 2 - (c % 2) debug("Mats: " + str(this.mats.names())) for mat in this.mats.names(): this.settings[mat] = tk.IntVar() this.settings[mat].set(1 if mat in selected else 0) chk = nb.Checkbutton(frame, text=mat, variable=this.settings[mat]).grid(sticky=tk.W, row=1 + c // 2, column=c % 2) c = c + 1 c = c + 2 nb.Button(frame, text="Select All", command=select_all).grid(sticky=tk.W, row=c // 2, column=0) nb.Button(frame, text="Select None", command=select_none).grid(sticky=tk.W, row=c // 2, column=1) return frame
def plugin_prefs(parent, cmdr, is_beta): PADX = 5 frame = nb.Frame(parent) frame.columnconfigure(0, weight=1) nb.Checkbutton(frame, variable=this.edsmBodyCheck, text="Display number of bodies known to EDSM in current system").grid(padx=PADX, sticky=tk.W) # enable projects ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PADX * 2, pady=8, sticky=tk.EW) nb.Label(frame, text="Please choose which projects to enable").grid(padx=PADX, sticky=tk.W) for rseProject in this.rseData.projects_dict.values(): invertedFlag = not (this.rseData.ignored_projects_flags & rseProject.project_id == rseProject.project_id) variable = this.ignoredProjectsCheckboxes.setdefault(rseProject.project_id, tk.BooleanVar(value=invertedFlag)) text = rseProject.name if not rseProject.enabled: text += " (globally disabled)" nb.Checkbutton(frame, variable=variable, text=text).grid(padx=PADX, sticky=tk.W) nb.Label(frame, text=rseProject.explanation).grid(padx=PADX * 4, sticky=tk.W) # overwrite disabled state when EDDN/EDSM is off in EDMC ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PADX * 2, pady=8, sticky=tk.EW) nb.Checkbutton(frame, variable=this.clipboard, text="Copy system name to clipboard after jump").grid(padx=PADX, sticky=tk.W) nb.Checkbutton(frame, variable=this.overwrite, text="I use another tool to transmit data to EDSM/EDDN").grid(padx=PADX, sticky=tk.W) # clear caches ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PADX * 2, pady=8, sticky=tk.EW) nb.Label(frame, text="Clear caches").grid(padx=PADX, sticky=tk.W) clearCachesFrame = nb.Frame(frame) clearCachesFrame.grid(padx=PADX * 2, pady=8, sticky=tk.EW) frame.columnconfigure(2, weight=1) nb.Button(clearCachesFrame, text="Fully scanned systems", command=lambda: clear_scanned_systems_cache_callback(RseData.CACHE_FULLY_SCANNED_BODIES, "fully scanned systems"))\ .grid(padx=PADX, sticky=tk.W, row=0, column=0) nb.Button(clearCachesFrame, text="Ignored systems", command=lambda: clear_scanned_systems_cache_callback(RseData.CACHE_IGNORED_SYSTEMS, "ignored systems")) \ .grid(padx=PADX, sticky=tk.W, row=0, column=1) # links ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PADX * 2, pady=8, sticky=tk.EW) nb.Label(frame, text="Plugin Version: {}".format(RseData.VERSION)).grid(padx=PADX, sticky=tk.W) if not this.edmc_has_logging_support: nb.Checkbutton(frame, variable=this.debug, text="Verbose Logging").grid(padx=PADX, sticky=tk.W) HyperlinkLabel(frame, text="Open the Github page for this plugin", background=nb.Label().cget("background"), url="https://github.com/Thurion/EDSM-RSE-for-EDMC", underline=True).grid(padx=PADX, sticky=tk.W) HyperlinkLabel(frame, text="A big thanks to EDTS for providing the coordinates.", background=nb.Label().cget("background"), url="http://edts.thargoid.space/", underline=True).grid(padx=PADX, sticky=tk.W) return frame
def plugin_prefs(parent: nb.Notebook, cmdr: str, is_beta: bool) -> Optional[tk.Frame]: """ Return a TK Frame for adding to the EDMC settings dialog. """ frame = nb.Frame(parent) frame.columnconfigure(0, weight=1) test_snd = nb.Button(frame, text="Test Sound") test_snd.grid(sticky=tk.W) test_snd.config(command=test_sound_func) scale = tk.Scale(frame, from_=1, to=150, variable=this.sound_value, length=250, showvalue=1, label="Sound Volume", orient=tk.HORIZONTAL) scale.set(this.sound_value.get()) scale.grid(sticky=tk.W) nb.Checkbutton(frame, text="No Sound on 1st In Route", variable=this.no_sound_on1st_route).grid(sticky=tk.W) # Retrieve saved value from config loadConfigValues() return frame
def journal_entry(cmdr, is_beta, system, station, entry, state): ############################# # # FSDJump happens often enough in the journal to use for debugging purposes. if entry['event'] == 'FSDJump': # We arrived at a new system! sys.stderr.write("(Debug) Arrived at: {}\n".format( entry['StarSystem'])) status.set("(Debug) Arrived at: {}\n".format(entry['StarSystem'])) ############################## # # What we're really after are unique discoveries. if entry['event'] == 'CodexDiscovery': # We discovered something! # Lines 111, and 112 might not work the way I think they should. I don't know "tuple" well. sys.stderr.write("{} Discovered on {},{}\n".format( entry['Discovered'], ['System'], ['Body'])) status.set("{} Discovered on {},{}\n".format(entry['Discovered'], ['System'], ['Body'])) nb.Label(frame).grid() # spacer nb.Button(frame, text="Submit Discovery Report", command=bulletin_callback).grid(row=10, column=0, columnspan=2, padx=PADX, sticky=tk.W)
def setup_preferences(self, parent: nB.Notebook, cmdr: str, is_beta: bool) -> Optional[tk.Frame]: current_row = 0 frame = nB.Frame(parent) frame.grid_columnconfigure(0, weight=1) nB.Label(frame, text="Load List").grid(padx=10, pady=(10, 0), row=current_row, sticky="w") current_row += 1 self.lb = tk.Listbox(frame) self.lb.grid(padx=10, pady=8, row=current_row, sticky="nsew") self.refresh_list() current_row += 1 button_frame = nB.Frame(frame) button_frame.grid(row=current_row) nB.Button(button_frame, text="Add", command=self.add_program).grid(row=0, column=0) nB.Button(button_frame, text="Delete", command=self.del_program).grid(row=0, column=1) nB.Button(button_frame, text="Launch All", command=self.run_programs).grid(row=0, column=2) current_row += 1 nB.Label( frame, text=f"EDMC Autoloader {PLUGIN_VERSION} by CMDR Blocker226").grid( padx=10, pady=(20, 0), row=current_row, sticky="w") current_row += 1 HyperlinkLabel(frame, text='https://github.com/Blocker226/EDMC-AutoLoader', background=nB.Label().cget('background'), url="https://github.com/Blocker226/EDMC-AutoLoader")\ .grid(padx=10, row=current_row, sticky="nsew") return frame
def plugin_prefs(parent, cmdr, is_beta): """ Return a TK Frame for adding to the EDMC settings dialog. """ frame = nb.Frame(parent) nb.Label(frame, text="Faction to monitor").grid(column=0, sticky=tk.W) factionname = nb.Entry(frame, textvariable=this.FactionName, width=40).grid(column=0, sticky=tk.W) systemlabel = nb.Label(frame, text="System to monitor").grid(column=0, sticky=tk.W) systemname = nb.Entry(frame, textvariable=this.SystemName, width=40).grid(column=0, sticky=tk.W) Reset = nb.Button(frame, text="Reset Counter").place(x=0, y=290) return frame
def journal_entry(cmdr, is_beta, system, station, entry, state): if entry['event'] == 'CodexEntry': # Define variables to be passed along to submit ATEL Function this.timestamp = (format(entry['timestamp'])) this.cmdr = cmdr entry['commanderName'] = cmdr this.name = (format(entry['Name_Localised'])) this.system = (format(entry['System'])) # Apparently Python 3's requests library breaks json. Not surprised. # do this the old fashioned way (version 1.08) with artisinal, hand-crafted JSON BS. CODEX_DATA = '{{ "timestamp":"{}", "Name_Localised":"{}", "System":"{}" }}'.format( entry['timestamp'], entry['Name_Localised'], entry['System']) API_POST = requests.post(url=this.api, data=CODEX_DATA) # Submit ATEL Button if CMDR wants to make a public discovery announcement. # Added a value check - unless a CodexEntry event generates a Voucher from a composition scan, we don't offer the report button. # This prevents ATEL reports for "mundane" discoveries like standard gas giants, non-terraformables, brown dwarfs, etc. try: this.voucher = (format(entry['VoucherAmount'])) this.status.set("Codex discovery data sent.\n " + this.name) this.b1 = nb.Button(frame, text="[Submit ATEL Report?]", command=bulletin_callback) retrieve(this.b1) except KeyError: this.status.set("Codex discovery data sent.\n " + this.name) # The print statements below can be uncommented to debug data transmission issues. # Log file located at: \user_name\AppData\Local\Temp\EDMarketConnector.log #print(str(this.api)) #print(str(CODEX_DATA)) #print(str(API_POST.request.body)) #print(str(API_POST.text)) else: # FSDJump happens often enough to clear the status window if entry['event'] == 'FSDJump': this.cmdr = cmdr entry['commanderName'] = cmdr this.system = (format(entry['StarSystem'])) this.timestamp = (format(entry['timestamp'])) this.status.set("Waiting for Codex discovery data...") try: forget(this.b1) except AttributeError: this.status.set("Waiting for Codex discovery data...")
def journal_entry(cmdr, is_beta, system, station, entry, state): if entry['event'] == 'CodexEntry': # Define variables to be passed along to submit ATEL Function this.timestamp=(format(entry['timestamp'])) this.cmdr = cmdr entry['commanderName'] = cmdr this.entryid=(format(entry['EntryID'])) this.name=(format(entry['Name'])) this.name_stripped=(re.sub(";|\$|_Name", "", this.name)) this.name_lower = str.lower(this.name_stripped) this.name_localised=(format(entry['Name_Localised'])) this.system=(format(entry['System'])) this.systemaddress=(format(entry['SystemAddress'])) try: this.voucher=(format(entry['VoucherAmount'])) CODEX_DATA = '{{ "timestamp":"{}", "EntryID":"{}", "Name":"{}", "Name_Localised":"{}", "System":"{}", "SystemAddress":"{}", "App_Name":"{}", "App_Version":"{}"}}'.format(entry['timestamp'], entry['EntryID'], this.name_lower, entry['Name_Localised'], entry['System'], entry['SystemAddress'], this.app_name, this.installed_version,) API_POST = requests.post(url = this.api, data = CODEX_DATA) this.status.set("Codex discovery data sent.\n "+this.name_localised) # The print statements below can be uncommented to debug data transmission issues. # Log file located at: \user_name\AppData\Local\Temp\EDMarketConnector.log #print(str(this.api)) #print(str(CODEX_DATA)) #print(str(API_POST.request.body)) #print(str(API_POST.text)) this.b1 = nb.Button(frame, text="[Submit ATEL Report?]", command=bulletin_callback) retrieve(this.b1) except KeyError: this.status.set("Waiting for Codex discovery data...") else: # FSDJump happens often enough to clear the status window if entry['event'] == 'FSDJump': this.cmdr = cmdr entry['commanderName'] = cmdr this.system=(format(entry['StarSystem'])) this.timestamp=(format(entry['timestamp'])) this.status.set("Waiting for Codex discovery data...") try: forget(this.b1) except AttributeError: this.status.set("Waiting for Codex discovery data...")
def plugin_prefs(parent, cmdr, is_beta): frame = nb.Frame(parent) settings = get_settings() if this.settings == []: this.settings = [tk.StringVar(), tk.StringVar()] nb.Label(frame, text='Value for each body in a discovery scan:').grid(row=0, column=0, padx=10, pady=(10, 0)) this.settings[0].set(settings[0]) nb.Entry(frame, textvariable=this.settings[0]).grid(row=0, column=1, sticky=tk.W, pady=(10, 0)) this.settings[1].set(settings[1]) nb.Checkbutton(frame, text='Display plugin events.', variable=this.settings[1], onvalue='Y', offvalue='N').grid(row=1, column=0, columnspan=2, padx=10, sticky=tk.W) nb.Button(frame, text="Clear Banked Data", command=this.bank.clearBank).grid(row=2, column=0, padx=10, sticky=tk.W) nb.Label(frame, text="WARNING: Clearing your banked data is irreversable.").grid( row=2, column=1, sticky=tk.W) nb.Label(frame, text='Version {}'.format(VERSION)).grid(padx=10, pady=10, sticky=tk.W) return frame
def plugin_prefs(parent): PADX = 10 # formatting frame = nb.Frame(parent) frame.columnconfigure(1, weight=1) HyperlinkLabel(frame, text='Mobius PVE website', background=nb.Label().cget('background'), url='https://elitepve.com/', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) # Don't translate nb.Label(frame, text="Mobius Plug-in - pre-alpha release Version {VER}".format( VER=MH_VERSION)).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Label(frame).grid() # spacer nb.Button(frame, text="UPGRADE", command=upgrade_callback).grid(columnspan=2, padx=PADX, sticky=tk.W) return frame
def plugin_prefs(parent): PADX = 10 # formatting frame = nb.Frame(parent) frame.columnconfigure(5, weight=1) HyperlinkLabel(frame, text='ATEL GitHub', background=nb.Label().cget('background'), url='https://github.com/Elite-IGAU/ATEL-EDMC', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Label(frame, text="ATEL {VER}".format(VER=VERSION)).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Label(frame).grid() # spacer nb.Button(frame, text="UPGRADE", command=upgrade_callback).grid(row=10, column=0, columnspan=2, padx=PADX, sticky=tk.W) # # Todo - Add option to defer ATEL transmission until docked and cartographic data is sold. # return frame
def plugin_prefs(parent): PADX = 10 # formatting frame = nb.Frame(parent) frame.columnconfigure(5, weight=1) HyperlinkLabel(frame, text='FactionGist GitHub', background=nb.Label().cget('background'), url='https://github.com/OdysseyScorpio/FactionGist', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Label( frame, text= "FactionGist - crazy-things-might-happen-pre-pre-alpha release Version {VER}" .format(VER=FG_VERSION)).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Label(frame).grid() # spacer nb.Button(frame, text="UPGRADE", command=upgrade_callback).grid(row=10, column=0, columnspan=2, padx=PADX, sticky=tk.W) nb.lblReportingFactions = tk.Label(frame) nb.lblReportingFactions.grid(row=3, column=0, columnspan=2, padx=PADX, sticky=tk.W) nb.lblReportingFactions.config(text='Factions I am supporting') nb.Entry1 = tk.Entry(frame, textvariable=availableFactions) nb.Entry1.grid(row=4, column=0, columnspan=2, padx=PADX, sticky=tk.W + tk.E) return frame
def plugin_prefs(parent, cmdr, is_beta): ''' Prepare the preferences tab in the settings window that appears ''' # Skeletony bits this.frame = nb.Frame(parent) frameTop = nb.Frame(this.frame) frameTop.grid(row=0, column=0, sticky=tk.W) frameBottom = nb.Frame(this.frame) frameBottom.grid(row=1, column=0, sticky=tk.SW) #End skeleton #headline this.evacCount = tk.IntVar(value=config.getint("EvacCountSetting")) # Retrieve saved value from config frame = nb.Frame(parent) # Should we display totals? evacuatedTotal = nb.Checkbutton(frameBottom, variable=evacuatedTotalOption, text="Calculate totals") evacuatedTotal.var = evacuatedTotalOption evacuatedTotal.grid(row=0, column=0, padx=this.PADX * 2, sticky=tk.W) resetButton = nb.Button(frameBottom, text="Reset Totals", command=resetTotalEvacuated) resetButton.grid(row=1, column=0, padx=this.PADX * 4, pady=5, sticky=tk.W) # Calculate numbers for current session? evacuatedSession = nb.Checkbutton(frameBottom, variable=evacuatedSessionOption, text="Calculate totals for current session") evacuatedSession.var = evacuatedSessionOption evacuatedSession.grid(row=2, column=0, padx=this.PADX * 2, sticky=tk.W) # radio button value: 1 = calculate for ED session; 0 = calculate for EDMC session evacuatedSessionEdmc = nb.Radiobutton(frameBottom, variable=evacuatedSessionSelected, value=0, text="EDMC session") evacuatedSessionEdmc.var = evacuatedSessionSelected evacuatedSessionEdmc.grid(row=3, column=0, padx=this.PADX * 4, sticky=tk.W) evacuatedSessionElite = nb.Radiobutton(frameBottom, variable=evacuatedSessionSelected, value=1, text="Elite session") evacuatedSessionElite.var = evacuatedSessionSelected evacuatedSessionElite.grid(row=4, column=0, padx=this.PADX * 4, sticky=tk.W) # Search and Rescue settings nb.Label(frameBottom, text="Search and rescue options").grid(row=5, column=0, padx=this.PADX, sticky=tk.W) sarBlackBox = nb.Checkbutton(frameBottom, variable=blackBoxOption, text="Track black boxes") sarBlackBox.var = blackBoxOption sarBlackBox.grid(row=6, column=0, padx=this.PADX * 2, sticky=tk.W) sarWreckage = nb.Checkbutton(frameBottom, variable=wreckageOption, text="Track wreckage") sarWreckage.var = wreckageOption sarWreckage.grid(row=7, column=0, padx=this.PADX * 2, sticky=tk.W) sarEscapePod = nb.Checkbutton(frameBottom, variable=occupiedPodOption, text="Track occupied escape pods") sarEscapePod.var = occupiedPodOption sarEscapePod.grid(row=8, column=0, padx=this.PADX * 2, sticky=tk.W) sarPersonalEffects = nb.Checkbutton(frameBottom, variable=personalEffectsOption, text="Track personal effects") sarPersonalEffects.var = personalEffectsOption sarPersonalEffects.grid(row=9, column=0, padx=this.PADX * 2, sticky=tk.W) sarDamagedPod = nb.Checkbutton(frameBottom, variable=damagedPodOption, text="Track damaged pods") sarDamagedPod.var = damagedPodOption sarDamagedPod.grid(row=10, column=0, padx=this.PADX * 2, sticky=tk.W) sarPrisoners = nb.Checkbutton(frameBottom, variable=prisonersOption, text="Track political prisoners") sarPrisoners.var = prisonersOption sarPrisoners.grid(row=11, column=0, padx=this.PADX * 2, sticky=tk.W) sarEncrypted = nb.Checkbutton(frameBottom, variable=correspondenceOption, text="Track encrypted correspondence") sarEncrypted.var = correspondenceOption sarEncrypted.grid(row=12, column=0, padx=this.PADX * 2, sticky=tk.W) setStateRadioButtons(evacuatedSessionEdmc, evacuatedSessionElite) evacuatedSession.config(command=partial(setStateRadioButtons, evacuatedSessionEdmc, evacuatedSessionElite)) nb.Label(frameBottom).grid(row=13) # spacer nb.Label(frameBottom).grid(row=14) # spacer nb.Label(frameBottom, text="Plugin version: {0}".format(this.VERSION)).grid(row=15, column=0, padx=this.PADX, sticky=tk.W) return this.frame
def __init__(self, parent, callback): tk.Toplevel.__init__(self, parent) self.parent = parent self.callback = callback self.title(platform == 'darwin' and _('Preferences') or _('Settings')) 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 if platform == 'win32': self.attributes('-toolwindow', tk.TRUE) elif platform == 'darwin': # http://wiki.tcl.tk/13428 parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility') self.resizable(tk.FALSE, tk.FALSE) self.cmdr = False # Note if Cmdr changes in the Journal self.is_beta = False # Note if Beta status changes in the Journal self.cmdrchanged_alarm = None frame = ttk.Frame(self) frame.grid(sticky=tk.NSEW) notebook = nb.Notebook(frame) notebook.bind('<<NotebookTabChanged>>', self.outvarchanged) # Recompute on tab change PADX = 10 BUTTONX = 12 # indent Checkbuttons and Radiobuttons PADY = 2 # close spacing credframe = nb.Frame(notebook) credframe.columnconfigure(1, weight=1) nb.Label(credframe, text=_('Credentials')).grid( padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) self.cred_label = nb.Label(credframe) self.cred_label.grid(padx=PADX, columnspan=2, sticky=tk.W) self.cmdr_label = nb.Label(credframe, text=_('Cmdr')) # Main window self.cmdr_label.grid(row=10, padx=PADX, sticky=tk.W) self.username_label = nb.Label( credframe, text=_('Username (Email)') ) # Use same text as E:D Launcher's login dialog self.username_label.grid(row=11, padx=PADX, sticky=tk.W) self.password_label = nb.Label( credframe, text=_('Password')) # Use same text as E:D Launcher's login dialog self.password_label.grid(row=12, padx=PADX, sticky=tk.W) self.cmdr_text = nb.Label(credframe) self.cmdr_text.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.W) self.username = nb.Entry(credframe) self.username.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) if monitor.cmdr: self.username.focus_set() self.password = nb.Entry(credframe, show=u'•') self.password.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(credframe).grid(sticky=tk.W) # big spacer nb.Label(credframe, text=_('Privacy')).grid( padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) self.out_anon = tk.IntVar(value=config.getint('anonymous') and 1) nb.Label( credframe, text=_('How do you want to be identified in the saved data')).grid( columnspan=2, padx=PADX, sticky=tk.W) nb.Radiobutton(credframe, text=_('Cmdr name'), variable=self.out_anon, value=0).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # Privacy setting nb.Radiobutton(credframe, text=_('Pseudo-anonymized ID'), variable=self.out_anon, value=1).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # Privacy setting notebook.add(credframe, text=_('Identity')) # Tab heading in settings outframe = nb.Frame(notebook) outframe.columnconfigure(0, weight=1) output = config.getint('output') or ( config.OUT_MKT_EDDN | config.OUT_SYS_EDDN | config.OUT_SHIP ) # default settings self.out_label = nb.Label(outframe, text=_('Please choose what data to save')) self.out_label.grid(columnspan=2, padx=PADX, sticky=tk.W) self.out_csv = tk.IntVar(value=(output & config.OUT_MKT_CSV) and 1) self.out_csv_button = nb.Checkbutton( outframe, text=_('Market data in CSV format file'), variable=self.out_csv, command=self.outvarchanged) self.out_csv_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_td = tk.IntVar(value=(output & config.OUT_MKT_TD) and 1) self.out_td_button = nb.Checkbutton( outframe, text=_('Market data in Trade Dangerous format file'), variable=self.out_td, command=self.outvarchanged) self.out_td_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_ship = tk.IntVar( value=(output & (config.OUT_SHIP | config.OUT_SHIP_EDS | config.OUT_SHIP_CORIOLIS) and 1)) self.out_ship_button = nb.Checkbutton( outframe, text=_('Ship loadout'), variable=self.out_ship, command=self.outvarchanged) # Output setting self.out_ship_button.grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) self.out_auto = tk.IntVar(value=0 if output & config.OUT_MKT_MANUAL else 1) # inverted self.out_auto_button = nb.Checkbutton( outframe, text=_('Automatically update on docking'), variable=self.out_auto, command=self.outvarchanged) # Output setting self.out_auto_button.grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) self.outdir = tk.StringVar() self.outdir.set(config.get('outdir')) self.outdir_label = nb.Label(outframe, text=_('File location') + ':') # Section heading in settings self.outdir_label.grid(padx=PADX, pady=(5, 0), sticky=tk.W) self.outdir_entry = nb.Entry(outframe, takefocus=False) self.outdir_entry.grid(columnspan=2, padx=PADX, pady=(0, PADY), sticky=tk.EW) self.outbutton = nb.Button( outframe, text=( platform == 'darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), # Folder selection button on Windows command=lambda: self.filebrowse(_('File location'), self.outdir)) self.outbutton.grid(column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) nb.Frame(outframe).grid(pady=5) # bottom spacer notebook.add(outframe, text=_('Output')) # Tab heading in settings eddnframe = nb.Frame(notebook) HyperlinkLabel(eddnframe, text='Elite Dangerous Data Network', background=nb.Label().cget('background'), url='https://github.com/EDSM-NET/EDDN/wiki', underline=True).grid(padx=PADX, sticky=tk.W) # Don't translate self.eddn_station = tk.IntVar( value=(output & config.OUT_MKT_EDDN) and 1) self.eddn_station_button = nb.Checkbutton( eddnframe, text=_('Send station data to the Elite Dangerous Data Network'), variable=self.eddn_station, command=self.outvarchanged) # Output setting self.eddn_station_button.grid(padx=BUTTONX, pady=(5, 0), sticky=tk.W) self.eddn_auto_button = nb.Checkbutton( eddnframe, text=_('Automatically update on docking'), variable=self.out_auto, command=self.outvarchanged) # Output setting self.eddn_auto_button.grid(padx=BUTTONX, sticky=tk.W) self.eddn_system = tk.IntVar( value=(output & config.OUT_SYS_EDDN) and 1) self.eddn_system_button = nb.Checkbutton( eddnframe, text=_( 'Send system and scan data to the Elite Dangerous Data Network' ), variable=self.eddn_system, command=self.outvarchanged) # Output setting new in E:D 2.2 self.eddn_system_button.grid(padx=BUTTONX, pady=(5, 0), sticky=tk.W) self.eddn_delay = tk.IntVar( value=(output & config.OUT_SYS_DELAY) and 1) self.eddn_delay_button = nb.Checkbutton( eddnframe, text=_('Delay sending until docked'), variable=self.eddn_delay ) # Output setting under 'Send system and scan data to the Elite Dangerous Data Network' new in E:D 2.2 self.eddn_delay_button.grid(padx=BUTTONX, sticky=tk.W) notebook.add(eddnframe, text='EDDN') # Not translated # build plugin prefs tabs for plugin in plug.PLUGINS: plugframe = plugin.get_prefs(notebook, monitor.cmdr, monitor.is_beta) if plugframe: notebook.add(plugframe, text=plugin.name) configframe = nb.Frame(notebook) configframe.columnconfigure(1, weight=1) self.logdir = tk.StringVar() self.logdir.set( config.get('journaldir') or config.default_journal_dir or '') self.logdir_entry = nb.Entry(configframe, takefocus=False) if platform != 'darwin': # Apple's SMB implementation is way too flaky - no filesystem events and bogus NULLs nb.Label( configframe, text=_('E:D journal file location') + ':').grid( columnspan=4, padx=PADX, sticky=tk.W) # Location of the new Journal file in E:D 2.2 self.logdir_entry.grid(columnspan=4, padx=PADX, pady=(0, PADY), sticky=tk.EW) self.logbutton = nb.Button( configframe, text=( platform == 'darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), # Folder selection button on Windows command=lambda: self.filebrowse(_('E:D journal file location'), self.logdir)) self.logbutton.grid(row=10, column=3, padx=PADX, pady=PADY, sticky=tk.EW) if config.default_journal_dir: nb.Button( configframe, text=_('Default'), command=self.logdir_reset, state=config.get('journaldir') and tk.NORMAL or tk.DISABLED).grid( row=10, column=2, pady=PADY, sticky=tk.EW) # Appearance theme and language setting if platform == 'win32': ttk.Separator(configframe, orient=tk.HORIZONTAL).grid(columnspan=4, padx=PADX, pady=PADY * 4, sticky=tk.EW) if platform in ['darwin', 'win32']: self.hotkey_code = config.getint('hotkey_code') self.hotkey_mods = config.getint('hotkey_mods') self.hotkey_only = tk.IntVar( value=not config.getint('hotkey_always')) self.hotkey_play = tk.IntVar( value=not config.getint('hotkey_mute')) nb.Label( configframe, text=platform == 'darwin' and _('Keyboard shortcut') or # Hotkey/Shortcut settings prompt on OSX _('Hotkey') # Hotkey/Shortcut settings prompt on Windows ).grid(row=20, padx=PADX, sticky=tk.W) if platform == 'darwin' and not was_accessible_at_launch: if AXIsProcessTrusted(): nb.Label( configframe, text=_('Re-start {APP} to use shortcuts').format( APP=applongname), foreground='firebrick').grid( padx=PADX, sticky=tk.W) # Shortcut settings prompt on OSX else: nb.Label( configframe, text=_('{APP} needs permission to use shortcuts' ).format(APP=applongname), foreground='firebrick').grid( columnspan=4, padx=PADX, sticky=tk.W) # Shortcut settings prompt on OSX nb.Button( configframe, text=_('Open System Preferences'), command=self.enableshortcuts).grid( padx=PADX, sticky=tk.E) # Shortcut settings button on OSX else: self.hotkey_text = nb.Entry(configframe, width=(platform == 'darwin' and 20 or 30), justify=tk.CENTER) self.hotkey_text.insert( 0, self.hotkey_code and hotkeymgr.display(self.hotkey_code, self.hotkey_mods) or _('None')) # No hotkey/shortcut currently defined self.hotkey_text.bind('<FocusIn>', self.hotkeystart) self.hotkey_text.bind('<FocusOut>', self.hotkeyend) self.hotkey_text.grid(row=20, column=1, columnspan=2, padx=PADX, pady=(5, 0), sticky=tk.W) self.hotkey_only_btn = nb.Checkbutton( configframe, text=_('Only when Elite: Dangerous is the active app'), variable=self.hotkey_only, state=self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_only_btn.grid(columnspan=4, padx=PADX, pady=(5, 0), sticky=tk.W) self.hotkey_play_btn = nb.Checkbutton( configframe, text=_('Play sound'), variable=self.hotkey_play, state=self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_play_btn.grid(columnspan=4, padx=PADX, sticky=tk.W) ttk.Separator(configframe, orient=tk.HORIZONTAL).grid(columnspan=4, padx=PADX, pady=PADY * 4, sticky=tk.EW) nb.Label(configframe, text=_('Preferred Shipyard')).grid( columnspan=4, padx=PADX, sticky=tk.W ) # Setting to decide which ship outfitting website to link to - either E:D Shipyard or Coriolis. self.shipyard = tk.IntVar(value=config.getint('shipyard')) nb.Radiobutton(configframe, text='E:D Shipyard', variable=self.shipyard, value=config.SHIPYARD_EDSHIPYARD).grid(columnspan=3, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Radiobutton(configframe, text='Coriolis', variable=self.shipyard, value=config.SHIPYARD_CORIOLIS).grid(columnspan=3, padx=BUTTONX, sticky=tk.W) nb.Label(configframe).grid(sticky=tk.W) # big spacer notebook.add(configframe, text=_('Configuration')) # Tab heading in settings self.languages = Translations().available_names() self.lang = tk.StringVar(value=self.languages.get( config.get('language'), _('Default'))) # Appearance theme and language setting self.always_ontop = tk.BooleanVar(value=config.getint('always_ontop')) self.theme = tk.IntVar(value=config.getint('theme')) self.theme_colors = [ config.get('dark_text'), config.get('dark_highlight') ] self.theme_prompts = [ _('Normal text'), # Dark theme color setting _('Highlighted text'), # Dark theme color setting ] themeframe = nb.Frame(notebook) themeframe.columnconfigure(2, weight=1) nb.Label(themeframe, text=_('Language')).grid( row=10, padx=PADX, sticky=tk.W) # Appearance setting prompt self.lang_button = nb.OptionMenu(themeframe, self.lang, self.lang.get(), *self.languages.values()) self.lang_button.grid(row=10, column=1, columnspan=2, padx=PADX, sticky=tk.W) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 4, sticky=tk.EW) nb.Label(themeframe, text=_('Theme')).grid(columnspan=3, padx=PADX, sticky=tk.W) # Appearance setting nb.Radiobutton( themeframe, text=_('Default'), variable=self.theme, value=0, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme and language setting nb.Radiobutton(themeframe, text=_('Dark'), variable=self.theme, value=1, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme setting if platform == 'win32': nb.Radiobutton(themeframe, text=_('Transparent'), variable=self.theme, value=2, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme setting self.theme_label_0 = nb.Label(themeframe, text=self.theme_prompts[0]) self.theme_label_0.grid(row=20, padx=PADX, sticky=tk.W) self.theme_button_0 = nb.ColoredButton( themeframe, text=_('Station'), background='grey4', command=lambda: self.themecolorbrowse(0)) # Main window self.theme_button_0.grid(row=20, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) self.theme_label_1 = nb.Label(themeframe, text=self.theme_prompts[1]) self.theme_label_1.grid(row=21, padx=PADX, sticky=tk.W) self.theme_button_1 = nb.ColoredButton( themeframe, text=' Hutton Orbital ', background='grey4', command=lambda: self.themecolorbrowse(1)) # Do not translate self.theme_button_1.grid(row=21, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 4, sticky=tk.EW) self.ontop_button = nb.Checkbutton(themeframe, text=_('Always on top'), variable=self.always_ontop, command=self.themevarchanged) self.ontop_button.grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance setting nb.Label(themeframe).grid(sticky=tk.W) # big spacer notebook.add(themeframe, text=_('Appearance')) # Tab heading in settings # Plugin settings and info plugsframe = nb.Frame(notebook) plugsframe.columnconfigure(0, weight=1) plugdir = tk.StringVar() plugdir.set(config.plugin_dir) nb.Label(plugsframe, text=_('Plugins folder') + ':').grid( padx=PADX, sticky=tk.W) # Section heading in settings plugdirentry = nb.Entry(plugsframe, justify=tk.LEFT) self.displaypath(plugdir, plugdirentry) plugdirentry.grid(row=10, padx=PADX, sticky=tk.EW) nb.Button( plugsframe, text=_('Open'), # Button that opens a folder in Explorer/Finder command=lambda: webbrowser.open('file:///%s' % plugdir.get()) ).grid(row=10, column=1, padx=(0, PADX), sticky=tk.NSEW) nb.Label( plugsframe, text= _("Tip: You can disable a plugin by{CR}adding '{EXT}' to its folder name" ).format(EXT='.disabled')).grid( # Help text in settings columnspan=2, padx=PADX, pady=10, sticky=tk.NSEW) enabled_plugins = [x for x in plug.PLUGINS if x.folder and x.module] if len(enabled_plugins): ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW) nb.Label(plugsframe, text=_('Enabled Plugins') + ':').grid( padx=PADX, sticky=tk.W) # List of plugins in settings for plugin in enabled_plugins: if plugin.name == plugin.folder: label = nb.Label(plugsframe, text=plugin.name) else: label = nb.Label(plugsframe, text='%s (%s)' % (plugin.folder, plugin.name)) label.grid(columnspan=2, padx=PADX * 2, sticky=tk.W) disabled_plugins = [ x for x in plug.PLUGINS if x.folder and not x.module ] if len(disabled_plugins): ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW) nb.Label(plugsframe, text=_('Disabled Plugins') + ':').grid( padx=PADX, sticky=tk.W) # List of plugins in settings for plugin in disabled_plugins: nb.Label(plugsframe, text=plugin.name).grid(columnspan=2, padx=PADX * 2, sticky=tk.W) notebook.add(plugsframe, text=_('Plugins')) # Tab heading in settings if platform == 'darwin': self.protocol("WM_DELETE_WINDOW", self.apply) # close button applies changes else: buttonframe = ttk.Frame(frame) buttonframe.grid(padx=PADX, pady=PADX, sticky=tk.NSEW) buttonframe.columnconfigure(0, weight=1) ttk.Label(buttonframe).grid(row=0, column=0) # spacer button = ttk.Button(buttonframe, text=_('OK'), command=self.apply) button.grid(row=0, column=1, sticky=tk.E) button.bind("<Return>", lambda event: self.apply()) self.protocol("WM_DELETE_WINDOW", self._destroy) # Selectively disable buttons depending on output settings self.cmdrchanged() self.themevarchanged() # disable hotkey for the duration hotkeymgr.unregister() # 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))
def __init__(self, parent, callback): tk.Toplevel.__init__(self, parent) self.parent = parent self.callback = callback self.title(platform=='darwin' and _('Preferences') or _('Settings')) 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') style = ttk.Style() frame = ttk.Frame(self) frame.grid(sticky=tk.NSEW) notebook = nb.Notebook(frame) PADX = 10 BUTTONX = 12 # indent Checkbuttons and Radiobuttons PADY = 2 # close spacing credframe = nb.Frame(notebook) credframe.columnconfigure(1, weight=1) nb.Label(credframe, text=_('Credentials')).grid(padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(credframe, text=_('Please log in with your Elite: Dangerous account details')).grid(padx=PADX, columnspan=2, sticky=tk.W) # Use same text as E:D Launcher's login dialog nb.Label(credframe, text=_('Username (Email)')).grid(row=10, padx=PADX, sticky=tk.W) # Use same text as E:D Launcher's login dialog nb.Label(credframe, text=_('Password')).grid(row=11, padx=PADX, sticky=tk.W) # Use same text as E:D Launcher's login dialog self.username = nb.Entry(credframe) self.username.insert(0, config.get('username') or '') self.username.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.EW) self.username.focus_set() self.password = nb.Entry(credframe, show=u'•') self.password.insert(0, config.get('password') or '') self.password.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(credframe).grid(sticky=tk.W) # big spacer nb.Label(credframe, text=_('Privacy')).grid(padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) self.out_anon= tk.IntVar(value = config.getint('anonymous') and 1) nb.Label(credframe, text=_('How do you want to be identified in the saved data')).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Radiobutton(credframe, text=_('Cmdr name'), variable=self.out_anon, value=0).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # EDSM & privacy setting nb.Radiobutton(credframe, text=_('Pseudo-anonymized ID'), variable=self.out_anon, value=1).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # Privacy setting notebook.add(credframe, text=_('Identity')) # Tab heading in settings outframe = nb.Frame(notebook) outframe.columnconfigure(0, weight=1) output = config.getint('output') or (config.OUT_EDDN | config.OUT_SHIP_EDS) # default settings nb.Label(outframe, text=_('Please choose what data to save')).grid(columnspan=2, padx=PADX, sticky=tk.W) self.out_eddn= tk.IntVar(value = (output & config.OUT_EDDN) and 1) nb.Checkbutton(outframe, text=_('Send station data to the Elite Dangerous Data Network'), variable=self.out_eddn, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_csv = tk.IntVar(value = (output & config.OUT_CSV ) and 1) nb.Checkbutton(outframe, text=_('Market data in CSV format file'), variable=self.out_csv, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_bpc = tk.IntVar(value = (output & config.OUT_BPC ) and 1) nb.Checkbutton(outframe, text=_("Market data in Slopey's BPC format file"), variable=self.out_bpc, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_td = tk.IntVar(value = (output & config.OUT_TD ) and 1) nb.Checkbutton(outframe, text=_('Market data in Trade Dangerous format file'), variable=self.out_td, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_ship_eds= tk.IntVar(value = (output & config.OUT_SHIP_EDS) and 1) nb.Checkbutton(outframe, text=_('Ship loadout in E:D Shipyard format file'), variable=self.out_ship_eds, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W) self.out_ship_coriolis= tk.IntVar(value = (output & config.OUT_SHIP_CORIOLIS) and 1) nb.Checkbutton(outframe, text=_('Ship loadout in Coriolis format file'), variable=self.out_ship_coriolis, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_log_file = tk.IntVar(value = (output & config.OUT_LOG_FILE) and 1) nb.Checkbutton(outframe, text=_('Flight log in CSV format file'), variable=self.out_log_file, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W) self.out_log_auto = tk.IntVar(value = output & config.OUT_LOG_AUTO and 1 or 0) self.out_log_auto_button = nb.Checkbutton(outframe, text=_('Automatically make a log entry on entering a system'), variable=self.out_log_auto, command=self.outvarchanged) # Output setting self.out_log_auto_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_log_auto_text = nb.Label(outframe, foreground='firebrick') self.out_log_auto_text.grid(columnspan=2, padx=(30,0), sticky=tk.W) self.outdir_label = nb.Label(outframe, text=_('File location')) # Section heading in settings self.outdir_label.grid(padx=BUTTONX, sticky=tk.W) self.outdir = nb.Entry(outframe, takefocus=False) if config.get('outdir').startswith(config.home): self.outdir.insert(0, '~' + config.get('outdir')[len(config.home):]) else: self.outdir.insert(0, config.get('outdir')) self.outdir.grid(row=20, padx=(PADX,0), sticky=tk.EW) self.outbutton = nb.Button(outframe, text=(platform=='darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), command=self.outbrowse) # Folder selection button on Windows self.outbutton.grid(row=20, column=1, padx=PADX) nb.Frame(outframe).grid(pady=5) # bottom spacer notebook.add(outframe, text=_('Output')) # Tab heading in settings edsmframe = nb.Frame(notebook) edsmframe.columnconfigure(1, weight=1) HyperlinkLabel(edsmframe, text='Elite Dangerous Star Map', background=nb.Label().cget('background'), url='http://www.edsm.net/', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) # Don't translate ttk.Separator(edsmframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) self.out_log_edsm = tk.IntVar(value = (output & config.OUT_LOG_EDSM) and 1) nb.Checkbutton(edsmframe, text=_('Send flight log to Elite Dangerous Star Map'), variable=self.out_log_edsm, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.edsm_autoopen = tk.BooleanVar(value = config.getint('edsm_autoopen')) self.edsm_autoopen_button = nb.Checkbutton(edsmframe, text=_(u"Automatically open uncharted systems’ EDSM pages"), variable=self.edsm_autoopen) self.edsm_autoopen_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.edsm_log_auto_button = nb.Checkbutton(edsmframe, text=_('Automatically make a log entry on entering a system'), variable=self.out_log_auto, command=self.outvarchanged) # Output setting self.edsm_log_auto_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.edsm_log_auto_text = nb.Label(edsmframe, foreground='firebrick') self.edsm_log_auto_text.grid(columnspan=2, padx=(30,0), sticky=tk.W) self.edsm_label = HyperlinkLabel(edsmframe, text=_('Elite Dangerous Star Map credentials'), background=nb.Label().cget('background'), url='http://www.edsm.net/settings/api', underline=True) # Section heading in settings self.edsm_label.grid(columnspan=2, padx=PADX, sticky=tk.W) self.edsm_cmdr_label = nb.Label(edsmframe, text=_('Cmdr name')) # EDSM & privacy setting self.edsm_cmdr_label.grid(row=10, padx=PADX, sticky=tk.W) self.edsm_cmdr = nb.Entry(edsmframe) self.edsm_cmdr.insert(0, config.get('edsm_cmdrname') or '') self.edsm_cmdr.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.EW) self.edsm_apikey_label = nb.Label(edsmframe, text=_('API Key')) # EDSM setting self.edsm_apikey_label.grid(row=11, padx=PADX, sticky=tk.W) self.edsm_apikey = nb.Entry(edsmframe) self.edsm_apikey.insert(0, config.get('edsm_apikey') or '') self.edsm_apikey.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) notebook.add(edsmframe, text='EDSM') # Not translated if platform in ['darwin','win32']: self.hotkey_code = config.getint('hotkey_code') self.hotkey_mods = config.getint('hotkey_mods') self.hotkey_only = tk.IntVar(value = not config.getint('hotkey_always')) self.hotkey_play = tk.IntVar(value = not config.getint('hotkey_mute')) hotkeyframe = nb.Frame(notebook) hotkeyframe.columnconfigure(1, weight=1) nb.Label(hotkeyframe).grid(sticky=tk.W) # big spacer if platform == 'darwin' and not was_accessible_at_launch: if AXIsProcessTrusted(): nb.Label(hotkeyframe, text = _('Re-start {APP} to use shortcuts').format(APP=applongname), foreground='firebrick').grid(padx=PADX, sticky=tk.NSEW) # Shortcut settings prompt on OSX else: nb.Label(hotkeyframe, text = _('{APP} needs permission to use shortcuts').format(APP=applongname), foreground='firebrick').grid(columnspan=2, padx=PADX, sticky=tk.W) # Shortcut settings prompt on OSX nb.Button(hotkeyframe, text = _('Open System Preferences'), command = self.enableshortcuts).grid(column=1, padx=PADX, sticky=tk.E) # Shortcut settings button on OSX else: self.hotkey_text = nb.Entry(hotkeyframe, width = (platform == 'darwin' and 20 or 30), justify=tk.CENTER) self.hotkey_text.insert(0, self.hotkey_code and hotkeymgr.display(self.hotkey_code, self.hotkey_mods) or _('None')) # No hotkey/shortcut currently defined self.hotkey_text.bind('<FocusIn>', self.hotkeystart) self.hotkey_text.bind('<FocusOut>', self.hotkeyend) nb.Label(hotkeyframe, text = platform=='darwin' and _('Keyboard shortcut') or # Tab heading in settings on OSX _('Hotkey') # Tab heading in settings on Windows ).grid(row=10, column=0, padx=PADX, sticky=tk.NSEW) self.hotkey_text.grid(row=10, column=1, padx=PADX, sticky=tk.NSEW) nb.Label(hotkeyframe).grid(sticky=tk.W) # big spacer self.hotkey_only_btn = nb.Checkbutton(hotkeyframe, text=_('Only when Elite: Dangerous is the active app'), variable=self.hotkey_only, state = self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_only_btn.grid(columnspan=2, padx=PADX, sticky=tk.W) self.hotkey_play_btn = nb.Checkbutton(hotkeyframe, text=_('Play sound'), variable=self.hotkey_play, state = self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_play_btn.grid(columnspan=2, padx=PADX, sticky=tk.W) notebook.add(hotkeyframe, text = platform=='darwin' and _('Keyboard shortcut') or # Tab heading in settings on OSX _('Hotkey')) # Tab heading in settings on Windows # build plugin prefs tabs for plugname in plug.PLUGINS: plugframe = plug.get_plugin_pref(plugname, notebook) if plugframe: notebook.add(plugframe, text=plugname) if platform=='darwin': self.protocol("WM_DELETE_WINDOW", self.apply) # close button applies changes else: buttonframe = ttk.Frame(frame) buttonframe.grid(padx=PADX, pady=PADX, sticky=tk.NSEW) buttonframe.columnconfigure(0, weight=1) ttk.Label(buttonframe).grid(row=0, column=0) # spacer button = ttk.Button(buttonframe, text=_('OK'), command=self.apply) button.grid(row=0, column=1, sticky=tk.E) button.bind("<Return>", lambda event:self.apply()) self.protocol("WM_DELETE_WINDOW", self._destroy) # Selectively disable buttons depending on output settings self.proxypoll() # disable hotkey for the duration hotkeymgr.unregister() # wait for window to appear on screen before calling grab_set self.wait_visibility() self.grab_set()
def __init__(self, parent, callback): tk.Toplevel.__init__(self, parent) self.parent = parent self.callback = callback self.title(platform == 'darwin' and _('Preferences') or _('Settings')) 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 if platform == 'win32': self.attributes('-toolwindow', tk.TRUE) elif platform == 'darwin': # http://wiki.tcl.tk/13428 parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility') self.resizable(tk.FALSE, tk.FALSE) self.cmdr = False # Note if Cmdr changes in the Journal self.is_beta = False # Note if Beta status changes in the Journal self.cmdrchanged_alarm = None frame = ttk.Frame(self) frame.grid(sticky=tk.NSEW) notebook = nb.Notebook(frame) notebook.bind('<<NotebookTabChanged>>', self.tabchanged) # Recompute on tab change PADX = 10 BUTTONX = 12 # indent Checkbuttons and Radiobuttons PADY = 2 # close spacing outframe = nb.Frame(notebook) outframe.columnconfigure(0, weight=1) output = config.getint('output') # default settings self.out_label = nb.Label(outframe, text=_('Please choose what data to save')) self.out_label.grid(columnspan=2, padx=PADX, sticky=tk.W) # self.out_csv = tk.IntVar(value = (output & config.OUT_MKT_CSV ) and 1) # self.out_csv_button = nb.Checkbutton(outframe, text=_('Market data in CSV format file'), variable=self.out_csv, command=self.outvarchanged) # self.out_csv_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # self.out_td = tk.IntVar(value = (output & config.OUT_MKT_TD ) and 1) # self.out_td_button = nb.Checkbutton(outframe, text=_('Market data in Trade Dangerous format file'), variable=self.out_td, command=self.outvarchanged) # self.out_td_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_ship = tk.IntVar(value=(output & config.OUT_SHIP) and 1) self.out_ship_button = nb.Checkbutton( outframe, text=_('Ship loadout'), variable=self.out_ship, command=self.outvarchanged) # Output setting self.out_ship_button.grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) self.outdir = tk.StringVar() self.outdir.set(config.get('outdir')) self.outdir_label = nb.Label(outframe, text=_('File location') + ':') # Section heading in settings self.outdir_label.grid(padx=PADX, pady=(5, 0), sticky=tk.W) self.outdir_entry = nb.Entry(outframe, takefocus=False) self.outdir_entry.grid(columnspan=2, padx=PADX, pady=(0, PADY), sticky=tk.EW) self.outbutton = nb.Button( outframe, text=( platform == 'darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), # Folder selection button on Windows command=lambda: self.filebrowse(_('File location'), self.outdir)) self.outbutton.grid(column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) nb.Frame(outframe).grid(pady=5) # bottom spacer notebook.add(outframe, text=_('Output')) # Tab heading in settings # build theme settings self.languages = Translations.available_names() self.lang = tk.StringVar(value=self.languages.get( config.get('language'), _('Default'))) # Appearance theme and language setting self.always_ontop = tk.BooleanVar(value=config.getint('always_ontop')) self.theme = tk.IntVar(value=config.getint('theme')) self.theme_colors = [ config.get('dark_text'), config.get('dark_highlight') ] self.theme_prompts = [ _('Normal text'), # Dark theme color setting _('Highlighted text'), # Dark theme color setting ] themeframe = nb.Frame(notebook) themeframe.columnconfigure(2, weight=1) nb.Label(themeframe, text=_('Language')).grid( row=10, padx=PADX, sticky=tk.W) # Appearance setting prompt self.lang_button = nb.OptionMenu(themeframe, self.lang, self.lang.get(), *self.languages.values()) self.lang_button.grid(row=10, column=1, columnspan=2, padx=PADX, sticky=tk.W) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 4, sticky=tk.EW) nb.Label(themeframe, text=_('Theme')).grid(columnspan=3, padx=PADX, sticky=tk.W) # Appearance setting nb.Radiobutton( themeframe, text=_('Default'), variable=self.theme, value=0, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme and language setting nb.Radiobutton(themeframe, text=_('Dark'), variable=self.theme, value=1, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme setting if platform == 'win32': nb.Radiobutton(themeframe, text=_('Transparent'), variable=self.theme, value=2, command=self.themevarchanged).grid( columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme setting self.theme_label_0 = nb.Label(themeframe, text=self.theme_prompts[0]) self.theme_label_0.grid(row=20, padx=PADX, sticky=tk.W) self.theme_button_0 = nb.ColoredButton( themeframe, text=_('Station'), background='grey4', command=lambda: self.themecolorbrowse(0)) # Main window self.theme_button_0.grid(row=20, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) self.theme_label_1 = nb.Label(themeframe, text=self.theme_prompts[1]) self.theme_label_1.grid(row=21, padx=PADX, sticky=tk.W) self.theme_button_1 = nb.ColoredButton( themeframe, text=' Hutton Orbital ', background='grey4', command=lambda: self.themecolorbrowse(1)) # Do not translate self.theme_button_1.grid(row=21, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 4, sticky=tk.EW) self.ontop_button = nb.Checkbutton(themeframe, text=_('Always on top'), variable=self.always_ontop, command=self.themevarchanged) self.ontop_button.grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance setting nb.Label(themeframe).grid(sticky=tk.W) # big spacer notebook.add(themeframe, text=_('Appearance')) # Tab heading in settings # build plugin prefs tabs for plugin in plug.PLUGINS: #print(f'plug in pref {plugin.name}') plugframe = plugin.get_prefs(notebook, monitor.cmdr, monitor.is_beta) if plugframe: notebook.add(plugframe, text=plugin.name) # Plugin settings and info plugsframe = nb.Frame(notebook) plugsframe.columnconfigure(0, weight=1) plugdir = tk.StringVar() plugdir.set(config.plugin_dir) nb.Label(plugsframe, text=_('Plugins folder') + ':').grid( padx=PADX, sticky=tk.W) # Section heading in settings plugdirentry = nb.Entry(plugsframe, justify=tk.LEFT) self.displaypath(plugdir, plugdirentry) plugdirentry.grid(row=10, padx=PADX, sticky=tk.EW) nb.Button( plugsframe, text=_('Open'), # Button that opens a folder in Explorer/Finder command=lambda: webbrowser.open('file:///%s' % plugdir.get()) ).grid(row=10, column=1, padx=(0, PADX), sticky=tk.NSEW) nb.Label( plugsframe, text= _("Tip: You can disable a plugin by{CR}adding '{EXT}' to its folder name" ).format(EXT='.disabled')).grid( # Help text in settings columnspan=2, padx=PADX, pady=10, sticky=tk.NSEW) enabled_plugins = [x for x in plug.PLUGINS if x.folder and x.module] if len(enabled_plugins): ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW) nb.Label(plugsframe, text=_('Enabled Plugins') + ':').grid( padx=PADX, sticky=tk.W) # List of plugins in settings for plugin in enabled_plugins: if plugin.name == plugin.folder: label = nb.Label(plugsframe, text=plugin.name) else: label = nb.Label(plugsframe, text='%s (%s)' % (plugin.folder, plugin.name)) label.grid(columnspan=2, padx=PADX * 2, sticky=tk.W) disabled_plugins = [ x for x in plug.PLUGINS if x.folder and not x.module ] if len(disabled_plugins): ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW) nb.Label(plugsframe, text=_('Disabled Plugins') + ':').grid( padx=PADX, sticky=tk.W) # List of plugins in settings for plugin in disabled_plugins: nb.Label(plugsframe, text=plugin.name).grid(columnspan=2, padx=PADX * 2, sticky=tk.W) notebook.add(plugsframe, text=_('Plugins')) # Tab heading in settings if platform == 'darwin': self.protocol("WM_DELETE_WINDOW", self.apply) # close button applies changes else: buttonframe = ttk.Frame(frame) buttonframe.grid(padx=PADX, pady=PADX, sticky=tk.NSEW) buttonframe.columnconfigure(0, weight=1) ttk.Label(buttonframe).grid(row=0, column=0) # spacer button = ttk.Button(buttonframe, text=_('OK'), command=self.apply) button.grid(row=0, column=1, sticky=tk.E) button.bind("<Return>", lambda event: self.apply()) self.protocol("WM_DELETE_WINDOW", self._destroy) # Selectively disable buttons depending on output settings self.cmdrchanged() # wait for window to appear on screen before calling grab_set self.parent.update_idletasks() 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' and CalculatePopupWindowPosition: 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))
def __init__(self, parent, callback): tk.Toplevel.__init__(self, parent) self.parent = parent self.callback = callback self.title(platform=='darwin' and _('Preferences') or _('Settings')) 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 if platform=='win32': self.attributes('-toolwindow', tk.TRUE) elif platform=='darwin': # http://wiki.tcl.tk/13428 parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility') self.resizable(tk.FALSE, tk.FALSE) style = ttk.Style() frame = ttk.Frame(self) frame.grid(sticky=tk.NSEW) notebook = nb.Notebook(frame) PADX = 10 BUTTONX = 12 # indent Checkbuttons and Radiobuttons PADY = 2 # close spacing credframe = nb.Frame(notebook) credframe.columnconfigure(1, weight=1) nb.Label(credframe, text=_('Credentials')).grid(padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(credframe, text=_('Please log in with your Elite: Dangerous account details')).grid(padx=PADX, columnspan=2, sticky=tk.W) # Use same text as E:D Launcher's login dialog nb.Label(credframe, text=_('Username (Email)')).grid(row=10, padx=PADX, sticky=tk.W) # Use same text as E:D Launcher's login dialog nb.Label(credframe, text=_('Password')).grid(row=11, padx=PADX, sticky=tk.W) # Use same text as E:D Launcher's login dialog self.username = nb.Entry(credframe) self.username.insert(0, config.get('username') or '') self.username.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.EW) self.username.focus_set() self.password = nb.Entry(credframe, show=u'•') self.password.insert(0, config.get('password') or '') self.password.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) nb.Label(credframe).grid(sticky=tk.W) # big spacer nb.Label(credframe, text=_('Privacy')).grid(padx=PADX, sticky=tk.W) # Section heading in settings ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2, padx=PADX, pady=PADY, sticky=tk.EW) self.out_anon= tk.IntVar(value = config.getint('anonymous') and 1) nb.Label(credframe, text=_('How do you want to be identified in the saved data')).grid(columnspan=2, padx=PADX, sticky=tk.W) nb.Radiobutton(credframe, text=_('Cmdr name'), variable=self.out_anon, value=0).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # Privacy setting nb.Radiobutton(credframe, text=_('Pseudo-anonymized ID'), variable=self.out_anon, value=1).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) # Privacy setting notebook.add(credframe, text=_('Identity')) # Tab heading in settings outframe = nb.Frame(notebook) outframe.columnconfigure(0, weight=1) output = config.getint('output') or (config.OUT_MKT_EDDN | config.OUT_SYS_EDDN | config.OUT_SHIP_EDS) # default settings nb.Label(outframe, text=_('Please choose what data to save')).grid(columnspan=2, padx=PADX, sticky=tk.W) self.out_csv = tk.IntVar(value = (output & config.OUT_MKT_CSV ) and 1) nb.Checkbutton(outframe, text=_('Market data in CSV format file'), variable=self.out_csv, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_bpc = tk.IntVar(value = (output & config.OUT_MKT_BPC ) and 1) nb.Checkbutton(outframe, text=_("Market data in Slopey's BPC format file"), variable=self.out_bpc, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_td = tk.IntVar(value = (output & config.OUT_MKT_TD ) and 1) nb.Checkbutton(outframe, text=_('Market data in Trade Dangerous format file'), variable=self.out_td, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_ship_eds= tk.IntVar(value = (output & config.OUT_SHIP_EDS) and 1) nb.Checkbutton(outframe, text=_('Ship loadout in E:D Shipyard format file'), variable=self.out_ship_eds, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W) self.out_ship_coriolis= tk.IntVar(value = (output & config.OUT_SHIP_CORIOLIS) and 1) nb.Checkbutton(outframe, text=_('Ship loadout in Coriolis format file'), variable=self.out_ship_coriolis, command=self.outvarchanged).grid(columnspan=2, padx=BUTTONX, sticky=tk.W) self.out_auto = tk.IntVar(value = 0 if output & config.OUT_MKT_MANUAL else 1) # inverted self.out_auto_button = nb.Checkbutton(outframe, text=_('Automatically update on docking'), variable=self.out_auto, command=self.outvarchanged) # Output setting self.out_auto_button.grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W) self.outdir_label = nb.Label(outframe, text=_('File location')+':') # Section heading in settings self.outdir_label.grid(padx=BUTTONX, pady=(5,0), sticky=tk.W) self.outdir = nb.Entry(outframe, takefocus=False) if config.get('outdir').startswith(config.home): self.outdir.insert(0, '~' + config.get('outdir')[len(config.home):]) else: self.outdir.insert(0, config.get('outdir')) self.outdir.grid(row=20, padx=(PADX,0), sticky=tk.EW) self.outbutton = nb.Button(outframe, text=(platform=='darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), # Folder selection button on Windows command = lambda:self.filebrowse(_('File location'), self.outdir)) self.outbutton.grid(row=20, column=1, padx=PADX, sticky=tk.NSEW) nb.Frame(outframe).grid(pady=5) # bottom spacer notebook.add(outframe, text=_('Output')) # Tab heading in settings eddnframe = nb.Frame(notebook) HyperlinkLabel(eddnframe, text='Elite Dangerous Data Network', background=nb.Label().cget('background'), url='https://github.com/jamesremuscat/EDDN/wiki', underline=True).grid(padx=PADX, sticky=tk.W) # Don't translate self.eddn_station= tk.IntVar(value = (output & config.OUT_MKT_EDDN) and 1) nb.Checkbutton(eddnframe, text=_('Send station data to the Elite Dangerous Data Network'), variable=self.eddn_station, command=self.outvarchanged).grid(padx=BUTTONX, pady=(5,0), sticky=tk.W) # Output setting self.eddn_auto_button = nb.Checkbutton(eddnframe, text=_('Automatically update on docking'), variable=self.out_auto, command=self.outvarchanged) # Output setting self.eddn_auto_button.grid(padx=BUTTONX, sticky=tk.W) self.eddn_system = tk.IntVar(value = (output & config.OUT_SYS_EDDN) and 1) self.eddn_system_button = nb.Checkbutton(eddnframe, text=_('Send system and scan data to the Elite Dangerous Data Network'), variable=self.eddn_system, command=self.outvarchanged) # Output setting new in E:D 2.2 self.eddn_system_button.grid(padx=BUTTONX, pady=(5,0), sticky=tk.W) self.eddn_delay= tk.IntVar(value = (output & config.OUT_SYS_DELAY) and 1) self.eddn_delay_button = nb.Checkbutton(eddnframe, text=_('Delay sending until docked'), variable=self.eddn_delay, command=self.outvarchanged) # Output setting under 'Send system and scan data to the Elite Dangerous Data Network' new in E:D 2.2 self.eddn_delay_button.grid(padx=BUTTONX, sticky=tk.W) notebook.add(eddnframe, text='EDDN') # Not translated edsmframe = nb.Frame(notebook) edsmframe.columnconfigure(1, weight=1) HyperlinkLabel(edsmframe, text='Elite Dangerous Star Map', background=nb.Label().cget('background'), url='https://www.edsm.net/', underline=True).grid(columnspan=2, padx=PADX, sticky=tk.W) # Don't translate self.edsm_log = tk.IntVar(value = (output & config.OUT_SYS_EDSM) and 1) self.edsm_log_button = nb.Checkbutton(edsmframe, text=_('Send flight log to Elite Dangerous Star Map'), variable=self.edsm_log, command=self.outvarchanged) self.edsm_log_button.grid(columnspan=2, padx=BUTTONX, pady=(5,0), sticky=tk.W) nb.Label(edsmframe).grid(sticky=tk.W) # big spacer self.edsm_label = HyperlinkLabel(edsmframe, text=_('Elite Dangerous Star Map credentials'), background=nb.Label().cget('background'), url='https://www.edsm.net/settings/api', underline=True) # Section heading in settings self.edsm_label.grid(columnspan=2, padx=PADX, sticky=tk.W) self.edsm_cmdr_label = nb.Label(edsmframe, text=_('Commander Name')) # EDSM setting self.edsm_cmdr_label.grid(row=10, padx=PADX, sticky=tk.W) self.edsm_cmdr = nb.Entry(edsmframe) self.edsm_cmdr.insert(0, config.get('edsm_cmdrname') or '') self.edsm_cmdr.grid(row=10, column=1, padx=PADX, pady=PADY, sticky=tk.EW) self.edsm_apikey_label = nb.Label(edsmframe, text=_('API Key')) # EDSM setting self.edsm_apikey_label.grid(row=11, padx=PADX, sticky=tk.W) self.edsm_apikey = nb.Entry(edsmframe) self.edsm_apikey.insert(0, config.get('edsm_apikey') or '') self.edsm_apikey.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) notebook.add(edsmframe, text='EDSM') # Not translated configframe = nb.Frame(notebook) configframe.columnconfigure(1, weight=1) self.logdir = nb.Entry(configframe, takefocus=False) logdir = config.get('journaldir') or config.default_journal_dir if not logdir: pass elif logdir.startswith(config.home): self.logdir.insert(0, '~' + logdir[len(config.home):]) else: self.logdir.insert(0, logdir) self.logdir['state'] = 'readonly' if platform != 'darwin': # Apple's SMB implementation is way too flaky - no filesystem events and bogus NULLs nb.Label(configframe, text = _('E:D journal file location')+':').grid(columnspan=3, padx=PADX, sticky=tk.W) # Location of the new Journal file in E:D 2.2 self.logdir.grid(row=10, columnspan=2, padx=(PADX,0), sticky=tk.EW) self.logbutton = nb.Button(configframe, text=(platform=='darwin' and _('Change...') or # Folder selection button on OSX _('Browse...')), # Folder selection button on Windows command = lambda:self.filebrowse(_('E:D journal file location'), self.logdir)) self.logbutton.grid(row=10, column=2, padx=PADX, sticky=tk.EW) if config.default_journal_dir: nb.Button(configframe, text=_('Default'), command=self.logdir_reset, state = config.get('journaldir') and tk.NORMAL or tk.DISABLED).grid(column=2, padx=PADX, pady=(5,0), sticky=tk.EW) # Appearance theme and language setting if platform == 'win32': ttk.Separator(configframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY*8, sticky=tk.EW) if platform in ['darwin','win32']: self.hotkey_code = config.getint('hotkey_code') self.hotkey_mods = config.getint('hotkey_mods') self.hotkey_only = tk.IntVar(value = not config.getint('hotkey_always')) self.hotkey_play = tk.IntVar(value = not config.getint('hotkey_mute')) nb.Label(configframe, text = platform=='darwin' and _('Keyboard shortcut') or # Hotkey/Shortcut settings prompt on OSX _('Hotkey') # Hotkey/Shortcut settings prompt on Windows ).grid(row=20, padx=PADX, sticky=tk.W) if platform == 'darwin' and not was_accessible_at_launch: if AXIsProcessTrusted(): nb.Label(configframe, text = _('Re-start {APP} to use shortcuts').format(APP=applongname), foreground='firebrick').grid(padx=PADX, sticky=tk.W) # Shortcut settings prompt on OSX else: nb.Label(configframe, text = _('{APP} needs permission to use shortcuts').format(APP=applongname), foreground='firebrick').grid(columnspan=3, padx=PADX, sticky=tk.W) # Shortcut settings prompt on OSX nb.Button(configframe, text = _('Open System Preferences'), command = self.enableshortcuts).grid(column=2, padx=PADX, sticky=tk.E) # Shortcut settings button on OSX else: self.hotkey_text = nb.Entry(configframe, width = (platform == 'darwin' and 20 or 30), justify=tk.CENTER) self.hotkey_text.insert(0, self.hotkey_code and hotkeymgr.display(self.hotkey_code, self.hotkey_mods) or _('None')) # No hotkey/shortcut currently defined self.hotkey_text.bind('<FocusIn>', self.hotkeystart) self.hotkey_text.bind('<FocusOut>', self.hotkeyend) self.hotkey_text.grid(row=20, column=1, columnspan=2, padx=PADX, pady=(5,0), sticky=tk.W) self.hotkey_only_btn = nb.Checkbutton(configframe, text=_('Only when Elite: Dangerous is the active app'), variable=self.hotkey_only, state = self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_only_btn.grid(columnspan=3, padx=PADX, pady=(5,0), sticky=tk.W) self.hotkey_play_btn = nb.Checkbutton(configframe, text=_('Play sound'), variable=self.hotkey_play, state = self.hotkey_code and tk.NORMAL or tk.DISABLED) # Hotkey/Shortcut setting self.hotkey_play_btn.grid(columnspan=3, padx=PADX, sticky=tk.W) notebook.add(configframe, text=_('Configuration')) # Tab heading in settings self.languages = Translations().available_names() self.lang = tk.StringVar(value = self.languages.get(config.get('language'), _('Default'))) # Appearance theme and language setting self.always_ontop = tk.BooleanVar(value = config.getint('always_ontop')) self.theme = tk.IntVar(value = config.getint('theme') and 1 or 0) self.theme_colors = [config.get('dark_text'), config.get('dark_highlight')] self.theme_prompts = [ _('Normal text'), # Dark theme color setting _('Highlighted text'), # Dark theme color setting ] themeframe = nb.Frame(notebook) themeframe.columnconfigure(2, weight=1) nb.Label(themeframe, text=_('Language')).grid(row=10, padx=PADX, sticky=tk.W) # Appearance setting prompt self.lang_button = nb.OptionMenu(themeframe, self.lang, self.lang.get(), *self.languages.values()) self.lang_button.grid(row=10, column=1, columnspan=2, padx=PADX, sticky=tk.W) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY*8, sticky=tk.EW) nb.Label(themeframe, text=_('Theme')).grid(columnspan=3, padx=PADX, sticky=tk.W) # Appearance setting nb.Radiobutton(themeframe, text=_('Default'), variable=self.theme, value=0, command=self.themevarchanged).grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme and language setting nb.Radiobutton(themeframe, text=_('Dark'), variable=self.theme, value=1, command=self.themevarchanged).grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance theme setting self.theme_label_0 = nb.Label(themeframe, text=self.theme_prompts[0]) self.theme_label_0.grid(row=20, padx=PADX, sticky=tk.W) self.theme_button_0 = nb.ColoredButton(themeframe, text=_('Station'), background='grey4', command=lambda:self.themecolorbrowse(0)) # Main window self.theme_button_0.grid(row=20, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) self.theme_label_1 = nb.Label(themeframe, text=self.theme_prompts[1]) self.theme_label_1.grid(row=21, padx=PADX, sticky=tk.W) self.theme_button_1 = nb.ColoredButton(themeframe, text=' Hutton Orbital ', background='grey4', command=lambda:self.themecolorbrowse(1)) # Do not translate self.theme_button_1.grid(row=21, column=1, padx=PADX, pady=PADY, sticky=tk.NSEW) ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY*8, sticky=tk.EW) self.ontop_button = nb.Checkbutton(themeframe, text=_('Always on top'), variable=self.always_ontop, command=self.themevarchanged) self.ontop_button.grid(columnspan=3, padx=BUTTONX, sticky=tk.W) # Appearance setting nb.Label(themeframe).grid(sticky=tk.W) # big spacer notebook.add(themeframe, text=_('Appearance')) # Tab heading in settings # build plugin prefs tabs for plugname in plug.PLUGINS: plugframe = plug.get_plugin_pref(plugname, notebook) if plugframe: notebook.add(plugframe, text=plugname) if platform=='darwin': self.protocol("WM_DELETE_WINDOW", self.apply) # close button applies changes else: buttonframe = ttk.Frame(frame) buttonframe.grid(padx=PADX, pady=PADX, sticky=tk.NSEW) buttonframe.columnconfigure(0, weight=1) ttk.Label(buttonframe).grid(row=0, column=0) # spacer button = ttk.Button(buttonframe, text=_('OK'), command=self.apply) button.grid(row=0, column=1, sticky=tk.E) button.bind("<Return>", lambda event:self.apply()) self.protocol("WM_DELETE_WINDOW", self._destroy) # Selectively disable buttons depending on output settings self.outvarchanged() self.themevarchanged() # disable hotkey for the duration hotkeymgr.unregister() # 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()
def plugin_prefs(parent: nb.Notebook, cmdr: str, is_beta: bool) -> nb.Frame: global xpos_var, ypos_var, width_var, height_var xpos_var = tk.IntVar(value=int(config.get("edmcoverlay2_xpos") or 0)) ypos_var = tk.IntVar(value=int(config.get("edmcoverlay2_ypos") or 0)) width_var = tk.IntVar(value=int(config.get("edmcoverlay2_width") or 1920)) height_var = tk.IntVar( value=int(config.get("edmcoverlay2_height") or 1080)) frame = nb.Frame(parent) frame.columnconfigure(0, weight=1) PAD_X = 10 PAD_Y = 2 f0 = nb.Frame(frame) HyperlinkLabel(f0, text="edmcoverlay2", url="https://github.com/sersorrel/edmcoverlay2", background=nb.Label().cget('background'), underline=True).grid(row=0, column=0, sticky=tk.W, padx=(PAD_X, 0)) nb.Label(f0, text="by Ash Holland").grid(row=0, column=1, sticky=tk.W, padx=(0, PAD_X)) f0.grid(sticky=tk.EW) ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PAD_X, pady=2 * PAD_Y, sticky=tk.EW) f1 = nb.Frame(frame) nb.Label(f1, text="Overlay configuration:").grid(row=0, column=0, columnspan=3, padx=PAD_X, pady=PAD_Y, sticky=tk.W) nb.Label(f1, text="X position").grid(row=1, column=0, padx=PAD_X, pady=(PAD_Y, 0), sticky=tk.E) nb.Entry(f1, textvariable=xpos_var).grid(row=1, column=1, columnspan=3, padx=(0, PAD_X), pady=PAD_Y, sticky=tk.W) nb.Label(f1, text="Y position").grid(row=2, column=0, padx=PAD_X, pady=(PAD_Y, 0), sticky=tk.E) nb.Entry(f1, textvariable=ypos_var).grid(row=2, column=1, columnspan=3, padx=(0, PAD_X), pady=PAD_Y, sticky=tk.W) nb.Label(f1, text="Width").grid(row=3, column=0, padx=PAD_X, pady=(PAD_Y, 0), sticky=tk.E) nb.Entry(f1, textvariable=width_var).grid(row=3, column=1, columnspan=3, padx=(0, PAD_X), pady=PAD_Y, sticky=tk.W) nb.Label(f1, text="Height").grid(row=4, column=0, padx=PAD_X, pady=(PAD_Y, 0), sticky=tk.E) nb.Entry(f1, textvariable=height_var).grid(row=4, column=1, columnspan=3, padx=(0, PAD_X), pady=PAD_Y, sticky=tk.W) f1.grid(sticky=tk.EW) ttk.Separator(frame, orient=tk.HORIZONTAL).grid(padx=PAD_X, pady=2 * PAD_Y, sticky=tk.EW) f2 = nb.Frame(frame) nb.Label(f2, text="Manual overlay controls:").grid(row=0, column=0, padx=PAD_X, pady=PAD_Y) nb.Button(f2, text="Start overlay", command=lambda: start_overlay()).grid(row=0, column=1, padx=PAD_X, pady=PAD_Y) nb.Button(f2, text="Stop overlay", command=lambda: stop_overlay()).grid(row=0, column=2, padx=PAD_X, pady=PAD_Y) f2.grid(sticky=tk.EW) return frame
def plugin_prefs(parent, cmdr, is_beta): """ Return a TK Frame for adding to the EDMC settings dialog. """ this.mysetting = tk.IntVar(value=config.getint( "MyPluginSetting")) # Retrieve saved value from config frame = nb.Frame(parent) frameMain = nb.Frame(frame) frameMain.grid(row=0, column=0, sticky=tk.W) frameBottom = nb.Frame(frame) frameBottom.grid(row=1, column=0, sticky=tk.SW) # this.emptyFrame = nb.Frame(frame) nb.Label(frameMain, text="").grid(row=0, column=0, sticky=tk.W) nb.Label(frameMain, text="Journal Dir: ").grid(row=1, column=0, sticky=tk.W) nb.Label(frameMain, text=journal_dir).grid(row=1, column=1, sticky=tk.W) nb.Label(frameMain, text="Save Dir: ").grid(row=2, column=0, sticky=tk.W) nb.Label(frameMain, text=out_dir).grid(row=2, column=1, sticky=tk.W) nb.Label(frameMain, text="").grid(row=3, column=0, sticky=tk.W) exButt = nb.Button(frameMain, text="Export Scans", width=20) exButt.grid(row=4, column=1, rowspan=3, columnspan=2, sticky=tk.W) exButt.config(width=50, command=journal_export) nb.Label( frameMain, text="\nCreates a CSV file of all journals regardless of cmdr.").grid( row=7, column=1, columnspan=2, sticky=tk.W) nb.Label(frameMain, text="The layout mimics the output and order that ").grid( column=1, columnspan=2, sticky=tk.W) nb.Label( frameMain, text="EDDiscovery produces, (since some tools depend on that)").grid( column=1, columnspan=2, sticky=tk.W) nb.Label( frameMain, text="but also includes all planetary and stellar ring data.").grid( column=1, columnspan=2, sticky=tk.W) nb.Label(frameMain).grid(row=11) # spacer nb.Label(frameMain, text="Need this to output something that it isn't? Click on the " ).grid(row=12, column=1, columnspan=2, sticky=tk.W) # spacer nb.Label(frameMain, text="Github link below.").grid(column=1, columnspan=2, sticky=tk.W) # spacer nb.Label(frameBottom).grid(row=0) # spacer nb.Label( frameBottom, text= "EDDx was created by Cmdr. Taen who kn(ew|ows) basically nothing about programming." ).grid(row=1, columnspan=3, sticky=tk.SW) nb.Label(frameBottom, text="Last Updated: 2018-01-12 -- Version 1.0").grid(row=3, columnspan=3, sticky=tk.SW) nb.Label(frameBottom).grid(row=2) # spacer link = nb.Label(frameBottom, text="Open the Github page for this plugin", fg="blue", cursor="hand2") link.grid(row=5, column=0, sticky=tk.W) link.bind("<Button-1>", openGithub) return frame
def plugin_prefs(parent, cmdr, is_beta): this.frame = nb.Frame(parent) this.frame.bind_all("<<DistanceCalc-EDSM-Response>>", updatePrefsUI) frameTop = nb.Frame(this.frame) frameTop.grid(row=0, column=0, sticky=tk.W) frameBottom = nb.Frame(this.frame) frameBottom.grid(row=1, column=0, sticky=tk.SW) # headline nb.Label(frameTop, text="Systems").grid(row=0, column=0, sticky=tk.EW) nb.Label(frameTop, text="X").grid(row=0, column=1, sticky=tk.EW) nb.Label(frameTop, text="Y").grid(row=0, column=2, sticky=tk.EW) nb.Label(frameTop, text="Z").grid(row=0, column=3, sticky=tk.EW) this.errorLabel = nb.Label(frameTop, text="") this.settingsUiElements = list() vcmd = (frameTop.register(validate), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W') # create and add fields to enter systems for i in range(3): systemEntry = nb.Entry(frameTop) systemEntry.grid(row=i + 1, column=0, padx=(this.PADX * 2, this.PADX), sticky=tk.W) systemEntry.config( width=this.WIDTH * 4 ) # set fixed width. columnconfigure doesn't work because it already fits xEntry = nb.Entry(frameTop, validate='key', validatecommand=vcmd) xEntry.grid(row=i + 1, column=1, padx=this.PADX, sticky=tk.W) xEntry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits yEntry = nb.Entry(frameTop, validate='key', validatecommand=vcmd) yEntry.grid(row=i + 1, column=2, padx=this.PADX, sticky=tk.W) yEntry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits zEntry = nb.Entry(frameTop, validate='key', validatecommand=vcmd) zEntry.grid(row=i + 1, column=3, padx=this.PADX, sticky=tk.W) zEntry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits clearButton = nb.Button(frameTop, text="Clear", command=partial(clearInputFields, systemEntry, xEntry, yEntry, zEntry)) clearButton.grid(row=i + 1, column=4, padx=this.PADX, sticky=tk.W) clearButton.config(width=7) edsmButton = nb.Button(frameTop, text="EDSM") edsmButton.grid(row=i + 1, column=5, padx=(this.PADX, this.PADX * 2), sticky=tk.W) edsmButton.config(width=7, command=partial(fillSystemInformationFromEdsmAsync, i, systemEntry)) this.settingsUiElements.append( SettingsUiElements(systemEntry, xEntry, yEntry, zEntry, edsmButton)) # EDSM result label and information about what coordinates can be entered this.errorLabel.grid(row=4, column=0, columnspan=6, padx=this.PADX * 2, sticky=tk.W) nb.Label( frameTop, text= "You can get coordinates from EDDB or EDSM or enter any valid coordinate." ).grid(row=5, column=0, columnspan=6, padx=this.PADX * 2, sticky=tk.W) ttk.Separator(frameTop, orient=tk.HORIZONTAL).grid(row=6, columnspan=6, padx=this.PADX * 2, pady=8, sticky=tk.EW) # total travelled distance travelledTotal = nb.Checkbutton(frameBottom, variable=this.travelledTotalOption, text="Calculate total travelled distance") travelledTotal.var = this.travelledTotalOption travelledTotal.grid(row=0, column=0, padx=this.PADX * 2, sticky=tk.W) resetButton = nb.Button(frameBottom, text="Reset", command=resetTotalTravelledDistance) resetButton.grid(row=1, column=0, padx=this.PADX * 4, pady=5, sticky=tk.W) travelledSession = nb.Checkbutton( frameBottom, variable=this.travelledSessionOption, text="Calculate travelled distance for current session") travelledSession.var = this.travelledSessionOption travelledSession.grid(row=2, column=0, padx=this.PADX * 2, sticky=tk.W) # radio button value: 1 = calculate for ED session; 0 = calculate for EDMC session travelledSessionEdmc = nb.Radiobutton( frameBottom, variable=this.travelledSessionSelected, value=0, text="EDMC session") travelledSessionEdmc.var = this.travelledSessionSelected travelledSessionEdmc.grid(row=3, column=0, padx=this.PADX * 4, sticky=tk.W) travelledSessionElite = nb.Radiobutton( frameBottom, variable=this.travelledSessionSelected, value=1, text="Elite session") travelledSessionElite.var = this.travelledSessionSelected travelledSessionElite.grid(row=4, column=0, padx=this.PADX * 4, sticky=tk.W) setStateRadioButtons(travelledSessionEdmc, travelledSessionElite) travelledSession.config(command=partial( setStateRadioButtons, travelledSessionEdmc, travelledSessionElite)) nb.Label(frameBottom).grid(row=5) # spacer nb.Label(frameBottom).grid(row=6) # spacer nb.Label(frameBottom, text="Plugin version: {0}".format( this.VERSION)).grid(row=7, column=0, padx=this.PADX, sticky=tk.W) HyperlinkLabel(this.frame, text="Open the Github page for this plugin", background=nb.Label().cget("background"), url="https://github.com/Thurion/DistanceCalc/", underline=True).grid(row=8, column=0, padx=this.PADX, sticky=tk.W) HyperlinkLabel(this.frame, text="Get estimated coordinates from EDTS", background=nb.Label().cget("background"), url="http://edts.thargoid.space/", underline=True)\ .grid(row=9, column=0, padx=this.PADX, sticky=tk.W) def fillEntries(s, x, y, z, systemEntry, xEntry, yEntry, zEntry): systemEntry.insert(0, s) xEntry.insert(0, Locale.stringFromNumber(x)) yEntry.insert(0, Locale.stringFromNumber(y)) zEntry.insert(0, Locale.stringFromNumber(z)) row = 0 if len(this.distances) > 0: for var in this.distances: settingsUiElement = this.settingsUiElements[row] fillEntries(var["system"], var["x"], var["y"], var["z"], settingsUiElement.systemEntry, settingsUiElement.xEntry, settingsUiElement.yEntry, settingsUiElement.zEntry) row += 1 return this.frame
def plugin_prefs(parent, cmdr, is_beta): if not config.get_str("ugc_cmdr"): config.set("ugc_cmdr", cmdr.encode("ascii", "replace").decode()) this.CMDr = config.get_str("ugc_cmdr") crypter() this.paras = { 'Content-type': 'application/json', 'Accept': 'text/plain', 'version': this.__VERSION__, "br": this.__MINOR__, "branch": this.__BRANCH__, "cmdr": str(this.send_cmdr), "uuid": this.UUID, "token": this.Hash, "onlyBGS": str(this.show_all_bgs) } PADX = 10 BUTTONX = 12 # indent Checkbuttons and Radiobuttons PADY = 2 this.wurl = config.get_str("ugc_wurl") this.rurl = config.get_str("ugc_rurl") frame = nb.Frame(parent) #Config Entry for Data-Receiver URL this.wurl_label = nb.Label(frame, text="Sende URL") this.wurl_label.grid(row=11, padx=PADX, sticky=tk.W) this.wurl_cfg = nb.Entry(frame) this.wurl_cfg.grid(row=11, column=1, padx=PADX, pady=PADY, sticky=tk.EW) this.wurl_cfg.insert(0, this.wurl) #Config Entry for Data-Receiver URL this.rurl_label = nb.Label(frame, text="State URL") this.rurl_label.grid(row=12, padx=PADX, sticky=tk.W) this.rurl_cfg = nb.Entry(frame) this.rurl_cfg.grid(row=12, column=1, padx=PADX, pady=PADY, sticky=tk.EW) this.rurl_cfg.insert(0, this.rurl) #Config Entry for Verify-Token this.vtk_label = nb.Label(frame, text="Verify Token") this.vtk_label.grid(row=13, padx=PADX, sticky=tk.W) this.vtk_cfg = nb.Entry(frame) this.vtk_cfg.grid(row=13, column=1, padx=PADX, pady=PADY, sticky=tk.EW) this.vtk_cfg.insert(0, "") #config interface nb.Checkbutton(frame, text="CMDr Namen übertragen", variable=this.send_cmdr_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Checkbutton(frame, text="Gesamte Liste Zeigen", variable=this.show_all_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Checkbutton(frame, text="Nur BGS relevante zeigen", variable=this.show_all_bgs_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Checkbutton(frame, text="Auto Update", variable=this.update_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Checkbutton(frame, text="Slow State", variable=this.slow_state_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Checkbutton(frame, text="Debug", variable=this.debug_cfg).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Label(frame, text="Textfarben: ").grid(columnspan=2, padx=5, pady=(2, 0), sticky=tk.W) nb.Label(frame, text="Green: Start Up").grid(columnspan=2, padx=5, pady=(0, 0)) nb.Label(frame, text="Orange: Bussy").grid(columnspan=2, padx=5, pady=(0, 0)) nb.Label(frame, text="White: Idle").grid(columnspan=2, padx=5, pady=(0, 0)) nb.Label(frame, text="Red: Error").grid(columnspan=2, padx=5, pady=(0, 0)) nb.Label(frame, text="Version: " + str(this.__VERSION__) + "." + this.__MINOR__ + " " + str(this.__BRANCH__)).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Label(frame, text="CMDr: " + str(cmdr)).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) nb.Button(frame, text="Test", command=lambda: send_test(cmdr, is_beta)).grid(columnspan=2, padx=BUTTONX, pady=(5, 0), sticky=tk.W) return frame
def open_prefs(self, parent, cmdr: str, is_beta: bool): row_top = 0 def next_row_top(): nonlocal row_top row_top += 1 return row_top self.prefs_frame = nb.Frame(parent) self.prefs_frame.bind_all(DistanceCalc.EVENT_EDSM_RESPONSE, self.update_prefs_ui) frame_top = nb.Frame(self.prefs_frame) frame_top.grid(row=0, column=0, sticky=tk.W) frame_bottom = nb.Frame(self.prefs_frame) frame_bottom.grid(row=1, column=0, sticky=tk.SW) # headline nb.Label(frame_top, text="Systems").grid(row=row_top, column=2, sticky=tk.EW) nb.Label(frame_top, text="X").grid(row=row_top, column=3, sticky=tk.EW) nb.Label(frame_top, text="Y").grid(row=row_top, column=4, sticky=tk.EW) nb.Label(frame_top, text="Z").grid(row=row_top, column=5, sticky=tk.EW) self.error_label = nb.Label(frame_top, text="") self.settings_ui_elements = list() vcmd = (frame_top.register(self.validate), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W') # create and add fields to enter systems for i in range(this.NUMBER_OF_SYSTEMS): next_row_top() up_button = nb.Button(frame_top, text="\u25B2", command=partial(self.rearrange_order, i, i - 1)) up_button.grid(row=row_top, column=0, padx=(this.PADX * 2, 1), sticky=tk.W) up_button.config(width=3) if i == 0: up_button["state"] = tk.DISABLED down_button = nb.Button(frame_top, text="\u25BC", command=partial(self.rearrange_order, i, i + 1)) down_button.grid(row=row_top, column=1, padx=(1, this.PADX), sticky=tk.W) down_button.config(width=3) if i == this.NUMBER_OF_SYSTEMS - 1: down_button["state"] = tk.DISABLED system_entry = nb.Entry(frame_top) system_entry.grid(row=row_top, column=2, padx=this.PADX, sticky=tk.W) system_entry.config( width=this.WIDTH * 4 ) # set fixed width. columnconfigure doesn't work because it already fits x_entry = nb.Entry(frame_top, validate='key', validatecommand=vcmd) x_entry.grid(row=row_top, column=3, padx=this.PADX, sticky=tk.W) x_entry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits y_entry = nb.Entry(frame_top, validate='key', validatecommand=vcmd) y_entry.grid(row=row_top, column=4, padx=this.PADX, sticky=tk.W) y_entry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits z_entry = nb.Entry(frame_top, validate='key', validatecommand=vcmd) z_entry.grid(row=row_top, column=5, padx=this.PADX, sticky=tk.W) z_entry.config( width=this.WIDTH ) # set fixed width. columnconfigure doesn't work because it already fits clear_button = nb.Button(frame_top, text="Clear", command=partial(self.clear_input_fields, i)) clear_button.grid(row=row_top, column=6, padx=this.PADX, sticky=tk.W) clear_button.config(width=7) edsm_button = nb.Button(frame_top, text="EDSM") edsm_button.grid(row=row_top, column=7, padx=(this.PADX, this.PADX * 2), sticky=tk.W) edsm_button.config( width=7, command=partial(self.fill_system_information_from_edsm_async, i, system_entry)) self.settings_ui_elements.append( SettingsUiElements(system_entry, x_entry, y_entry, z_entry, edsm_button)) # EDSM result label and information about what coordinates can be entered self.error_label.grid(row=next_row_top(), column=0, columnspan=6, padx=this.PADX * 2, sticky=tk.W) nb.Label( frame_top, text= "You can get coordinates from EDDB or EDSM or enter any valid coordinate." ).grid(row=next_row_top(), column=0, columnspan=6, padx=this.PADX * 2, sticky=tk.W) ttk.Separator(frame_top, orient=tk.HORIZONTAL).grid(row=next_row_top(), columnspan=6, padx=this.PADX * 2, pady=8, sticky=tk.EW) row_bottom = 0 def next_row_bottom(): nonlocal row_bottom row_bottom += 1 return row_bottom # total travelled distance travelled_total = nb.Checkbutton( frame_bottom, variable=self.travelled_total_option, text="Calculate total travelled distance") travelled_total.var = self.travelled_total_option travelled_total.grid(row=row_bottom, column=0, padx=this.PADX * 2, sticky=tk.W) reset_button = nb.Button(frame_bottom, text="Reset", command=self.reset_total_travelled_distance) reset_button.grid(row=next_row_bottom(), column=0, padx=this.PADX * 4, pady=5, sticky=tk.W) travelled_session = nb.Checkbutton( frame_bottom, variable=self.travelled_session_option, text="Calculate travelled distance for current session") travelled_session.var = self.travelled_session_option travelled_session.grid(row=next_row_bottom(), column=0, padx=this.PADX * 2, sticky=tk.W) # radio button value: 1 = calculate for ED session; 0 = calculate for EDMC session travelled_session_edmc = nb.Radiobutton( frame_bottom, variable=self.travelled_session_selected, value=0, text="EDMC session") travelled_session_edmc.var = self.travelled_session_selected travelled_session_edmc.grid(row=next_row_bottom(), column=0, padx=this.PADX * 4, sticky=tk.W) travelled_session_elite = nb.Radiobutton( frame_bottom, variable=self.travelled_session_selected, value=1, text="Elite session") travelled_session_elite.var = self.travelled_session_selected travelled_session_elite.grid(row=next_row_bottom(), column=0, padx=this.PADX * 4, sticky=tk.W) self.set_state_radio_buttons(travelled_session_edmc, travelled_session_elite) travelled_session.config( command=partial(self.set_state_radio_buttons, travelled_session_edmc, travelled_session_elite)) nb.Label(frame_bottom).grid(row=next_row_bottom()) # spacer nb.Label(frame_bottom).grid(row=next_row_bottom()) # spacer nb.Label(frame_bottom, text="Plugin version: {0}".format( this.VERSION)).grid(row=next_row_bottom(), column=0, padx=this.PADX, sticky=tk.W) HyperlinkLabel(self.prefs_frame, text="Open the Github page for this plugin", background=nb.Label().cget("background"), url="https://github.com/Thurion/DistanceCalc/", underline=True).grid(row=next_row_bottom(), column=0, padx=this.PADX, sticky=tk.W) HyperlinkLabel(self.prefs_frame, text="Get estimated coordinates from EDTS", background=nb.Label().cget("background"), url="http://edts.thargoid.space/", underline=True).grid(row=next_row_bottom(), column=0, padx=this.PADX, sticky=tk.W) row = 0 if len(self.distances) > 0: for var in self.distances: settings_ui_element = self.settings_ui_elements[row] self.fill_entries(var["system"], var["x"], var["y"], var["z"], settings_ui_element.system_entry, settings_ui_element.x_entry, settings_ui_element.y_entry, settings_ui_element.z_entry) row += 1 return self.prefs_frame