home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 116
/
FreelogNo116-JuilletSeptembre2013.iso
/
Bureautique
/
gImageReader
/
gimagereader_0.9-1_win32.exe
/
bin
/
gimagereader
/
dialogs.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2011-03-24
|
5KB
|
135 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
import webbrowser
import gtk
import os
import gettext
_ = gettext.gettext
def question_dialog(primaryText, secondaryText = None, parent = None):
''' Displays a yes/no question dialog.
\t\t\tprimaryText (str): the primary text, bold
\t\t\tsecondaryText=None (str): the secondary text
\t\t\tparent=None (gtk.Window): the parent window
\t'''
dialog = gtk.MessageDialog(parent, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, message_format = primaryText)
dialog.format_secondary_text(secondaryText)
dialog.set_default_response(gtk.RESPONSE_YES)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_NO:
return 0
if None == gtk.RESPONSE_YES:
return 1
return None
def error_dialog(primaryText, secondaryText = None, parent = None):
''' Displays an error dialog.
\t\t\tprimaryText (str): the primary text, bold
\t\t\tsecondaryText=None (str): the secondary text
\t\t\tparent=None (gtk.Window): the parent window
\t'''
dialog = gtk.MessageDialog(parent, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message_format = primaryText)
dialog.format_secondary_text(secondaryText)
dialog.run()
dialog.destroy()
def save_text(curdir, filename, parent = None):
''' Displays the save output dialog.
\t\t\tfilename (str): the default filename
\t\t\tparent (gtk.Window): the parent window
\t'''
dialog = gtk.FileChooserDialog(_('Save Output...'), parent, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK))
dialog.set_local_only(False)
if curdir != None:
dialog.set_current_folder(curdir)
dialog.set_current_name(filename)
dialog.set_do_overwrite_confirmation(True)
filter = gtk.FileFilter()
filter.set_name(_('Text Files'))
filter.add_pattern('*.txt')
dialog.add_filter(filter)
response = dialog.run()
filename = dialog.get_filename()
dialog.destroy()
if response == gtk.RESPONSE_OK:
return filename
return None
class image_open_dialog:
def __init__(self, parent):
''' Initializes the image open dialog.
\t\t\t\tparent (gtk.Window): the parent window
\t\t'''
self.dialog = gtk.FileChooserDialog(_('Choose Image(s)...'), parent, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
self.dialog.set_local_only(False)
self.dialog.set_default_response(gtk.RESPONSE_OK)
self.dialog.set_select_multiple(True)
filefilter = gtk.FileFilter()
filefilter.set_name(_('Images and PDFs'))
filefilter.add_pixbuf_formats()
filefilter.add_mime_type('application/pdf')
filefilter.add_pattern('*.pdf')
self.dialog.add_filter(filefilter)
def run(self, curdir = None):
''' Runs the dialog
\t\t\t\tcudir=None (str): the directory opened at run
\t\t'''
if curdir != None:
self.dialog.set_current_folder(curdir)
response = self.dialog.run()
self.dialog.hide()
if response == gtk.RESPONSE_OK:
return self.dialog.get_filenames()
return None
class image_save_dialog:
def __init__(self, parent):
''' Initializes the image save dialog.
\t\t\t\tparent (gtk.Window): the parent window
\t\t'''
self.dialog = gtk.FileChooserDialog(_('Choose Output Image...'), parent, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
self.dialog.set_local_only(False)
self.dialog.set_default_response(gtk.RESPONSE_OK)
filefilter = gtk.FileFilter()
filefilter.set_name(_('Images'))
filefilter.add_mime_type('image/png')
filefilter.add_mime_type('image/jpeg')
filefilter.add_mime_type('image/tif')
filefilter.add_pattern('*.png')
filefilter.add_pattern('*.jpg')
filefilter.add_pattern('*.tif')
filefilter.add_pattern('*.tiff')
self.dialog.add_filter(filefilter)
def run(self, curfile = None):
''' Runs the dialog
\t\t\t\tcudir=None (str): the directory opened at run
\t\t'''
if curfile != None:
self.dialog.set_current_folder(os.path.dirname(curfile))
self.dialog.set_current_name(os.path.basename(curfile))
response = self.dialog.run()
self.dialog.hide()
if response == gtk.RESPONSE_OK:
return self.dialog.get_filename()
return None
manual = os.path.join('file://' + os.path.dirname(__file__), 'manual.html')
def help(section = ''):
webbrowser.open(manual + '#' + section)