Home arrow Python arrow Page 5 - Dialogs in wxPython

wxDirDialog - Python

You are probably already familiar with a few dialogs that can be used in your wxPython applications. Of course, wxPython contains many more dialogs, ranging in complexity from very simple to pretty advanced and covering a variety of topics, from text selection to color selection. In this article, we'll take a look at more of wxPython's dialogs what they are for and how they are placed in an application.

TABLE OF CONTENTS:
  1. Dialogs in wxPython
  2. wxScrolledMessageDialog
  3. wxProgressDialog
  4. ImageDialog
  5. wxDirDialog
  6. wxFileDialog
By: Peyton McCullough
Rating: starstarstarstarstar / 18
August 01, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

If your application requires the user to select a directory for something, consider using wxDirDialog. It allows the user to pick a directory from a tree:

from wxPython.wx import *

application = wxPySimpleApp()

# Create the dialog

dialog = wxDirDialog ( None, message = 'Pick a directory.' )

# Show the dialog and get user input

if dialog.ShowModal() == wxID_OK:

   print 'Directory:', dialog.GetPath()

# The user cancelled

else:

   print 'No directory.'

# Get rid of the dialog

dialog.Destroy()

It is also possible to allow the user to create a new directory from within the dialog by passing the wxDD_NEW_DIR_BUTTON style:

from wxPython.wx import *

application = wxPySimpleApp()

dialog = wxDirDialog ( None, message = 'Pick a directory.', style = wxDD_NEW_DIR_BUTTON )

if dialog.ShowModal() == wxID_OK:

   print 'Directory:', dialog.GetPath()

else:

   print 'No directory.'

dialog.Destroy()



 
 
>>> More Python Articles          >>> More By Peyton McCullough
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: