私はGUIには新しく、変数の継承に関する簡単な質問があります。Python QtGui:クラス間での変数の継承
私のGUIには2つのボタンがあり、1つはxlsxファイルを選択し、もう1つはグラフを表示します。 ...
(私はグラフのコードのビットに追加しました)class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
vBoxLayout = QtGui.QVBoxLayout(self)
file_btn = QtGui.QPushButton('Select File', self)
file_btn.clicked.connect(self.get_graph_file)
graphing_btn = QtGui.QPushButton('Plot Graph', self)
graphing_btn.clicked.connect(Plotting_Graph)
self.show()
def get_graph_file(self):
fname_graphfile = QtGui.QFileDialog.getOpenFileName(self, 'Open file', '/Users/.../', 'excel files (*.xlsx)')
...第二はfname_graphfile
を継承し、それをグラフ化する必要があります最初のclass
は、下のボタンを設定し、ファイルを選択し、
class Plotting_Graph(Example):
def __init__(self):
self.PlottingGraph()
def PlottingGraph(self):
xl = ef(fname_graphfile[0])......
実行すると、エラーglobal name 'fname_graphfile' is not defined
が返されます。
class
で定義したものを覚えておくには、どのように2番目のclass
を取得しますか?