Exemplo n.º 1
0
 def test_make_scale_labels(self):
     blobs = BlobWidget()
     blobs.width = 25
     scale_labels = blobs._make_scale_labels(0)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(2)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(10)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(11)
     self.assertEqual("         10        20    ", scale_labels)
     scale_labels = blobs._make_scale_labels(4589)
     self.assertEqual(" 4580      4590      ", scale_labels)
Exemplo n.º 2
0
    def __init__(self, pump):
        self.header = urwid.AttrWrap(
            urwid.Text("PipeInspector", align="center"), "header")

        self.blob_browser = BlobBrowser()

        self.info_area = urwid.Text("")
        self.blobs = BlobWidget()
        self.footer = urwid.Columns([self.info_area, self.blobs])

        self.frame = urwid.AttrWrap(
            urwid.Frame(self.blob_browser,
                        header=self.header,
                        footer=self.footer),
            "default",
        )
        urwid.Frame.__init__(self, self.frame)
        self.overlay = None

        self.pump = pump

        urwid.connect_signal(self.blobs, "blob_selected", self.blob_selected)
        self.blobs.goto_blob(0)
Exemplo n.º 3
0
 def test_make_scale_labels(self):
     blobs = BlobWidget()
     blobs.width = 25
     scale_labels = blobs._make_scale_labels(0)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(2)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(10)
     self.assertEqual("0         10        20   ", scale_labels)
     scale_labels = blobs._make_scale_labels(11)
     self.assertEqual("         10        20    ", scale_labels)
     scale_labels = blobs._make_scale_labels(4589)
     self.assertEqual(" 4580      4590      ", scale_labels)
Exemplo n.º 4
0
    def __init__(self, pump):
        self.header = urwid.AttrWrap(urwid.Text("PipeInspector", align='center'),
                                     'header')

        self.blob_browser = BlobBrowser()

        self.info_area = urwid.Text('')
        self.blobs = BlobWidget()
        self.footer = urwid.Columns([self.info_area, self.blobs])

        self.frame = urwid.AttrWrap(urwid.Frame(self.blob_browser,
                                                header=self.header,
                                                footer=self.footer), 'default')
        urwid.Frame.__init__(self, self.frame)
        self.overlay = None

        self.pump = pump

        urwid.connect_signal(self.blobs, 'blob_selected', self.blob_selected)
        self.blobs.goto_blob(0)
Exemplo n.º 5
0
 def test_make_ruler(self):
     blobs = BlobWidget()
     blobs.width = 25
     ruler = blobs._make_ruler(0)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(2)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(10)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(11)
     self.assertEqual("    '    |    '    |    '", ruler)
     ruler = blobs._make_ruler(12)
     self.assertEqual("   '    |    '    |    ' ", ruler)
     ruler = blobs._make_ruler(19)
     self.assertEqual(" |    '    |    '    |   ", ruler)
     ruler = blobs._make_ruler(20)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(23)
     self.assertEqual("  '    |    '    |    '  ", ruler)
     ruler = blobs._make_ruler(109)
     self.assertEqual(" |    '    |    '    |   ", ruler)
Exemplo n.º 6
0
class MainFrame(urwid.Frame):
    """
    Represents the main GUI

    """
    def __init__(self, pump):
        self.header = urwid.AttrWrap(urwid.Text("PipeInspector", align='center'),
                                     'header')

        self.blob_browser = BlobBrowser()

        self.info_area = urwid.Text('')
        self.blobs = BlobWidget()
        self.footer = urwid.Columns([self.info_area, self.blobs])

        self.frame = urwid.AttrWrap(urwid.Frame(self.blob_browser,
                                                header=self.header,
                                                footer=self.footer), 'default')
        urwid.Frame.__init__(self, self.frame)
        self.overlay = None

        self.pump = pump

        urwid.connect_signal(self.blobs, 'blob_selected', self.blob_selected)
        self.blobs.goto_blob(0)

    def blob_selected(self, index):
        self.info_area.set_text("Blob: {0}".format(index))

        #blob = self.pump.process(None)
        blob = self.pump.get_blob(index)
        self.blob_browser.load(blob)

    def keypress(self, size, key):
        input = urwid.Frame.keypress(self, size, key)
        if input is None:
            return
        if input in UI.keys['left']:
            self.blobs.previous_blob()
        elif input in UI.keys['right']:
            self.blobs.next_blob()
        elif input in [key.upper() for key in UI.keys['left']]:
            self.blobs.previous_blob(step=10)
        elif input in [key.upper() for key in UI.keys['right']]:
            self.blobs.next_blob(step=10)
        elif input in UI.keys['home']:
            self.blobs.goto_blob(0)
        else:
            return self.body.keypress(size, input)
Exemplo n.º 7
0
 def test_make_ruler(self):
     blobs = BlobWidget()
     blobs.width = 25
     ruler = blobs._make_ruler(0)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(2)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(10)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(11)
     self.assertEqual("    '    |    '    |    '", ruler)
     ruler = blobs._make_ruler(12)
     self.assertEqual("   '    |    '    |    ' ", ruler)
     ruler = blobs._make_ruler(19)
     self.assertEqual(" |    '    |    '    |   ", ruler)
     ruler = blobs._make_ruler(20)
     self.assertEqual("|    '    |    '    |    ", ruler)
     ruler = blobs._make_ruler(23)
     self.assertEqual("  '    |    '    |    '  ", ruler)
     ruler = blobs._make_ruler(109)
     self.assertEqual(" |    '    |    '    |   ", ruler)
Exemplo n.º 8
0
class MainFrame(urwid.Frame):
    """
    Represents the main GUI

    """
    def __init__(self, pump):
        self.header = urwid.AttrWrap(
            urwid.Text("PipeInspector", align="center"), "header")

        self.blob_browser = BlobBrowser()

        self.info_area = urwid.Text("")
        self.blobs = BlobWidget()
        self.footer = urwid.Columns([self.info_area, self.blobs])

        self.frame = urwid.AttrWrap(
            urwid.Frame(self.blob_browser,
                        header=self.header,
                        footer=self.footer),
            "default",
        )
        urwid.Frame.__init__(self, self.frame)
        self.overlay = None

        self.pump = pump

        urwid.connect_signal(self.blobs, "blob_selected", self.blob_selected)
        self.blobs.goto_blob(0)

    def blob_selected(self, index):
        self.info_area.set_text("Blob: {0}".format(index))

        blob = self.pump[index]
        self.blob_browser.load(blob)

    def keypress(self, size, key):
        input = urwid.Frame.keypress(self, size, key)
        if input is None:
            return
        if input in UI.keys["left"]:
            self.blobs.previous_blob()
        elif input in UI.keys["right"]:
            self.blobs.next_blob()
        elif input in [key.upper() for key in UI.keys["left"]]:
            self.blobs.previous_blob(step=10)
        elif input in [key.upper() for key in UI.keys["right"]]:
            self.blobs.next_blob(step=10)
        elif input in UI.keys["home"]:
            self.blobs.goto_blob(0)
        else:
            return self.body.keypress(size, input)