Ejemplo n.º 1
0
    def __init__(self, tap, smoothed):
        if smoothed:
            self.speed_graph = SpeedGraph(['background', 'bar'],
                                          ['background', 'bar'],
                                          {(1, 0): 'bar:top'})

            self.cagraph = urwid.BarGraph(['ca:background', 'ca:c', 'ca:a'],
                                          ['ca:background', 'ca:c', 'ca:a'], {
                                              (1, 0): 'ca:c:top',
                                              (2, 0): 'ca:a:top',
                                          })
        else:
            self.speed_graph = SpeedGraph([('background', ' '), ('bar', ' ')],
                                          ['background', 'bar'])

            self.cagraph = urwid.BarGraph([
                ('ca:background', ' '),
                ('ca:c', ' '),
                ('ca:a', ' '),
            ])

        self.last_reading = urwid.Text("", align="right")
        scale = urwid.GraphVScale(graph_lines_captions(), graph_range())
        footer = self.last_reading
        graph_cols = urwid.Columns([('fixed', 5, scale), self.speed_graph,
                                    ('fixed', 4, self.cagraph)],
                                   dividechars=1)
        self.top = urwid.Frame(graph_cols, footer=footer)

        self.spd = Speedometer(6)
        self.feed = tap.feed
        self.description = tap.description()
        super(GraphDisplay, self).__init__(self.top)
Ejemplo n.º 2
0
    def __init__(self, attlist, hatt=None, satt=None):
        if satt is None:
            self.graph = urwid.BarGraph(attlist, hatt)
        else:
            self.graph = urwid.BarGraph(attlist, hatt, satt)
        # override BarGraph's get_data
        self.graph.get_data = self.get_data

        self.smoothed = satt is not None

        self.log = []
        self.bar = []
Ejemplo n.º 3
0
 def sbgtest(self, desc, data, top, exp ):
     urwid.set_encoding('utf-8')
     g = urwid.BarGraph( ['black','red','blue'],
             None, {(1,0):'red/black', (2,1):'blue/red'})
     g.set_data( data, top )
     rval = g.calculate_display((5,3))
     assert rval == exp, "%s expected %r, got %r"%(desc,exp,rval)
Ejemplo n.º 4
0
    def makeGraphArea():
        nonlocal graph, graphVscale, graphColumns
        graph = urwid.BarGraph(attlist=['graph_bg', 'graph_bar'])
        graph.set_data([], top=1)

        labels = [[i, '{:.3f}'.format(i)]
                  for i in numpy.arange(0.0, 1.0, 0.01)]
        graphVscale = urwid.AttrWrap(urwid.GraphVScale(labels=labels, top=1),
                                     'graph_label')
        graphColumns = urwid.Columns([
            (7, urwid.Padding(graphVscale, left=0, right=1)), graph,
            (7, urwid.Padding(graphVscale, left=1, right=0))
        ])

        graphFrame = makeMountedFrame(graphColumns, 'Rolling Loss')
        return graphFrame
Ejemplo n.º 5
0
    def __init__(self):
        self.walker = urwid.SimpleFocusListWalker(contents=self.log_messages)
        self.list_box = urwid.ListBox(self.walker)

        self.graph = urwid.BarGraph(
            attlist=['graph bg background', 'graph bg 1', 'graph bg 2'],
            satt={
                (1, 0): 'graph bg 1 smooth',
                (2, 0): 'graph bg 2 smooth'
            })

        self.graph_widget = urwid.LineBox(self.graph, title=self.graph_title)

        self.default_widget = urwid.Columns(
            [urwid.LineBox(self.list_box, title="Logger"), self.graph_widget])

        self.logger_widget = urwid.LineBox(self.list_box, title="Logger")
Ejemplo n.º 6
0
    def show(self):
        # Progress bar is an urwid.BarGraph instead of a real urwid.ProgressBar
        # because urwid.ProgressBar cannot pulse and always display
        # the percentage of completion
        self.progress_bar = urwid.BarGraph(['highlight', 'highlight focused'])

        # Show body
        body = urwid.Pile((
            ('flow', urwid.Text(self.text)),
            ('fixed', 2, self.progress_bar),
            ('weight', 1, urwid.SolidFill()),
        ))

        super(ProgressDialog, self).show(body)

        # Run main loop
        self.loop = urwid.MainLoop(self.frame, self.PALETTE)
        self.loop.screen.start()
        self.loop.draw_screen()
Ejemplo n.º 7
0
 def bar_graph(self, smooth=False):
     satt = None
     if smooth:
         satt = {(1, 0): 'bg 1 smooth', (2, 0): 'bg 2 smooth'}
     w = urwid.BarGraph(['bg background', 'bg 1', 'bg 2'], satt=satt)
     return w
Ejemplo n.º 8
0
 def test_bargraph(self):
     self.wstest(urwid.BarGraph(['foo','bar']))
Ejemplo n.º 9
0
 def bar_graph(self, smooth=False):
     w = urwid.BarGraph(['bg background', 'bg 1', 'bg 2'])
     return w
