dialogs/MessageBoxOnce.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 12 Mar 2023 00:51:53 +0100
branchwxPython4
changeset 3746 41be039fbb8c
parent 3573 1ee56fb544fc
child 3750 f62625418bff
permissions -rw-r--r--
IDE: fix again ruberband with gtk3.

DC logical functions are now disabled when using GTK3.
Apparently using XOR was still having an effect.
Use regular black pen with no logical funciton instead.
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
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
    10
from __future__ import absolute_import
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)