Пример #1
0
    def _start_comp(self, ref):
        component = Component.Component()

        ref = [x.strip() for x in ref.split(",")]
        for x in ref:
            component.addLocation(Location.Location(x))

        self.stack.append(component)
 def fetch_component(self, target_id, target_row, target_col):
   # Add component if not found
   if target_id in self.cd:
     return self.cd[target_id]
   else:
     target_component = Component(id=target_id, row=target_row, col=target_col, img=self.img)
     self.cd[target_id] = target_component
     return target_component
Пример #3
0
 def dfs(self):
     for i in range(self.rows):
         for j in range(self.cols):
             if (i, j) in self.V: continue
             self.mark_visited((i, j))
             if (self.binimage[i][j] == 0):
                 comp = Component(self.id)
                 self.components.append(comp)
                 comp.append_point((i, j))
                 self.id += 1
                 self.bfs_iterative(comp, i, j)
    def changeType(self, event):
        #TODO: change types available for edges
        if self.nodes == None:  # if a node is selected rather than an edge
            if self.v.get() == "Create New":
                typeLabel = tkSimpleDialog.askstring(title="New Type",
                                                     prompt="Enter a new type")

                if typeLabel != None:
                    # select new 'type' in dropdown
                    self.optionList.insert(len(self.optionList) - 1, typeLabel)
                    self.v.set(self.optionList[len(self.optionList) - 2])

                    # redraw dropdown
                    self.dropdown.destroy()
                    self.dropdown = OptionMenu(self.propGroup,
                                               self.v,
                                               *self.optionList,
                                               command=self.changeType)
                    self.dropdown.config(highlightbackground=self.color,
                                         bg=self.color)
                    self.dropdown.grid(row=1,
                                       column=1,
                                       columnspan=2,
                                       padx=5,
                                       pady=5,
                                       sticky=E + W)

            elif self.v.get() == "Component":
                for widget in self.parent.grid_slaves():
                    if int(widget.grid_info()['row']) == 1:
                        widget.destroy()
                try:
                    self.leftFrame.dockedWindows.subNetworkExit()
                except AttributeError:
                    pass
                self.componentInfo = Component(self.parent, self.leftFrame,
                                               self.index, self.G,
                                               self.manager)

            elif self.v.get() == "Compartment":
                for widget in self.parent.grid_slaves():
                    if int(widget.grid_info()['row']) == 1 or int(
                            widget.grid_info()['row']) == 2:
                        widget.destroy()
                self.compartmentInfo = Compartment(self.parent, self.leftFrame,
                                                   self.index, self.G,
                                                   self.manager)
Пример #5
0
def generate_component(component_type, api_override = None):
    """
    Factory method, generates a component of component_type, if the api is overridden then the api_will include the
    specified modifications
    :param component_type: A component of the Base, Strict, Complex variety
    :param api_override: A dict containing the permission overrides for
    api access
    :return: Returns a constructed component with the specified parameters
    """
    if api_override is None:
        api_override = component_type.api_accessibility
    return Component(component_type.msg_key,
                     component_type.conn_crit,
                     component_type.disc_crit,
                     component_type.is_conn_crit_mut,
                     component_type.is_disc_crit_mut,
                     api_override,
                     component_type.api_mutable)
Пример #6
0
                print arduino.debugSerial(text)
            elif (text.split(":")[0] == "eval"):
                # This is direct code injection. Don't use.
                eval(text.split(":")[1:])
            else:
                print "Error: Unexpected input. Discarding command"

            moveOn = raw_input("Jamesons modules done...move on to Abis? (yes/no): ")
            if (moveOn == "yes"):
                JAMESONISGO = False
                print "Moving on to Abis mods...."
            else:
                continue
                

    nextComponent = Component()    
    nextComponent.nextComponent("R","9.95k","default",2,4,[0,0,0,0]) #VALUES NEED TO BE CORRECTED
    grid.addComponent(nextComponent)

    grid.drawGrid()

    moveOn = raw_input("Component added...move on to Check? (yes/no): ")
    if (moveOn == "yes"):
        LETSBUILD = False
        print "Moving on to CHECK mode...."
    else:
        continue


