Code: Alles auswählen
"puselmuckelside": {
"Artist": {
"Attri": "",
"Single": 0,
"XPath": "//div[@class='vdoCast']/a[contains(@href,'/model')]"
},
"Beschreibung": {
"Attri": "",
"Clicks": 0,
"XPath": "//div[@class='vdoDesc']"
},
"Film": "",
"NebenSide": {
"Clicks": 0,
"XPath": "//div[@class='vdoCast']/a[1]"
},
"NummerID": {
"XPath": "//div[@class='thumbsHolder elipsTxt']/div/div[@class='echThumb']/a[contains(@id,'videos')]"
},
}
in der json hab ich ca. 40 puselpuckelsides
hier die Tabelle:
Code: Alles auswählen
def LoadJSON(self):
with open(Path(__file__).absolute().parent / "JSON/websides.json",'r') as file:
websides = json.loads(file.read())
side=self.lblWebside.text()
try:
web=websides[side]
for zeile,item in enumerate(web):
try:
xpath=web[item]
self.tblWdg_WebSides.setItem(zeile,0,QtWidgets.QTableWidgetItem(xpath['XPath']))
zustand=xpath.get("Attri")
if zustand is not None:
zustand=xpath["Attri"]
print(f"Attri: {zustand} bei {xpath}")
self.tblWdg_WebSides.setItem(zeile,1,QtWidgets.QTableWidgetItem(zustand))
zustand=xpath.get("Single")
if zustand is not None:
zustand=xpath["Single"]
if zustand==0:
zustand=True
else: zustand=False
print(f"Single: {zustand} bei {xpath}")
self.tblWdg_WebSides.setCellWidget(zeile,2,self.TrueFalse(zustand))
zustand=xpath.get("Art")
if zustand is not None:
zustand=xpath["Art"]
print(f"Art: {zustand} bei {xpath}")
self.tblWdg_WebSides.setItem(zeile,3,QtWidgets.QTableWidgetItem(xpath[zustand]))
zustand=xpath.get("Gross")
if zustand is not None:
zustand=xpath["Gross"]
if zustand==0:
zustand=True
else: zustand=False
print(f"Gross: {zustand} bei {xpath}")
self.tblWdg_WebSides.setCellWidget(zeile,4,self.TrueFalse(zustand))
zustand=xpath.get("Click")
if zustand is not None:
zustand=xpath["Click"]
if zustand==0:
zustand=True
else: zustand=False
print(f"Click: {zustand} bei {xpath}")
self.tblWdg_WebSides.setCellWidget(zeile,5,self.TrueFalse(zustand))
zustand=xpath.get("Skip")
if zustand is not None:
zustand=xpath["Skip"]
if zustand==0:
zustand=True
else: zustand=False
print(f"Skip: {zustand} bei {xpath}")
self.tblWdg_WebSides.setCellWidget(zeile,6,self.TrueFalse(zustand))
except TypeError:
self.tblWdg_WebSides.setItem(zeile,0,QtWidgets.QTableWidgetItem(web[item]))
except KeyError:
with open(Path(__file__).absolute().parent / "JSON/Arten.json",'r') as file:
Arten = json.loads(file.read())
self.tblWdg_WebSides.setRowCount(len(Arten["Arten"]))
self.tblWdg_WebSides.setVerticalHeaderLabels(Arten["Arten"])
self.tblWdg_WebSides.resizeColumnsToContents()
def TrueFalse(self,zustand):
selectItem = QtWidgets.QComboBox()
selectItem.addItems(['True', 'False'])
selectItem.setCurrentText(zustand)
return selectItem
das mit selectItem habe ich von :https://www.programcreek.com/python/exa ... ableWidget
ich denke er hat ein Problem mit "self.tblWdg_WebSides.setCellWidget(zeile,6,self.TrueFalse(zustand))"
dann bekommt er ein TypeError und macht garnichts mehr, sprich keine Daten in der Tabelle.
auf programmcreek machen die das doch auch so:
Code: Alles auswählen
for i in range(length):
imageItem = QTableWidgetItem(self.DataSetsHist[i])
selectItem = QtWidgets.QComboBox()
selectItem.addItems(['Training', 'Validation', 'Test'])
self.table.setItem(i, 0, imageItem)
self.table.setCellWidget(i, 1, selectItem)
Edit:
selectItem.setCurrentIndex(zustand)
und dieses
Code: Alles auswählen
if zustand==0:
zustand=True
else: zustand=False
weggelassen
kommt schon mal ein dropdown
nur irgendwann keine daten mehr in der tabelle