def __init__(
        self, parent, msg, caption, pos=wx.DefaultPosition, size=(500, 300)
    ):

        wx.Dialog.__init__(self, parent, -1, caption, pos, size)
        x, y = pos
        if x == -1 and y == -1:
            self.CenterOnScreen(wx.BOTH)

        text = wx.TextCtrl(
            self,
            -1,
            msg,
            wx.DefaultPosition,
            wx.DefaultSize,
            wx.TE_READONLY | wx.TE_MULTILINE | wx.HSCROLL | wx.TE_RICH2,
        )

        font = wx.Font(8, wx.MODERN, wx.NORMAL, wx.NORMAL)
        text.SetStyle(0, len(msg), wx.TextAttr(font=font))

        ok = wx.Button(self, wx.ID_OK, "OK")
        text.SetConstraints(Layoutf("t=t5#1;b=t5#2;l=l5#1;r=r5#1", (self, ok)))
        ok.SetConstraints(Layoutf("b=b5#1;x%w50#1;w!80;h!25", (self,)))

        self.SetAutoLayout(1)
        self.Layout()
Exemple #2
0
 def __init__(self, parent, msg, caption, textSize=(80, 40), centered=True):
     from wx.lib.layoutf import Layoutf
     wx.Dialog.__init__(self, parent, -1, caption)
     text = wx.TextCtrl(self, -1, msg, wx.DefaultPosition, wx.DefaultSize,
                        wx.TE_MULTILINE | wx.TE_READONLY)
     text.SetFont(g.modernFont())
     dc = wx.WindowDC(text)
     w, h = dc.GetFullTextExtent(' ', g.modernFont())[:2]
     ok = wx.Button(self, wx.ID_OK, "OK")
     ok.SetDefault()
     text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self, ok)))
     text.SetSize((w * textSize[0] + 30, h * textSize[1]))
     text.ShowPosition(1)  # scroll to the first line
     ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!35', (self, )))
     self.SetAutoLayout(True)
     self.Fit()
     if centered:
         self.CenterOnScreen(wx.BOTH)