dialogs/MessageBoxOnce.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 26 Apr 2024 09:24:26 +0200
changeset 3938 fc4af5685aa3
parent 3750 f62625418bff
permissions -rw-r--r--
merge
3573
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
# This file is part of Beremiz
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
# Copyright (C) 2022: Edouard TISSERANT
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
#
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     7
# See COPYING file for copyrights details.
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     8
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
3750
f62625418bff automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents: 3573
diff changeset
    10
3573
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
import wx
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
# class RichMessageDialog is still not available in wxPython 3.0.2
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
class  MessageBoxOnce(wx.Dialog):
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
    """
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
    wx.MessageBox that user can ask not to show again
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
    """
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
    def __init__(self, title, message, config_key):
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
        self.Config = wx.ConfigBase.Get()
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
        self.config_key = config_key
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
        dont_show = self.Config.Read(self.config_key) == "True"
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
        if dont_show:
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    25
            return
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
        wx.Dialog.__init__(self, None, title=title)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
        main_sizer = wx.BoxSizer(wx.VERTICAL)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    30
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
        message = wx.StaticText(self, label=message)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
        main_sizer.Add(message, border=20,
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
            flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.LEFT | wx.RIGHT)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
        self.check = wx.CheckBox(self, label=_("don't show this message again"))
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
        main_sizer.Add(self.check, border=20,
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    40
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
        Button = wx.Button(self, label="OK")
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    42
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    43
        self.Bind(wx.EVT_BUTTON, self.OnOKButton, Button)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    44
        buttons_sizer.Add(Button)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    45
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
        main_sizer.Add(buttons_sizer, border=20,
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
                            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_RIGHT)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    49
        self.SetSizer(main_sizer)
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
        self.Fit()
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
        self.ShowModal()
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
    def OnOKButton(self, event):
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
        if self.check.GetValue():
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    56
            self.Config.Write(self.config_key, "True")
1ee56fb544fc IDE, SVGHMI: Workaround Snap package not launching Inskape, POEdit or Chromium directly, producing lot of output in Incskape CLI, and messing with TMPDIR
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    57
        self.EndModal(wx.ID_OK)