私は、ちょうどので、私はいくつかのことをテストすることができ、私のQtableWidgetからのデータの行を選択し、自分のコンソールにそれらをプリントアウトしようとしているはQTableWidgetからのデータの行全体を選択することはできません
問題文データをプロットすることができます。しかし、私は決してデータの行全体をつかむことはできません。
背景
私は、具体的形式のCSVファイルをインポートすることによって、いくつかのQTableWidgetsを埋め込むことができるGUIを行いました。目標は、同じまたは異なるテーブルから複数の行からデータを取得し、それらを並行してプロットできるようにすることです。データの各行はそれ自身のデータセットであり、それ自身のプロットを持ちますが、同じ図に複数のプロットがあります。
このタスクを完了するには、「Compare」というQpushbuttonが押されたときに開くCompareWindowというウィンドウを作成しました。ウィンドウには、プロットするテーブルの名前とそのテーブルの各行を入力するように求められます。
この情報が送信された後、インスタンス化されたすべてのQTableObjectを保存した参照できる辞書があります。ここで、キーは、対応するテーブルオブジェクトに接続されているテーブルに与えられた名前です。
私は行データをつかむしようとした2つの主な方法がある問題
...
最初のアイデアは私が望んでいた行を反復でしょうTableObject.selectRow()コマンドを使用していたが、私がこれをしたときはいつでも、非型を返すでしょう。
私が試みた2番目の方法は、項目値を追加してリストを1つずつ埋め込むように、特定の行の列を反復することでした。しかし、私がこれをしたときには、Qtableの最初のセルだった同じ番号のリストが繰り返し埋められました。
明示的に特定の行または列を呼び出した場合でも、同じ出力が得られます。プルされる出力は、CSVファイルの最初のセルからの数値である.12です。
ここに問題のコードがあります。問題があります。 https://github.com/Silvuurleaf/Data-Visualize-Project
問題は方法initiateMultiPlotの私のファイルPerspective.pyで発生します。
def initiateMultiPlot(self, tableV, rowV, PlotV):
"""
1. Match TableName values with the key values in our TableDB
2. When we find a match look at that key's corresponding Table Object, and iterate
through that objects rows and select the rows specified by rowV
3.Call plot for those values
"""
#calls my class and creates a blank figure where eventually we will plot data on
f = CreateFigure.FigureAssembly()
print("")
for i in tableV:
"""
tableV: is list of strings that represent assigned tablenames [Table1, Table2, Table3]
rowV: is a list, containing lists representing rows from corresponding Tables the user wishes to plot.
for example [[1,2],[3,4],[1]] means rows 1,2 from table1, rows 3,4 from table2... so on
PlotV: is a string that is ethier "box" or "whisker" to tell what method to plot. Default right now
is to do a simple boxplot
"""
print("Creating table instance")
#Table Dictionary is setup so the names of the Tables (tableV) are the keys of the dictionary
#and the actual table objects are referenced by these keys
self.TableOBJ = self.TableDictionary[i]
print("Data Type for the table object is..................{}".format(type(self.TableOBJ)))
#empty list that will store our row data
self.Elements = []
try:
for rows in rowV:
for i in rows:
print("rowV value is... {}".format(rowV))
print("current row list{}".format(rows))
print("i value is {}".format(i))
print("itterating")
for j in range(self.TableOBJ.columnCount()):
print("i value is ...{}".format(i))
print("j value is .... {}".format(j))
#FIRST idea try selecting entire row of data
print("i value is ...{}".format(i))
print("j value is .... {}".format(j))
#entire row returns none-type
EntireRow = self.TableOBJ.selectRow(i)
print(EntireRow)
#selecteditems
#SECOND idea try using for loop and iterating through every value in a row
item = self.TableOBJ.itemAt(i,j)
#explicit call for (row 1, col 1) and (row 3, col 3), both which output .12
print(self.TableOBJ.itemAt(1,1).text())
print(self.TableOBJ.itemAt(3,3).text())
print("printing item...... {}".format(item))
element = item.text()
print(element)
#list of .12
self.Elements.append(element)
#elements = [self.TableOBJ.item(i, j).text() for j in range(self.TableOBJ.columnCount()) if
# self.TableOBJ.item(i, j).text() != ""]
#print(elements)
except Exception as e:
print(e)
print(self.Elements)
は、ここに私のすべてのファイルを含む私のGitHubのリンクです。 CompareWindow.pyファイルは私のPerspective.pyにシグナルを送り、initateMultiPlotに接続します。詳細な説明が必要な場合はお問い合わせください。 documentationによれば
ああ私はあなたに感謝していない!私は –