Module albow.dialog.FileSaveDialog

Source code
import os

from albow.dialog.DialogUtilities import ask
from albow.dialog.FileDialog import FileDialog


class FileSaveDialog(FileDialog):

    saving         = True
    default_prompt = "Save as:"
    ok_label       = "Save"

    def get_filename(self):
        return self.filename_box.value

    def set_filename(self, x):
        dsuf = self.suffixes[0]
        if x.endswith(dsuf):
            x = x[:-len(dsuf)]
        self.filename_box.value = x

    filename = property(get_filename, set_filename)

    def get_pathname(self):
        path = os.path.join(self.directory, self.filename_box.value)
        suffixes = self.suffixes
        if suffixes and not path.endswith(suffixes[0]):
            path = path + suffixes[0]
        return path

    pathname = property(get_pathname)

    def double_click_file(self, name):
        self.filename_box.value = name

    def ok(self):
        path = self.pathname
        if os.path.exists(path):
            answer = ask("Replace existing '%s'?" % os.path.basename(path))
            #
            # Python 3 update
            # if answer <> "OK":
            if answer != "OK":
                return
        FileDialog.ok(self)

    def update(self):
        FileDialog.update(self)

    def ok_enable(self):

        #
        # Python 3 update
        #
        # return self.filename_box.text <> ""
        return self.filename_box.text != ""

Classes

class FileSaveDialog (prompt=None, suffixes=None, **kwds)

The Dialog class provides a convenient container for implementing modal dialogs. Pressing Return or Enter dismisses the dialog with the value True, and pressing Escape dismisses it with the value False.

See the albow.core.ui.Widget dismiss() and present() methods

Args

client
The widget the dialog is on top of
responses
A list of responses
default
The index to the default response; Default is the first
cancel
The index to the cancel response; Default is None

**kwds:

Source code
class FileSaveDialog(FileDialog):

    saving         = True
    default_prompt = "Save as:"
    ok_label       = "Save"

    def get_filename(self):
        return self.filename_box.value

    def set_filename(self, x):
        dsuf = self.suffixes[0]
        if x.endswith(dsuf):
            x = x[:-len(dsuf)]
        self.filename_box.value = x

    filename = property(get_filename, set_filename)

    def get_pathname(self):
        path = os.path.join(self.directory, self.filename_box.value)
        suffixes = self.suffixes
        if suffixes and not path.endswith(suffixes[0]):
            path = path + suffixes[0]
        return path

    pathname = property(get_pathname)

    def double_click_file(self, name):
        self.filename_box.value = name

    def ok(self):
        path = self.pathname
        if os.path.exists(path):
            answer = ask("Replace existing '%s'?" % os.path.basename(path))
            #
            # Python 3 update
            # if answer <> "OK":
            if answer != "OK":
                return
        FileDialog.ok(self)

    def update(self):
        FileDialog.update(self)

    def ok_enable(self):

        #
        # Python 3 update
        #
        # return self.filename_box.text <> ""
        return self.filename_box.text != ""

Ancestors

Class variables

var default_prompt
var ok_label
var saving

Instance variables

var filename
Source code
def get_filename(self):
    return self.filename_box.value
var pathname
Source code
def get_pathname(self):
    path = os.path.join(self.directory, self.filename_box.value)
    suffixes = self.suffixes
    if suffixes and not path.endswith(suffixes[0]):
        path = path + suffixes[0]
    return path

Methods

def double_click_file(self, name)
Source code
def double_click_file(self, name):
    self.filename_box.value = name
def get_filename(self)
Source code
def get_filename(self):
    return self.filename_box.value
def get_pathname(self)
Source code
def get_pathname(self):
    path = os.path.join(self.directory, self.filename_box.value)
    suffixes = self.suffixes
    if suffixes and not path.endswith(suffixes[0]):
        path = path + suffixes[0]
    return path
def ok(self)
Source code
def ok(self):
    path = self.pathname
    if os.path.exists(path):
        answer = ask("Replace existing '%s'?" % os.path.basename(path))
        #
        # Python 3 update
        # if answer <> "OK":
        if answer != "OK":
            return
    FileDialog.ok(self)
def ok_enable(self)
Source code
def ok_enable(self):

    #
    # Python 3 update
    #
    # return self.filename_box.text <> ""
    return self.filename_box.text != ""
def set_filename(self, x)
Source code
def set_filename(self, x):
    dsuf = self.suffixes[0]
    if x.endswith(dsuf):
        x = x[:-len(dsuf)]
    self.filename_box.value = x
def update(self)
Source code
def update(self):
    FileDialog.update(self)

Inherited members