本文整理汇总了Python中PyQt5.Qt.QTextEdit.document方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.document方法的具体用法?Python QTextEdit.document怎么用?Python QTextEdit.document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTextEdit
的用法示例。
在下文中一共展示了QTextEdit.document方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExportToSqlite
# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import document [as 别名]
#.........这里部分代码省略.........
result = self.database.select("*","gm_perso",True,'name=="'+heros+'" AND ID_groupe=='+str(id_groupe))
self.nb_heros_inserted[1] = self.nb_heros_inserted[1] + 1
else:
self.nb_heros_unchanged[1] = self.nb_heros_unchanged[1] + 1
return result
@staticmethod
def hasSubGroup (path):
sub_list = os.listdir (path)
print ('hasSubGroup',sub_list)
if len(sub_list)!= 0 and os.path.isdir(os.path.join(path,sub_list[0])):
sub_list2 = os.listdir(os.path.join(path,sub_list[0]))
print ('sub_list_2',sub_list2)
if os.path.isdir(os.path.join(path,sub_list[0],sub_list2[0])):
print ('return true')
return True
return False
def process (self, faction,empire,kingdom):
super(ExportToSqlite,self).process(faction,empire,kingdom)
self.progress.setLabelText("Export to sqlite")
self.progress.setMinimum(0)
self.progress.setMaximum(self.total_heros)
self.success = False
nb_heros = 0
#si la faction n existe pas encore la creer
result = self.addFaction (self.faction)
result.next()
print ('result',result.value("name"))
id_faction = result.value("ID")
print ('ID faction',id_faction)
#si l empire n existe pas encore le creer
color = ""
empire = self.empire
if len(self.empire.split["-"])>=2 :
color = self.empire.split["-"][1]
empire = self.empire.split["-"][0]
result = self.addEmpire(empire,id_faction,color)
result.next()
id_empire= result.value("ID")
print ('ID empire',id_empire)
#si le royaume n existe pas encore le creer
result = self.addKingdom(self.kingdom,id_empire)
result.next()
id_kingdom= result.value("ID")
print ('ID kingdom',id_kingdom)
list_group = list(filter(SqliteModel.isValid,os.listdir (self.fullPath)))
for group in list_group :
result = self.addGroupe(group,id_kingdom)
result.next()
id_groupe= result.value("ID")
currentPath = os.path.join(self.fullPath,group)
if (ExportToSqlite.hasSubGroup(currentPath)):
list_sub_group = list(filter(SqliteModel.isValid,os.listdir(currentPath)))
id_master_group = id_groupe
for sub in list_sub_group :
result = self.addGroupe(sub, id_kingdom, id_master_group)
result.next()
id_groupe= result.value("ID")
list_heros = list(filter(SqliteModel.isValid,os.listdir(os.path.join(currentPath,sub))))
for heros in list_heros :
self.createDescriptionFile(heros,os.path.join(currentPath,sub,heros))
self.addHeros(heros,id_groupe)
nb_heros+=1
self.progress.setValue(nb_heros)
else:
list_heros = list(filter(SqliteModel.isValid,os.listdir(currentPath)))
for heros in list_heros :
self.createDescriptionFile(heros,os.path.join(currentPath,heros))
self.success = True
self.addHeros(heros,id_groupe)
nb_heros+=1
self.progress.setValue(nb_heros)
if self.stop == True :
break
self.progress.setValue(self.total_heros)
result_info = [self.nb_faction_inserted,self.nb_empire_inserted,self.nb_kingdom_inserted,self.nb_groupes_inserted,self.nb_heros_inserted,self.nb_faction_unchanged,self.nb_empire_unchanged,self.nb_kingdom_unchanged,self.nb_groupes_unchanged,self.nb_heros_unchanged]
self.showResultInfos(result_info)
def createDescriptionFile(self, name, path_file):
file_name = "description.html"
file = open(os.path.join(Config().instance.settings.value("global/resources_path"),"template_profil.html"))
ddd = file.read()
print ('ooooo',type(ddd))
ddd = ddd.replace("tname",name)
print ('mmmm',ddd)
chemin = os.path.join(path_file,file_name)
if (not os.path.exists(chemin)):
self.textEdit = QTextEdit()
self.textEdit.setText(ddd)
writer = QTextDocumentWriter(chemin)
success = writer.write(self.textEdit.document())