Ejemplo n.º 10
0
                      title="Crawlers"), 'crawlerAreabg')

    writers = [urwid.Text("Idle", align="center") for writer in writerThreads]
    writer_wrap = [
        urwid.AttrMap(urwid.Padding(writer, width=50), "crawlerbg")
        for writer in writers
    ]
    writer_area = urwid.AttrMap(
        urwid.LineBox(urwid.Padding(urwid.GridFlow(writer_wrap, 50, 3, 1,
                                                   'center'),
                                    left=4,
                                    right=4,
                                    min_width=50),
                      title="Writers"), 'crawlerAreabg')

    bar_chart = urwid.BarGraph(['graphbg', 'graphbars'], hatt=['line'])
    bar_chart_box = urwid.AttrMap(
        urwid.LineBox(urwid.BoxAdapter(bar_chart, 30), title="PERFORMANCE"),
        "statusbar")

    bottom_items = [
        urwid.Text("Starting"),
        urwid.Text("Starting"),
        urwid.Text("Starting"),
        urwid.Text("Starting")
    ]
    bottom_col = urwid.AttrMap(urwid.Columns(bottom_items), "statusbar")

    fill = urwid.Frame(urwid.ListBox(
        [big_text_wrap, crawler_area, writer_area, bar_chart_box]),
                       footer=bottom_col)
Ejemplo n.º 11
0
 def meters_control(self):
     satt = {(1, 0): 'meter low smooth', (2, 0): 'meter high smooth'}
     w = urwid.BarGraph(['bg', 'meter low', 'meter high'], satt=satt)
     return w
Ejemplo n.º 12
0
import statistics
import math
import argparse

parser = argparse.ArgumentParser(description="Plots value from database")
parser.add_argument("sensor_type",
                    type=str,
                    help="Type of the sensor to be plotted")
parser.add_argument("spot_tag",
                    type=str,
                    help="Spot at which the values were measured")

args = parser.parse_args()

graph = urwid.BarGraph(
    ["normal", ("bar", "\u2502"), "normal"],
    ["normal", "barline", "normal"],
)

gscale = urwid.GraphVScale([], 0)

type_t = urwid.Text(("vals", args.sensor_type), align="right")
cur_t = urwid.Text("", align="right")
min_t = urwid.Text("", align="right")
avg_t = urwid.Text("", align="right")
max_t = urwid.Text("", align="right")
spot_t = urwid.Text(("vals", args.spot_tag), align="right")

stats = urwid.ListBox([
    urwid.Text("type"),
    type_t,
    urwid.Text("cur"),
Ejemplo n.º 13
0
    def __init__(self):

        # Variables used to build status line
        self.batteryVoltage = 0.00
        self.mqttHost = mqtt_server

        # Data list where points are put for bar graph plotting
        self.plotData = []

        # name,          foreground,    background,  mono         , foreground_high, background_high
        palette = [('body', 'black', 'light gray', 'standout'),
                   ('header', 'white', 'dark red', 'bold'),
                   ('screen edge', 'light blue', 'dark cyan'),
                   ('main shadow', 'dark gray', 'black'),
                   ('line', 'black', 'light gray', 'standout'),
                   ('bg background', 'light gray', 'black'),
                   ('bg 1', 'black', 'dark blue', 'standout'),
                   ('bg 1 smooth', 'dark blue', 'black'),
                   ('bg 2', 'black', 'dark cyan', 'standout'),
                   ('bg 2 smooth', 'dark cyan', 'black'),
                   ('button normal', 'light gray', 'dark blue', 'standout'),
                   ('button select', 'white', 'dark green'),
                   ('line', 'black', 'light gray', 'standout'),
                   ('pg normal', 'white', 'black', 'standout'),
                   ('pg complete', 'white', 'dark magenta'),
                   ('pg smooth', 'dark magenta', 'black'),
                   ('bigtext', 'dark green', 'dark red')]

        # Title
        txtTitle = urwid.BigText(("bigtext", "@alexmaswarrior fridge"),
                                 urwid.font.Thin6x6Font())
        txtTitleBox = urwid.Padding(txtTitle, "center", width="clip")
        txtTitleBox = urwid.Filler(txtTitleBox, "bottom")
        txtTitleBox = urwid.BoxAdapter(txtTitleBox, 7)
        titlePile = urwid.Pile([txtTitleBox])

        # Big temperature numerals
        self.txtTemperature = urwid.BigText("", urwid.font.HalfBlock7x7Font())
        txtTemperatureBox = urwid.Padding(self.txtTemperature,
                                          "center",
                                          width="clip")
        txtTemperatureBox = urwid.Filler(txtTemperatureBox, "bottom")
        txtTemperatureBox = urwid.BoxAdapter(txtTemperatureBox, 7)

        # Footer
        self.txtFooter = urwid.Text("MQTT Host:     Battery Voltage:")

        # History graph
        self.BarGraph = urwid.BarGraph(['bg background', 'bg 1', 'bg 2'])
        self.BarGraph.set_data([(0, ), (1, ), (2, )], 8)
        self.BarGraph.set_bar_width(1)
        BarGraphBox = urwid.Columns([("weight", 2, self.BarGraph)])
        BarGraphBox = urwid.Padding(self.BarGraph, ("fixed left", 1))
        BarGraphBox = urwid.BoxAdapter(BarGraphBox, 25)

        # put it together
        cols = urwid.Columns([txtTemperatureBox, BarGraphBox])
        fill = urwid.Filler(cols, "middle")

        frame = urwid.Frame(fill, header=titlePile, footer=self.txtFooter)
        frameLineBox = urwid.LineBox(frame,
                                     title="Refrigerator Display Thing",
                                     tlcorner="\u2554",
                                     tline="\u2550",
                                     lline="\u2551",
                                     trcorner="\u2557",
                                     blcorner="\u255A",
                                     rline="\u2551",
                                     bline="\u2550",
                                     brcorner="\u255d")

        screen = urwid.raw_display.Screen()
        screen.register_palette(palette)
        self.loop = urwid.MainLoop(frameLineBox, palette, screen=screen)

        # Gets the writing end of pipes to the UI event loop
        self.temperature_write_pipe = self.loop.watch_pipe(
            self.temperature_pipe_event)
        self.voltage_write_pipe = self.loop.watch_pipe(self.voltage_pipe_event)