def __init__(self): self.w = Window((350, 600), "Instance Interpolations Report", minSize=(300, 450)) self.w.textEditor = TextEditor((10, 10, -10, -10), text=text, readOnly=True) self.w.open()
def _helpCallback(self, sender): self.w = Window((300, 300), "Help", closable=True, fullSizeContentView=True, titleVisible=False, minSize=(300, 300), maxSize=(600, 800)) self.topics = [] for key in docstring.keys(): self.topics.append(key) self.pathList = NSPopUpButton.alloc().initWithFrame_( ((0, 0), (160, 20))) self.pathList.addItemsWithTitles_(self.topics) toolbarItems = [ dict(itemIdentifier="Help", label="Help", toolTip="Topic", view=self.pathList, callback=self._getTopic), ] self.w.addToolbar("Help Toolbar", toolbarItems=toolbarItems, displayMode="icon") output = self.getContent(self.key) self.w.helptext = TextEditor((10, 47, -10, -10), text=output, readOnly=True) self.w.helptext._nsObject.setBorderType_(NSNoBorder) self.w.helptext.getNSTextView().setDrawsBackground_(False) self.w.helptext.getNSScrollView().setDrawsBackground_(False) self.w.open()
def __init__(self): self.fontName = "Bitcount Grid Single" fnt = getFont(self.fontName) axesInfo = getAxisInfo(fnt) self.w = Window((500, 400), "Test", minSize=(300, 200)) # self.w.button = Button((10, 10, 120, 24), "Click", callback=self.myCallback) y = 10 self.sliderMapping = {} for index, axisInfo in enumerate(axesInfo): slider = Slider((10, y, 130, 24), value=axisInfo['default'], minValue=axisInfo['minValue'], maxValue=axisInfo['maxValue'], callback=self.sliderChanged) self.sliderMapping[slider] = axisInfo['tag'] setattr(self.w, "slider_%s" % index, slider) y += 34 self.w.textEditor = TextEditor((150, 0, 0, 0)) attrs = {AppKit.NSFontAttributeName: fnt} self.w.textEditor._textView.setTypingAttributes_(attrs) self.w.open()
def _selectionCallback(self, sender): try: if not self.w.list.getSelection(): # Application did not finish loading yet pass else: # Get job name self.selected.clear() job = sender.get()[self.w.list.getSelection()[0]] self.selected['name'] = job['name'] self.valueGroups = [] # Get job path and file location item = self.pathList.titleOfSelectedItem() if 'User' in item: import getpass username = getpass.getuser() user = username path = '/Users/%s/Library/Launch' % username elif 'Global' in item: user = '******' path = '/Library/Launch' elif 'System' in item: user = '******' path = '/System/Library/Launch' if 'Agents' in item: path += 'Agents/' else: path += 'Daemons/' self.selected['path'] = path self.selected['file'] = str(self.selected['path'].replace( ' ', '\ ')) + job['name'].replace(' ', '\ ') + '.plist' f = open(self.selected['file'], "r") self.selected['raw'] = str(f.read()) self.selected['short'] = ( self.selected['name'][:32] + '…') if len( self.selected['name']) > 32 else self.selected['name'] # Get status if job['image'] == NSImage.imageNamed_(NSImageNameStatusNone): status = None else: status = 'Available' self.selected['status'] = status index = sender.getSelection()[0] relativeRect = sender.getNSTableView().rectOfRow_(index) self.pop = Popover((300, 100)) self.pop.tabs = Tabs((20, 40, -20, -20), ["Editor", "Raw View"]) self.pop.tabs._nsObject.setTabViewType_(NSNoTabsNoBorder) self.pop.tabBtn = SegmentedButton( (10, 10, -10, 20), [dict(title="Editor"), dict(title="Raw View")], callback=self._segmentPressed, selectionStyle='one') self.pop.tabBtn.set(0) self.edit = self.pop.tabs[0] self.rawEdit = self.pop.tabs[1] self.rawEdit.editor = TextEditor((0, 0, -0, -45), text=self.selected['raw']) self.selected['dict'] = launchd.plist.read( self.selected['name']) # TODO: Add stackview to scrollview as group # Waiting for merge into master: https://github.com/robotools/vanilla/issues/132 self.edit.stack = VerticalStackGroup((0, 0, -0, -45)) for idx, (key, value) in enumerate( sorted(self.selected['dict'].items())): group = ValueGroup((0, 0, -0, -0), sender=self, key=key, value=value, idx=idx) self.valueGroups.append(group) self.edit.stack.addView( self.valueGroups[idx], 300, self.valueGroups[idx].getPosSize()[3]) self.pop.save = Button((20, -50, -20, 40), "Save", callback=self._savePlist) self.pop.save.enable(False) self.pop.open(parentView=sender.getNSTableView(), preferredEdge='right', relativeRect=relativeRect) except: pass
def __init__(self): u""" Initialize the window and open it. """ self.w = view = Window((AppC.WINDOW_WIDTH, AppC.WINDOW_HEIGHT), "Xierpa 3", closable=True, minSize=(200, 200), maxSize=(1600, 1000)) siteLabels = self.getSiteLabels() #y = len(siteLabels)*20 y = 10 bo = 25 # Button offset view.optionalSites = PopUpButton((10, y, 150, 24), siteLabels, sizeStyle='small', callback=self.selectSiteCallback) #view.optionalSites = RadioGroup((10, 10, 150, y), siteLabels, # callback=self.selectSiteCallback, sizeStyle='small') self.w.optionalSites.set(0) y = y + 32 view.openSite = Button((10, y, 150, 20), 'Open site', callback=self.openSiteCallback, sizeStyle='small') y += bo self.w.saveSite = Button((10, y, 150, 20), 'Save HTML+CSS', callback=self.saveSiteCallback, sizeStyle='small') y += bo view.openCss = Button((10, y, 150, 20), 'Open CSS', callback=self.openCssCallback, sizeStyle='small') y += bo #view.openSass = Button((10, y, 150, 20), 'Open SASS', callback=self.openSassCallback, sizeStyle='small') #y += bo view.openDocumentation = Button( (10, y, 150, 20), 'Documentation', callback=self.openDocumentationCallback, sizeStyle='small') y += bo view.openAsPhp = Button((10, y, 150, 20), 'Open as PHP', callback=self.openAsPhpCallback, sizeStyle='small') #view.makeSite = Button((10, y+95, 150, 20), 'Make site', callback=self.makeSiteCallback, sizeStyle='small') view.forceCss = CheckBox((180, 10, 150, 20), 'Force make CSS', sizeStyle='small', value=True) view.doIndent = CheckBox((180, 30, 150, 20), 'Build indents', sizeStyle='small', value=True) view.forceCopy = CheckBox((180, 50, 150, 20), 'Overwrite files', sizeStyle='small', value=True) view.isOnline = CheckBox((180, 70, 150, 20), 'Online', sizeStyle='small', value=True, callback=self.isOnlineCallback) view.console = EditText((10, -200, -10, -10), sizeStyle='small') # Path defaults y = 20 view.mampRootLabel = TextBox((300, y, 100, 20), 'MAMP folder', sizeStyle='small') view.mampRoot = EditText((400, y, -10, 20), self.C.PATH_MAMP, sizeStyle='small') y += bo view.exampleRootLabel = TextBox((300, y, 100, 20), 'Root folder', sizeStyle='small') view.exampleRoot = EditText((400, y, -10, 20), self.C.PATH_EXAMPLES, sizeStyle='small') # Scripting y += bo view.script = TextEditor((300, y, -10, -240)) view.runScript = Button((500, -230, 150, -210), 'Run script', callback=self.runScriptCallback, sizeStyle='small') view.script.set(self.EXAMPLE_SCRIPT) view.open()
def __init__(self, proofGroup): """ Initialize inspector with proofGroup data. proofGroup is a dictionary passed in by ProofDrawer(). """ self.proofGroup = proofGroup self.editedProofGroup = {} left = 10 row = 10 textboxWidth = 92 leftEditText = left + 95 pointSizes = ["6", "8", "10", "12", "14", "18",\ "21", "24", "36", "48", "60", "72"] self.w = FloatingWindow( (400, 275), "Edit Proof Group: %s" % self.proofGroup["name"]) self.w.groupName = TextBox((left, row + 2, textboxWidth, 20), "Group name:", alignment="right") self.w.groupNameEdit = EditText((leftEditText, row, -10, 22), self.proofGroup["name"]) row += 33 self.w.typeSize = TextBox((left, row + 2, textboxWidth, 20), "Type size (pt):", alignment="right") self.w.typeSizeEdit = ComboBox((leftEditText, row, 55, 22), pointSizes, continuous=True, callback=self._checkFloat) self.w.typeSizeEdit.set(self.proofGroup["typeSize"]) self.w.leading = TextBox((leftEditText + 80, row + 2, 60, 22), "Leading:") self.w.leadingEdit = ComboBox((leftEditText + 139, row, 55, 22), pointSizes, continuous=True, callback=self._checkFloat) self.w.leadingEdit.set(self.proofGroup["leading"]) row += 33 self.w.contents = TextBox((left, row, textboxWidth, 20), "Contents:", alignment="right") self.w.contentsEdit = TextEditor( (leftEditText, row, -10, 150), "\n".join(self.proofGroup["contents"])) self.w.contentsEdit.getNSTextView().setFont_(monoFont) row += 160 self.w.cancelButton = Button((leftEditText, row, 138, 20), "Cancel", callback=self.cancelCB) leftEditText += 147 self.w.okButton = Button((leftEditText, row, 138, 20), "OK", callback=self.okCB) self.w.setDefaultButton(self.w.okButton) self.w.bind("close", self._postCloseEvent)
def __init__(self, mainWindow, presetsList): self.presets = presetsList self.presetNames = [preset.name for preset in self.presets] self.selectedPreset = None self.selectedGroupIndex = None gutter = 10 left = 10 row = 10 colWidth = 275 listHeight = 115 col2Left = left + colWidth + gutter btnWidth = 85 btnHeight = 22 boxWidth = btnWidth * 2 + 15 windowWidth = col2Left + boxWidth + 10 self.w = Sheet((windowWidth, 550), mainWindow) self.w.presetsText = TextBox((left, row, colWidth, 20), "Presets:", sizeStyle="small") row += 17 self.w.presetsList = List((left, row, colWidth, listHeight), items=self.presetNames, allowsSorting=False, allowsMultipleSelection=False, allowsEmptySelection=False, selectionCallback=self.updatePresetInfo) self.w.presetCtrls = Box((col2Left, row, boxWidth, listHeight)) boxLeft = 0 boxRow = 0 self.w.presetCtrls.edit = TextBox((boxLeft, boxRow, btnWidth, 20), "Edit:", sizeStyle="small") boxRow += 15 self.w.presetCtrls.newBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "New", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.dupeBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Duplicate", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.renameBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Rename", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.delBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Delete", sizeStyle="small", callback=self.testerCB) boxRow = 0 boxLeft += btnWidth + 7 self.w.presetCtrls.importText = TextBox((boxLeft, boxRow, btnWidth, 20), "Import:", sizeStyle="small") boxRow += 15 self.w.presetCtrls.importJSON = Button((boxLeft, boxRow, btnWidth, btnHeight), "JSON", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.importGroups = Button((boxLeft, boxRow, btnWidth, btnHeight), "Proof groups", sizeStyle="small", callback=self.testerCB) row += listHeight + 12 self.w.proofGroupsText = TextBox((left, row, colWidth, 20), "Proof groups:", sizeStyle="small") row += 17 listHeight = 150 self.w.proofGroupNames = List((left, row, colWidth, listHeight), items=[], allowsSorting=False, allowsMultipleSelection=False, selectionCallback=self.updateGroupContents) self.w.groupCtrls = Box((col2Left, row, boxWidth, listHeight)) boxLeft = 0 boxRow = 0 self.w.groupCtrls.newBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "New", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.dupeBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Duplicate", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.rename = Button((boxLeft, boxRow, btnWidth, btnHeight), "Rename", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.delBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Delete", sizeStyle="small", callback=self.testerCB) boxRow = 22 boxLeft += btnWidth + 7 + (btnWidth / 2 - 15) self.w.groupCtrls.upBtn = Button((boxLeft, boxRow, 30, btnHeight), "↑", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.dnBtn = Button((boxLeft, boxRow, 30, btnHeight), "↓", sizeStyle="small", callback=self.testerCB) row += listHeight + 12 self.w.groupContentsText = TextBox((left, row, colWidth, 20), "Group contents:", sizeStyle="small") row += 17 self.w.groupContents = TextEditor((left, row, -10, -36), text="", readOnly=True, callback=self.editGroupContents) self.w.groupContents.getNSTextView().setFont_(monoFont) # self.w.renameText = TextBox((left, row, colWidth, 20), # "Rename preset:", # sizeStyle="small") # self.w.renameEdit = EditText((left, row, colWidth, btnHeight)) row += 17 self.w.okButton = Button((windowWidth/2 - btnWidth/2, -31, btnWidth, btnHeight), "OK", callback=self.closeCB) self.w.setDefaultButton(self.w.okButton) self.updatePresetInfo()