LETSCHECK = True
while(LETSCHECK):
Пример #7
0
             log("PARSING", "too few arguments for component!", i,
                 lines[i])
         exit()
     else:
         checkAlpha(validWords, [1, 2], i)
         print(validWords)
         try:
             name = validWords[0]
             type = validWords[0][0]
             ports = []
             ports.append(validWords[1])
             ports.append(validWords[2])
             dependencies = []
             value = float(validWords[3])
             ckt.append(
                 Component(name, type, ports, dependencies, value))
         except ValueError:
             log(
                 "INVALID_VALUE",
                 "the arguments specified to component are not convertible to float!",
                 i, lines[i])
             exit()
 elif validWords[0][0] in [DEP_SRC_VCCS, DEP_SRC_VCVS]:
     # NAME n1 n2 n3 n4 VALUE
     # verify this syntax and feed it into the component object
     if len(validWords) != 6:
         if (len(validWords) > 6):
             log("PARSING", "too many arguments for component!", i,
                 lines[i])
         else:
             log("PARSING", "too few arguments for component!", i,
Пример #8
0
    def initUI(self):

        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        mainMenu = self.menuBar()
        self.Component = Component()

        # ========== newAction ===========
        newAction = QAction('&New', self)
        newAction.setShortcut('CTRL+N')
        newAction.setStatusTip('New Document')
        # newAction.triggered.connect(self.newCall)

        # ========== openAction ===========
        openAction = QAction('&Open', self)
        openAction.setShortcut('CTRL+O')
        openAction.setStatusTip('Open Document')
        # openAction.triggered.connect(self.OpenCall)

        # ========== exitAction ===========
        exitAction = QAction('&Exit', self)
        exitAction.setShortcut('CTRL+Q')
        exitAction.setStatusTip('Exit Application')
        # exitAction.triggered.connect(self.ExitCall)

        # ========== compAction ===========
        compAction = QAction('&Component Database', self)
        compAction.setStatusTip('Connect to Component Database')
        compAction.triggered.connect(self.Component.exec_)

        # ========== compAction ===========
        eleAction = QAction('&Element Database', self)
        eleAction.setStatusTip('Connect to Element Database')
        # eleAction.triggered.connect()

        # ========== file menu ===========
        fileMenu = mainMenu.addMenu('File')
        fileMenu.addAction(newAction)
        fileMenu.addAction(openAction)
        fileMenu.addSeparator()
        fileMenu.addAction(exitAction)

        # ========== Edit menu ===========
        editMenu = mainMenu.addMenu('Edit')
        editMenu.addAction(compAction)
        editMenu.addAction(eleAction)

        # ========== View menu ===========
        viewMenu = mainMenu.addMenu('View')

        # ========== Search menu ===========
        searchMenu = mainMenu.addMenu('Graphics')

        # ========== Tools menu ===========
        toolsMenu = mainMenu.addMenu('Model')

        # ========== run menu ===========
        runMenu = mainMenu.addMenu('Run')

        # ========== help menu ===========
        helpMenu = mainMenu.addMenu('Help')

        # toolbar feature
        toolbar = QToolBar("My main toolbar")
        self.addToolBar(toolbar)
        toolbar.setIconSize(QSize(20, 20))
        for i in range(12):
            self.test(toolbar, "images/image" + str(i))
        # create toolbar
        self.toolbar = QToolBar()
        # create toolbar label
        # ======= left arrow tool bar ===========
        self.left = ToolbarArrow("left")
        self.left.setToolTip("Left Arrow")
        # add label to toolbars
        self.toolbar.addWidget(self.left)
        self.toolbar.addSeparator()

        # ======= right arrow tool bar ===========
        self.right = ToolbarArrow("right")
        self.right.setToolTip("Right Arrow")
        # add label to toolbars
        self.toolbar.addWidget(self.right)
        self.toolbar.addSeparator()

        # ======= top arrow tool bar ===========
        self.top = ToolbarArrow("top")
        self.top.setToolTip("Top Arrow")
        # add label to toolbars
        self.toolbar.addWidget(self.top)
        self.toolbar.addSeparator()

        # ======= down arrow tool bar ===========
        self.down = ToolbarArrow("down")
        self.down.setToolTip("Down Arrow")
        # add label to toolbars
        self.toolbar.addWidget(self.down)
        self.toolbar.addSeparator()
        # add toolbars to window
        self.addToolBar(self.toolbar)
        # done done
        layout = QGridLayout()
        layout.setRowStretch(0, 1)
        layout.setRowStretch(1, 9)
        layout1 = QHBoxLayout()

        label = QLabel('Browser')
        buttons = []
        ii = 13
        for i in range(6):
            buttons.append(self.create_push_button("images/image_" + str(ii)))
            ii += 1
        input = QLineEdit()
        input.setPlaceholderText("Model")
        input.setFocus()
        input.setMaximumWidth(400)
        input.setFixedWidth(420)

        layout1.addWidget(label)
        layout1.addWidget(buttons[0])

        layout1.addWidget(buttons[1])
        layout1.addWidget(buttons[2])
        layout1.addWidget(buttons[3])
        layout1.addWidget(buttons[4])
        layout1.addWidget(buttons[5])
        layout1.addWidget(input)

        layout2 = QHBoxLayout()

        layout_fn = QVBoxLayout()
        layout_drag = QVBoxLayout()
        layout_image = QVBoxLayout()

        layout_fn.setSpacing(5)

        name_label = QLabel("Model")
        name_label.setStyleSheet("font-weight:bold")
        layout_fn.addWidget(name_label)
        layout_fn.setAlignment(Qt.AlignRight)
        feature_images = []
        for i in range(3):
            feature_images.append(self.create_qlabel_with_images("images/icon1.png"))

        layout_fn.addWidget(feature_images[0])
        layout_fn.addWidget(QLabel("Hose_Flow_Rate"))
        layout_fn.addWidget(feature_images[1])
        layout_fn.addWidget(QLabel("Input_Rate"))
        i1 = self.create_qlabel_with_images("images/icon2.png")
        layout_fn.addWidget(i1)
        layout_fn.addWidget(QLabel("Leakage_Fraction"))
        layout_fn.addWidget(feature_images[2])
        layout_fn.addWidget(QLabel("Tank_Capacity"))
        layout_fn.addStretch()

        calculate = QPushButton('Calculate')
        calculate.setStyleSheet("background-color : #2366a8;color: white")
        calculate.setMaximumWidth(100)
        calculate.setFixedWidth(120)

        layout_drag.addWidget(calculate)
        textEdit = DrawingPanel()

        # adding a property dynamically
        self.drawingBoard = textEdit
        textEdit = QGraphicsView(textEdit)
        rcontent = textEdit.contentsRect()
        textEdit.setSceneRect(0, 0, rcontent.width(), rcontent.height())

        layout_drag.addWidget(textEdit)
        # undo redo
        buttons[5].clicked.connect(self.redo)
        buttons[4].clicked.connect(self.undo)

        bold_name = QLabel("              Model")
        bold_name.setStyleSheet("font-weight:bold")
        layout_image.addWidget(bold_name)

        self.add_model_images("kiln", "images/kiln.png", "                Kiln", layout_image)
        self.add_model_images("kiln2", "images/kiln2", "                Kiln2", layout_image)

        layout_image.addStretch()

        layout2.addLayout(layout_fn)
        layout2.addLayout(layout_drag)
        layout2.addLayout(layout_image)

        layout.addLayout(layout1, 0, 0)
        layout.addLayout(layout2, 1, 0)

        widget = QWidget()
        widget.setLayout(layout)
        self.setCentralWidget(widget)

        self.show()
Пример #9
0
def default_api():
    """
    Gets the default api of a component
    :return:  A list of strings containing the API function names
    """
    return Component(Base.msg_key).exec_list.keys()
Пример #10
0
def get_component(g):
    c = Component(g)
    print 'components:'
    print c.ccount, c.id
    return c