Exemplo n.º 1
0
    def render(self, c):
        TextFigure.render(self, c)

        content_diameter = min(self.width, self.height)

        c.save()
        c.translate(self.x, self.y)
        self.apply_attributes(c)

        c.save()
        c.set_source_rgb(0.93, 0.93, 0.93)
        c.arc(
            content_diameter / 2, content_diameter / 2,
            min(self.width - self._line_width, self.height - self._line_width)
            / 2, 0, math.pi * 2)
        c.stroke()
        c.restore()

        c.arc(
            content_diameter / 2, content_diameter / 2,
            min(self.width - self._line_width, self.height - self._line_width)
            / 2, 0, max(self._value * math.pi * 2, 0.02))
        c.stroke()

        c.set_font(self._font, False, True)
        c.set_font_size(16)
        c.set_source_rgba(*self._text_color)
        c.move_to(
            content_diameter + 4 + 16, self.height -
            (content_diameter - c.text_extents(self._caption).width) / 2)
        c.rotate(-math.pi / 2)
        c.show_text(self._caption)
        c.stroke()
        c.restore()
Exemplo n.º 2
0
    def create_ui(self):
        #self.create_basic_ui("title_dashboard.png", "Dashboard")

        self._form_deactivated_conn = mforms.Form.main_form(
        ).add_deactivated_callback(self.form_deactivated)

        self.content = mforms.newScrollPanel(0)

        self.drawbox = RenderBox(self)
        self.canvas = Canvas(self.set_needs_repaint)
        self.drawbox.canvas = self.canvas
        self.drawbox.set_size(1024, 700)
        self.content.add(self.drawbox)

        self.widgets = []

        self.last_refresh_time = None

        #
        self.drawbox.variable_values = self.ctrl_be.server_variables
        server_version = Version.fromgrt(self.ctrl_be.target_version)
        GLOBAL_DASHBOARD_WIDGETS = GLOBAL_DASHBOARD_WIDGETS_NETWORK + GLOBAL_DASHBOARD_WIDGETS_MYSQL_PRE_80 + GLOBAL_DASHBOARD_WIDGETS_INNODB
        if server_version and server_version.is_supported_mysql_version_at_least(
                8, 0, 0):
            GLOBAL_DASHBOARD_WIDGETS = GLOBAL_DASHBOARD_WIDGETS_NETWORK + GLOBAL_DASHBOARD_WIDGETS_MYSQL_POST_80 + GLOBAL_DASHBOARD_WIDGETS_INNODB
        # create all widgets
        for caption, wclass, args, init, (
                calc,
                calc_expr), color, pos, hover_text in GLOBAL_DASHBOARD_WIDGETS:
            if caption:
                fig = TextFigure(caption)
                fig.set_text_color(0.3, 0.3, 0.3)
                fig.set_font_size(13)
                fig.set_font_bold(True)
                self.drawbox.add(fig)
                fig.move(pos[0], pos[1] - 20)

            w = wclass(calc(calc_expr) if calc else None, *args)
            self.drawbox.add(w)
            w.set_main_color(color)
            w.move(*pos)
            if hover_text:
                w.hover_text_template = hover_text

            if init:
                init_calc, init_expr = init
                w.init(
                    init_calc(init_expr).handle(self.ctrl_be.server_variables,
                                                None))

            self.widgets.append(w)

        self.refresh()
        self._refresh_tm = mforms.Utilities.add_timeout(
            self.ctrl_be.status_variable_poll_interval, self.refresh)

        self.ctrl_be.add_me_for_event("server_started", self)
        self.ctrl_be.add_me_for_event("server_stopped", self)

        return self.content
Exemplo n.º 3
0
    def render(self, c):
        TextFigure.render(self, c)
        
        content_diameter = min(self.width, self.height)
        
        c.save()
        c.translate(self.x, self.y)
        self.apply_attributes(c)
        
        c.save()
        c.set_source_rgb(0.93, 0.93, 0.93)
        c.arc(content_diameter/2, content_diameter/2, min(self.width - self._line_width, self.height - self._line_width)/2,
          0, math.pi*2)
        c.stroke()
        c.restore()

        c.arc(content_diameter/2, content_diameter/2, min(self.width - self._line_width, self.height - self._line_width)/2,
              0, max(self._value * math.pi*2, 0.02))
        c.stroke()

        c.set_font(self._font, False, True)
        c.set_font_size(16)
        c.set_source_rgba(*self._text_color)
        c.move_to(content_diameter + 4 + 16, self.height - (content_diameter - c.text_extents(self._caption).width)/2)
        c.rotate(-math.pi/2)
        c.show_text(self._caption)
        c.stroke()
        c.restore()
