Пример #1
0
 def __init__(self, text):
     self.text = text
     self.header_widget = urwid.Text(self.text, align='left')
     self.popup = SimplePopupLauncher()
     self.popup_padding = urwid.Padding(self.popup, 'right', 20)
     self.popup_map = urwid.AttrMap(self.popup_padding, 'indicator')
     self.header_map = urwid.AttrMap(self.header_widget, 'head')
     super(Header, self).__init__([self.header_map, self.popup_map])
Пример #2
0
Файл: tui.py Проект: pol51/Aker
    def draw(self):
        self.palette = [
            ('body', 'black', 'light gray'),  # Normal Text
            ('focus', 'light green', 'black', 'standout'),  # Focus
            ('head', 'white', 'dark gray', 'standout'),  # Header
            ('foot', 'light gray', 'dark gray'),  # Footer Separator
            ('key', 'light green', 'dark gray', 'bold'),
            ('title', 'white', 'black', 'bold'),
            ('popup', 'white', 'dark red'),
            ('msg', 'yellow', 'dark gray'),
            ('SSH', 'dark blue', 'light gray', 'underline'),
            ('SSH_focus', 'light green', 'dark blue', 'standout')
        ]  # Focus

        self.header_text = [('key', "Aker"), " ", ('msg', "User:"******"%s" % self.aker.posix_user), " "]

        self.footer_text = [('msg', "Move:"), ('key', "Up"), ",",
                            ('key', "Down"), ",", ('key', "PgUp"), ",",
                            ('key', "PgDn"), ",", ('msg', "Select:"),
                            ('key', "Enter"), " ", ('msg', "Refresh:"),
                            ('key', "F5"), " ", ('msg', "Quit:"),
                            ('key', "F9"), " ", ('msg', "By:"),
                            ('key', "Ahmed Nazmy")]

        # Hosts ListBox
        self.hosts_listbox = self.refresh_hosts(
            self.aker.user.allowed_ssh_hosts)
        self.hosts_map = urwid.AttrWrap(self.hosts_listbox, 'body')

        # Edit Text area to capture user input
        self.search_edit = urwid.Edit("Type to search:\n")
        urwid.connect_signal(self.search_edit, 'change', self.search_change,
                             self.hosts_listbox)  # search field change action

        # Frame
        self.frame = urwid.Frame(self.hosts_map, header=self.search_edit)

        #Footer
        self.footer_text = urwid.Text(self.footer_text, align='center')
        self.footer = urwid.AttrMap(self.footer_text, 'foot')

        # Popup
        self.popup = SimplePopupLauncher()
        self.popup_padding = urwid.Padding(self.popup, 'right', 20)
        self.popup_map = urwid.AttrMap(self.popup_padding, 'indicator')

        # Header
        self.header_widget = urwid.Text(self.header_text, align='left')
        self.header_map = urwid.AttrMap(self.header_widget, 'head')
        self.header = urwid.Columns([self.header_map, self.popup_map])

        # Top most frame
        self.top = urwid.Frame(self.frame,
                               header=self.header,
                               footer=self.footer)
        self.screen = urwid.raw_display.Screen()

        #MainLoop start
        self.loop = urwid.MainLoop(self.top,
                                   palette=self.palette,
                                   unhandled_input=self.update_search_edit,
                                   screen=self.screen,
                                   pop_ups=True)