本文整理汇总了Python中Rule.Rule.setName方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.setName方法的具体用法?Python Rule.setName怎么用?Python Rule.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule.Rule
的用法示例。
在下文中一共展示了Rule.setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RuleEditor
# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import setName [as 别名]
#.........这里部分代码省略.........
st = '\n'.join(file.readlines())
self.ruleSet.fromString(st)
if len(self.scene.items()) > 0:
for item in self.scene.items():
self.scene.removeItem(item)
self.currentElementFile = self.ruleSet.elementsFileName
self.fileName.setText(os.path.basename(self.currentElementFile))
self.loadElementsFile()
self.scene.setMode(ChainScene.MoveItem)
self.updateRuleList()
self.changeCurrentRule(0)
self.setWindowTitle("WordChain : Rule editor : " + self.currentRuleFile)
###########################################################################
def showWindow(self):
self.show()
self.updateRuleList()
def updateRuleList(self):
self.ruleListWidget.clear()
rowCount = 0
for rule in self.ruleSet.ruleList:
self.ruleListWidget.insertItem(rowCount, rule.name)
rowCount += 1
def newRule(self):
name, ok = QInputDialog.getText(None, "Create new rule", "Enter new rule name:")
if name is not None and ok:
self.rule = Rule()
self.rule.setName(name)
self.ruleSet.addRule(self.rule)
self.updateRuleList()
self.changeCurrentRule(len(self.ruleSet.ruleList) - 1)
self.ruleListWidget.setCurrentRow(len(self.ruleSet.ruleList) - 1)
def changeCurrentRule(self, idx):
self.rule.fromElementList(self.scene.items())
self.rule = self.ruleSet.getRule(idx)
self.loadRuleToScene()
def removeRule(self):
self.ruleSet.deleteRule(self.ruleListWidget.currentRow())
self.updateRuleList()
def loadRuleToScene(self):
self.scene.clear()
for ruleElem in self.rule.elements:
for el in self.elementSet.elementList:
if el.elementName == ruleElem['elementName']:
item = MetaElement(el.leftConnectorType,
el.rightConnectorType,
el.elementName,
el.color)
item.addProperties(el.properties)
self.scene.addItem(item)
item.setPos(QPoint(ruleElem['x'], ruleElem['y']))
for ruleConn in self.rule.connections:
el1 = self.scene.items()[ruleConn['p1']]
el2 = self.scene.items()[ruleConn['p2']]
name = ruleConn.get('name', '')
conn = self.scene.addConnection(el2, el1, name)
conn.p1Properties = ruleConn['p1Properties']
conn.p2Properties = ruleConn['p2Properties']
self.scene.addItem(conn)
###########################################################################
def chooseElementsFile(self):
ret = QFileDialog.getOpenFileName(filter='*.elms')
self.currentElementFile = ret[0]
self.ruleSet.setElementsFileName(self.currentElementFile)
self.fileName.setText(os.path.basename(self.currentElementFile))
###########################################################################
def loadElementsFile(self):
if self.currentElementFile is not None:
file = open(self.currentElementFile, 'r')
st = '\n'.join(file.readlines())
self.elementSet.fromString(st)
file.close()
self.layoutToolBox()
###########################################################################
def updateElementListView(self):
self.elemListWidget.clear()
for item in self.elementSet.elementList:
self.elemListWidget.addItem(item.elementName)
###########################################################################
def testRule(self):
self.rule.fromElementList(self.scene.items())
print(self.ruleSet.toString())