![]() Once we know the file path is not empty, we place it on the inputFileLineEdit: def onInputFileButtonClicked (self):įilename, filter = (parent=self, caption= 'Open file', dir= '.', filter= 'Kicad PCB Files (*.kicad_pcb)') We have to check this in order to discard that input. If the user cancels the dialog, it will return an empty string. Once the dialog is closed, the function will return the file path of the selected file, as well as the filter corresponding to that file. Now, we can create a dialog inside the callback, to be presented to the user when the inputFileButton is pressed: def onInputFileButtonClicked (self):įilename, filter = (parent=self, caption= 'Open file', dir= '.', filter= '*.kicad_pcb')Īs arguments, we pass the parent widget (the window), the caption that will appear on the dialog title bar, the current directory and a filter that restricts the supported files to be *.kicad_pcb files. Then, we connect it to the clicked button event: (self.onInputFileButtonClicked) ![]() The first step is to create a callback function: def onInputFileButtonClicked (self): pass When the button next to the input file lineEdit is pressed, we want the program to show a file selection dialog for the user to select the input file. In this chapter we will learn how to use default dialogs to allow the user to select the input and output files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |