qfiledialog

Can't add extension to file in QFileDialog

给你一囗甜甜゛ 提交于 2020-07-21 11:23:05
问题 I've got a problem with saving file with extension (get path to file and append extension) in PyQt4 with QFileDialog. My Python code looks like that: dialog = QtGui.QFileDialog() dialog.setDefaultSuffix(".json") file = dialog.getSaveFileName(None, "Title", "", "JSON (.json)") It works, path is correct, dialog title and filter are in dialog window, but second line was ignored. File doesn't have any extension. How to add extension by default? What am I doing wrong? 回答1: Calling setDefaultSuffix

Can't add extension to file in QFileDialog

[亡魂溺海] 提交于 2020-07-21 11:20:46
问题 I've got a problem with saving file with extension (get path to file and append extension) in PyQt4 with QFileDialog. My Python code looks like that: dialog = QtGui.QFileDialog() dialog.setDefaultSuffix(".json") file = dialog.getSaveFileName(None, "Title", "", "JSON (.json)") It works, path is correct, dialog title and filter are in dialog window, but second line was ignored. File doesn't have any extension. How to add extension by default? What am I doing wrong? 回答1: Calling setDefaultSuffix

QFileDialog: Selecting directories and files

百般思念 提交于 2020-04-21 06:18:32
问题 I'm using the code below to build a qstringlist of filenames: QStringList filenames = QFileDialog::getOpenFileNames(this,"",QDir::currentPath() ); How can I change this so I can select directories as well? I looked at: dialog.setFileMode(QFileDialog::AnyFile); but I don't get how to use it with my code. 回答1: This code snippet linked in the comment above solves my issue. QFileDialog* _f_dlg = new QFileDialog(this); _f_dlg->setFileMode(QFileDialog::Directory); _f_dlg->setOption(QFileDialog:

QFileDialog: Selecting directories and files

断了今生、忘了曾经 提交于 2020-04-21 06:17:13
问题 I'm using the code below to build a qstringlist of filenames: QStringList filenames = QFileDialog::getOpenFileNames(this,"",QDir::currentPath() ); How can I change this so I can select directories as well? I looked at: dialog.setFileMode(QFileDialog::AnyFile); but I don't get how to use it with my code. 回答1: This code snippet linked in the comment above solves my issue. QFileDialog* _f_dlg = new QFileDialog(this); _f_dlg->setFileMode(QFileDialog::Directory); _f_dlg->setOption(QFileDialog:

Python PyQt Pyside - setNameFilters in QFileDialog does not work

寵の児 提交于 2020-01-23 02:46:10
问题 (Windows 7 64 Bit, PyCharm 3.4.1 Pro, Python 3.4.0, PySide 1.2.2) I want to make a file dialog with filters and preselect one filter. If i use the static method, it works, i can use filters and preselect one filter. dir = self.sourceDir filters = "Text files (*.txt);;Images (*.png *.xpm *.jpg)" selected_filter = "Images (*.png *.xpm *.jpg)" fileObj = QFileDialog.getOpenFileName(self, " File dialog ", dir, filters, selected_filter) If i use an object it does not work, my filters are not there.

PyQt5 QFileDialog finishes app when called from child window

你说的曾经没有我的故事 提交于 2020-01-16 07:42:47
问题 I have a bit complex structure of my application. First_Main_Window(QtWidgets.QMainWindow) calls ---> Second_Main_Window(QtWidgets.QMainWindow) calls ---> Third_Window = slides_form (QtWidgets.QDialog) It means in First Window I have list of workers, in second window - data of some worker (Phone, address) in third window - standard stages of work (i.e. photos) the worker does.. The 'First_Main_Window' opens Second_Main_Window , using this function: def OpenWindowCurrentWorker(self): self

Saving text from QPlainTextEdit by QFileDialog and creating .txt file

纵然是瞬间 提交于 2020-01-06 05:30:14
问题 I have troubles with saving note(text from QPlainTextEdit). I need only saving in txt format. After typing text and clicking button program displays error 'expected string or bytes-like object not nonetype'.Notepad's program starts from class fileeki till class fileush. I use Python 3.7, PyQt5 and QtDesigner for creating interface.Opening works well, but not saving.Please download all elements of my project. Also there is modules, which you must install.Thanks for trying. import sys from

QFileDialog::getExistingDirectory does not close after choosing a folder

别等时光非礼了梦想. 提交于 2020-01-04 06:06:13
问题 In Qt, QFileDialog *dlg = new QFileDialog(); QDir dir = dlg->getExistingDirectory(this, tr("Choose folder"), qgetenv("HOME")); opens a folder choose dialog. Once I select a folder (press choose button) the folder is not closing automatically. So I tried: if(dlg->close() == true) delete(dlg); When I debug the dlg->close() returns true and the code delete(dlg) is hit. Still the Folder chooser dialog box is not closing. I am using Ubuntu 11.10 64 bit OS. Using Qt libraries from the repository.

'selectedFilters' is not a valid keyword argument

做~自己de王妃 提交于 2020-01-01 19:01:37
问题 I use PyQt5 and I have an error when I try to save the file name : csv_file_list = QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', '', '*.csv') fileName = csv_file_list fileName = QtWidgets.QFileDialog.getSaveFileName(self, 'Dialog Title', '/path/to/default/directory', selectedFilters='*.txt') if fileName: print (fileName) And it display me this error : 'selectedFilters' is not a valid keyword argument. I don't know if the error is here because of PyQt5 or not 回答1: For various

How to use QFileDialog options and retrieve saveFileName?

喜你入骨 提交于 2019-12-31 22:37:28
问题 I'm trying to use a QFileDialog to prompt a user to provide a filename and location to save a text file at. I played around with the QtGui.QFileDialog.getSaveFileName, but I was interested in using some of the options, like setting the default suffix, and enabling the Detail view of the save file dialog, which, from what I could tell, isn't possible to do, using the getSaveFileName alone. Whenever I set those, the getSaveFileName dialog just ignored them. So, I ended up with something like