Home arrow Python arrow Page 4 - Dialogs in wxPython

ImageDialog - 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

The ImageDialog is a very nice dialog. It displays the images in a given directory. It's very simple to use:

from wxPython.wx import *

# Import the required module

from wxPython.lib import imagebrowser

application = wxPySimpleApp()

# Create the dialog

dialog = imagebrowser.ImageDialog ( None )

# Show the dialog

dialog.ShowModal()

# Destroy the dialog

dialog.Destroy()

Of course, we'll need to retrieve the file name of the image that the user specifies. This is easily done:

from wxPython.wx import *

from wxPython.lib import imagebrowser

application = wxPySimpleApp()

dialog = imagebrowser.ImageDialog ( None )

# Display the file name if the user selected one

if dialog.ShowModal() == wxID_OK:

   print 'You picked:', dialog.GetFile()

# Otherwise, yell and scream at the user for cancelling

else:

   print 'You did not select an image!'

dialog.Destroy()

If we need to set a directory other than the current directory, it's possible to do so by passing a second argument:

from wxPython.wx import *

from wxPython.lib import imagebrowser

application = wxPySimpleApp()

# Specify a directory

dialog = imagebrowser.ImageDialog ( None, 'C:\' )

if dialog.ShowModal() == wxID_OK:

   print 'You picked:', dialog.GetFile()

else:

   print 'You did not select an image!'

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: