Ejemplo n.º 1
0
        analysis = namedanalysis.getNamedBdyAnalysis(analysisname)
        dfile.startCmd(mainmenu.OOF.LoadData.NamedBdyAnalysis)
        dfile.argument('name', analysisname)
        dfile.argument('boundary', analysis.boundary)
        dfile.argument('analyzer', analysis.analyzer)
        dfile.endCmd()


bdyanalysismenu.addItem(
    oofmenu.OOFMenuItem(
        "SaveAnalysisDefs",
        callback=_saveAnalysis,
        params=[
            filenameparam.WriteFileNameParameter('filename',
                                                 tip='Name of the file.'),
            filenameparam.WriteModeParameter(
                'mode', tip="'w' to (over)write, 'a' to append."),
            enum.EnumParameter('format',
                               datafile.DataFileFormat,
                               datafile.ASCII,
                               tip="Format of the file."),
            namedanalysis.BdyAnalysisNamesParameter(
                'names', tip="Names of the analyses to be saved.")
        ],
        help=
        "Save the definitions of named boundary analysis operations in a file.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/menu/savebdyanal.xml')))


def _retrieveNamedAnalyis(menutiem, name):
    switchboard.notify("retrieve boundary analysis", name)
Ejemplo n.º 2
0
    def __init__(self, tutor):
        debug.mainthreadTest()

        for menuitem in mainmenu.OOF.Help.Tutorials.items:
            menuitem.disable()

        subWindow.SubWindow.__init__(self, title=tutor.subject, menu="")

        self.subwindow_menu.File.addItem(
            oofmenu.OOFMenuItem(
                'Save_Text',
                callback=self.savePrintable,
                params=[
                    filenameparam.WriteFileNameParameter('filename',
                                                         ident="FileMenu"),
                    filenameparam.WriteModeParameter('mode')
                ],
                help="Save the text of this tutorial in a file.",
                no_log=1,
                ordering=-1))

        labelhbox = gtk.HBox()
        self.subject = gtk.Label()
        self.slideIndex = gtk.Label()
        labelhbox.pack_start(self.subject, expand=1, fill=1, padding=2)
        labelhbox.pack_end(self.slideIndex, expand=0, fill=0, padding=2)
        self.mainbox.pack_start(labelhbox, expand=0, fill=0, padding=2)

        self.msgscroll = gtk.ScrolledWindow()
        self.scrollsignals = gtklogger.logScrollBars(self.msgscroll,
                                                     "TutorialScroll")
        self.msgscroll.set_shadow_type(gtk.SHADOW_IN)
        self.msgscroll.set_border_width(2)
        self.msgscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.mainbox.pack_start(self.msgscroll, expand=1, fill=1)
        self.textview = gtk.TextView()
        self.textview.set_cursor_visible(False)
        self.textview.set_editable(False)
        textattrs = self.textview.get_default_attributes()
        self.centerImageTag = self.textview.get_buffer().create_tag(
            'center-image', justification=gtk.JUSTIFY_CENTER)
        self.boldTag = self.textview.get_buffer().create_tag(
            "bold",
            weight=pango.WEIGHT_BOLD,  # why doesn't this work?
            foreground="blue")
        ##         self.boldTag = self.textview.get_buffer().create_tag(
        ##             "bold",
        ##             weight=pango.WEIGHT_HEAVY,  # why doesn't this work?
        ##             underline=pango.UNDERLINE_SINGLE)
        self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self.msgscroll.add(self.textview)

        buttonbox = gtk.HBox(homogeneous=1, spacing=2)
        self.mainbox.pack_end(buttonbox, expand=0, fill=0, padding=2)
        self.backbutton = gtkutils.StockButton(gtk.STOCK_GO_BACK, "Back")
        gtklogger.setWidgetName(self.backbutton, "Back")
        gtklogger.connect(self.backbutton, "clicked", self.backCB)
        tooltips.set_tooltip_text(self.backbutton,
                                  "Move to the previous slide.")

        self.nextbutton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, "Next")
        gtklogger.setWidgetName(self.nextbutton, "Next")
        gtklogger.connect(self.nextbutton, "clicked", self.nextCB)
        tooltips.set_tooltip_text(self.nextbutton, "Move to the next slide.")

        self.jumpbutton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST, "Jump")
        gtklogger.setWidgetName(self.jumpbutton, "Jump")
        gtklogger.connect(self.jumpbutton, "clicked", self.jumpCB)
        tooltips.set_tooltip_text(self.jumpbutton,
                                  "Jump to the leading slide.")

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...")
        gtklogger.setWidgetName(self.savebutton, "Save")
        gtklogger.connect(self.savebutton, "clicked", self.saveCB)
        tooltips.set_tooltip_text(self.savebutton,
                                  "Save your tutorial session.")

        self.closebutton = gtkutils.StockButton(gtk.STOCK_CLOSE, "Close")
        gtklogger.setWidgetName(self.closebutton, "Close")
        gtklogger.connect(self.closebutton, "clicked", self.closeCB)
        tooltips.set_tooltip_text(self.closebutton, "Quit the tutorial.")

        buttonbox.pack_start(self.backbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.nextbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.jumpbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.savebutton, expand=1, fill=1, padding=2)
        buttonbox.pack_end(self.closebutton, expand=1, fill=1, padding=2)

        self.gtk.connect('destroy', self.closeCB)
        self.gtk.set_default_size(500, 300)

        self.progress = 0  # How far has the tutorial gone?
        # It's not affected by "Back" command.
        self.index = 0  # which slide?
        self.signalReceived = 0  # Received a signal, if any.
        self.tutor = tutor
        self.newLesson()
        self.tutor.lessons[0].activate()
        self.saved = None  # if saved or not

        switchboard.requestCallbackMain("task finished", self.signalCB)
