messages.py :  » Network » FtpCube » ftpcube-0.5.1 » libftpcube » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Network » FtpCube 
FtpCube » ftpcube 0.5.1 » libftpcube » messages.py
"""
FtpCube
Copyright (C) Michael Gilfix

This file is part of FtpCube.

You should have received a file COPYING containing license terms
along with this program; if not, write to Michael Gilfix
(mgilfix@eecs.tufts.edu) for a copy.

This version of FtpCube is open source; you can redistribute it and/or
modify it under the terms listed in the file COPYING.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""

import wx

import utils

class MessageDialog(wx.MessageDialog):
    """Message dialog wrapper class."""
    pass

class InputBox(wx.TextEntryDialog):
    """Text input box wrapper class."""
    pass

class FileDialog(wx.FileDialog):
    """File choosing dialog wrapper class."""
    pass

class DirDialog(wx.DirDialog):
    """Directory browsing dialog wrapper class."""
    pass

def displayErrorDialog(frame, msg):
    """Displays an error message to the end user.

    The specified message is the error text displayed. The frame serves as
    the parent frame for this error dialog."""
    dialog = MessageDialog(frame, str(msg), _("Ftpcube Error"), style=wx.OK | wx.ICON_ERROR)
    dialog.SetIcon(utils.getAppIcon())
    dialog.ShowModal()
    dialog.Destroy()

def displayMessageDialog(frame, title, msg, style):
    """Displays a message to the user.

    The specified message is the error text displayed. The frame serves as
    the parent frame for the message dialog. The title sets the dialog window
    title and the style corresponds to the wxPython style for the window."""
    dialog = MessageDialog(frame, str(msg), title, style)
    dialog.SetIcon(utils.getAppIcon())
    ret = dialog.ShowModal()
    dialog.Destroy()
    return ret

def displayInputDialog(frame, title, msg):
    """Displays a text input box to the end user.

    Displays a text input box using the specified frame as the parent frame.
    The title and message are used to decorate the box. If the user responds
    by clicking the OK button, then the contents of the box are returned.
    Otherwise, the None value is returned."""
    input_box = InputBox(frame, str(msg), title)
    input_box.SetIcon(utils.getAppIcon())
    ret = input_box.ShowModal()
    if ret == wx.ID_OK:
        return input_box.GetValue()
    else:
        return None

def displayFileDialog(frame, title, style=None):
    """Displays a file choosing dialog.

    Displays a file choosing dialog using the specified frame as the parent
    frame. The specified title is set on the dialog window. If the user
    responds by clicking on the OK button for the dialog, then the corresponding
    file path is returned. Otherwise, the None value is returned."""
    if style is None:
        style = wx.FILE_MUST_EXIST
    dialog = FileDialog(frame, title, utils.getStartPath(), '', style=style)
    dialog.SetIcon(utils.getAppIcon())
    ret = dialog.ShowModal()
    if ret == wx.ID_OK:
        return dialog.GetPath()
    else:
        return None

def displayDirDialog(frame, title):
    """Displays a directory browsing dialog.

    Displays a directory browsing dialog using the specified frame as the parent
    frame. The specified title is set on the dialog window. If the user responds
    by clicking on the OK button for the dialog, then the corresponding
    directory path is returned. Otherwise, the None value is returned."""
    dialog = DirDialog(frame, title, utils.getStartPath())
    dialog.SetIcon(utils.getAppIcon())
    ret = dialog.ShowModal()
    if ret == wx.ID_OK:
        return dialog.GetPath()
    else:
        return None
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.