Skip to content

Commit

Permalink
Auto-select first available terminal on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
Pidgeot committed Oct 16, 2017
1 parent c5d43fc commit f38ee8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
18 changes: 11 additions & 7 deletions tkgui/child_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def yes(self):

class TerminalSelector(ChildWindow):
"""Used to select a terminal for launcing child programs on Linux."""
def __init__(self, parent):
def __init__(self, parent, first_run):
self.first_run = first_run
super(TerminalSelector, self).__init__(parent, 'Configure terminal')
self.running_test = False
self.running_status = ''
Expand All @@ -319,13 +320,16 @@ def create_controls(self, container):
Label(f, text='Please select which terminal should be used when '
'launching programs requiring it (e.g. DFHack).').grid(
column=0, row=0)
self.term = StringVar(self.parent)
cur = terminal.get_configured_terminal()
try:
self.term.set(cur.name)
except NameError:
pass
terminals = [t.name for t in terminal.get_valid_terminals()]
self.term = StringVar(self.parent)
if self.first_run:
cur = terminals[0]
else:
try:
cur = terminal.get_configured_terminal().name
except NameError:
pass
self.term.set(cur)
OptionMenu(f, self.term, self.term.get(), *terminals).grid(
column=0, row=1)

Expand Down
11 changes: 7 additions & 4 deletions tkgui/tkgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self):
'PyLNP',
'You need to configure a terminal to allow things like DFHack '
'to work correctly. Press OK to do this now.')
self.configure_terminal()
self.configure_terminal(True)
self.root.deiconify()

root.option_add('*tearOff', FALSE)
Expand Down Expand Up @@ -441,9 +441,12 @@ def reload_program(self):
self.do_reload = True
self.exit_program()

def configure_terminal(self):
"""Configures the command used to launch a terminal on Linux."""
TerminalSelector(self.root)
def configure_terminal(self, first_run=False):
"""
Configures the command used to launch a terminal on Linux.
If first_run is set, a terminal will be selected automatically.
"""
TerminalSelector(self.root, first_run)

def configure_updates(self, days):
"""Sets the number of days until next update check."""
Expand Down

0 comments on commit f38ee8d

Please sign in to comment.