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.Widgetdismiss()andpresent()methodsArgs- 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 codeclass 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 != ""AncestorsClass variables- var default_prompt
- var ok_label
- var saving
 Instance variables- var filename
- 
Source codedef get_filename(self): return self.filename_box.value
- var pathname
- 
Source codedef 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 codedef double_click_file(self, name): self.filename_box.value = name
- def get_filename(self)
- 
Source codedef get_filename(self): return self.filename_box.value
- def get_pathname(self)
- 
Source codedef 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 codedef 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 codedef ok_enable(self): # # Python 3 update # # return self.filename_box.text <> "" return self.filename_box.text != ""
- def set_filename(self, x)
- 
Source codedef 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 codedef update(self): FileDialog.update(self)
 Inherited members- FileDialog:- add
- add_anchor
- add_centered
- anchor
- attention_lost
- augment_mouse_event
- bg_color
- bg_image
- border_color
- border_width
- call_handler
- call_parent_handler
- cancel_response
- click_outside_response
- defer_drawing
- dismiss
- draw
- draw_over
- enter_response
- fg_color
- focus
- focus_switch
- font
- get_cursor
- get_focus
- get_margin_rect
- get_root
- get_top_widget
- get_visible
- global_to_local
- has_focus
- inherited
- invalidate
- is_gl_container
- key_down
- key_up
- local_to_global
- margin
- menu_bar
- parent
- parent_resized
- present
- rect
- relative_mode
- remove
- remove_anchor
- resized
- scale_bg
- sel_color
- set_parent
- set_size_for_text
- tab_stop
- up_button_text
- visible