summaryrefslogtreecommitdiff
path: root/lib/gui/warnings.py
blob: eda1ca2e787446f0cf7304175104e7cf9c748cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Authors: see git history
#
# Copyright (c) 2021 Authors
# Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.

import wx

from ..i18n import _


class WarningPanel(wx.Panel):
    """A wx.Panel for to display warnings.
    """

    def __init__(self, parent, *args, **kwargs):
        wx.Panel.__init__(self, parent, wx.ID_ANY, *args, **kwargs)

        self.main_sizer = wx.BoxSizer(wx.VERTICAL)

        self.warning = wx.StaticText(self)
        self.warning.SetLabel(_("An error occurred while rendering the stitch plan:"))
        self.warning.SetForegroundColour(wx.Colour(255, 25, 25))
        self.main_sizer.Add(self.warning, 1, wx.LEFT | wx.BOTTOM | wx.EXPAND, 10)

        tc_style = wx.TE_MULTILINE | wx.TE_READONLY | wx.VSCROLL | wx.TE_RICH2
        self.warning_text = wx.TextCtrl(self, size=(300, 100), style=tc_style)
        font = self.warning_text.GetFont()
        font.SetFamily(wx.FONTFAMILY_TELETYPE)
        self.warning_text.SetFont(font)
        self.main_sizer.Add(self.warning_text, 3, wx.LEFT | wx.BOTTOM | wx.EXPAND, 10)

        self.SetSizerAndFit(self.main_sizer)
        self.Layout()

    def set_warning_text(self, text):
        self.warning_text.SetValue(text)

    def clear(self):
        self.warning_text.SetValue("")