I've recently updated to the new version of Qt5 for Python. In doing so, I've been having to alter my code in accordance to some of the notable changes that have occurred. I wanted to get some insight into this line of code that I've created. It feels like a dirty way of solving the problem of getting a string
instead of a tuple
from the function. (Note the [0]
at the end of the line)
filename = QtWidgets.QFileDialog.getOpenFileName(None, "Open " + key + " Data File", '.', "(*.csv)")[0]
I want filename = {str}'C:/.././.../format.csv'
not filename = <class 'tuple'>: ('C:/.././.../format.csv', '(*.csv)')
After looking through a repository that was being updated to Qt5 as well; I found they used a line like this.
filename, _filter = QtWidgets.QFileDialog.getOpenFileName(None, "Open " + key + " Data File", '.', "(*.csv)")
filename
is a string and the (*.csv) gets discarded in the _filter
variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With