forked from monash-merc/cvl-fabric-launcher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MacMessageDialog.py
89 lines (70 loc) · 3.86 KB
/
MacMessageDialog.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import wx
import IconPys.MASSIVElogoTransparent64x64
class LauncherMessageDialog(wx.Dialog):
def __init__(self, parent, message, title, helpEmailAddress="[email protected]", **kw):
wx.Dialog.__init__(self, parent, style=wx.DEFAULT_DIALOG_STYLE|wx.STAY_ON_TOP, **kw)
if parent!=None:
self.CenterOnParent()
else:
self.Centre()
self.helpEmailAddress = helpEmailAddress
self.ButtonLabels=['OK']
self.dialogPanel = wx.Panel(self, wx.ID_ANY)
iconAsBitmap = IconPys.MASSIVElogoTransparent64x64.getMASSIVElogoTransparent64x64Bitmap()
self.iconBitmap = wx.StaticBitmap(self.dialogPanel, wx.ID_ANY, iconAsBitmap, pos=(25,15), size=(64,64))
self.titleLabel = wx.StaticText(self.dialogPanel, wx.ID_ANY, title, pos=(105,15))
titleFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
titleFont.SetWeight(wx.BOLD)
titleFont.SetPointSize(13)
self.titleLabel.SetFont(titleFont)
smallFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
smallFont.SetPointSize(11)
messageWidth = 330
self.messageLabel = wx.StaticText(self.dialogPanel, wx.ID_ANY, message, pos=(105,39), size=(messageWidth,-1))
self.messageLabel.SetForegroundColour((0,0,0))
self.messageLabel.SetFont(smallFont)
self.messageLabel.Wrap(messageWidth)
dialogPanelWidth = 475
dialogPanelHeight = max(self.messageLabel.GetPosition().y + self.messageLabel.GetSize().height + 70, 140)
self.SetClientSize(wx.Size(dialogPanelWidth,dialogPanelHeight))
self.dialogPanel.SetSize(wx.Size(dialogPanelWidth,dialogPanelHeight))
okButtonSize = wx.Size(72,22)
okButtonPosition = wx.Point(dialogPanelWidth - okButtonSize.width - 25, dialogPanelHeight - okButtonSize.height - 18)
self.okButton = wx.Button(self.dialogPanel, wx.ID_ANY, "OK", pos=okButtonPosition, size=okButtonSize)
self.okButton.SetDefault()
self.Bind(wx.EVT_CLOSE, self.onClose)
self.Bind(wx.EVT_BUTTON, self.onClose, id=self.okButton.GetId())
self.contactQueriesContactLabel = wx.StaticText(self.dialogPanel, label = "For queries, please contact:")
self.contactQueriesContactLabel.SetFont(smallFont)
self.contactQueriesContactLabel.SetForegroundColour(wx.Colour(0,0,0))
self.contactQueriesContactLabel.SetPosition(wx.Point(25,okButtonPosition.y))
self.contactEmailHyperlink = wx.HyperlinkCtrl(self.dialogPanel, id = wx.ID_ANY, label = self.helpEmailAddress, url = "mailto:" + self.helpEmailAddress)
self.contactEmailHyperlink.SetFont(smallFont) # Or maybe even smaller font?
#hyperlinkPosition = wx.Point(self.contactQueriesContactLabel.GetPosition().x+self.contactQueriesContactLabel.GetSize().width+10,okButtonPosition.y)
hyperlinkPosition = wx.Point(self.contactQueriesContactLabel.GetPosition().x+self.contactQueriesContactLabel.GetSize().width,okButtonPosition.y)
self.contactEmailHyperlink.SetPosition(hyperlinkPosition)
def onClose(self, event):
obj=event.GetEventObject()
if (isinstance(obj,wx.Button)):
label=obj.GetLabel()
ln=0
for i in self.ButtonLabels:
if (label==i):
self.EndModal(ln)
else:
ln=ln+1
else:
self.EndModal(-1)
def onClose(self, event):
self.Show(False)
self.Destroy()
self.EndModal(0)
class MyApp(wx.App):
def OnInit(self):
message = "You have requested 2880 CPU hours, but you only have 455.0 CPU hours remaining in your quota for project \"Desc002\"."
dialog = LauncherMessageDialog(parent=None, message=message, title="Strudel")
dialog.ShowModal()
return True
if __name__ == '__main__':
app = MyApp(False)
app.MainLoop()