Beautify the configuration interface and keep the interface style consistent with the c tool.
This commit is contained in:
parent
0f40dd6a57
commit
df3262f011
|
@ -585,10 +585,12 @@ class MenuConfig(object):
|
||||||
self.list = tk.Listbox(
|
self.list = tk.Listbox(
|
||||||
dlg,
|
dlg,
|
||||||
selectmode=tk.SINGLE,
|
selectmode=tk.SINGLE,
|
||||||
activestyle=tk.UNDERLINE,
|
activestyle=tk.NONE,
|
||||||
font=font.nametofont('TkFixedFont'),
|
font=font.nametofont('TkFixedFont'),
|
||||||
height=1,
|
height=1,
|
||||||
)
|
)
|
||||||
|
self.list['foreground'] = 'Blue'
|
||||||
|
self.list['background'] = 'Gray95'
|
||||||
# Make selection invisible
|
# Make selection invisible
|
||||||
self.list['selectbackground'] = self.list['background']
|
self.list['selectbackground'] = self.list['background']
|
||||||
self.list['selectforeground'] = self.list['foreground']
|
self.list['selectforeground'] = self.list['foreground']
|
||||||
|
@ -633,6 +635,8 @@ class MenuConfig(object):
|
||||||
dlg.bind('<Return>', self.handle_keypress)
|
dlg.bind('<Return>', self.handle_keypress)
|
||||||
dlg.bind('<Right>', self.handle_keypress)
|
dlg.bind('<Right>', self.handle_keypress)
|
||||||
dlg.bind('<Left>', self.handle_keypress)
|
dlg.bind('<Left>', self.handle_keypress)
|
||||||
|
dlg.bind('<Up>', self.handle_keypress)
|
||||||
|
dlg.bind('<Down>', self.handle_keypress)
|
||||||
dlg.bind('n', self.handle_keypress)
|
dlg.bind('n', self.handle_keypress)
|
||||||
dlg.bind('m', self.handle_keypress)
|
dlg.bind('m', self.handle_keypress)
|
||||||
dlg.bind('y', self.handle_keypress)
|
dlg.bind('y', self.handle_keypress)
|
||||||
|
@ -655,6 +659,10 @@ class MenuConfig(object):
|
||||||
for n,c in widget.children.items():
|
for n,c in widget.children.items():
|
||||||
self._set_option_to_all_children(c, option, value)
|
self._set_option_to_all_children(c, option, value)
|
||||||
|
|
||||||
|
def _invert_colors(self, idx):
|
||||||
|
self.list.itemconfig(idx, {'bg' : self.list['foreground']})
|
||||||
|
self.list.itemconfig(idx, {'fg' : self.list['background']})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _selected_entry(self):
|
def _selected_entry(self):
|
||||||
# type: (...) -> ListEntry
|
# type: (...) -> ListEntry
|
||||||
|
@ -676,6 +684,7 @@ class MenuConfig(object):
|
||||||
if idx is not None:
|
if idx is not None:
|
||||||
self.list.activate(idx)
|
self.list.activate(idx)
|
||||||
self.list.see(idx)
|
self.list.see(idx)
|
||||||
|
self._invert_colors(idx)
|
||||||
|
|
||||||
def handle_keypress(self, ev):
|
def handle_keypress(self, ev):
|
||||||
keysym = ev.keysym
|
keysym = ev.keysym
|
||||||
|
@ -683,6 +692,10 @@ class MenuConfig(object):
|
||||||
self._select_action(prev=True)
|
self._select_action(prev=True)
|
||||||
elif keysym == 'Right':
|
elif keysym == 'Right':
|
||||||
self._select_action(prev=False)
|
self._select_action(prev=False)
|
||||||
|
elif keysym == 'Up':
|
||||||
|
self.refresh_display(reset_selection=False)
|
||||||
|
elif keysym == 'Down':
|
||||||
|
self.refresh_display(reset_selection=False)
|
||||||
elif keysym == 'space':
|
elif keysym == 'space':
|
||||||
self._selected_entry.toggle()
|
self._selected_entry.toggle()
|
||||||
elif keysym in ('n', 'm', 'y'):
|
elif keysym in ('n', 'm', 'y'):
|
||||||
|
@ -777,6 +790,7 @@ class MenuConfig(object):
|
||||||
else:
|
else:
|
||||||
# Select the topmost entry
|
# Select the topmost entry
|
||||||
self.list.activate(0)
|
self.list.activate(0)
|
||||||
|
self._invert_colors(0)
|
||||||
# Select ACTION_SELECT on each refresh (mimic C menuconfig)
|
# Select ACTION_SELECT on each refresh (mimic C menuconfig)
|
||||||
self.tk_selected_action.set(self.ACTION_SELECT)
|
self.tk_selected_action.set(self.ACTION_SELECT)
|
||||||
# Display current location in configuration tree
|
# Display current location in configuration tree
|
||||||
|
@ -804,6 +818,7 @@ class MenuConfig(object):
|
||||||
self.show_node(parent_node)
|
self.show_node(parent_node)
|
||||||
# Restore previous selection
|
# Restore previous selection
|
||||||
self._select_node(select_node)
|
self._select_node(select_node)
|
||||||
|
self.refresh_display(reset_selection=False)
|
||||||
|
|
||||||
def ask_for_string(self, ident=None, title='Enter string', value=None):
|
def ask_for_string(self, ident=None, title='Enter string', value=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue