def newDialog(self, demoDialogData): pd = Dialog(Rect(20, 6, 60, 19), "Demo Dialog") b = CheckBoxes(Rect(3, 3, 18, 6), ("~H~avarti", "~T~ilset", "~J~arlsberg")) pd.insert(b) pd.insert(Label(Rect(2, 2, 10, 3), "Cheeses", b)) b = RadioButtons(Rect(22, 3, 34, 6), ("~S~olid", "~R~unny", "~M~elted")) pd.insert(b) pd.insert(Label(Rect(21, 2, 33, 3), "Consistency", b)) b = InputLine(Rect(3, 8, 37, 9), 128) pd.insert(b) pd.insert(Label(Rect(2, 7, 24, 8), "Delivery Instructions", b)) pd.insert(Button(Rect(15, 10, 25, 12), "~O~K", cmOK, bfDefault)) pd.insert(Button(Rect(28, 10, 38, 12), "~C~ancel", cmCancel, bfNormal)) pd.setData(demoDialogData) control = self.desktop.execView(pd) data = None if control != cmCancel: data = pd.getData() del pd return data
def inputBoxRect(bounds, title, aLabel, s, limit): dialog = Dialog(bounds, title) r = Rect(4 + len(aLabel), 2, dialog.size.x - 3, 3) control = InputLine(r, limit) dialog.insert(control) r = Rect(2, 2, 3 + len(aLabel), 3) dialog.insert(Label(r, aLabel, control)) r = Rect(dialog.size.x - 24, dialog.size.y - 4, dialog.size.x - 14, dialog.size.y - 2) dialog.insert(Button(r, MsgBoxText.okText, cmOK, bfDefault)) r.topLeft.x += 12 r.bottomRight.x += 12 dialog.insert(Button(r, MsgBoxText.cancelText, cmCancel, bfNormal)) dialog.selectNext(False) dialog.setData([s]) c = execView(dialog) rec = None if c != cmCancel: rec = dialog.getData()[0] return c, rec
def __init__(self, options, historyId): super().__init__(Rect(16, 2, 64, 20), self.changeDirTitle) self.options |= ofCentered self.dirInput = InputLine(Rect(3, 3, 30, 4), 68) self.insert(self.dirInput) self.insert(Label(Rect(2, 2, 17, 3), self.dirNameText, self.dirInput)) self.insert(History(Rect(30, 3, 33, 4), self.dirInput, historyId)) sb = ScrollBar(Rect(32, 6, 33, 16)) self.insert(sb) self.dirList = DirListBox(Rect(3, 6, 32, 16), sb) self.insert(self.dirList) self.insert(Label(Rect(2, 5, 17, 6), self.dirTreeText, self.dirList)) self.okButton = Button(Rect(35, 6, 45, 8), self.okText, cmOK, bfDefault) self.insert(self.okButton) self.chDirButton = Button(Rect(35, 9, 45, 11), self.chDirText, cmChangeDir, bfNormal) self.insert(self.chDirButton) if options & cdHelpButton: self.insert( Button(Rect(35, 15, 45, 17), self.helpText, cmHelp, bfNormal)) if not options & cdNoLoadDir: self.setupDialog() self.selectNext(False)
def __init__(self): super().__init__(Rect(0, 0, 34, 12), _('Mouse options')) r = Rect(3, 4, 30, 5) self.options |= ofCentered self.mouseScrollBar = ScrollBar(r) self.mouseScrollBar.setParams(1, 1, 20, 20, 1) self.mouseScrollBar.options |= ofSelectable self.mouseScrollBar.setValue(EventQueue.doubleDelay) self.insert(self.mouseScrollBar) r = Rect(2, 2, 21, 3) self.insert(Label(r, _('~M~ouse double click'), self.mouseScrollBar)) r = Rect(3, 3, 30, 4) self.insert(ClickTester(r, _('Fast Medium Slow'))) r = Rect(3, 6, 30, 7) self.insert(CheckBoxes(r, (_('~R~everse mouse buttons'), ))) self.oldDelay = EventQueue.doubleDelay r = Rect(9, 9, 19, 11) self.insert(Button(r, _('O~K~'), cmOK, bfDefault)) r = Rect(21, 9, 31, 11) self.insert(Button(r, _('Cancel'), cmCancel, bfNormal)) self.selectNext(False)
def __init__(self, palette, groups): super().__init__(Rect(0, 0, 79, 18), self.colors) self.groupIndex = None self.colorIndexes = None self.options |= ofCentered if palette: self.pal = palette else: self.pal = None sb = ScrollBar(Rect(27, 3, 28, 14)) self.insert(sb) self._groups = ColorGroupList(Rect(3, 3, 27, 14), sb, groups) self.insert(self._groups) self.insert(Label(Rect(3, 2, 10, 3), self.groupText, self._groups)) sb = ScrollBar(Rect(59, 3, 60, 14)) self.insert(sb) p = ColorItemList(Rect(30, 3, 59, 14), sb, groups.items) self.insert(p) self.insert(Label(Rect(30, 2, 36, 3), self.itemText, p)) self._forSel = ColorSelector(Rect(63, 3, 75, 7), ColorSelector.csForeground) self.insert(self._forSel) self._forLabel = Label(Rect(63, 2, 75, 3), self.forText, self._forSel) self.insert(self._forLabel) self._bakSel = ColorSelector(Rect(63, 9, 75, 11), ColorSelector.csBackground) self.insert(self._bakSel) self._bakLabel = Label(Rect(63, 8, 75, 9), self.bakText, self._bakSel) self.insert(self._bakLabel) self._display = ColorDisplay(Rect(62, 12, 76, 14), self.textText) self.insert(self._display) self._monoSel = MonoSelector(Rect(62, 3, 77, 7)) self._monoSel.hide() self.insert(self._monoSel) self._monoLabel = Label(Rect(62, 2, 69, 3), self.colorText, self._monoSel) self._monoLabel.hide() self.insert(self._monoLabel) self.insert(Button(Rect(51, 15, 61, 17), self.okText, cmOK, bfDefault)) self.insert( Button(Rect(63, 15, 73, 17), self.cancelText, cmCancel, bfNormal)) self.selectNext(False) if self.pal: self.setData(self.pal)
def __init__(self, wildCard, title, inputLabel, options, histId): super().__init__(Rect(15, 1, 64, 20), title) self.directory = '' self.options |= ofCentered self.wildCard = wildCard self.filename = FileInputLine(Rect(3, 3, 31, 4), 79) self.filename.setData(self.wildCard) self.insert(self.filename) self.insert(Label(Rect(2, 2, 3 + nameLength(inputLabel), 3), inputLabel, self.filename)) self.insert(History(Rect(31, 3, 34, 4), self.filename, histId)) sb = ScrollBar(Rect(3, 14, 34, 15)) self.insert(sb) self.fileList = FileList(Rect(3, 6, 34, 14), sb) self.insert(self.fileList) self.insert(Label(Rect(2, 5, 8, 6), self.filesText, self.fileList)) opt = bfDefault r = Rect(35, 3, 46, 5) if options & fdOpenButton: self.insert(Button(r, self.openText, cmFileOpen, opt)) opt = bfNormal r.topLeft.y += 3 r.bottomRight.x += 3 if options & fdOKButton: self.insert(Button(r, self.okText, cmFileOpen, opt)) opt = bfNormal r.topLeft.y += 3 r.bottomRight.y += 3 if options & fdReplaceButton: self.insert(Button(r, self.replaceText, cmFileReplace, opt)) r.topLeft.y += 3 r.bottomRight.y += 3 if options & fdClearButton: self.insert(Button(r, self.clearText, cmFileClear, opt)) r.topLeft.y += 3 r.bottomRight.y += 3 self.insert(FileInfoPane(Rect(1, 16, 48, 18))) self.selectNext(False) if not (options & fdNoLoadDir): self._readCurrentDirectory()
def createFindDialog(): d = Dialog(Rect(0, 0, 38, 12), 'Find') d.options |= ofCentered control = InputLine(Rect(3, 3, 32, 4), 80) d.insert(control) d.insert(Label(Rect(2, 2, 32, 3), '~T~ext to find', control)) d.insert(History(Rect(32, 3, 35, 4), control, 10)) d.insert( CheckBoxes(Rect(3, 5, 35, 7), ('~C~ase sensitive', '~W~hole words only', None))) d.insert(Button(Rect(14, 9, 24, 11), 'O~K~', cmOK, bfDefault)) d.insert(Button(Rect(26, 9, 36, 11), 'Cancel', cmCancel, bfNormal)) d.selectNext(False) return d
def AboutDialog(self): pd = Dialog(Rect(0, 0, 35, 10), 'About') pd.options |= ofCentered pd.insert( StaticText(Rect(1, 2, 34, 6), '\003Grid View\n' '\003Fairly Crap\n')) pd.insert(Button(Rect(13, 7, 22, 9), '~O~K', cmOK, bfDefault)) self.desktop.execView(pd) self.destroy(pd)
def aboutDialogBox(self): aboutBox = Dialog(Rect(0, 0, 39, 13), 'About') aboutBox.insert( StaticText(Rect(9, 2, 30, 9), '\x03Vision Tutorial\n\n\x03Python Version\n\n\x03Splash Screen Demo.') ) aboutBox.insert(Button(Rect(14, 10, 26, 12), 'OK', cmOK, bfDefault)) aboutBox.options |= ofCentered self.executeDialog(aboutBox, None)
def aboutBox(self): box = Dialog(Rect(0, 0, 32, 10), 'About') box.insert( StaticText( Rect(1, 2, 31, 7), """\x03Conway's Game of Life\n\x03The classic life example""")) box.insert(Button(Rect(11, 7, 21, 9), 'O~K~', cmOK, bfDefault)) box.options |= ofCentered self.executeDialog(box, None)
def aboutBox(self): pd = Dialog(Rect(0, 0, 35, 12), 'About') pd.insert(StaticText(Rect(1, 2, 34, 7), '\x03Turbo Vision\n\n' + '\x03Creating a nested menu\n\n' + '\x03Borland Technical Support')) pd.insert(Button(Rect(3, 9, 32, 11), '~O~key-d~O~key', cmOK, bfDefault)) pd.options |= ofCentered self.desktop.execView(pd) self.destroy(pd)
def AboutDialog(self): d = Dialog(Rect(0, 0, 35, 12), 'About') d.options |= ofCentered d.insert( StaticText( Rect(1, 2, 34, 7), """\x03Turbo Vision Example\n\n\x03Modifying the desktop\n\n\x03Borland Technical Support""" )) d.insert(Button(Rect(3, 9, 32, 11), "~O~k", cmOK, bfDefault)) self.desktop.execView(d) self.destroy(d)
def aboutDialogBox(self): aboutBox = Dialog(Rect(0, 0, 39, 13), 'About') aboutBox.insert( StaticText(Rect(9, 2, 30, 9), """\003Vindauga Demo\n\n\003Python Version\n\n\003Copyright (C) 1994\n\n\003Borland International""") ) aboutBox.insert( Button(Rect(14, 10, 26, 12), ' OK', cmOK, bfDefault) ) aboutBox.options |= ofCentered self.executeDialog(aboutBox, None)
def __init__(self): super().__init__(Rect(0, 0, 40, 10), 'Dynamic Text') self.options |= ofCentered self.__master = InputLine(Rect(10, 2, 32, 3), 21) self.insert(self.__master) self.__slave = DynamicText(Rect(11, 4, 31, 5), 'Initial Text', False) self.insert(self.__slave) self.insert(Button(Rect(15, 6, 25, 8), 'O~K~', cmOK, bfNormal)) self.__master.select()
def aboutDialog(self): pd = Dialog(Rect(0, 0, 35, 12), "About") pd.options |= ofCentered pd.insert( StaticText( Rect(1, 2, 34, 7), "\003Turbo Vision Example\n\n" "\003Creating a Popup Menu\n\n" "\003Borland Technical Support")) pd.insert(Button(Rect(3, 9, 32, 11), "~O~k", cmOK, bfDefault)) self.desktop.execView(pd) self.destroy(pd)
def newDialog(self): pd = Dialog(Rect(20, 6, 60, 19), 'Demo Dialog') sb = ScrollBar(Rect(25, 2, 26, 11)) pd.insert(sb) lb = ListBox(Rect(2, 2, 24, 11), 2, sb) pd.insert(lb) names = random.sample(animals, 20) tsc = StringCollection(names) pd.insert(Button(Rect(28, 6, 38, 8), '~O~K', cmOK, bfDefault)) pd.insert(Button(Rect(28, 10, 38, 12), '~C~ancel', cmCancel, bfNormal)) data = ListBoxRec() data.items = tsc data.selection = 2 items = [data] pd.setData(items) control = self.desktop.execView(pd) if control != cmCancel: data = pd.getData() data = data[0] if control == cmOK: messageBox('\x03Your selection is {}'.format(tsc[data.selection]), mfInformation, (mfOKButton,)) self.destroy(pd)
def createReplaceDialog(): d = Dialog(Rect(0, 0, 40, 16), 'Replace') d.options |= ofCentered control = InputLine(Rect(3, 3, 34, 4), 80) d.insert(control) d.insert(Label(Rect(2, 2, 34, 3), '~T~ext to find', control)) d.insert(History(Rect(34, 3, 37, 4), control, 10)) control = InputLine(Rect(3, 6, 34, 7), 80) d.insert(control) d.insert(Label(Rect(2, 5, 34, 6), '~N~ew _text', control)) d.insert(History(Rect(34, 6, 37, 7), control, 11)) d.insert( CheckBoxes(Rect(3, 8, 37, 12), ('~C~ase sensitive', '~W~hole words only', '~P~rompt on replace', '~R~eplace all'))) d.insert(Button(Rect(17, 13, 27, 15), 'O~K~', cmOK, bfDefault)) d.insert(Button(Rect(28, 13, 38, 15), 'Cancel', cmCancel, bfNormal)) d.selectNext(False) return d
def newDialog(self): pd = Dialog(Rect(20, 6, 60, 19), 'Demo Dialog') b = CheckBoxes(Rect(3, 3, 18, 6), ('~H~avarti', '~T~ilset', '~J~arlsberg')) pd.insert(b) pd.insert(Label(Rect(2, 2, 10, 3), 'Cheeses', b)) b = RadioButtons(Rect(22, 3, 34, 6), ('~S~olid', '~R~unny', '~M~elted',)) pd.insert(b) pd.insert(Label(Rect(21, 2, 33, 3), 'Consistency', b)) b = InputLine(Rect(3, 8, 37, 9), 128) pd.insert(b) pd.insert(Label(Rect(2, 7, 24, 8), 'Delivery Instructions', b)) pd.insert(Button(Rect(15, 10, 25, 12), '~O~K', cmOK, bfDefault)) pd.insert(Button(Rect(28, 10, 38, 12), '~C~ancel', cmCancel, bfNormal)) pd.setData(demoDialogData) control = self.desktop.execView(pd) data = [] if control != cmCancel: data = pd.getData() del pd return data
def __init__(self): super().__init__(Rect(5, 3, 29, 19), _('Calculator')) self.options |= ofFirstClick for i, c in enumerate(calcButtons): x = (i % 4) * 5 + 2 y = (i // 4) * 2 + 4 r = Rect(x, y, x + 5, y + 2) tv = Button(r, c, cmCalcButton, bfNormal | bfBroadcast) tv.options &= ~ofSelectable self.insert(tv) r = Rect(3, 2, 21, 3) self.insert(Calculator(r))
def newDialog(self): random.seed() items = random.sample(animals, 10) collection = GenCollection(items) r = Rect(2, 1, 27, 10) pd = Dialog(r, 'Combobox') tv = InputLine(Rect(2, 1, 20, 2), 128) pd.insert(tv) pd.insert(ComboBox(Rect(20, 1, 21, 2), tv, collection)) tv = StaticInputLine(Rect(2, 3, 20, 4), 128, collection) pd.insert(tv) pd.insert(ComboBox(Rect(20, 3, 21, 4), tv, collection)) pd.insert(Button(Rect(1, 6, 11, 8), '~O~K', cmOK, bfDefault)) pd.insert(Button(Rect(12, 6, 22, 8), 'Cancel', cmCancel, bfNormal)) pd.selectNext(False) self.desktop.execView(pd) data = pd.getData() logger.info('Combo Box: %s', data) self.destroy(pd)
def __init__(self, bounds): super().__init__(bounds, 'Data ListBox') t = self.getExtent() t.topLeft.x += 1 t.topLeft.y += 1 t.bottomRight.x -= 1 t.bottomRight.y -= 2 sb = ScrollBar( Rect(t.bottomRight.x - 2, t.topLeft.y + 1, t.bottomRight.x - 1, t.bottomRight.y - 2)) self.insert(sb) self.insert(TechInfoList(t, 1, sb)) self.insert( Button(Rect(10, t.bottomRight.y - 1, 20, t.bottomRight.y + 1), '~O~k', cmClose, bfDefault))
def __init__(self): super().__init__(Rect(0, 0, 42, 16), 'Validator Example') self.options |= ofCentered obj = InputLine(Rect(23, 1, 40, 2), 40) self.insert(obj) self.insert(Label(Rect(1, 1, 22, 2), 'No validator', obj)) obj = InputLine(Rect(23, 3, 27, 4), 3, RangeValidator(1, 31)) self.insert(obj) self.insert(Label(Rect(1, 3, 22, 4), 'Date Style', obj)) self.insert(StaticText(Rect(27, 3, 28, 4), '/')) line = InputLine(Rect(28, 3, 32, 4), 3) self.insert(line) line.setValidator(RangeValidator(1, 12)) self.insert(StaticText(Rect(32, 3, 33, 4), '/')) self.insert( InputLine(Rect(33, 3, 39, 4), 5, RangeValidator(1950, 2050))) self.insert(Button(Rect(1, 13, 11, 15), 'O~K~', cmOK, bfDefault)) self.insert( Button(Rect(12, 13, 24, 15), '~C~ancel', cmCancel, bfNormal)) self.selectNext(False)
def __init__(self): super().__init__() dlg = Dialog(Rect(0, 0, 40, 30), 'Test Dialog') dlg.options |= ofCentered dlg.flags |= wfGrow box = FlexBox(Rect(1, 1, 38, 28), GrowDirection.GrowVertical) dlg.insert(box) topBox = FlexBox(Rect(1, 1, 1, 1), GrowDirection.GrowHorizontal) bottomBox = FlexBox(Rect(1, 1, 1, 1), GrowDirection.GrowVertical) for x in range(4): ctrlString = 'T{:02d}'.format(x) widget = Button(Rect(0, 0, 1, 1), ctrlString, 0, 0) topBox.insert(widget) ctrlString = 'B{:02d}'.format(x) widget = Button(Rect(0, 0, 1, 3), ctrlString, 0, 0) bottomBox.insert(widget) box.insert(topBox) box.insert(bottomBox) if self.validView(dlg): self.desktop.execView(dlg) self.destroy(dlg)
def messageBoxRect(r, msg, messageType, buttons): dialog = Dialog(r, TITLES[messageType]) dialog.insert( StaticText(Rect(3, 2, dialog.size.x - 2, dialog.size.y - 3), msg)) x = -2 buttons = (BUTTONS[b] for b in sorted(buttons)) buttonList = [ Button(Rect(0, 0, 10, 2), button[0], button[1], bfNormal) for button in buttons ] x += sum((2 + b.size.x) for b in buttonList) x = (dialog.size.x - x) // 2 for b in buttonList: dialog.insert(b) b.moveTo(x, dialog.size.y - 3) x += b.size.x + 2 dialog.selectNext(False) return execView(dialog)
class ChangeDirDialog(Dialog): changeDirTitle = _('Change Directory') dirNameText = _('Directory ~N~ame') dirTreeText = _('Directory ~T~ree') chDirText = _('~C~hdir') okText = _('O~K~') helpText = _('~H~elp') invalidText = _('Invalid Directory') def __init__(self, options, historyId): super().__init__(Rect(16, 2, 64, 20), self.changeDirTitle) self.options |= ofCentered self.dirInput = InputLine(Rect(3, 3, 30, 4), 68) self.insert(self.dirInput) self.insert(Label(Rect(2, 2, 17, 3), self.dirNameText, self.dirInput)) self.insert(History(Rect(30, 3, 33, 4), self.dirInput, historyId)) sb = ScrollBar(Rect(32, 6, 33, 16)) self.insert(sb) self.dirList = DirListBox(Rect(3, 6, 32, 16), sb) self.insert(self.dirList) self.insert(Label(Rect(2, 5, 17, 6), self.dirTreeText, self.dirList)) self.okButton = Button(Rect(35, 6, 45, 8), self.okText, cmOK, bfDefault) self.insert(self.okButton) self.chDirButton = Button(Rect(35, 9, 45, 11), self.chDirText, cmChangeDir, bfNormal) self.insert(self.chDirButton) if options & cdHelpButton: self.insert( Button(Rect(35, 15, 45, 17), self.helpText, cmHelp, bfNormal)) if not options & cdNoLoadDir: self.setupDialog() self.selectNext(False) def consumesData(self): return True def getData(self): return self.dirInput.getDataString() def setData(self, data): self.dirInput.setData(data.value) def handleEvent(self, event): super().handleEvent(event) if event.what == evCommand: emc = event.message.command if emc == cmRevert: curDir = getCurDir() elif emc == cmChangeDir: p = self.dirList.getList()[self.dirList.focused] curDir = p.dir() if curDir[-1] != os.sep: curDir += os.sep elif emc == cmDirSelection: self.chDirButton.makeDefault(event.message.infoPtr) return else: return self.dirList.newDirectory(curDir) if curDir and curDir[-1] == os.sep: curDir = curDir[:-1] self.dirInput.setData(curDir) self.dirInput.drawView() self.dirList.select() def valid(self, command): if command != cmOK: return True rec = DataRecord() self.dirInput.getData() path = rec.value if not path: event = Event(evCommand) event.message.command = cmChangeDir self.putEvent(event) return False path = fexpand(path) if path and path[-1] == os.sep: path = path[:-1] if self.changeDir(path): messageBox(self.invalidText, mfError, (mfOKButton, )) return False return True def setupDialog(self): if self.dirList: curDir = getCurDir() self.dirList.newDirectory(curDir) if self.dirInput: if curDir and curDir[-1] == os.sep: curDir = curDir[:-1] self.dirInput.setData(curDir) self.dirInput.drawView() def changeDir(self, path): try: os.chdir(path) return False except: return True