示例#1
0
    def __init__(self, controller, application):
        super(MapInfoPage, self).__init__(controller, application)

        self.map_context = application.data_provider.map_context
        self.lbl_header = self.get_header_label('{}')
        self.lbl_pos = self.get_label("GPS: {}, {}")
        self.pnl_tags = StackPanel(controller.display, self)
        self.pnl_image = StackPanel(controller.display, self)
        self.pnl_horizontal = StackPanel(controller.display,
                                         self,
                                         is_horizontal=True)
        self.pnl_horizontal.children = [self.pnl_image, self.pnl_tags]
        self.panel.children = [
            self.lbl_header, self.lbl_pos, self.pnl_horizontal
        ]
示例#2
0
    def __init__(self, controller, application, drive, auto_scroll=True):
        super(DiskDetailsPage, self).__init__(controller, application,
                                              auto_scroll)

        self.drive = drive

        self.segment_panel = StackPanel(self.display,
                                        self,
                                        is_horizontal=True,
                                        auto_orient=True,
                                        keep_together=True)
        self.panel.children = [
            self.get_header_label("Drive Information"), self.segment_panel
        ]

        # Display basic attributes for the drive
        general_panel = StackPanel(self.display, self)
        general_panel.children.append(self.get_label("General"))
        for info_item in self.drive.get_general_info():
            lbl = self.get_label(info_item)
            lbl.font = self.controller.display.fonts.list
            general_panel.children.append(lbl)
        self.segment_panel.children.append(general_panel)

        if drive.can_get_usage():
            usage_panel = StackPanel(self.display, self)
            usage_panel.children.append(self.get_label("Storage"))
            for info_item in self.drive.get_storage_info():
                lbl = self.get_list_label(info_item)
                if info_item.endswith('% Full'):
                    chart = BarChart(self.display,
                                     self,
                                     value=float(self.drive.usage_percent))
                    chart.height = lbl.font.size
                    chart.width = lbl.font.size
                    pnl = StackPanel(self.display, self, is_horizontal=True)
                    pnl.children = [chart, lbl]
                    usage_panel.children.append(pnl)
                else:
                    usage_panel.children.append(lbl)

            self.segment_panel.children.append(usage_panel)

        if self.drive.counters:
            self.perf_panel = StackPanel(self.display, self)
            self.refresh_performance_counters()
            self.segment_panel.children.append(self.perf_panel)
            self.last_refresh = datetime.now()
示例#3
0
    def __init__(self,
                 display,
                 page,
                 title,
                 weather=None,
                 forecast=None,
                 is_forecast=True):
        super(WeatherForecastDashboardWidget,
              self).__init__(display, page, DashboardStatus.Inactive)

        self.title = title
        self.forecast = forecast
        self.weather = weather
        self.is_forecast = is_forecast
        self.minutes_to_clean_frost = None

        self.panel = StackPanel(display, page)

        self.lbl_title = TextBlock(display, page, title, is_highlighted=True)
        self.lbl_title.font = display.fonts.list
        self.panel.children.append(self.lbl_title)

        pnl_value = StackPanel(display, page, is_horizontal=True)
        pnl_value.center_align = True

        self.lbl_condition = TextBlock(display, page, "{}")
        self.lbl_condition.font = display.fonts.weather

        self.lbl_value = TextBlock(display, page, "Offline")
        self.lbl_value.font = display.fonts.list

        pnl_value.children = [self.lbl_value, self.lbl_condition]

        self.panel.children.append(pnl_value)

        self.chart = BoxChart(display, page)
        self.chart.width = 150
        self.chart.range_low = -20
        self.chart.range_high = 120
        self.chart.is_highlighted = False
        self.chart.box_width = 0
        self.chart.ticks = (0, 32, 100)
        self.panel.children.append(self.chart)

        self.lbl_frost = TextBlock(display, page, None)
        self.lbl_frost.font = display.fonts.list
        self.panel.children.append(self.lbl_frost)
