def graph_controls(self):
""" Dislplay sidebar controls. i.e. buttons, and controls"""
modes = self.controller.get_modes()
# setup mode radio buttons
group = []
for m in modes:
rb = radio_button(group, m, self.on_mode_button)
self.mode_buttons.append(rb)
# Create list of buttons
control_options = [button("Reset", self.on_reset_button)]
if stress_installed:
control_options.append(button('Stress Options', self.on_stress_menu_open))
control_options.append(button('Temp Sensors', self.on_temp_sensors_menu_open))
control_options.append(button('Help', self.on_help_menu_open))
control_options.append(button('About', self.on_about_menu_open))
# Create the menu
animate_controls = urwid.GridFlow(control_options, 18, 2, 0, 'center')
if urwid.get_encoding_mode() == "utf8":
unicode_checkbox = urwid.CheckBox(
"Smooth Graph", state=False,
on_state_change=self.on_unicode_checkbox)
else:
unicode_checkbox = urwid.Text(
"UTF-8 encoding not detected")
install_stress_message = urwid.Text("")
if not stress_installed:
install_stress_message = urwid.Text(('button normal', u"(N/A) install stress"))
graph_checkboxes = [urwid.CheckBox(x.get_graph_name(), state=True,
on_state_change=lambda w, state, x=x: self.change_checkbox_state(x, state))
for x in self.available_graphs.values()]
unavalable_graphs = [urwid.Text(( "[N/A] " + x.get_graph_name()) ) for x in self.graphs.values() if x.source.get_is_available() == False]
graph_checkboxes += unavalable_graphs
buttons = [urwid.Text(('bold text', u"Modes"), align="center"),
] + self.mode_buttons + [
install_stress_message,
urwid.Divider(),
urwid.Text(('bold text', u"Control Options"), align="center"),
animate_controls,
urwid.Divider(),
self.refresh_rate_ctrl,
urwid.Divider(),
urwid.LineBox(urwid.Pile(graph_checkboxes)),
urwid.LineBox(unicode_checkbox),
urwid.Divider(),
button("Quit", self.exit_program),
]
return buttons
评论列表
文章目录