def readPcbFile(self): ####################################################################################################################### # READ PCB FILE and EXTRACT ITS FOOTPRINTS # ####################################################################################################################### print('Loading PCB file...') self.pcb = Layout(self.args.pcbfile) # pcb.mod.printTree() print() # TODO 0: remove debug code #self.pcb.sexp.printTree() # used only for debugging #exit() print('Footprints on PCB:') l = self.pcb.getFootprints() if l: for w in l: print(w.word) self.pcbFootprints.append(Footprint(w)) print() # set footprintLibPath for all footprints on PCB: for fp in self.pcbFootprints: fp.footprintLibPath = self.fpLibs[fp.libName]
def __init__(self, id, name=None, parent=None, key=None): BaseField.__init__(self, id, name, parent) self.key = key inputContainer = Layout.Box(id + "_inputContainer", '', self) inputContainer.style['float'] = 'left' inputContainer.style['clear'] = 'none' userInput = Inputs.CheckBox(id, None, self, key=key) self.userInput.addJavascriptEvent('onload', 'CCClickCheckbox(this)') self.userInput.addJavascriptEvent('onclick', CallBack(self, 'toggleChildren')) self.userInput = self.userInput.replaceWith(userInput) self.inputContainer = self.addChildElement(inputContainer) labelContainer = Layout.Box(id + "_labelContainer", '', self) labelContainer.style['float'] = 'left' labelContainer.style['clear'] = 'none' labelContainer.style['margin-top'] = "3px" label = Display.Label(id + "_label", '', self) self.label = labelContainer.addChildElement(label) self.labelContainer = self.addChildElement(labelContainer) self.addChildElement(Layout.LineBreak()) childContainer = Layout.Box(id + "_childContainer", name, self) childContainer.style['display'] = CallBack(self, 'displayValue') self.childContainer = self.addChildElement(childContainer) self.addChildElementsTo = childContainer
def predict(model, input_path): print('predict') model.eval() img = Image.open(input_path).convert("RGB") trans = transforms.Compose([ transforms.Resize((cf.pano_size)), transforms.ToTensor() ]) color = torch.unsqueeze(trans(img), 0).to(device) [fp, fc, h] = model(color) e2p = E2P(cf.pano_size, cf.fp_size, cf.fp_fov, gpu=not args.cpu) [fc_up, fc_down] = e2p(fc) [fp, fc_up, fc_down, h] = Utils.var2np([fp, fc_up, fc_down, h]) fp_pts, fp_pred = postproc.run(fp, fc_up, fc_down, h) # Visualization scene_pred = Layout.pts2scene(fp_pts, h) edge = Layout.genLayoutEdgeMap(scene_pred, [512 , 1024, 3], dilat=2, blur=0) img = img.resize((1024,512)) img = np.array(img, np.float32) / 255 vis = img * 0.5 + edge * 0.5 vis = Image.fromarray(np.uint8(vis* 255)) vis.save(os.path.splitext(input_path)[0] + "_vis.jpg") #Save output 3d layout as json Layout.saveSceneAsJson(os.path.splitext(input_path)[0] + "_res.json", scene_pred) return
def get_test_layout_and_svc(): svc = SavedViewConfig( theme_identifier=FauxTheme.identifier, shop=get_default_shop(), view_name=printable_gibberish(), status=SavedViewConfigStatus.CURRENT_DRAFT ) layout = Layout(FauxTheme, "ph") layout.add_plugin("text", {"text_*": "hello"}) svc.set_layout_data(layout.placeholder_name, layout) svc.save() return layout, svc
def __init__(self, id, name=None, parent=None): Layout.Vertical.__init__(self, id, name, parent=parent) self.inputContainer = self.addChildElement(Layout.Horizontal()) self.label = self.inputContainer.addChildElement(Display.Label()) self.fieldActions = self.inputContainer.addChildElement(Layout.Box()) self.addChildElementsTo = self.fieldActions self.userInput = self.inputContainer.addChildElement(Base.Invalid()) errorContainer = self.addChildElement(Layout.Horizontal()) self.formError = errorContainer.addChildElement( Display.FormError(id, parent=self))
def __init__(self, units, ok_button): DocumentWindow.__init__(self) x = (self.winfo_screenwidth() - 200) / 2 y = (self.winfo_screenheight() - 200) / 2 self.geometry("+%d+%d" % (x, y)) heading = self.heading = Label(self, wrap = 300, anchor = 'w', just = 'left') chooser_frame = Frame(self) choosers = [UnitChooser(chooser_frame, unit) for unit in units] Layout.grid(choosers, padx = 10) heading.grid(row = 0, padx = 5, pady = 5, sticky = 'ew') chooser_frame.grid(row = 1, padx = 5) if ok_button: b = Button(self, text = "OK", width = 6, command = self.ok) b.grid(row = 2, sticky = 'e')
def testAddChild(self): base = self.base child = Layout({"width":500, "height":500}) self.base.add_child(child) self.assertEqual(len(base.get_children), 1) self.assertTrue(child in base.get_children()) self.assertIs(child.parent(), self.base) self.base.add_child(child) self.assertEqual(len(base.get_children()), 1) self.remove_child(child) self.assertEqual(len(base.get_children()), 0)
def readBF(path): flag = 0 #Columnas columns = 0 #Total contenedores total = 0 maxSize = 0 stacks = [] with open(path) as file: for line in file: s = line.split() #Si es la primera linea entonces se guarda las columnas y el total if flag == 0: #Actualiza columns columns = s[0] #Actualiza total total = s[1] #Actualiza flag para que no pase denuevo flag = 1 #En caso contrario sen otros datos de interes else: #Se ve el size mayor de la columna para definirlo automatico aux = int(s[0]) if maxSize <= aux: maxSize = aux #Se crean los stacks temporalStack = [] for i in range(1, len(s)): temporalStack.append(int(s[i])) stacks.append(temporalStack) #Se crea el layout layout = Layout.Layout(stacks, maxSize) return layout
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.list = wx.ListCtrl( self, -1, style=wx.LC_LIST #| wx.BORDER_SUNKEN #| wx.BORDER_NONE #| wx.LC_EDIT_LABELS #| wx.LC_SORT_ASCENDING #| wx.LC_NO_HEADER #| wx.LC_VRULES #| wx.LC_HRULES | wx.LC_SINGLE_SEL) self.imagelist = wx.ImageList(16, 16) self.imagelist.Add( wx.ArtProvider_GetBitmap(wx.ART_NEW, wx.ART_OTHER, (16, 16))) self.imagelist.Add( wx.ArtProvider_GetBitmap(wx.ART_QUESTION, wx.ART_OTHER, (16, 16))) self.imagelist.Add( wx.ArtProvider_GetBitmap(wx.ART_REDO, wx.ART_OTHER, (16, 16))) self.list.SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL) self.list.InsertImageStringItem(0, 'Global', 0) self.list.InsertImageStringItem(1, 'Each User', 0) self.list.InsertImageStringItem(2, 'Each Iteration', 0) import Layout Layout.SingleLayout(self, self.list)
def SF_move_(layout, pos=0): s_o = None s_d = None min_dif = 10000 actions = [] for i in range(len(layout.stacks)): h = len(layout.stacks[i]) if(layout.is_sorted_stack(i) and h < layout.H): #no se consideran stacks con H-1 contenedores #si solo hay 3 stacks no llenos #print(layout.stacks, layout.full_stacks) if h==layout.H-1 and layout.full_stacks >= len(layout.stacks)-3: continue top = Layout.gvalue(layout.stacks[i]) for k in range(len(layout.stacks)): h = len(layout.stacks[k]) if k!=i and (not layout.is_sorted_stack(k) or (h==layout.H and layout.full_stacks >= len(layout.stacks)-2)): if layout.stacks[k][-1] <= top : actions.append( (top - layout.stacks[k][-1], k, i)) actions.sort() if len(actions)>pos: min_df, s_o, s_d = actions[pos] return (s_o, s_d), len(actions) return False, len(actions)
def __updateUI__(self): self.tabLabel.textAfterChildren = self.text or self.name if self.imageName: image = self.tabLabel.addChildElement(Layout.Box()) image.addClass(self.imageName) image.style['margin'] = "auto" image.style['clear'] = "both"
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.list = wx.ListCtrl( self, -1, style=wx.LC_LIST #| wx.BORDER_SUNKEN #| wx.BORDER_NONE #| wx.LC_EDIT_LABELS #| wx.LC_SORT_ASCENDING #| wx.LC_NO_HEADER #| wx.LC_VRULES #| wx.LC_HRULES | wx.LC_SINGLE_SEL) self.imagelist = wx.ImageList(16, 16) self.imagelist.Add(IconImages.getPythonBitmap()) self.imagelist.Add(IconImages.getIfBitmap()) self.imagelist.Add(IconImages.getLoopBitmap()) self.imagelist.Add(IconImages.getBlockBitmap()) self.list.SetImageList(self.imagelist, wx.IMAGE_LIST_SMALL) self.list.InsertImageStringItem(0, 'SCRIPT', 0) self.list.InsertImageStringItem(1, 'IF', 1) self.list.InsertImageStringItem(2, 'LOOP', 2) self.list.InsertImageStringItem(3, 'BLOCK', 3) # layout import Layout Layout.SingleLayout(self, self.list) # event binding self.list.Bind(wx.EVT_LIST_BEGIN_DRAG, self.OnBeginDrag) # self.BindGetUserData()
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) self.leftsplitter = wx.SplitterWindow(self.splitter, style=wx.BORDER_NONE) p1 = ControllersPanel(self.leftsplitter) p2 = RecordPanel(self.leftsplitter, True) self.leftsplitter.SplitHorizontally(p1, p2, -300) p3 = SpecialsPanel(self.splitter) p4 = DetailsPanel(self.splitter) self.splitter.AppendWindow(self.leftsplitter, 180) self.splitter.AppendWindow(p3, 180) self.splitter.AppendWindow(p4, 150) self.controllersPanel = p1 self.specialsPanel = p3 self.detailsPanel = p4 self.recordPanel = p2 # layout import Layout Layout.SingleLayout(self, self.splitter) # bindings self.Bind(wx.EVT_BUTTON, self.OnPlay, self.detailsPanel.testButton) self.specialsPanel.onSelChangedCallback = self.detailsPanel.Load
def __init__(self, master, unit, heading = None): ViewFrame.__init__(self, master) quantity_symbol = unit.quantity_symbol if heading is None: heading = unit.quantity_name headinglbl = Layout.group_label(self, heading) num_units = len(prefixes) listbox = self.listbox = Listbox(self, width = 5, height = num_units, selectmode = 'browse', exportselection = 0, background = 'white') listbox.bind("<ButtonRelease>", self.selection_changed) listbox.bind("<KeyRelease>", self.selection_changed) for _, prefix in prefixes: listbox.insert('end', prefix + quantity_symbol) listbox.selection_set((num_units / 2)) Layout.grid([headinglbl], [listbox]) self.set_model(unit)
def SD_move(layout, pos=0, stack=-1): if len(layout.stacks[stack]) == 0: return False,0 if stack==-1: actions = select_dismantling_stacks(layout) else: actions = [(0,stack)] if len(actions)<=pos : return False ev, s_o = actions[pos] while len(layout.stacks[s_o])>0: ev, s_o = actions[pos] s_d, _ = Layout.select_destination_stack(layout,s_o) layout.move(s_o,s_d) if Layout.reachable_height(layout,s_o)==layout.H: return True, len(actions) return True, len(actions)
def __init__(self): super().__init__() self.title = 'Basic Web Scraper' self.setMinimumWidth(500) self.setWindowTitle(self.title) self.setCentralWidget(Layout.Layout(self)) self.show()
def __init__(self): """ Creates the game manager to manage the game """ self.layout = Layout.LayoutManager() self.items = Items.ItemGenerator() self.player = 'Null' self.playLoop = True #Gameloop vairable self.playGame = True #T/F for starting a NEW game
def __init__(self, id, name=None, parent=None): Layout.Box.__init__(self, id + "${suffix}", name, parent) baseId = id id += "${suffix}" self.index = 0 self.id = id + "Controller" self.name = id + "Controller" if self.hidden: self.style['display'] = 'none' controller = HiddenInputs.HiddenValue(name="serverController") controller.setValue(baseId) self.addChildElement(controller) self.function = self.addChildElement( HiddenInputs.HiddenValue(name="callFunction")) content = Layout.Box(id) content.addClass(id) self.ajaxContent = self.addChildElement(content) loading = self.Loading(id + ":Loading", parent=self) self.loadingBanner = self.addChildElement(loading) if self.autoload != "AJAX": loading.hide() self.defaultFields = loading.addChildElement( Layout.Box(id + ":Defaults")) self.defaultFields.hide() self.addJSFunctions(AjaxController) if self.autoload == "AJAX": self.addScript("ajaxUpdate('" + id + "');") if self.autoreload: self.addScript("setInterval('ajaxUpdate(\"" + id + "\", true)', " + unicode(self.autoreload) + ");")
def OutputTemplateFiles(OutDir: Path, Book: BookType, LayoutName: str, Margin: Margin, Gutter: Gutter) -> None: Path(f'{OutDir}/{Book.Name}/{Slugify(LayoutName)}').mkdir(exist_ok=True) File = open(f'{OutDir}/{Book.Name}/{Slugify(LayoutName)}/templatePages.lua', 'w') PaperUuid = uuid.uuid4() Templates = '' for PageUuid, Grid in Layout.GetSinglePages(): Templates += GenerateTemplate(OutDir, Book, LayoutName, PageUuid, Grid, Margin, Gutter) for PageUuid, Grid in Layout.GetDoublePages(): Templates += GenerateTemplate(OutDir, Book, LayoutName, PageUuid, Grid, Margin, Gutter, IsDoublePage=True) File.write(f'''\ pages = {{ actualBookHeight = {Book.GetDimensions()[1]}, actualBookWidth = {Book.GetDimensions()[0]}, backgrounds = {{ }}, bookHeight = {Book.GetDimensions()[1]}, bookWidth = {Book.GetDimensions()[0]}, covers = {{ hardcover_imagewrap = {{ }}, hardcover_jacket = {{ }}, softcover = {{ }}, }}, hints = {{ bookTitle = "{LayoutName}", hintType = "bookOptions", paperId = "{Book.Name}", styleName = "{Slugify(LayoutName)}", }}, pages = {{ {Templates} }}, paperId = "{PaperUuid}", }} ''')
def SDpp(layout, s_o, rank, quitar): capac = capacity(layout, s_o) # espacio libre ss_o = layout.stacks[s_o] #print() #print("THE DATA") #print(capac) #print(ss_o) #print() retirar = len(ss_o) - quitar while len(layout.stacks[s_o]) > retirar: top = Layout.gvalue(ss_o) #print ("TOP: "+str(top)) slack = capac - len(ss_o) # holgura #print ("SLACK: "+str(slack)) #SEPARADOR############################ #print("\n instancia: \n") #for s in layout.stacks: #print (s) #SEPARADOR############################ #print("Columna seleccionada: ") #print (s_o) #SEPARADOR############################ max_pos = rank[top] + slack #print() s_d = Layout.select_destination_stack(layout, s_o, max_pos=rank[top] + slack) pos = layout.H - len(layout.stacks[s_d]) if rank[top] < pos - slack: # rellenar stack s_d #c=layout.stacks[s_o].pop(-1) fill_stack(layout, s_d, (pos - slack) - rank[top], s_o, rank) #layout.stacks[s_o].append(c) capac -= 1 layout.move(s_o, s_d)
def __init__(self, id, name=None, parent=None): Layout.Vertical.__init__(self, id, name, parent) self.addClass("WebElementAccordion") self.toggle = self.addChildElement(Layout.Horizontal()) self.toggle.addClass('AccordionToggle') self.toggle.addJavascriptEvent('onclick', CallBack(self, 'jsToggle')) self.toggleImage = self.toggle.addChildElement( Display.Image(id + "Image")) self.toggleImage.addClass('AccordionImage') self.toggleLabel = self.toggle.addChildElement(Display.Label()) self.toggleLabel.addClass('AccordionLabel') self.isOpen = self.toggle.addChildElement( HiddenInputs.HiddenBooleanValue(id + "Value")) self.contentElement = self.addChildElement(Layout.Box(id + "Content")) self.contentElement.addClass('AccordionContent') self.addChildElementsTo = self.contentElement self.isOpen.connect('valueChanged', True, self, 'open') self.isOpen.connect('valueChanged', False, self, 'close') self.close() self.addJSFunctions(Accordion)
def __init__(self, id, name=None, parent=None): Layout.Box.__init__(self, id + "Field", name, parent) self.submitIfDisabled = False self.layout = self.addChildElement(Layout.Vertical(id + "Container")) self.inputContainer = self.layout.addChildElement(Layout.Horizontal()) self.label = self.inputContainer.addChildElement(Display.Label()) self.inputAndActions = self.inputContainer.addChildElement( Layout.Horizontal()) self.userInput = self.inputAndActions.addChildElement( self.inputElement(id, name=name)) self.fieldActions = self.inputAndActions.addChildElement(Layout.Box()) self.addChildElementsTo = self.fieldActions errorContainer = self.layout.addChildElement(Layout.Horizontal()) self.formError = errorContainer.addChildElement( Display.FormError(id, parent=self)) self.layout.addChildElement(errorContainer) self.connect('beforeToHtml', None, self, '__checkIfNeedsValidation__') self.connect('beforeToHtml', None, self, '__updateReadOnly__')
def __init__(self, parent): wx.Panel.__init__(self, parent, -1) self.splitter = wx.SplitterWindow(self, style=wx.BORDER_NONE) self.list = wx.ListCtrl(self.splitter, -1, style=wx.LC_REPORT #| wx.BORDER_SUNKEN #| wx.BORDER_NONE #| wx.LC_EDIT_LABELS #| wx.LC_SORT_ASCENDING #| wx.LC_NO_HEADER #| wx.LC_VRULES #| wx.LC_HRULES | wx.LC_SINGLE_SEL ) self.list.InsertColumn(0, "ID") self.list.InsertColumn(1, "Label") self.list.InsertColumn(2, "Avg") self.list.InsertColumn(3, "Max") self.list.InsertColumn(4, "Min") self.list.InsertColumn(5, "Count") self.list.InsertColumn(6, "Error") self.list.SetColumnWidth(0, 60) self.list.SetColumnWidth(1, 60) self.list.SetColumnWidth(2, 60) self.list.SetColumnWidth(3, 60) self.list.SetColumnWidth(4, 60) self.list.SetColumnWidth(5, 60) self.list.SetColumnWidth(6, 60) self.chartPanel = LineChartPanel.LineChart(self.splitter) self.chartPanel.xformat = LineChartPanel.XTimeFormatter self.chartPanel.yformat = LineChartPanel.YMSFormatter self.splitter.SplitHorizontally(self.list, self.chartPanel, 180) import Layout Layout.SingleLayout(self, self.splitter) self.SetDropTarget(ReportDropTarget(self.LoadReport)) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list) self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnSwitch, self.list) self.chartPanel.Bind(wx.EVT_MIDDLE_UP, self.OnSwitchTime, self.chartPanel)
def SF_move_d(layout, s_d): s_o = None min_dif = 10000 if(layout.is_sorted_stack(s_d) and len(layout.stacks[s_d]) < layout.H): top = Layout.gvalue(layout.stacks[s_d]) for k in range(len(layout.stacks)): if k!=s_d and not layout.is_sorted_stack(k): if layout.stacks[k][-1] <= top and (top - layout.stacks[k][-1]) < min_dif: min_dif = top - layout.stacks[k][-1] s_o = k if s_o != None: layout.move(s_o,s_d) return True return False
def force_move(layout, s_o, pos, s_d): #pixie c=layout.stacks[s_o][pos] #if capacity(layout,s_o,s_d) < -pos-1 : return c, "failed" while pos<-1: s_tmp, _ = Layout.select_destination_stack(layout, s_o, black_list=[s_d]) if s_tmp==None: return c, "failed" layout.move(s_o,s_tmp) pos += 1 c=layout.move(s_o,s_d) return c, "success"
def __createNewSelection__(self, name): new = Layout.Horizontal() new.addClass('WSelectedMultiOption') label = new.addChildElement(Display.Label()) label.setText(name) label.style['overflow'] = 'hidden' label.attributes['title'] = name label.addClass('valueSelected') remove = new.addChildElement(Buttons.Button()) remove.setText("Remove") remove.name = "MultiFieldRemove" + name remove.addJavascriptEvent( 'onclick', 'multiField.removeSelectedOption(this, "%s");' % self.sortBy) return new
def test_layout_serialization(): theme = FauxTheme with plugin_override(): l = Layout(theme, "test") l.begin_column({"md": 8}) l.add_plugin("text", {"text": "yes"}) serialized = l.serialize() expected = { 'name': "test", 'rows': [ { 'cells': [ {'config': {'text': 'yes'}, 'plugin': 'text', 'sizes': {"md": 8}} ] } ] } assert serialized == expected assert Layout.unserialize(theme, serialized).serialize() == expected
def __init__(self, id, name, parent): BaseField.__init__(self, id, name=None, parent=None) self.toggleLayout = self.addChildElement(Layout.Vertical()) self.toggleLayout.style["font-size"] = "75%" self.toggleLayout.addClass("Clickable") self.label.style['display'] = "block" self.label.style['margin-top'] = "5px;" self.up = self.toggleLayout.addChildElement(Buttons.UpButton()) self.up.addClass("hidePrint") self.down = self.toggleLayout.addChildElement(Buttons.DownButton()) self.down.setValue('images/count_down.png') self.down.addClass("hidePrint") self.userInput.setValue(0) self.connect("beforeToHtml", None, self, "__addEvents__") self.connect("beforeToHtml", None, self, "__updateReadOnly__")
def __init__(self, id, name=None, parent=None): Base.WebElement.__init__(self, id, name, parent) self.tabs = {} self.selectedTab = None self.layout = self.addChildElement( self.__layoutElement__(id, name, parent)) self.layout.addClass("WebElement" + self.__class__.__name__) self.__tabLabelContainer__ = self.layout.addChildElement( self.__tabLayoutElement__()) self.__tabLabelContainer__.addClass('TabLabels') self.__tabContentContainer__ = self.layout.addChildElement( Layout.Box()) self.__tabContentContainer__.addClass('TabContents') self.addScript(CallBack(self, 'jsInit'))
def __init__(self, id, name=None, parent=None): SelectField.__init__(self, id, name, parent) self.sortBy = "innerHTML" self.userInput.id = id + "MultiField" self.userInput.name = (name or id) + "MultiField" self.selectContainer = self.addChildElement(Layout.Vertical()) self.hiddenMultiSelect = self.addChildElement(Inputs.MultiSelect(id)) self.hiddenMultiSelect.hide() self.hiddenMultiSelect.addClass('hiddenMultiSelectionField') self.selectContainer.addClass('selectContainer') self.userInput.addClass('selectionBox') self.userInput.addOption(' Click to add', ' ') self.addClass('multiField') self.userInput.addClientSideEvent( 'onChange', 'multiField.addSelectedOption(this)') self.connect('beforeToHtml', None, self, 'sort')
def __init__(self, parent, xmlstr=''): wx.Panel.__init__(self, parent, -1) self.nb = wx.Notebook(self, -1, style=wx.BK_BOTTOM) self.viewPanel = XMLPanel(self.nb, xmlstr) self.sourcePanel = CodeCtrl(self.nb, -1, style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) import editor.syntax.xml self.sourcePanel.SetSyntax(editor.syntax.xml) self.sourcePanel.SetValue(xmlstr) self.nb.AddPage(self.viewPanel, "View") self.nb.AddPage(self.sourcePanel, "Source") import Layout Layout.SingleLayout(self, self.nb) self.viewPanel.ResetSize()
def testRelativeSizing(self): child = Layout({"width":0.5, "height":0.1, "parent":self.base}) self.assertEqual(child.get_height(), 50) self.assertEqual(child.get_width(), 500) self.base.set_x(600) self.assertEqual(child.get_height(), 50) self.assertEqual(child.get_width(), 300) self.base.set_y(1000) self.assertEqual(child.get_height(),100) self.assertEqual(child.get_width(), 300) grandchild = Layout({"width":1.0, "height":0.6, "parent":self.child}) self.assertEqual(grandchild.get_width(), 300) self.assertEqual(grandchild.get_height(), 60) self.base.set_x(1000) self.assertEqual(child.get_width(), 500) self.assertEqual(grandchild.get_width(), 500) self.base.set_y(500) self.assertEqual(child.get_height(), 50) self.assertEqual(grandchild.get_height(), 25)
def setUp(self): self.base = Layout({"x":0, "y":0, "width":1000, "height": 500})
def testFloating(self): base = self.base child = Layout({"width":500, "height":500}) base.add_child(child) self.assertEqual(base.get_vertical_float(), "top") self.assertEqual(base.get_horizontal_float(), "left") child.assertEqual(child.get_x(), 0) child.assertEqual(child.get_y(), 0) grandchild = Layout({"width":100, "height":200}) child.add_child(grandchild) child.set_vertical_float("center") child.set_horizontal_float("center") self.assertEqual(base.get_x(), 200) self.assertEqual(base.get_y(), 150) base.set_horizontal_float("right") self.assertEqual(child.get_x(), 500) self.assertEqual(child.get_y(), 0) self.assertEqual(child.get_x(), 700) self.assertEqual(child.get_y(), 150)
# Parse graphs: graphs = Parser.readFile(args.infile, graphNum=args.tree, afTrait=args.ancestralFragmentTrait, debug=args.debug) if len(graphs)>1: print "Cannot yet deal with multiple trees. Please select an individual tree using --tree." exit(1) graph = graphs[0] # Sort nodes: if args.sortTree: graph.reorder() # Position nodes within a unit square: Layout.layout(graph) # Draw positioned nodes to output file using Cairo: painting = Painter.Painting(graph, rect=args.rect, drawNodes=args.drawNodes, nodeRadius=args.nodeRadius, colourTrait=args.colourTrait, lineWidth=args.lineWidth, aspect=args.aspectRatio) writerMap = {"svg": painting.writeSVG, "pdf": painting.writePDF, "ps": painting.writePS, "png": painting.writePNG} writerMap[args.format](args.outfile)