103 |
|
|
104 |
self._DIALOGS = {'about' :UIAbout, |
self._DIALOGS = {'about' :UIAbout, |
105 |
'messageBox' :UIMessageBox, |
'messageBox' :UIMessageBox, |
106 |
|
'genericBox' :UIGenericBox, |
107 |
} |
} |
108 |
|
|
109 |
self._aboutDialog = UIAbout |
self._aboutDialog = UIAbout |
984 |
# A dialog box providing basic message info |
# A dialog box providing basic message info |
985 |
# |
# |
986 |
class UIMessageBox(wxMessageDialog, UIHelper): |
class UIMessageBox(wxMessageDialog, UIHelper): |
987 |
def __init__(self, interface, message, caption): |
def __init__(self, interface, message, caption, buttonSet, defaultButton, cancelButton): |
988 |
message = lineWrap(message,60) |
message = lineWrap(message,60) |
989 |
wxMessageDialog.__init__(self, interface, message, caption, style=wxOK|wxICON_EXCLAMATION) |
wxMessageDialog.__init__(self, interface, message, caption, style=wxOK|wxICON_EXCLAMATION) |
990 |
|
|
991 |
|
|
992 |
|
# |
993 |
|
# UIGenericBox |
994 |
|
# |
995 |
|
# A generic box providing feedback info |
996 |
|
# |
997 |
|
class UIGenericBox(wxDialog, UIHelper): |
998 |
|
def __init__(self, interface, caption): |
999 |
|
self.interface = interface |
1000 |
|
self.caption = caption |
1001 |
|
|
1002 |
|
def createGenericBox(self, message, buttonSet): |
1003 |
|
self.genericBox = dlg = wxDialog(self.interface, -1, self.caption) |
1004 |
|
buttonCount = len(buttonSet) |
1005 |
|
|
1006 |
|
dlg.SetAutoLayout(true) |
1007 |
|
|
1008 |
|
#bmp = wxImage(images_dir+gConfig('smallPNG'), wxBITMAP_TYPE_PNG).ConvertToBitmap() |
1009 |
|
|
1010 |
|
messageField = WrappedStaticText(dlg, -1, str(message), 300, style=wxALIGN_CENTER) |
1011 |
|
|
1012 |
|
dlgWidth = messageField.GetSize().GetWidth() + 20 |
1013 |
|
|
1014 |
|
dlgHeight = messageField.GetSize().GetHeight() + 80 |
1015 |
|
|
1016 |
|
xSpacing = 0 |
1017 |
|
ySpacing = 0 |
1018 |
|
|
1019 |
|
idx = 0 |
1020 |
|
buttonSetWidth = 0 |
1021 |
|
maxButtonHeight = 0 |
1022 |
|
button = [] |
1023 |
|
|
1024 |
|
for buttonLabel in buttonSet: |
1025 |
|
buttonId = wxNewId() |
1026 |
|
button.append(wxButton(dlg,buttonId,_(buttonLabel))) |
1027 |
|
EVT_BUTTON(dlg, buttonId, lambda event, s=self, butt=idx+1: s.setResult(butt) ) |
1028 |
|
buttonSetWidth += button[idx].GetSize().GetWidth() |
1029 |
|
if maxButtonHeight < button[idx].GetSize().GetHeight(): |
1030 |
|
maxButtonHeight = button[idx].GetSize().GetHeight() |
1031 |
|
idx += 1 |
1032 |
|
|
1033 |
|
button[0].SetDefault() |
1034 |
|
dlgWidth = max(dlgWidth, buttonSetWidth + 6) + 20 |
1035 |
|
|
1036 |
|
dlgHeight += maxButtonHeight - 6 |
1037 |
|
|
1038 |
|
xSpacing += 10 # Add whitespace between widgets |
1039 |
|
ySpacing += 6 # Add whitespace between widgets |
1040 |
|
xPos = dlgWidth/2 |
1041 |
|
|
1042 |
|
# Create and position the logo |
1043 |
|
#wxStaticBitmap(dlg,-1, bmp, |
1044 |
|
# wxPoint((dlgWidth-bmp.GetWidth())/2, 12), |
1045 |
|
# wxSize(bmp.GetWidth(), bmp.GetHeight())) |
1046 |
|
|
1047 |
|
# Move the various widgets into position |
1048 |
|
messageField.SetPosition( |
1049 |
|
wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2, |
1050 |
|
30 )) |
1051 |
|
idx = 0 |
1052 |
|
currentX = 10 |
1053 |
|
for buttonLabel in buttonSet: |
1054 |
|
button[idx].SetPosition(wxPoint(currentX, dlgHeight - 10 - maxButtonHeight)) |
1055 |
|
currentX += button[idx].GetSize().GetWidth() + 10 |
1056 |
|
idx += 1 |
1057 |
|
|
1058 |
|
dlg.SetSize(wxSize(dlgWidth, dlgHeight)) |
1059 |
|
|
1060 |
|
dlg.Refresh() |
1061 |
|
dlg.Fit() |
1062 |
|
dlg.Raise() |
1063 |
|
dlg.CenterOnScreen() |
1064 |
|
|
1065 |
|
# If user cancels, this will be set to 0 |
1066 |
|
self._result = 0 |
1067 |
|
|
1068 |
|
return dlg |
1069 |
|
|
1070 |
|
def getResult(self): |
1071 |
|
return self._result |
1072 |
|
|
1073 |
|
def setResult(self, value): |
1074 |
|
self._result = value |
1075 |
|
self.genericBox.EndModal(1) |
1076 |
|
self.genericBox.Destroy() |
1077 |
|
|
1078 |
|
|
1079 |
##################################################################### |
##################################################################### |
1080 |
## |
## |
1081 |
## Keymapper Support |
## Keymapper Support |