示例#4
0
    def __init__(self, controller, application, auto_scroll=True):
        super(PerformancePage, self).__init__(controller, application,
                                              auto_scroll)

        self.pnl_cpu = StackPanel(controller.display, self)
        self.pnl_virt_mem = StackPanel(controller.display, self)
        self.pnl_swap_mem = StackPanel(controller.display, self)

        self.panel.is_horizontal = True
        self.panel.auto_orient = True
        self.panel.children = [
            self.pnl_cpu, self.pnl_virt_mem, self.pnl_swap_mem
        ]

        self.refresh()

        self.last_refresh = datetime.now()
示例#5
0
    def __init__(self, controller, application, auto_scroll=True):
        super(DataCategoriesPage, self).__init__(controller, application, auto_scroll)

        self.lbl_header = self.get_header_label("Data Categories")

        self.pnl_items = StackPanel(self.display, self)

        self.panel.children = [self.lbl_header, self.pnl_items]
示例#6
0
    def refresh(self):
        """
        Refreshes the list of drives
        """

        counter_index = 0

        self.panel.children = [
            self.get_header_label('Drives ({})'.format(
                len(self.application.data_provider.partitions)))
        ]

        is_first_control = True

        drives = list()

        for p in self.application.data_provider.partitions:

            drive = DiskDrive(p)
            drives.append(drive)

            if drive.can_get_usage() and counter_index < len(
                    self.application.data_provider.disk_counters):
                key = "PhysicalDrive" + str(counter_index)
                if key in self.application.data_provider.disk_counters:
                    drive.load_counters(
                        key, self.application.data_provider.disk_counters[key])
                else:
                    key = self.application.data_provider.disk_counters.keys(
                    )[counter_index]
                    drive.load_counters(
                        key, self.application.data_provider.disk_counters[key])
                counter_index += 1

            text = drive.get_display_text()

            lbl = self.get_list_label(text)
            chart = BarChart(self.display,
                             self,
                             float(drive.usage_percent),
                             width=lbl.font.size * 2,
                             height=lbl.font.size)
            sp = StackPanel(self.display, self, is_horizontal=True)
            sp.children = [chart, lbl]

            mi = MenuItem(self.controller.display, self, sp)
            mi.data_context = drive

            self.panel.children.append(mi)

            if is_first_control and not self.selected_device:
                self.set_focus(mi, play_sound=False)
                is_first_control = False
            elif self.selected_device and self.selected_device == drive.device:
                self.set_focus(mi, play_sound=False)

        self.last_refresh = datetime.now()
示例#7
0
    def __init__(self, display, page, label):
        super(CheckBox, self).__init__(display, page)

        self.text = label
        self.label = TextBlock(display, page, label)
        self.glyph = CheckBoxGlyph(display, page)

        self.panel = StackPanel(display, page, is_horizontal=True)
        self.panel.center_align = True
        self.panel.children = [self.label, self.glyph]
示例#8
0
    def __init__(self, controller, application):
        super(WMIServicesPage, self).__init__(controller, application)

        self.services = list()

        self.lbl_header = self.get_header_label('Services')
        self.pnl_services = StackPanel(controller.display, self)
        self.panel.children = [self.lbl_header, self.pnl_services]

        self.refresh_services()
示例#9
0
    def __init__(self, controller, application, data_page_provider, auto_scroll=True):
        super(DataPage, self).__init__(controller, application, auto_scroll)

        self.data_page_provider = data_page_provider
        self.lbl_header = self.get_header_label(data_page_provider.name)
        self.pnl_data = StackPanel(controller.display, self)

        self.refresh_children()

        self.panel.children = [self.lbl_header, self.pnl_data]
示例#10
0
    def __init__(self,
                 display,
                 page,
                 title="CPU",
                 values=None,
                 status=DashboardStatus.Passive):
        super(CpuDashboardWidget, self).__init__(display, page, status)

        self.title = title
        self.values = values

        self.panel = StackPanel(display, page)

        self.lbl_title = TextBlock(display, page, title, is_highlighted=True)
        self.lbl_title.font = display.fonts.list
        self.panel.children.append(self.lbl_title)

        self.pnl_charts = StackPanel(display, page, is_horizontal=True)
        self.pnl_charts.padding = 2, 0
        self.panel.children.append(self.pnl_charts)