Ejemplo n.º 3
0
def saveLog(menuitem, filename, mode):
    file = open(filename, mode.string())
    menuitem.root().saveLog(file)
    file.close()

_savemenu = _filemenu.addItem(
    OOFMenuItem('Save', help='Create data files and scripts.'))

_savemenu.addItem(OOFMenuItem(
    'Python_Log',
    callback=saveLog,
    ordering=10,
    params=[filenameparam.WriteFileNameParameter('filename', ident="load",
                                                 tip="Name of the file."),
            filenameparam.WriteModeParameter(
                'mode',
                tip="Whether to overwrite or append to an existing file.")],
    accel='s',
    ellipsis=1,
    no_log=1,
    help="Save the current session as a Python script.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/savelog.xml')
    ))

#################################

def quitCmd(menuitem):
    from ooflib.common import quit
    quit.quit()

_filemenu.addItem(OOFMenuItem(
Ejemplo n.º 4
0
    if format==datafile.ABAQUS:
        skeletonIO.writeABAQUSfromSkeleton(filename, mode.string(),
                                           skelcontext)
    else:
        dfile = datafile.writeDataFile(filename, mode.string(), format)
        microstructureIO.writeMicrostructure(dfile, skelcontext.getParent())
        skeletonIO.writeSkeleton(dfile, skelcontext)
        dfile.close()

OOF.File.Save.addItem(oofmenu.OOFMenuItem(
    'Skeleton',
    callback = saveSkeleton,
    ordering=70,
    params = [
    filenameparam.WriteFileNameParameter('filename', tip="Name of the file."),
    filenameparam.WriteModeParameter(
                'mode', tip="'w' for (over)write and 'a' to append."),
    enum.EnumParameter('format', datafile.DataFileFormatExt, datafile.ASCII,
                       tip="Format of the file."),
    whoville.WhoParameter('skeleton', skeletoncontext.skeletonContexts,
                          tip=parameter.emptyTipString)],
    help="Save a Skeleton to a file.",
    discussion="""
    <para>Store a &skel; in a file in one of several <link
    linkend='Section-Concepts-FileFormats'><varname>formats</varname></link>.
    The file can be reloaded by <xref
    linkend='MenuItem-OOF.File.Load.Script'/> or <xref
    linkend='MenuItem-OOF.File.Load.Data'/>, depending on the file
    format.</para>
    """
    ))
Ejemplo n.º 5
0
def getFileAndMode(ident=None, title=""):
    fileparam = filenameparam.WriteFileNameParameter('filename', ident=ident)
    modeparam = filenameparam.WriteModeParameter('mode')
    if parameterwidgets.getParameters(fileparam, modeparam, title=title):
        return fileparam.value, modeparam.value.string()
Ejemplo n.º 6
0
        callback=saveImage,
        ordering=40,
        params=[
            filenameparam.WriteFileNameParameter(
                'filename',
                'filename',
                tip="Name of the file.  In 3D, include '%i' for a file number."
            ),
            enum.EnumParameter('format',
                               ImageFormatE,
                               value="png",
                               tip="Image file format."),
            ## TODO 3.1: Does it make sense to have an OverwriteParameter
            ## here?  Images should never be appended to existing
            ## files.
            filenameparam.WriteModeParameter('mode'),
            whoville.WhoParameter('image',
                                  whoville.getClass('Image'),
                                  tip=parameter.emptyTipString)
        ],
        help="Save an Image in a file.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/image/menu/saveimage.xml')))


def _fix_image_save(*args):
    if imagecontext.imageContexts.nActual() == 0:
        mainmenu.OOF.File.Save.Image.disable()
    else:
        mainmenu.OOF.File.Save.Image.enable()
Ejemplo n.º 7
0
    def shortrepr(self):
        return self.filename


# newreg is referred to in outputdestinationwidget.py.
newreg = registeredclass.Registration(
    'Output Stream',
    OutputDestination,
    OutputStream,
    ordering=1,
    rewindable=True,
    params=[
        filenameparam.WriteFileNameParameter('filename',
                                             tip=parameter.emptyTipString),
        filenameparam.WriteModeParameter(
            'mode', tip="Whether to write or append to the file.")
    ],
    tip="Send output to a file.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/outputstream.xml'))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

msgWindowName = "<Message Window>"


class MessageWindowStream(TextOutputDestination):
    def __init__(self):
        TextOutputDestination.__init__(
            self,
            BaseOutputStream(msgWindowName, filenameparam.WriteMode("w"),
                             lambda f, m: reporter.fileobj))
Ejemplo n.º 8
0
def saveMicrostructure(menuitem, filename, mode, format, microstructure):
    ms = ooflib.common.microstructure.microStructures[microstructure]
    dfile = datafile.writeDataFile(filename, mode.string(), format)
    microstructureIO.writeMicrostructure(dfile, ms)
    dfile.close()


mainmenu.OOF.File.Save.addItem(
    oofmenu.OOFMenuItem(
        'Microstructure',
        callback=saveMicrostructure,
        ordering=30,
        params=[
            filenameparam.WriteFileNameParameter('filename',
                                                 tip="Name of the file."),
            filenameparam.WriteModeParameter('mode', tip="write or append?"),
            enum.EnumParameter('format',
                               datafile.DataFileFormat,
                               datafile.ASCII,
                               tip="File format."),
            whoville.WhoParameter('microstructure',
                                  ooflib.common.microstructure.microStructures,
                                  tip=parameter.emptyTipString)
        ],
        help="Save a Microstructure in a file.",
        discussion="""
    <para>Store a &micro; in a file in one of several <link
    linkend='Section-Concepts-FileFormats'><varname>formats</varname></link>.
    The file can be reloaded by <xref
    linkend='MenuItem-OOF.File.Load.Script'/> or <xref
    linkend='MenuItem-OOF.File.Load.Data'/>, depending on the file
Ejemplo n.º 9
0
# own file to avoid import loops.


from ooflib.common import debug
from ooflib.common.IO import mainmenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import filenameparam
from ooflib.common.IO import reporter

def saveMessages(menuitem, filename, mode, **messagetypes):
    file = open(filename, mode.string())
    for message in reporter.messagemanager.all_messages():
        if messagetypes[message[1]]:
            print >> file, message[0]
    file.close()

mainmenu.OOF.File.Save.addItem(oofmenu.OOFMenuItem(
    "Messages",
    help="Save the message logs from the message windows to a file.",
    callback=saveMessages,
    ordering=20,
    params=[filenameparam.WriteFileNameParameter('filename',
                                                 tip="Name of the file."),
            filenameparam.WriteModeParameter('mode',
                                             tip="'w' to (over)write and 'a' to append")] +
    [parameter.BooleanParameter(name, True,
                                tip="True to include and False to not.")
     for name in reporter.messageclasses],
    discussion="Unlike other <link linkend='MenuItem:OOF.File.Save'>OOF.File.Save</link> menu varieties, messages are saved only in an <emphasis>ascii</emphasis> format for an obvious reason."))