Exemplo n.º 4
0
    def create_ui(self):
        #self.create_basic_ui("title_dashboard.png", "Dashboard")

        self._form_deactivated_conn = mforms.Form.main_form(
        ).add_deactivated_callback(self.form_deactivated)

        self.content = mforms.newScrollPanel(0)

        self.drawbox = RenderBox(self)
        self.canvas = Canvas(self.set_needs_repaint)
        self.drawbox.canvas = self.canvas
        self.drawbox.set_size(1024, 700)
        self.content.add(self.drawbox)

        self.add(self.content, True, True)

        self.widgets = []

        self.last_refresh_time = None

        #
        self.drawbox.variable_values = self.ctrl_be.server_variables

        # create all widgets
        for caption, wclass, args, init, (
                calc,
                calc_expr), color, pos, hover_text in GLOBAL_DASHBOARD_WIDGETS:
            if caption:
                fig = TextFigure(caption)
                fig.set_text_color(0.5, 0.5, 0.5)
                fig.set_font_size(11)
                fig.set_font_bold(True)
                self.drawbox.add(fig)
                fig.move(pos[0], pos[1] - 20)

            w = wclass(calc(calc_expr) if calc else None, *args)
            self.drawbox.add(w)
            w.set_main_color(color)
            w.move(*pos)
            if hover_text:
                w.hover_text_template = hover_text

            if init:
                init_calc, init_expr = init
                w.init(
                    init_calc(init_expr).handle(self.ctrl_be.server_variables,
                                                None))

            self.widgets.append(w)

        self.refresh()
        self._refresh_tm = mforms.Utilities.add_timeout(
            self.ctrl_be.status_variable_poll_interval, self.refresh)
    def create_ui(self):
        #self.create_basic_ui("title_dashboard.png", "Dashboard")


        self._form_deactivated_conn = mforms.Form.main_form().add_deactivated_callback(self.form_deactivated)


        self.content = mforms.newScrollPanel(0)

        self.drawbox = RenderBox(self)
        self.canvas = Canvas(self.set_needs_repaint)
        self.drawbox.canvas = self.canvas
        self.drawbox.set_size(1024, 700)
        self.content.add(self.drawbox)

        self.add(self.content, True, True)

        self.widgets = []
        
        self.last_refresh_time = None
        
        #
        self.drawbox.variable_values = self.ctrl_be.server_variables
        server_version = Version.fromgrt(self.ctrl_be.target_version)
        GLOBAL_DASHBOARD_WIDGETS = GLOBAL_DASHBOARD_WIDGETS_NETWORK + GLOBAL_DASHBOARD_WIDGETS_MYSQL_PRE_80 + GLOBAL_DASHBOARD_WIDGETS_INNODB
        if server_version and server_version.is_supported_mysql_version_at_least(8, 0, 0):
            GLOBAL_DASHBOARD_WIDGETS = GLOBAL_DASHBOARD_WIDGETS_NETWORK + GLOBAL_DASHBOARD_WIDGETS_MYSQL_POST_80 + GLOBAL_DASHBOARD_WIDGETS_INNODB
        # create all widgets
        for caption, wclass, args, init, (calc, calc_expr), color, pos, hover_text in GLOBAL_DASHBOARD_WIDGETS:
            if caption:
                fig = TextFigure(caption)
                fig.set_text_color(0.5, 0.5, 0.5)
                fig.set_font_size(11)
                fig.set_font_bold(True)
                self.drawbox.add(fig)
                fig.move(pos[0], pos[1] - 20)
        
            w = wclass(calc(calc_expr) if calc else None, *args)
            self.drawbox.add(w)
            w.set_main_color(color)
            w.move(*pos)
            if hover_text:
                w.hover_text_template = hover_text
            
            if init:
                init_calc, init_expr = init
                w.init(init_calc(init_expr).handle(self.ctrl_be.server_variables, None))

            self.widgets.append(w)


        self.refresh()
        self._refresh_tm = mforms.Utilities.add_timeout(self.ctrl_be.status_variable_poll_interval, self.refresh)
            
        self.ctrl_be.add_me_for_event("server_started", self)
        self.ctrl_be.add_me_for_event("server_stopped", self)
Exemplo n.º 6
0
    def __init__(self, calc, caption):
        TextFigure.__init__(self, "")

        self.calc = calc

        self._value = 0

        self._caption = caption
        self.set_alignment(0.5, 0.5)

        self.set_line_width(25)
        self.set_font_bold(True)
        self.set_font_size(18)

        self.set_padding(0, 0, 0, 20)
        self.set_usize(120, 100)
Exemplo n.º 7
0
    def __init__(self, calc, caption):
        TextFigure.__init__(self, "")

        self.calc = calc
        
        self._value = 0
    
        self._caption = caption
        self.set_alignment(0.5, 0.5)
        
        self.set_line_width(25)
        self.set_font_bold(True)
        self.set_font_size(18)

        self.set_padding(0, 0, 0, 20)
        self.set_usize(120, 100)
Exemplo n.º 8
0
    def __init__(self, dummy, text):
        TextFigure.__init__(self)

        self.set_font_size(10)
        self.set_alignment(0.5, 0)
        self.set_text(text)
Exemplo n.º 9
0
 def __init__(self, dummy, text):
     TextFigure.__init__(self)
 
     self.set_font_size(10)
     self.set_alignment(0.5, 0)
     self.set_text(text)