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, bounds, title): super().__init__(bounds, title) self.flags &= ~wfClose self.options |= ofCentered self.degrees = 0 self.insert(StaticText(Rect(15, 2, 36, 3), 'Gauge Readings')) self.insert(StaticText(Rect(3, 4, 15, 5), 'Gauge #1')) self.insert(StaticText(Rect(3, 6, 15, 7), 'Gauge #2')) self.insert(StaticText(Rect(3, 8, 15, 9), 'Gauge #3')) self.gauge1 = Gauge(Rect(16, 4, 36, 5)) self.gauge1.setParams(60, 200) self.insert(self.gauge1) self.gauge2 = Gauge(Rect(16, 6, 36, 7)) self.gauge2.setParams(120, 200) self.insert(self.gauge2) self.gauge3 = Gauge(Rect(16, 8, 36, 9)) self.gauge3.setParams(180, 200) self.insert(self.gauge3) self.gauge1Value = ParamText(Rect(37, 4, 44, 5)) self.gauge1Value.setText('%3d', 60) self.insert(self.gauge1Value) self.gauge2Value = ParamText(Rect(37, 6, 44, 7)) self.gauge2Value.setText('%3d', 120) self.insert(self.gauge2Value) self.gauge3Value = ParamText(Rect(37, 8, 44, 9)) self.gauge3Value.setText('%3d', 180) self.insert(self.gauge3Value)
def test_isEmpty(self): r = Rect( 4, 4, 3, 3, ) assert r.isEmpty()
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 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 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 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 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 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 standardScrollBar(self, options): r = self.getExtent() if options & sbVertical: r = Rect(r.bottomRight.x - 1, r.topLeft.y + 1, r.bottomRight.x, r.bottomRight.y - 1) else: r = Rect(r.topLeft.x + 2, r.bottomRight.y - 1, r.bottomRight.x - 2, r.bottomRight.y) s = ScrollBar(r) self.insert(s) if options & sbHandleKeyboard: s.options |= ofPostProcess return s
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(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 __init__(self, bounds): super().__init__(bounds) self.value = 0 self.minVal = 0 self.maxVal = 0 self.pageStep = 1 self.arrowStep = 1 self.mouse = None self.extent = Rect(0, 0, 0, 0) if self.size.x == 1: self.growMode = gfGrowLoX | gfGrowHiX | gfGrowHiY self.chars = self.vChars else: self.growMode = gfGrowLoY | gfGrowHiX | gfGrowHiY self.chars = self.hChars
def getRect(bounds, menu): w = 10 h = 2 r = Rect(bounds.topLeft.x, bounds.topLeft.y, bounds.bottomRight.x, bounds.bottomRight.y) if menu: for p in menu.items: h += 1 if not p.name: continue nameLen = nameLength(p.name) + 6 if not p.command: nameLen += 3 elif p.param: nameLen += (nameLength(p.param) + 2) w = max(nameLen, w) if (r.topLeft.x + w) < r.bottomRight.x: r.bottomRight.x = r.topLeft.x + w else: r.topLeft.x = r.bottomRight.x - w if (r.topLeft.y + h) < r.bottomRight.y: r.bottomRight.y = r.topLeft.y + h else: r.topLeft.y = r.bottomRight.y - h return r
def popup(self): bounds = Rect(0, 0, 0, 0) # for clarity, we'll create separately the menu to insert into the menubox theMenu = Menu( MenuItem("Item ~1~", cmOne, kbAltI, hcNoContext, "Alt-1", nextItem=MenuItem("Item ~2~", cmTwo, kbAltT, hcNoContext, "Alt-2", nextItem=MenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, "Alt-X")))) # now create the menu with no parent mb = MenuBox(bounds, theMenu, 0) # however, if we don't specify appropriate bounds, we must do something to ensure it is appropriately # positioned on the desktop mb.options |= ofCentered # then make sure it's valid and execute it if self.validView(mb): result = self.desktop.execView(mb) self.destroy(mb) event = Event(evCommand) event.message.command = result self.putEvent(event) self.clearEvent(event)
def TechInfo(self): tr = Rect(10, 2, 40, 5) tv = TechInfoView(Rect(1, 1, 28, 3)) twr = Rect(tr.topLeft.x - 1, tr.topLeft.y - 1, tr.bottomRight.x + 1, tr.bottomRight.y + 1) tvw = Window(twr, 'Individual View', 2) tvw.insert(tv) self.desktop.insert(tvw) tr.topLeft.x = 10 tr.topLeft.y = 7 tr.bottomRight.x = 40 tr.bottomRight.y = 25 ti = TechInfoDialog(tr) self.desktop.execView(ti)
def __init__(self): super().__init__(Rect(1, 1, 21, 7), _('Puzzle'), wnNoNumber) self.flags &= ~(wfZoom | wfGrow) self.growMode = 0 r = self.getExtent() r.grow(-1, -1) self.insert(PuzzleView(r))
def calcTileRect(self, pos, bounds): def dividerLoc(lo, hi, num, dPos): return int((hi - lo) * dPos // num + lo) d = (self.numCols - self.leftOver) * self.numRows if pos < d: x, y = divmod(pos, self.numRows) else: x = (pos - d) // (self.numRows + 1) + (self.numCols - self.leftOver) y = (pos - d) % (self.numRows + 1) nRect = Rect(0, 0, 0, 0) nRect.topLeft.x = dividerLoc(bounds.topLeft.x, bounds.bottomRight.x, self.numCols, x) nRect.bottomRight.x = dividerLoc(bounds.topLeft.x, bounds.bottomRight.x, self.numCols, x + 1) if pos >= d: nRect.topLeft.y = dividerLoc(bounds.topLeft.y, bounds.bottomRight.y, self.numRows + 1, y) nRect.bottomRight.y = dividerLoc(bounds.topLeft.y, bounds.bottomRight.y, self.numRows + 1, y + 1) else: nRect.topLeft.y = dividerLoc(bounds.topLeft.y, bounds.bottomRight.y, self.numRows, y) nRect.bottomRight.y = dividerLoc(bounds.topLeft.y, bounds.bottomRight.y, self.numRows, y + 1) return nRect
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, 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 getItemRect(self, item): """ Classes derived from `MenuView` must override this member function in order to respond to mouse events. Your overriding functions in derived classes must return the rectangle occupied by the given menu item. :param item: Item to rect to return :return: `Rect` with the item bounds """ return Rect(0, 0, 0, 0)
def __init__(self, bounds, numCols, vScrollbar): r = Rect(bounds.topLeft.x, bounds.topLeft.y, bounds.bottomRight.x, bounds.bottomRight.y) r.topLeft.x += 2 r.topLeft.y += 1 r.bottomRight.x -= 3 r.bottomRight.y -= 2 super().__init__(r, numCols, vScrollbar) self.tc = MyCollection(data) self.newList(self.tc)
def __init__(self): super().__init__(Rect(1, 1, 23, 11), _('Calendar'), wnNoNumber) r = self.getExtent() self.flags &= ~(wfZoom | wfGrow) self.growMode = 0 self.palette = wpCyanWindow r.grow(-1, -1) self.insert(Calendar(r))
def __init__(self): super().__init__() dlg = ScrollDialog(Rect(0, 0, 40, 10), 'Test Dialog', sbVerticalBar) dlg.options |= ofCentered dlg.flags |= wfGrow for x in range(40): if x % 10: n = x + 1 ctrlString = 'Control {:02d}'.format(n) dlg.scrollGroup.insert(StaticText(Rect(0, x, 10, x + 1), ctrlString)) else: dlg.scrollGroup.insert(InputLine(Rect(0, x, 10, x + 1), 20)) dlg.scrollGroup.selectNext(False) dlg.scrollGroup.setLimit(0, 40) if self.validView(dlg): self.desktop.execView(dlg) self.destroy(dlg)
def getItemRect(self, item): """ Returns the rectangle occupied by the given menu item. It can be used to determine if a mouse click has occurred on a given menu selection. :param item: Item to locate :return: `Rect` bounds of the item """ y = list(self.menu.items).index(item) + 1 r = Rect(2, y, self.size.x - 2, y + 1) return r
def setScreenMode(self, *_args): """ Resizes and redraws the screen. :param _args: unused. Used to be screen mode. """ r = Rect(0, 0, Screen.screenWidth, Screen.screenHeight) self.changeBounds(r) self.setState(sfExposed, False) self.setState(sfExposed, True) self.redraw()