示例#11
0
    def __init__(self, display, page, label=None, text=None, text_width=100):
        super(TextBox, self).__init__(display, page)

        if text:
            text = str(text)
            
        self.text = text
        self.label_text = label
        self.label = TextBlock(display, page, label)
        self.glyph = TextGlyph(display, page)
        self.text_width = text_width

        self.panel = StackPanel(display, page, is_horizontal=True)
        self.panel.center_align = True
        self.panel.children = [self.label, self.glyph]
示例#12
0
    def __init__(self, display, page, label, value, items=None):

        """
        :type items: list
        """
        if not items:
            items = []

        super(SpinnerBox, self).__init__(display, page)
        self.label = label
        self.value = value
        self.label_block = TextBlock(display, page, label)
        self.value_block = TextBlock(display, page, value)
        self.panel = StackPanel(display, page, is_horizontal=True)
        self.panel.children = [self.label_block, self.value_block]
        self.items = items
示例#13
0
    def __init__(self, display, page, title, value, status=DashboardStatus.Passive):
        super(TextDashboardWidget, self).__init__(display, page, status)

        self.title = title
        self.value = value
        self.width = 150
        self.value_font = display.fonts.list

        self.panel = StackPanel(display, page)

        self.lbl_title = TextBlock(display, page, title, is_highlighted=True)
        self.lbl_title.font = display.fonts.list
        self.panel.children.append(self.lbl_title)

        self.lbl_value = TextBlock(display, page, value)
        self.lbl_value.font = display.fonts.list
        self.panel.children.append(self.lbl_value)
示例#14
0
    def __init__(self, display, page, title, value=0, range_low=0, range_high=100, status=DashboardStatus.Passive):
        super(BarChartDashboardWidget, self).__init__(display, page, status)

        self.width = 150

        self.title = title
        self.value = value

        self.panel = StackPanel(display, page)

        self.lbl_title = TextBlock(display, page, title, is_highlighted=True)
        self.lbl_title.font = display.fonts.list
        self.panel.children.append(self.lbl_title)

        self.chart = BarChart(display, page, value=value, range_low=range_low, range_high=range_high)
        self.chart.width = self.width
        self.chart.height = 15
        self.panel.children.append(self.chart)
示例#15
0
 def get_panel(self):
     """
     :type display: PiMFD.UI.DisplayManager.DisplayManager
     """
     return StackPanel(self.display, self)
