0

Good afternoon! I have a button, when clicked, QFileDialog opens. I select the file. The path is written in the LineEdit and variables. But the variable does not change the value

path = None
def get_file_dbf():
    if ui.file_dialog.exec_():
        file_name = ui.file_dialog.selectedFiles()
        ui.lineEdit.setText(file_name[0])
        path = str(file_name[0])

ui.toolButton.clicked.connect(get_file_dbf)

def go_transfer():
    print(path) #None

ui.pushButton.clicked.connect(go_transfer)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
duddeniska
  • 153
  • 3
  • add `global path` before `path = str(file_name[0])` – eyllanesc May 05 '20 at 18:52
  • I define a variable at the very beginning path = None @eyllanesc – duddeniska May 05 '20 at 18:55
  • I recommend you review the concept of "scope" of python, I will not elaborate further because I consider that the answers to the duplicate question clearly explain that concept. Also see https://docs.python.org/3/reference/executionmodel.html#resolution-of-names – eyllanesc May 05 '20 at 18:57

0 Answers0