def __init__(self, Parent, Message, **properties): SIOInstance = Parent.Screen() sMCOL = SIOInstance.MAXCOL sMROW = SIOInstance.MAXROW MsgLen = len(Message) DialogWidth = MsgLen + 4 DialogHeight = 6 if DialogWidth < 12: DialogWidth = 18 r1 = (sMROW - DialogHeight) / 2 r2 = r1 + DialogHeight c1 = (sMCOL - DialogWidth) / 2 c2 = c1 + DialogWidth apply(Dialog.__init__, (self, Parent, r1, c1, r2, c2), properties) tCmdYes = Button(self, "YesBtn", 5, (DialogWidth - 7) / 4, 7, "Yes") tCmdYes.EXITFORM = 1 self.AddDialogControl(tCmdYes) tCmdNo = Button(self, "NoBtn", 5, 2 + (2 * ((DialogWidth - 7)) / 4), 7, "No") tCmdNo.EXITFORM = 1 self.AddDialogControl(tCmdNo) self.AddDialogControl(Label(self, "TheMsg", 1, 2, Message))
def __init__(self, Parent, Prompt, DefaultText="", **properties): SIOInstance = Parent.Screen() sMCOL = SIOInstance.MAXCOL sMROW = SIOInstance.MAXROW if len(Prompt) < 40: DialogWidth = 40 else: DialogWidth = len(Prompt) + 4 DialogHeight = 6 r1 = (sMROW - DialogHeight) / 2 r2 = r1 + DialogHeight c1 = (sMCOL - DialogWidth) / 2 c2 = c1 + DialogWidth apply(Dialog.__init__, (self, Parent, r1, c1, r2, c2), properties) tCmdOK = Button(self, "OKBtn", 5, (DialogWidth - 10) / 4, 10, "OK") tCmdOK.EXITFORM = 1 self.AddDialogControl(tCmdOK) tCmdCancel = Button(self, "CnclBtn", 5, 2 + (2 * ((DialogWidth - 10)) / 4), 10, "Cancel") tCmdCancel.EXITFORM = 1 self.AddDialogControl(tCmdCancel) self.AddDialogControl(Label(self, "lbl", 1, 2, Prompt)) self.tTextBox = TextBox(self, "txtBox", 2, 2, DialogWidth - 4, DefaultText) self.tTextBox.DEPTH = len(DefaultText) self.AddDialogControl(self.tTextBox) self.STARTPOINT = 3
def __init__(self, Parent, Message, **properties): SIOInstance = Parent.Screen() sMCOL = SIOInstance.MAXCOL sMROW = SIOInstance.MAXROW MsgLen = len(Message) DialogWidth = MsgLen + 4 DialogHeight = 6 # adjust dialog, if need be, to hold OK btn comfortably if DialogWidth < 6: DialogWidth = 10 r1 = (sMROW - DialogHeight) / 2 r2 = r1 + DialogHeight c1 = (sMCOL - DialogWidth) / 2 c2 = c1 + DialogWidth apply(Dialog.__init__, (self, Parent, r1, c1, r2, c2), properties) tCmd = Button(self, "TheBtn", 5, (DialogWidth - 6) / 2, 6, "OK") tCmd.EXITFORM = 1 self.AddDialogControl(tCmd) self.AddDialogControl(Label(self, "TheMsg", 1, 2, Message))