Last change
on this file was 100, checked in by ruud, 19 months ago |
python installs also wheel to avoid error messages
|
File size:
952 bytes
|
Rev | Line | |
---|
[100] | 1 | from PyQt5.QtWidgets import QWidgetAction, QTextEdit, QPushButton, QGridLayout, \
|
---|
| 2 | QFileDialog, QWidget, QLineEdit
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | class MyFileChooser (QWidget):
|
---|
| 6 | '''
|
---|
| 7 | one-line panel with on left the chosen file and on the right a "Browse"
|
---|
| 8 | button. If you click browse button you can browse for a file. You can also
|
---|
| 9 | just type the file location.
|
---|
| 10 | '''
|
---|
| 11 |
|
---|
| 12 | def __init__(self):
|
---|
| 13 | super().__init__()
|
---|
| 14 | self.filenamearea = QLineEdit()
|
---|
| 15 | self.filenamearea.setText("select a file")
|
---|
| 16 | self.browsebutton = QPushButton()
|
---|
| 17 | self.browsebutton.setText("Browse")
|
---|
| 18 |
|
---|
| 19 | layout = QGridLayout()
|
---|
| 20 | self.setLayout(layout)
|
---|
| 21 |
|
---|
| 22 | layout.addWidget(self.filenamearea, 0, 0)
|
---|
| 23 | layout.addWidget(self.browsebutton, 0, 1)
|
---|
| 24 | self.browsebutton.clicked.connect(self.browseclick)
|
---|
| 25 |
|
---|
| 26 | def browseclick(self):
|
---|
| 27 | fc = QFileDialog()
|
---|
| 28 | if fc.exec_() > 0: # ? what does this function return?
|
---|
| 29 | self.filenamearea.setText(fc.selectedFiles()[0])
|
---|
| 30 |
|
---|
| 31 | def getFile(self) -> str:
|
---|
| 32 | return self.filenamearea.text();
|
---|
Note:
See
TracBrowser
for help on using the repository browser.