示例#16
0
    def refresh_performance_counters(self):

        self.panel.children = [
            self.get_header_label("{} (PID: {})".format(
                self.name, self.process.pid))
        ]

        # Render CPU
        pct = self.process.cpu_percent()
        if not pct:
            pct = 0.0

        lbl_cpu = self.get_list_label("CPU:")
        lbl_cpu_pct = self.get_list_label("{} %".format(pct))
        chrt_cpu = BarChart(self.display,
                            self,
                            pct,
                            width=25,
                            height=lbl_cpu.font.size)
        pnl_cpu = StackPanel(self.display, self, is_horizontal=True)
        pnl_cpu.children = [lbl_cpu, chrt_cpu, lbl_cpu_pct]

        self.panel.children.append(pnl_cpu)

        # Render Memory
        mem = self.process.memory_info()
        if mem:
            pnl_mem = StackPanel(self.display, self)
            pnl_mem.children.append(self.get_label("Memory"))
            pnl_mem.children.append(
                self.get_list_label("Memory Usage: {}".format(
                    format_size(mem.rss))))
            pnl_mem.children.append(
                self.get_list_label("Virtual Memory Size: {}".format(
                    format_size(mem.vms))))
            self.panel.children.append(pnl_mem)

        # Render Connections
        try:
            connections = self.process.connections()
            if connections:
                pnl_connections = StackPanel(self.display, self)
                pnl_connections.children.append(
                    self.get_label("Connections ({})".format(
                        len(connections))))
                self.panel.children.append(pnl_connections)

                for c in connections:
                    if c.laddr == c.raddr:
                        address_text = NetworkPage.get_address_text(c.raddr)
                    else:
                        address_text = "{}({})".format(
                            NetworkPage.get_address_text(c.raddr),
                            NetworkPage.get_address_text(c.laddr))

                    text = "{} {} {}/{}".format(
                        c.status, address_text,
                        NetworkPage.get_connection_type_text(c.type),
                        NetworkPage.get_connection_family_text(c.family))

                    lbl = self.get_list_label(text)
                    pnl_connections.children.append(lbl)

        except psutil.NoSuchProcess or psutil.AccessDenied:
            pass

        # Render Files
        try:
            files = self.process.open_files()
        except psutil.AccessDenied:
            files = None

        if files:
            pnl_files = StackPanel(self.display, self)
            pnl_files.children.append(
                self.get_label("Files ({})".format(len(files))))

            for f in files:
                lbl = self.get_list_label(f.path)
                lbl.data_context = f
                pnl_files.children.append(lbl)

            self.panel.children.append(pnl_files)

        # Render Children
        try:
            children = self.process.children()
        except psutil.NoSuchProcess or psutil.AccessDenied:
            children = None

        if children:
            pnl_children = StackPanel(self.display, self)
            pnl_children.children.append(
                self.get_label("Children ({})".format(len(children))))

            for c in children:
                name = self.get_process_name(c)
                lbl = self.get_list_label("{}: {}".format(c.pid, name))
                lbl.data_context = c
                pnl_children.children.append(lbl)

            self.panel.children.append(pnl_children)

        # Render threads
        try:
            threads = self.process.threads()
        except psutil.AccessDenied or psutil.NoSuchProcess:
            threads = None

        if threads:
            pnl_threads = StackPanel(self.display, self)
            pnl_threads.children = [
                self.get_label("Threads ({})".format(len(threads)))
            ]

            for t in threads:
                lbl = self.get_list_label("{}: User: {}, SYS: {}".format(
                    t.id, t.user_time, t.system_time))
                pnl_threads.children.append(lbl)

            self.panel.children.append(pnl_threads)
示例#17
0
    def __init__(self, controller, application, weather_provider):
        super(WeatherPage, self).__init__(controller, application)

        self.weather_provider = weather_provider

        # Build out the Today Panel
        self.pnl_today = StackPanel(controller.display, self)
        self.lbl_today_header = self.get_header_label("{} Weather")
        self.lbl_temp = self.get_label(u"      Temp: {}{} (Chill: {}{})")
        self.lbl_cond = self.get_label(u"Conditions: {}")
        self.lbl_cond_icon = self.get_label(u"{}")
        self.lbl_cond_icon.font = controller.display.fonts.weather
        pnl_cond = StackPanel(controller.display, self, is_horizontal=True)
        pnl_cond.children = (self.lbl_cond, self.lbl_cond_icon)
        self.lbl_wind = self.get_label(u"      Wind: {} {} {}")
        self.lbl_humidity = self.get_label(u"  Humidity: {} %")
        self.lbl_visible = self.get_label(u"Visibility: {} {}")
        self.lbl_pressure = self.get_label(u"  Pressure: {} {}")
        self.lbl_daylight = self.get_label(u"  Daylight: {} - {}")
        self.lbl_gps = self.get_label(u"       GPS: {}, {}")

        self.pnl_today.children = (self.lbl_today_header, self.lbl_temp,
                                   pnl_cond, self.lbl_wind, self.lbl_humidity,
                                   self.lbl_visible, self.lbl_pressure,
                                   self.lbl_daylight, self.lbl_gps)

        # Build out the Forecast Panel
        self.pnl_forecast = StackPanel(controller.display, self)
        forecast_header = self.get_header_label("Forecast")
        self.pnl_forecast.children.append(forecast_header)

        # Add placeholders for the individual forecasts
        self.lbl_forecast = dict()
        self.lbl_forecast_icon = dict()
        self.chart_forecast = dict()
        for i in range(0, self.max_forecasts):
            label = self.get_label(u"{}: {}-{}{}")
            self.lbl_forecast[i] = label

            icon = self.get_label(u"{}")
            icon.font = controller.display.fonts.weather
            self.lbl_forecast_icon[i] = icon

            pnl_day = StackPanel(controller.display, self, is_horizontal=True)
            pnl_day.children = (label, icon)

            self.pnl_forecast.children.append(pnl_day)

            chart = BoxChart(controller.display, self)
            chart.width = 225
            chart.range_low = -20
            chart.range_high = 120
            chart.ticks = (0, 32, 100)
            self.chart_forecast[i] = chart
            self.pnl_forecast.children.append(chart)

        self.pnl_forecast.children.append(SpacerLine(controller.display, self))

        # Set up the main content panel
        self.content_panel = StackPanel(controller.display,
                                        self,
                                        is_horizontal=True,
                                        keep_together=True)
        self.content_panel.pad_last_item = True
        self.content_panel.auto_orient = True
        self.content_panel.children = (self.pnl_today, self.pnl_forecast)

        # Set up the master panel
        self.panel.children = [self.content_panel]
        self.panel.pad_last_item = False
