author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Tue, 23 Mar 2021 05:11:23 +0100 | |
branch | svghmi |
changeset 3193 | 8006bb60a4dd |
parent 2492 | 7dd551ac2fa0 |
child 3303 | 0ffb41625592 |
permissions | -rw-r--r-- |
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
3 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
4 |
# See COPYING file for copyrights details. |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
5 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
6 |
from __future__ import absolute_import |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
7 |
import wx |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
8 |
|
2492
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
9 |
|
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
10 |
# class RichMessageDialog is still not available in wxPython 3.0.2 |
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
11 |
class IDMergeDialog(wx.Dialog): |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
12 |
def __init__(self, parent, title, question, optiontext, button_texts): |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
13 |
wx.Dialog.__init__(self, parent, title=title) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
14 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
15 |
main_sizer = wx.BoxSizer(wx.VERTICAL) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
16 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
17 |
message = wx.StaticText(self, label=question) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
18 |
main_sizer.AddWindow(message, border=20, |
2492
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
19 |
flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.LEFT | wx.RIGHT) |
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
20 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
21 |
self.check = wx.CheckBox(self, label=optiontext) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
22 |
main_sizer.AddWindow(self.check, border=20, |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
23 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
24 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
25 |
buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) |
2492
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
26 |
for label, wxID in zip(button_texts, [wx.ID_YES, wx.ID_NO, wx.ID_CANCEL]): |
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
27 |
Button = wx.Button(self, label=label) |
2492
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
28 |
|
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
29 |
def OnButtonFactory(_wxID): |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
30 |
return lambda event: self.EndModal(_wxID) |
2492
7dd551ac2fa0
check_sources.sh makes me become even less productive
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2428
diff
changeset
|
31 |
|
2428
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
32 |
self.Bind(wx.EVT_BUTTON, OnButtonFactory(wxID), Button) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
33 |
buttons_sizer.AddWindow(Button) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
34 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
35 |
main_sizer.AddSizer(buttons_sizer, border=20, |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
36 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_RIGHT) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
37 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
38 |
self.SetSizer(main_sizer) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
39 |
self.Fit() |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
40 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
41 |
self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
42 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
43 |
def OnEscapeKey(self, event): |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
44 |
keycode = event.GetKeyCode() |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
45 |
if keycode == wx.WXK_ESCAPE: |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
46 |
self.EndModal(wx.ID_CANCEL) |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
47 |
else: |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
48 |
event.Skip() |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
49 |
|
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
50 |
def OptionChecked(self): |
e0f16317668e
IDManager : finished Import/Export. Added merging capability to import (asks if particular ID is replaced during import). Added ESC as closing shortcut to IDManager dialog, and adjusted its size.
Edouard Tisserant
parents:
diff
changeset
|
51 |
return self.check.GetValue() |