Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22874

IslandT: wxPython Tutorial — Create File Dialog Box

$
0
0

In this example tutorial of wxPython I am going to create a file dialog box on the previously created wxPython program. This dialog box will get created every time the user has clicked on the button thus the CreateFileDialog function will be put under the same ‘OnButton’ function as the CreateDialogBox function as follows:-

def OnButton(self, event):
   self.CreateDialogBox()
   self.CreateFileDialog()

Below is the function which will create and show the file dialog box after the user has clicked on the button.

def CreateFileDialog(self):
  self.fileDialog = wx.FileDialog(parent = self.the_frame, message="Select a file",
       defaultDir="", defaultFile="",
       wildcard="", name="Select file")
  self.fileDialog.ShowModal() # show file dialog

According to the official page of this widget, these are the parameters of that widget but I am not using each one of them.

Parameters
parent (wx.Window) – Parent window.

message (string) – Message to show on the dialog.

defaultDir (string) – The default directory, or the empty string.

defaultFile (string) – The default filename, or the empty string.

wildcard (string) – A wildcard, such as “x.x” or “BMP files (.bmp)|.bmp|GIF files (.gif)|.gif”. Note that the native Motif dialog has some limitations with respect to wildcards; see the Remarks section above.

style (long) – A dialog style. See FD_* styles for more info.

pos (wx.Point) – Dialog position. Not implemented.

size (wx.Size) – Dialog size. Not implemented.

name (string) – Dialog name. Not implemented.

The outcome is as follows:-

This is the last article about wxPython, there are still lots of widgets that I have not yet covered in my post and you can find all of them on the official page of wxPython. After using this module I think I really like it thus I will always recommend you to use either Tkinter or wxPython if you want to write a python application that contains the user interface!


Viewing all articles
Browse latest Browse all 22874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>