示例#18
0
    def refresh(self):
        """
        Refreshes the list of drives
        """

        # CPU Usage
        if self.application.data_provider.percentages:
            self.pnl_cpu.children = [self.get_header_label('CPU Performance')]
            cpu_index = 1
            for percent in self.application.data_provider.percentages:

                # Protect against bad values on first round
                if not percent:
                    percent = 0.0

                pnl = StackPanel(self.display, self, is_horizontal=True)
                lbl = self.get_list_label('{:02.1f} %'.format(percent))
                chart = BarChart(self.display, self)
                chart.value = percent
                chart.width, chart.height = 50, lbl.font.size
                pnl.children = [
                    self.get_list_label('{}:'.format(cpu_index)), chart, lbl
                ]
                self.pnl_cpu.children.append(pnl)
                cpu_index += 1

        # Virtual Memory
        virt_mem = self.application.data_provider.virt_mem
        if virt_mem:
            self.pnl_virt_mem.children = [
                self.get_header_label('Virtual Memory')
            ]
            self.pnl_virt_mem.children.append(
                self.get_list_label("Percent Used: {} %".format(
                    virt_mem.percent)))

            self.pnl_virt_mem.children.append(
                BarChart(self.display,
                         self,
                         value=virt_mem.percent,
                         width=200,
                         height=5))

            self.pnl_virt_mem.children.append(
                self.get_list_label("Total: {}".format(
                    format_size(virt_mem.total))))
            self.pnl_virt_mem.children.append(
                self.get_list_label("Used: {}".format(
                    format_size(virt_mem.used))))
            self.pnl_virt_mem.children.append(
                self.get_list_label("Free: {}".format(
                    format_size(virt_mem.free))))
            if virt_mem.free != virt_mem.available:
                self.pnl_virt_mem.children.append(
                    self.get_list_label("Available: {}".format(
                        format_size(virt_mem.available))))

        # Swap Memory
        swap_mem = self.application.data_provider.swap_mem
        if swap_mem:
            self.pnl_swap_mem.children = [self.get_header_label('Swap Memory')]
            self.pnl_swap_mem.children.append(
                self.get_list_label("Percent Used: {} %".format(
                    swap_mem.percent)))

            self.pnl_swap_mem.children.append(
                BarChart(self.display,
                         self,
                         value=swap_mem.percent,
                         width=200,
                         height=5))

            self.pnl_swap_mem.children.append(
                self.get_list_label("Total: {}".format(
                    format_size(swap_mem.total))))
            self.pnl_swap_mem.children.append(
                self.get_list_label("Used: {}".format(
                    format_size(swap_mem.used))))
            self.pnl_swap_mem.children.append(
                self.get_list_label("Free: {}".format(
                    format_size(swap_mem.free))))