Esempio n. 1
0
 def __init__(self, parent=None):
     debug.mainthreadTest()
     self.dialog = gtklogger.Dialog(title="OOF2 Font Selector", parent=parent)
     gtklogger.newTopLevelWidget(self.dialog, "FontSelector")
     self.dialog.add_button(gtk.STOCK_OK, self.OK)
     self.dialog.add_button(gtk.STOCK_CANCEL, self.CANCEL)
     self.fontselector = gtk.FontSelection()
     self.dialog.vbox.pack_start(self.fontselector, expand=1, fill=1)
Esempio n. 2
0
    def __init__(self, *parameters, **kwargs):
        debug.mainthreadTest()
        # A title for the dialog box can be specified by a REQUIRED
        # 'title' keyword argument.  A WidgetScope can be specified
        # with a 'scope' keyword.  If a parent window is specified
        # with the 'parentwindow' argument, the dialog will be brought
        # up as a transient window for it.
        try:
            scope = kwargs['scope']
        except KeyError:
            scope = None
        widgetscope.WidgetScope.__init__(self, scope)

        try:
            data_dict = kwargs['dialog_data']
        except KeyError:
            pass
        else:
            self.__dict__.update(data_dict)

        try:
            parentwindow = kwargs['parentwindow']
        except KeyError:
            parentwindow=None

        try:
            scopedata = kwargs['data']
        except KeyError:
            pass
        else:
            for key,value in scopedata.items():
                self.setData(key, value)
            
        self.parameters = parameters
        self.dialog = gtklogger.Dialog(parent=parentwindow,
                                       flags=gtk.DIALOG_MODAL)
        try:
            title = kwargs['title']
        except KeyError:
            raise ooferror.ErrPyProgrammingError("Untitled dialog!")
        gtklogger.newTopLevelWidget(self.dialog, 'Dialog-'+kwargs['title'])

        self.dialog.set_title(title)
        hbox = gtk.HBox()
        self.dialog.vbox.pack_start(hbox, expand=0, fill=0, padding=5)
        hbox.pack_start(gtk.Label(title), expand=1, fill=1, padding=10)

        self._button_hook()

        self.table = ParameterTable(parameters, scope=self)
        self.sbcallback = switchboard.requestCallbackMain(
            ('validity', self.table),
            self.validityCB)
        self.dialog.vbox.pack_start(self.table.gtk,
                                    expand=self.table.expandable,
                                    fill=True)
        self.response = None
        self.sensitize()
Esempio n. 3
0
    def __init__(self, mode, title=None, filename=None, params=None,
                 pattern=False):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.dialog = gtklogger.Dialog()
        self.set_title(title)
        gtklogger.newTopLevelWidget(self.dialog, self.dialog.get_title())
        self.filechooser = gtk.FileChooserWidget(action=_modes[mode])
        self.dialog.set_default_size(500, 300)
        self.filechooser.show()
        self.dialog.vbox.pack_start(self.filechooser, expand=1, fill=1)
        gtklogger.setWidgetName(self.filechooser, "FileChooser")
        gtklogger.connect(self.filechooser, 'selection-changed',
                          self.selectionchangedCB)
        self.dialog.add_button(gtk.STOCK_OK, self.OK)
        self.dialog.add_button(gtk.STOCK_CANCEL, self.CANCEL)
        self.dialog.set_default_response(self.OK)

        self.pattern = (pattern and (mode=='r'))
        if self.pattern:
            # TODO: Fix aesthetics of the widgets.
            self.filechooser.set_select_multiple(True)
            self.patternrow = gtk.HBox()
            self.patternrow.pack_start(gtk.Label("Pattern: "), expand=0, fill=0, padding=5)
            self.pattern_entry = gtk.Entry()
            self.pattern_entry.set_editable(1)
            self.pattern_entry.set_text("*")
            gtklogger.connect(self.pattern_entry, 'changed', self.patternchangedCB)
            self.patternrow.pack_start(self.pattern_entry, expand=1, fill=1, padding=5)
            self.patternrow.show_all()

        if params is None:
            self.table = None
            if self.pattern:
                self.filechooser.set_extra_widget(self.patternrow)
        else:
            self.table = parameterwidgets.ParameterTable(params, scope=self,
                                                         name="Parameters")
            self.sbcallback = switchboard.requestCallbackMain(
                ('validity', self.table), self.validityCB)
            if not self.pattern:
                self.filechooser.set_extra_widget(self.table.gtk)
            else:
                vbox = gtk.VBox()
                vbox.pack_start(self.patternrow)
                vbox.pack_start(self.table.gtk)
                vbox.show()
                self.filechooser.set_extra_widget(vbox)

        if filename is not None:
            self.filechooser.set_current_name(filename)
Esempio n. 4
0
    def __init__(self, message):
        debug.mainthreadTest()
        self.gtk = gtklogger.Dialog()
        gtklogger.newTopLevelWidget(self.gtk, "Warning")
        self.gtk.set_title("%s Warning"%subWindow.oofname())

        self.gtk.vbox.set_spacing(3)

        self.gtk.vbox.pack_start(gtk.Label("WARNING"))
        self.gtk.vbox.pack_start(gtk.Label(message))

        self.gtk.add_button("OK", self.OK)
        disable_button = self.gtk.add_button("Disable warnings", self.NO_MORE)
        tooltips.set_tooltip_text(disable_button,
            "Warnings can be re-enabled in the Help menu of the main window.")

        self.gtk.vbox.show_all()
Esempio n. 5
0
    def __init__(self, question, *answers, **kwargs):
        debug.mainthreadTest()

        if len(answers)==0:
            raise ooferror.ErrSetupError(
                "Questioner must have at least one possible answer.")

        self.answers = answers
        self.gtk = gtklogger.Dialog(parent=guitop.top().gtk)
        gtklogger.newTopLevelWidget(self.gtk, "Questioner")
        hbox = gtk.HBox()
        self.gtk.vbox.pack_start(hbox, padding=15)
        hbox.pack_start(gtk.Label(question), padding=15)
        self.defaultbutton = None

        try:
            self.default = kwargs['default']
        except KeyError:
            self.default=None
        else:
            if not self.default in answers:
                self.answers = (self.default,)+answers

        self.answerdict = {}
        count = 1
        for answer in self.answers:
            try:
                stock = _stock[answer]
                button = self.gtk.add_button(stock, count)
                # Replace the label on the stock button with the answer text.
                label = gtkutils.findChild(gtk.Label, button)
                label.set_text(answer)
            except KeyError:
                debug.fmsg('no stock icon for', answer)
                self.gtk.add_button(answer, count)
            self.answerdict[count] = answer
            if answer == self.default:
                self.gtk.set_default_response(count)
            count += 1
        hbox.show_all()
Esempio n. 6
0
def gtkOOFPopUpMenu(menu, basewidget):
    # Create a pop-up menu for an OOFMenu. The basewidget argument
    # can be any existing gtk Widget on the same screen as the pop-up.
    # The pop-up is returned. 

    # Example:
    #  popup = gtkOOFPopUpMenu(oofmenu, basewidget)
    #  gtklogger.connect(basewidget, 'button-press-event', callback)
    #
    #  def callback(gtkobj, event):
    #     if event.button == 3:  # right-click
    #         popup.popup(None, None, None, event.button, event.time)
    #         ## The Nones are some vestigial gtk cruft, apparently.
    debug.mainthreadTest()
    popupmenu = gtk.Menu()
    gtklogger.newTopLevelWidget(popupmenu, 'PopUp-'+menu.name)
    popupmenu.set_screen(basewidget.get_screen())
    gtklogger.connect_passive(popupmenu, 'deactivate')
    for item in menu:
        item.construct_gui(menu, popupmenu, None)
    popupmenu.show_all()
    return popupmenu
Esempio n. 7
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
        self.output = output
        self.time = time
        self.position = position
        self.sbcallbacks = []
        self.gsbcallbacks = []          # callbacks from a specific gfx window
        self.updateLock = lock.Lock()

        self.outputparam = \
                     ooflib.engine.IO.output.AggregateOutputParameter('output')

        # Although it's not displayed, we need a mesh widget in the
        # widgetscope, or the OutputParameterWidget won't work.
        # TODO LATER: Is this ugly, or what?
        self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self,
                                              name="Godot")

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        title = utils.underscore2space(self._name)
        self.gtk.set_title(title)
        gtklogger.newTopLevelWidget(self.gtk, title)
        gtklogger.connect_passive(self.gtk, 'delete-event')
        gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Put this window into the Windows menu.  The menu item can't
        # be logged, since the creation and operation of the window
        # aren't logged, so scripts shouldn't refer to it at all.
        mainmenu.OOF.Windows.Mesh_Data.addItem(oofmenu.OOFMenuItem(
            self._name,
            no_log=1,
            help="Raise Mesh Data window %d." % current_count,
            threadable=oofmenu.UNTHREADABLE,
            callback=self.raiseWindow))

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander)
        expander.set_expanded(1)
        
        self.table = gtk.Table(rows=config.dimension()+4, columns=2)
        expander.add(self.table)

        label = gtk.Label("Source Window:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=3, xoptions=gtk.FILL)
        tooltips.set_tooltip_text(label,
            "Display data for mouse clicks in this Graphics window.")

        self.gfxWindowChooser = chooser.ChooserWidget([],
                                                      callback=self.chooserCB,
                                                      name='GfxWindow')
        self.table.attach(self.gfxWindowChooser.gtk, 1,2, 0,1,
                     xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)


        label = gtk.Label("Mesh:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,"Data is displayed for values on this mesh.")

        self.meshText = gtk.Entry()
        gtklogger.setWidgetName(self.meshText, "meshname")
        self.meshText.set_editable(False)
        self.meshText.set_size_request(12*guitop.top().charsize, -1)
        self.table.attach(self.meshText, 1,2, 1,2,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)

        # Position controls
        label = gtk.Label("position x:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 2,3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.xText = gtk.Entry()
        gtklogger.setWidgetName(self.xText, 'x')
        self.xText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.xText, 1,2, 2,3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.xsignal = gtklogger.connect(self.xText, 'changed',
                                         self.posChangedCB)

        label = gtk.Label("position y:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 3,4,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.yText = gtk.Entry()
        gtklogger.setWidgetName(self.yText, 'y')
        self.yText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.yText, 1,2, 3,4,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.ysignal = gtklogger.connect(self.yText, 'changed',
                                         self.posChangedCB)

        if config.dimension() == 3:
            label = gtk.Label("position z:")
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 4,5,
                              xpadding=3, xoptions=gtk.FILL, yoptions=0)
            self.zText = gtk.Entry()
            gtklogger.setWidgetName(self.zText, 'z')
            self.zText.set_size_request(12*guitop.top().digitsize, -1)
            self.table.attach(self.zText, 1,2, 4,5,
                              xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
            self.zsignal = gtklogger.connect(self.zText, 'changed', 
                                             self.posChangedCB)
            timerow = 5
        else:
            timerow = 6

        # Time controls.  Typing in the time widget does not
        # immediately update the displayed data, because interpolating
        # to a new time is an expensive computation, and shouldn't be
        # done while the user is in the middle of typing.  Instead,
        # the time widget is normally desensitized and uneditable.
        # When the user clicks the "Edit" button, the widget becomes
        # editable, the rest of the window is desensitized, and the
        # "Edit" button changes do a "Done" button.  When the user
        # clicks "Done" the data is updated and the time widget
        # becomes uneditable again.
        label = gtk.Label("time:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tBox = gtk.HBox(spacing=3)
        self.table.attach(tBox, 1,2, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.tText = gtk.Entry()
        self.tText.set_editable(False)
        self.tText.set_sensitive(False)
        tBox.pack_start(self.tText, expand=1, fill=1)
        gtklogger.setWidgetName(self.tText, 't')
        self.tText.set_size_request(12*guitop.top().digitsize, -1)
        self.tEditButton = gtk.Button("Edit")
        tBox.pack_start(self.tEditButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.tEditButton, "tEdit")
        gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB)
        self.tEditMode = False
 
        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,"Choose which data is displayed.")
        
        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk, 1,2, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        vbox = gtk.VBox()
        frame.add(vbox)
        self.databox = gtk.HBox()
        vbox.pack_start(self.databox, expand=1, fill=1, padding=3)
        self.datawidget = None       # set by updateData

        # Buttons at the bottom of the window
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3)
        # Freeze buttons 
        freezeframe = gtk.Frame("Freeze")
        gtklogger.setWidgetName(freezeframe, "Freeze")
        buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3)
        hbox = gtk.HBox()
        freezeframe.add(hbox)
        # Freeze Space button
        self.freezeSpaceFlag = False
        self.freezeSpaceButton = gtk.CheckButton('Space')
        gtklogger.setWidgetName(self.freezeSpaceButton, 'Space')
        hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0)
        self.freezeSpaceButton.set_active(self.freezeSpaceFlag)
        gtklogger.connect(self.freezeSpaceButton, 'clicked', 
                          self.freezeSpaceButtonCB)
        tooltips.set_tooltip_text(self.freezeSpaceButton,
                        "Prevent the data in this window from being updated when the sample position changes.")
        # Freeze Time button
        self.freezeTimeFlag = False
        self.freezeTimeButton = gtk.CheckButton('Time')
        gtklogger.setWidgetName(self.freezeTimeButton, "Time")
        hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0)
        self.freezeTimeButton.set_active(self.freezeTimeFlag)
        gtklogger.connect(self.freezeTimeButton,'clicked',
                          self.freezeTimeButtonCB)
        tooltips.set_tooltip_text(self.freezeTimeButton,
            "Prevent the data in this window from being updated when the Mesh's time changes.")

        # Clone button
        self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone')
        gtklogger.setWidgetName(self.cloneButton, 'Clone')
        gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB)
        buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(self.cloneButton,
            "Make a copy of this window with its current settings.")

        # Close button
        self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        gtklogger.setWidgetName(self.closeButton, 'Close')
        gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB)
        buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3)

        self.gtk.connect('destroy', self.destroyCB)

        self.updateGfxWindowChooser()
        if gfxwindow:
            self.gfxWindowChooser.set_state(gfxwindow.name)
        if position is not None:
            self.updatePosition(position)
        self.currentMesh = None
        self.updateMesh()

        self.setupSwitchboard()         # gfx window dependent callbacks
        self.sbcallbacks += [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('mesh data changed',
                                            self.meshDataChanged),
            switchboard.requestCallbackMain((gfxwindow, "time changed"),
                                            self.timeChanged)
            ]

        
        self.gtk.show_all()
Esempio n. 8
0
    def __init__(self, title, menu=None, callback=None, guiloggable=True):
        debug.mainthreadTest()
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(title)
        if guiloggable:
            gtklogger.newTopLevelWidget(self.gtk, title)
            gtklogger.connect_passive(self.gtk, 'delete-event')
            gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Checking the type is clumsy; the idea is that the caller
        # must provide either the name for the auto-generated menu, or
        # a menu to use instead.  TODO LATER: It would be cleaner for
        # the Layer Editor and the Activity Viewer if the SubWindow
        # class could provide the window-specific (i.e "Close" and
        # "Quit") menu items under "File" (creating it, if necessary,
        # and prepending it to the passed-in menu) even when a menu is
        # passed in.  This would prevent duplication of effort by
        # separate subclasses of subwindow.
        if type(menu)==types.StringType:
            # If no menu is provided, then build a non-logging local
            # one with 'Close' and 'Quit'.
            self.subwindow_menu = oofmenu.OOFMenuItem(
                menu, secret=1, gui_only=1, no_log=1)

            file_item = oofmenu.OOFMenuItem('File', gui_only=1, no_log=1)
            self.subwindow_menu.addItem(file_item)

            file_item.addItem(oofmenu.OOFMenuItem(
                'Close', help="Close this window.",
                callback=self.menu_close,
                no_log=1, gui_only=1, accel='w'))
            
            file_item.addItem(oofmenu.OOFMenuItem(
                'Quit', gui_callback=quit.queryQuit,
                no_log=1, gui_only=1,
                help="Quit the OOF application.",
                accel='q', threadable = oofmenu.UNTHREADABLE))
                              
            mainmenu.OOF.addItem(self.subwindow_menu)
            self._local_menu = menu
        elif isinstance(menu, oofmenu.OOFMenuItem):
            self.subwindow_menu = menu
            self._local_menu = None # Flag indicating menu was passed in.
        else:
            raise TypeError("Incorrect type passed as menu to SubWindow.")

        # Build the menu bar and add it to the window.
##        self.menu_bar = None
        self.accel_group = gtk.AccelGroup()
        self.gtk.add_accel_group(self.accel_group)
        self.menu_bar = gfxmenu.gtkOOFMenuBar(
            self.subwindow_menu, accelgroup=self.accel_group)
        if guiloggable:
            gtklogger.setWidgetName(self.menu_bar, "MenuBar")

        self.mainbox.pack_start(self.menu_bar, fill=0, expand=0)

        # Add the "Windows" menu to the bar.
        self.windows_gtk_menu_item = gfxmenu.gtkOOFMenu(mainmenu.OOF.Windows,
                                                        self.accel_group)
        self.menu_bar.append(self.windows_gtk_menu_item)

        self.menu_bar.connect("destroy", self.menu_bar_destroyed)
        
        if callback is None:
            callback = self.destroySubWindow
        top().gtk.connect("destroy", callback)
Esempio n. 9
0
    def __init__(self, title, menu=None, callback=None, guiloggable=True):
        debug.mainthreadTest()
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(title)
        if guiloggable:
            gtklogger.newTopLevelWidget(self.gtk, title)
            gtklogger.connect_passive(self.gtk, 'delete-event')
            gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Checking the type is clumsy; the idea is that the caller
        # must provide either the name for the auto-generated menu, or
        # a menu to use instead.  TODO 3.1: It would be cleaner for
        # the Activity Viewer if the SubWindow class could provide the
        # window-specific (i.e "Close" and "Quit") menu items under
        # "File" (creating it, if necessary, and prepending it to the
        # passed-in menu) even when a menu is passed in.  This would
        # prevent duplication of effort by separate subclasses of
        # subwindow.
        if type(menu) == types.StringType:
            # If no menu is provided, then build a non-logging local
            # one with 'Close' and 'Quit'.
            self.subwindow_menu = oofmenu.OOFMenuItem(menu,
                                                      secret=1,
                                                      gui_only=1,
                                                      no_log=1)

            file_item = oofmenu.OOFMenuItem('File', gui_only=1, no_log=1)
            self.subwindow_menu.addItem(file_item)

            file_item.addItem(
                oofmenu.OOFMenuItem('Close',
                                    help="Close this window.",
                                    callback=self.menu_close,
                                    no_log=1,
                                    gui_only=1,
                                    accel='w'))

            file_item.addItem(
                oofmenu.OOFMenuItem('Quit',
                                    gui_callback=quit.queryQuit,
                                    no_log=1,
                                    gui_only=1,
                                    help="Quit the OOF application.",
                                    accel='q',
                                    threadable=oofmenu.UNTHREADABLE))

            mainmenu.OOF.addItem(self.subwindow_menu)
            self._local_menu = menu
        elif isinstance(menu, oofmenu.OOFMenuItem):
            self.subwindow_menu = menu
            self._local_menu = None  # Flag indicating menu was passed in.
        else:
            raise TypeError("Incorrect type passed as menu to SubWindow.")

        # Build the menu bar and add it to the window.
##        self.menu_bar = None
        self.accel_group = gtk.AccelGroup()
        self.gtk.add_accel_group(self.accel_group)
        self.menu_bar = gfxmenu.gtkOOFMenuBar(self.subwindow_menu,
                                              accelgroup=self.accel_group)
        if guiloggable:
            gtklogger.setWidgetName(self.menu_bar, "MenuBar")

        self.mainbox.pack_start(self.menu_bar, fill=0, expand=0)

        # Add the "Windows" menu to the bar.
        self.windows_gtk_menu_item = gfxmenu.gtkOOFMenu(
            mainmenu.OOF.Windows, self.accel_group)
        self.menu_bar.append(self.windows_gtk_menu_item)

        self.menu_bar.connect("destroy", self.menu_bar_destroyed)

        if callback is None:
            callback = self.destroySubWindow
        guitop.top().gtk.connect("destroy", callback)
Esempio n. 10
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
        self.output = output
        self.time = time
        self.position = position
        self.sbcallbacks = []
        self.gsbcallbacks = []  # callbacks from a specific gfx window
        self.updateLock = lock.Lock()

        self.outputparam = \
                     ooflib.engine.IO.output.ValueOutputParameter('output')

        # Although it's not displayed, we need a mesh widget in the
        # widgetscope, or the OutputParameterWidget won't work.
        # TODO 3.1: Is this ugly, or what?
        self.meshWidget = whowidget.WhoWidget(mesh.meshes,
                                              scope=self,
                                              name="Godot")

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        title = utils.underscore2space(self._name)
        self.gtk.set_title(title)
        gtklogger.newTopLevelWidget(self.gtk, title)
        gtklogger.connect_passive(self.gtk, 'delete-event')
        gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Put this window into the Windows menu.  The menu item can't
        # be logged, since the creation and operation of the window
        # aren't logged, so scripts shouldn't refer to it at all.
        mainmenu.OOF.Windows.Mesh_Data.addItem(
            oofmenu.OOFMenuItem(self._name,
                                no_log=1,
                                help="Raise Mesh Data window %d." %
                                current_count,
                                threadable=oofmenu.UNTHREADABLE,
                                callback=self.raiseWindow))

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander, expand=0, fill=0)
        expander.set_expanded(1)

        self.table = gtk.Table(rows=config.dimension() + 4, columns=2)
        expander.add(self.table)

        label = gtk.Label("Source Window:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 0, 1, xpadding=3, xoptions=gtk.FILL)
        tooltips.set_tooltip_text(
            label, "Display data for mouse clicks in this Graphics window.")

        self.gfxWindowChooser = chooser.ChooserWidget([],
                                                      callback=self.chooserCB,
                                                      name='GfxWindow')
        self.table.attach(self.gfxWindowChooser.gtk,
                          1,
                          2,
                          0,
                          1,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)

        label = gtk.Label("Mesh:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          1,
                          2,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tooltips.set_tooltip_text(
            label, "Data is displayed for values on this mesh.")

        self.meshText = gtk.Entry()
        gtklogger.setWidgetName(self.meshText, "meshname")
        self.meshText.set_editable(False)
        self.meshText.set_size_request(12 * guitop.top().charsize, -1)
        self.table.attach(self.meshText,
                          1,
                          2,
                          1,
                          2,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)

        # Position controls
        label = gtk.Label("position x:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          2,
                          3,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        self.xText = gtk.Entry()
        gtklogger.setWidgetName(self.xText, 'x')
        self.xText.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.xText,
                          1,
                          2,
                          2,
                          3,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.xsignal = gtklogger.connect(self.xText, 'changed',
                                         self.posChangedCB)

        label = gtk.Label("position y:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          3,
                          4,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        self.yText = gtk.Entry()
        gtklogger.setWidgetName(self.yText, 'y')
        self.yText.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.yText,
                          1,
                          2,
                          3,
                          4,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.ysignal = gtklogger.connect(self.yText, 'changed',
                                         self.posChangedCB)

        if config.dimension() == 3:
            label = gtk.Label("position z:")
            label.set_alignment(1.0, 0.5)
            self.table.attach(label,
                              0,
                              1,
                              4,
                              5,
                              xpadding=3,
                              xoptions=gtk.FILL,
                              yoptions=0)
            self.zText = gtk.Entry()
            gtklogger.setWidgetName(self.zText, 'z')
            self.zText.set_size_request(12 * guitop.top().digitsize, -1)
            self.table.attach(self.zText,
                              1,
                              2,
                              4,
                              5,
                              xpadding=3,
                              xoptions=gtk.EXPAND | gtk.FILL,
                              yoptions=0)
            self.zsignal = gtklogger.connect(self.zText, 'changed',
                                             self.posChangedCB)
            timerow = 5
        else:
            timerow = 6

        # Time controls.  Typing in the time widget does not
        # immediately update the displayed data, because interpolating
        # to a new time is an expensive computation, and shouldn't be
        # done while the user is in the middle of typing.  Instead,
        # the time widget is normally desensitized and uneditable.
        # When the user clicks the "Edit" button, the widget becomes
        # editable, the rest of the window is desensitized, and the
        # "Edit" button changes do a "Done" button.  When the user
        # clicks "Done" the data is updated and the time widget
        # becomes uneditable again.
        label = gtk.Label("time:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          timerow,
                          timerow + 1,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tBox = gtk.HBox(spacing=3)
        self.table.attach(tBox,
                          1,
                          2,
                          timerow,
                          timerow + 1,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        self.tText = gtk.Entry()
        self.tText.set_editable(False)
        self.tText.set_sensitive(False)
        tBox.pack_start(self.tText, expand=1, fill=1)
        gtklogger.setWidgetName(self.tText, 't')
        self.tText.set_size_request(12 * guitop.top().digitsize, -1)
        self.tEditButton = gtk.Button("Edit")
        tBox.pack_start(self.tEditButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.tEditButton, "tEdit")
        gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB)
        self.tEditMode = False

        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tooltips.set_tooltip_text(label, "Choose which data is displayed.")

        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk,
                          1,
                          2,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        # valign keeps the data widget at the top of the frame
        valign = gtk.Alignment(yalign=0.0)
        frame.add(valign)
        # dhbox just provides space between the data widget and the frame
        dhbox = gtk.HBox(spacing=5)
        valign.add(dhbox)
        # databox is where the data widget goes
        self.databox = gtk.VBox()
        dhbox.pack_start(self.databox, expand=1, fill=1, padding=5)
        self.datawidget = None  # set by updateData

        # Buttons at the bottom of the window
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3)
        # Freeze buttons
        freezeframe = gtk.Frame("Freeze")
        gtklogger.setWidgetName(freezeframe, "Freeze")
        buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3)
        hbox = gtk.HBox()
        freezeframe.add(hbox)
        # Freeze Space button
        self.freezeSpaceFlag = False
        self.freezeSpaceButton = gtk.CheckButton('Space')
        gtklogger.setWidgetName(self.freezeSpaceButton, 'Space')
        hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0)
        self.freezeSpaceButton.set_active(self.freezeSpaceFlag)
        gtklogger.connect(self.freezeSpaceButton, 'clicked',
                          self.freezeSpaceButtonCB)
        tooltips.set_tooltip_text(
            self.freezeSpaceButton,
            "Prevent the data in this window from being updated when the sample position changes."
        )
        # Freeze Time button
        self.freezeTimeFlag = False
        self.freezeTimeButton = gtk.CheckButton('Time')
        gtklogger.setWidgetName(self.freezeTimeButton, "Time")
        hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0)
        self.freezeTimeButton.set_active(self.freezeTimeFlag)
        gtklogger.connect(self.freezeTimeButton, 'clicked',
                          self.freezeTimeButtonCB)
        tooltips.set_tooltip_text(
            self.freezeTimeButton,
            "Prevent the data in this window from being updated when the Mesh's time changes."
        )

        # Clone button
        self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone')
        gtklogger.setWidgetName(self.cloneButton, 'Clone')
        gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB)
        buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(
            self.cloneButton,
            "Make a copy of this window with its current settings.")

        # Close button
        self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        gtklogger.setWidgetName(self.closeButton, 'Close')
        gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB)
        buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3)

        self.gtk.connect('destroy', self.destroyCB)

        self.updateGfxWindowChooser()
        if gfxwindow:
            self.gfxWindowChooser.set_state(gfxwindow.name)
        if position is not None:
            self.updatePosition(position)
        self.currentMesh = None
        self.updateMesh()

        self.setupSwitchboard()  # gfx window dependent callbacks
        self.sbcallbacks += [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('mesh data changed',
                                            self.meshDataChanged),
            switchboard.requestCallbackMain((gfxwindow, "time changed"),
                                            self.timeChanged)
        ]

        self.gtk.show_all()
Esempio n. 11
0
    def __init__(self):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(oofname)
        initial_width, initial_height = map(int, runtimeflags.geometry.split("x"))
        self.gtk.set_default_size(initial_width, initial_height)
        gtklogger.newTopLevelWidget(self.gtk, oofname)
        gtklogger.connect(self.gtk, "delete-event", self.deleteEventCB)
        gtklogger.connect_passive(self.gtk, "configure-event")
        self.gtk.connect("destroy", self.destroyCB)
        guitop.setTop(self)

        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        self.menubar = gtk.MenuBar()
        self.mainbox.pack_start(self.menubar, expand=0, fill=0)
        accelgrp = gtk.AccelGroup()
        self.gtk.add_accel_group(accelgrp)

        self.mainmenu = mainmenu.OOF
        self.oofmenu = gfxmenu.gtkOOFMenuBar(self.mainmenu, bar=self.menubar, accelgroup=accelgrp)
        gtklogger.setWidgetName(self.oofmenu, "MenuBar")
        self.pageChooserFrame = gtk.Frame()
        self.pageChooserFrame.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageChooserFrame, expand=0, fill=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        self.pageChooserFrame.add(align)
        chooserBox = gtk.HBox()
        chooserBox.set_border_width(2)
        gtklogger.setWidgetName(chooserBox, "Navigation")
        align.add(chooserBox)

        self.historian = historian.Historian(self.historianCB, self.sensitizeHistory)

        label = gtk.Label("Task: ")
        label.set_alignment(1.0, 0.5)
        chooserBox.pack_start(label, expand=0, fill=0)

        self.prevHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST)
        chooserBox.pack_start(self.prevHistoryButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevHistoryButton, "PrevHist")
        gtklogger.connect(self.prevHistoryButton, "clicked", self.historian.prevCB)
        tooltips.set_tooltip_text(self.prevHistoryButton, "Go to the chronologically previously page.")

        self.prevPageButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        chooserBox.pack_start(self.prevPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevPageButton, "Prev")
        gtklogger.connect(self.prevPageButton, "clicked", self.prevPageCB)
        self.pageChooser = chooser.ChooserWidget([], callback=self.pageChooserCB, name="PageMenu")
        chooserBox.pack_start(self.pageChooser.gtk, expand=0, fill=0)
        self.currentPageName = None

        self.nextPageButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        chooserBox.pack_start(self.nextPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextPageButton, "Next")
        gtklogger.connect(self.nextPageButton, "clicked", self.nextPageCB)

        self.nextHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST)
        chooserBox.pack_start(self.nextHistoryButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextHistoryButton, "NextHist")
        gtklogger.connect(self.nextHistoryButton, "clicked", self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextHistoryButton, "Go to the chronologically next page.")

        # Find the font size, so widgets can be sized appropriately.
        #  digitsize and charsize are in pixels.

        self.digitsize, self.charsize = gtkutils.widgetFontSizes(self.gtk)

        # Add a GUI callback to the "OOF2" windows item.
        oof2_item = self.mainmenu.Windows.OOF2
        oof2_item.add_gui_callback(self.menu_raise)

        # Frame around main pages.  GUI pages are added and removed
        # from it by installPage().
        self.pageframe = gtk.Frame()
        self.pageframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageframe, expand=1, fill=1)

        # Add pages that may have been created before the main GUI was built.
        for pagename, i in zip(pagenames, range(len(allPages))):
            self.addPage(allPages[pagename], i)
Esempio n. 12
0
    def __init__(self, e_type, value, tbacklist):
        debug.mainthreadTest()

        errorstrings = []  # list of strings
        self.tracebacks = []  # list of lists of \n-terminated strings

        # If there are previous unprocessed exceptions, print them
        # too.  The oldest exception is the first in the
        # _savedExceptions list.
        global _savedExceptions
        _savedExceptions.append((e_type, value, tbacklist))
        for e_type, value, tbacklist in _savedExceptions:
            # format_exception_only returns a list of string, each
            # terminated whith a newline.  The list has length 1,
            # except for syntax errors.
            errorstrings.extend([
                line.rstrip()
                for line in traceback.format_exception_only(e_type, value)
            ])

            if isinstance(value, ooferror.ErrErrorPtr):
                moreinfo = value.details()
                if moreinfo:
                    errorstrings.append(moreinfo)
            errorstrings.append("")  # blank line
            if tbacklist:
                self.tracebacks.append(traceback.format_list(tbacklist))

        _savedExceptions = []

        self.answer = None

        self.datestampstring = time.strftime("%Y %b %d %H:%M:%S %Z")
        self.gtk = gtklogger.Dialog()
        self.gtk.set_keep_above(True)
        # self.gtk = gtk.Dialog()
        gtklogger.newTopLevelWidget(self.gtk, "Error")
        self.gtk.set_title("%s Error" % subWindow.oofname())

        self.gtk.vbox.set_spacing(3)
        classname = string.split(str(e_type), '.')[-1]
        self.gtk.vbox.pack_start(gtk.Label("ERROR"), expand=0, fill=0)

        self.errframe = gtk.Frame()
        self.errframe.set_border_width(6)
        self.errframe.set_shadow_type(gtk.SHADOW_IN)
        self.gtk.vbox.pack_start(self.errframe, expand=1, fill=1)

        fd = pango.FontDescription(mainmenuGUI.getFixedFont())

        errscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(errscroll, "ErrorScroll")
        errscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.errframe.add(errscroll)
        self.errbox = gtk.TextView()  # error text goes here
        gtklogger.setWidgetName(self.errbox, "ErrorText")
        errscroll.add(self.errbox)
        self.errbox.set_editable(0)
        self.errbox.set_wrap_mode(gtk.WRAP_WORD)
        self.errbox.get_buffer().set_text("\n".join(errorstrings))
        self.errbox.modify_font(fd)

        self.gtk.add_button(gtk.STOCK_OK, self.OK)
        self.gtk.add_button("Abort", self.ABORT)
        self.gtk.set_default_response(self.OK)

        self.tracebutton = gtk.Button("View Traceback")
        gtklogger.setWidgetName(self.tracebutton, "ViewTraceback")
        gtklogger.connect(self.tracebutton, "clicked", self.trace)
        self.gtk.action_area.add(self.tracebutton)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE,
                                               "Save Traceback")
        gtklogger.setWidgetName(self.savebutton, "SaveTraceback")
        gtklogger.connect(self.savebutton, "clicked", self.savetrace)
        self.gtk.action_area.add(self.savebutton)

        self.scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.scroll, "TraceScroll")
        self.scroll.set_border_width(3)
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)

        self.tracepane = gtk.TextView()
        self.tracepane.set_editable(0)
        self.tracepane.set_wrap_mode(gtk.WRAP_WORD)
        self.tracepane.modify_font(fd)

        self.traceframe = gtk.Frame()
        self.traceframe.set_shadow_type(gtk.SHADOW_NONE)
        self.gtk.vbox.pack_start(self.traceframe, expand=0, fill=0)

        # Scroll is not added to the frame until the traceback button
        # is pressed.
        self.scroll.add(self.tracepane)

        if self.tracebacks:
            tbtext = ""
            for err, tb in zip(errorstrings, self.tracebacks):
                if tbtext:
                    tbtext += '\n----------\n\n'
                tbtext += err + '\n'
                tbtext += "".join(tb)
            self.tracepane.get_buffer().set_text(tbtext)

        else:
            self.savebutton.set_sensitive(0)
            self.tracebutton.set_sensitive(0)

        self.gtk.show_all()
Esempio n. 13
0
    def __init__(self,
                 mode,
                 title=None,
                 filename=None,
                 params=None,
                 pattern=False):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.dialog = gtklogger.Dialog()
        self.set_title(title)
        gtklogger.newTopLevelWidget(self.dialog, self.dialog.get_title())
        self.filechooser = gtk.FileChooserWidget(action=_modes[mode])
        self.dialog.set_default_size(500, 300)
        self.filechooser.show()
        self.dialog.vbox.pack_start(self.filechooser, expand=1, fill=1)
        gtklogger.setWidgetName(self.filechooser, "FileChooser")
        gtklogger.connect(self.filechooser, 'selection-changed',
                          self.selectionchangedCB)
        self.dialog.add_button(gtk.STOCK_OK, self.OK)
        self.dialog.add_button(gtk.STOCK_CANCEL, self.CANCEL)
        self.dialog.set_default_response(self.OK)

        self.pattern = (pattern and (mode == 'r'))
        if self.pattern:
            # TODO: Fix aesthetics of the widgets.
            self.filechooser.set_select_multiple(True)
            self.patternrow = gtk.HBox()
            self.patternrow.pack_start(gtk.Label("Pattern: "),
                                       expand=0,
                                       fill=0,
                                       padding=5)
            self.pattern_entry = gtk.Entry()
            self.pattern_entry.set_editable(1)
            self.pattern_entry.set_text("*")
            gtklogger.connect(self.pattern_entry, 'changed',
                              self.patternchangedCB)
            self.patternrow.pack_start(self.pattern_entry,
                                       expand=1,
                                       fill=1,
                                       padding=5)
            self.patternrow.show_all()

        if params is None:
            self.table = None
            if self.pattern:
                self.filechooser.set_extra_widget(self.patternrow)
        else:
            self.table = parameterwidgets.ParameterTable(params,
                                                         scope=self,
                                                         name="Parameters")
            self.sbcallback = switchboard.requestCallbackMain(
                ('validity', self.table), self.validityCB)
            if not self.pattern:
                self.filechooser.set_extra_widget(self.table.gtk)
            else:
                vbox = gtk.VBox()
                vbox.pack_start(self.patternrow)
                vbox.pack_start(self.table.gtk)
                vbox.show()
                self.filechooser.set_extra_widget(vbox)

        if filename is not None:
            self.filechooser.set_current_name(filename)
Esempio n. 14
0
    def buildBottomRow(self, mainbox):
        # Build the bottom row of widgets, containing the named
        # analysis buttons, the Destination chooser, and the Go
        # button.
        # Box along the bottom of the page, containing Named Analyses,
        # Destination, and Go.
        hbox = gtk.HBox()
        hbox.set_homogeneous(True)
        mainbox.pack_start(hbox, expand=0, fill=0, padding=3)

        # Named Analyses
        nameframe = gtk.Frame("Named Analyses")
        gtklogger.setWidgetName(nameframe, 'Name')
        nameframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(nameframe, expand=1, fill=1, padding=3)
        namebox = gtk.VBox(spacing=2)
        namebox.set_border_width(1)
        nameframe.add(namebox)

        # The namedOps_button isn't used as a button, really.  It's
        # just a place to click to bring up the menu of named analysis
        # operations.  There isn't room in the frame to make separate
        # buttons for all the operations and still display the name of
        # the current analysis, if any.
        self.namedOps_button = gtk.Button("Create/Delete/etc...")
        gtklogger.setWidgetName(self.namedOps_button, "Operations")
        namebox.pack_start(self.namedOps_button, expand=1, fill=1)
        gtklogger.connect(self.namedOps_button, 'button-press-event',
                          self.namedOpsCB)
        # Construct the menu of operations.
        self.namedOpsPopUp = gtk.Menu()
        gtklogger.newTopLevelWidget(self.namedOpsPopUp, self.menuWidgetName)
        self.namedOpsPopUp.set_screen(self.namedOps_button.get_screen())
        gtklogger.connect_passive(self.namedOpsPopUp, 'deactivate')
        self.namedOpsMenuItems = {}
        for position, (name, callback, tip) in enumerate([
            ('Create', self.createCB, "Create a new named analysis."),
            ('Save', self.savenamedCB, "Save named analysis definitions."),
            ('Delete', self.deleteCB, "Delete a named analysis.")
        ]):
            menuitem = gtk.MenuItem()
            self.namedOpsMenuItems[name] = menuitem
            gtklogger.setWidgetName(menuitem, name)
            label = gtk.Label(name + "...")
            tooltips.set_tooltip_text(label, tip)
            menuitem.add(label)
            self.namedOpsPopUp.insert(menuitem, position)
            gtklogger.connect(menuitem, 'activate', callback)
        self.namedOpsPopUp.show_all()
        # Display the name of the current analysis, if it has one.
        hbox4 = gtk.HBox()
        namebox.pack_start(hbox4, expand=0, fill=0)
        hbox4.pack_start(gtk.Label("Current:"), expand=0, fill=0)
        self.namedAnalysisChooser = chooser.ChooserWidget(
            [], callback=self.retrieveCB, name="Retrieve")
        hbox4.pack_start(self.namedAnalysisChooser.gtk, expand=1, fill=1)

        # reduce no. of calls to setNamedAnalysisChooser
        self.suppressRetrievalLoop = False

        # Destination
        destinationframe = gtk.Frame("Destination")
        destinationframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(destinationframe, expand=1, fill=1, padding=3)
        destbox = gtk.HBox()
        destbox.set_border_width(1)
        destinationframe.add(destbox)

        self.destwidget = outputdestinationwidget.TextDestinationWidget(
            name="Destination", framed=False)
        destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)

        # Go button
        self.go_button = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go")
        self.go_button.set_border_width(2)
        gtklogger.setWidgetName(self.go_button, 'Go')
        gtklogger.connect(self.go_button, "clicked", self.go_buttonCB)
        tooltips.set_tooltip_text(self.go_button,
                                  "Send the output to the destination.")
        hbox.pack_start(self.go_button, fill=1, expand=1, padding=2)
Esempio n. 15
0
    def __init__(self, e_type, value, tbacklist):
        debug.mainthreadTest()
        
        errorstrings = []     # list of strings
        self.tracebacks = []  # list of lists of \n-terminated strings

        # If there are previous unprocessed exceptions, print them
        # too.  The oldest exception is the first in the
        # _savedExceptions list.
        global _savedExceptions
        _savedExceptions.append((e_type, value, tbacklist))
        for e_type, value, tbacklist in _savedExceptions:
            # format_exception_only returns a list of string, each
            # terminated whith a newline.  The list has length 1,
            # except for syntax errors.
            errorstrings.extend(
                [line.rstrip() for line in
                 traceback.format_exception_only(e_type, value)])

            if isinstance(value, ooferror.ErrErrorPtr):
                moreinfo = value.details()
                if moreinfo:
                    errorstrings.append(moreinfo)
            errorstrings.append("") # blank line
            if tbacklist:
                self.tracebacks.append(traceback.format_list(tbacklist))

        _savedExceptions = []

        self.answer = None
        
        self.datestampstring = time.strftime("%Y %b %d %H:%M:%S %Z")
        self.gtk = gtklogger.Dialog()
        self.gtk.set_keep_above(True)
        # self.gtk = gtk.Dialog()
        gtklogger.newTopLevelWidget(self.gtk, "Error")
        self.gtk.set_title("%s Error"%subWindow.oofname())

        self.gtk.vbox.set_spacing(3)
        classname = string.split(str(e_type),'.')[-1]
        self.gtk.vbox.pack_start(gtk.Label("ERROR"), expand=0, fill=0)

        self.errframe = gtk.Frame()
        self.errframe.set_border_width(6)
        self.errframe.set_shadow_type(gtk.SHADOW_IN)
        self.gtk.vbox.pack_start(self.errframe, expand=1, fill=1)

        fd = pango.FontDescription(mainmenuGUI.getFixedFont())

        errscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(errscroll, "ErrorScroll")
        errscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.errframe.add(errscroll)
        self.errbox = gtk.TextView()    # error text goes here
        gtklogger.setWidgetName(self.errbox, "ErrorText")
        errscroll.add(self.errbox)
        self.errbox.set_editable(0)
        self.errbox.set_wrap_mode(gtk.WRAP_WORD)
        self.errbox.get_buffer().set_text("\n".join(errorstrings))
        self.errbox.modify_font(fd)

        self.gtk.add_button(gtk.STOCK_OK, self.OK)
        self.gtk.add_button("Abort", self.ABORT)
        self.gtk.set_default_response(self.OK)

        self.tracebutton = gtk.Button("View Traceback")
        gtklogger.setWidgetName(self.tracebutton, "ViewTraceback")
        gtklogger.connect(self.tracebutton, "clicked", self.trace)
        self.gtk.action_area.add(self.tracebutton)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save Traceback")
        gtklogger.setWidgetName(self.savebutton, "SaveTraceback")
        gtklogger.connect(self.savebutton, "clicked", self.savetrace)
        self.gtk.action_area.add(self.savebutton)

        self.scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.scroll, "TraceScroll")
        self.scroll.set_border_width(3)
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)
        
        self.tracepane = gtk.TextView()
        self.tracepane.set_editable(0)
        self.tracepane.set_wrap_mode(gtk.WRAP_WORD)
        self.tracepane.modify_font(fd)

        self.traceframe = gtk.Frame()
        self.traceframe.set_shadow_type(gtk.SHADOW_NONE)
        self.gtk.vbox.pack_start(self.traceframe, expand=0, fill=0)

        # Scroll is not added to the frame until the traceback button
        # is pressed.
        self.scroll.add(self.tracepane)

        if self.tracebacks:
            tbtext = ""
            for err, tb in zip(errorstrings, self.tracebacks):
                if tbtext:
                    tbtext += '\n----------\n\n'
                tbtext += err + '\n'
                tbtext += "".join(tb)
            self.tracepane.get_buffer().set_text(tbtext)
            
        else:
            self.savebutton.set_sensitive(0)
            self.tracebutton.set_sensitive(0)

        self.gtk.show_all()
Esempio n. 16
0
    def buildBottomRow(self, mainbox):
        # Build the bottom row of widgets, containing the named
        # analysis buttons, the Destination chooser, and the Go
        # button.
        # Box along the bottom of the page, containing Named Analyses,
        # Destination, and Go.
        hbox = gtk.HBox()
        hbox.set_homogeneous(True)
        mainbox.pack_start(hbox, expand=0, fill=0, padding=3)

        # Named Analyses
        nameframe = gtk.Frame("Named Analyses")
        gtklogger.setWidgetName(nameframe, 'Name')
        nameframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(nameframe, expand=1, fill=1, padding=3)
        namebox = gtk.VBox(spacing=2)
        namebox.set_border_width(1)
        nameframe.add(namebox)
        
        # The namedOps_button isn't used as a button, really.  It's
        # just a place to click to bring up the menu of named analysis
        # operations.  There isn't room in the frame to make separate
        # buttons for all the operations and still display the name of
        # the current analysis, if any.
        self.namedOps_button = gtk.Button("Create/Delete/etc...")
        gtklogger.setWidgetName(self.namedOps_button, "Operations")
        namebox.pack_start(self.namedOps_button, expand=1, fill=1)
        gtklogger.connect(self.namedOps_button, 'button-press-event', 
                          self.namedOpsCB)
        # Construct the menu of operations.
        self.namedOpsPopUp = gtk.Menu()
        gtklogger.newTopLevelWidget(self.namedOpsPopUp, self.menuWidgetName)
        self.namedOpsPopUp.set_screen(self.namedOps_button.get_screen())
        gtklogger.connect_passive(self.namedOpsPopUp, 'deactivate')
        self.namedOpsMenuItems = {}
        for position, (name, callback, tip) in enumerate([
                ('Create', self.createCB, "Create a new named analysis."),
                ('Save', self.savenamedCB, "Save named analysis definitions."),
                ('Delete', self.deleteCB, "Delete a named analysis.")]):
            menuitem = gtk.MenuItem()
            self.namedOpsMenuItems[name] = menuitem
            gtklogger.setWidgetName(menuitem, name)
            label = gtk.Label(name + "...")
            tooltips.set_tooltip_text(label, tip)
            menuitem.add(label)
            self.namedOpsPopUp.insert(menuitem, position)
            gtklogger.connect(menuitem, 'activate', callback)
        self.namedOpsPopUp.show_all()
        # Display the name of the current analysis, if it has one.
        hbox4 = gtk.HBox()
        namebox.pack_start(hbox4, expand=0, fill=0)
        hbox4.pack_start(gtk.Label("Current:"), expand=0, fill=0)
        self.namedAnalysisChooser = chooser.ChooserWidget(
            [], callback=self.retrieveCB, name="Retrieve")
        hbox4.pack_start(self.namedAnalysisChooser.gtk, expand=1, fill=1)

        # reduce no. of calls to setNamedAnalysisChooser
        self.suppressRetrievalLoop = False

        # Destination
        destinationframe = gtk.Frame("Destination")
        destinationframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(destinationframe, expand=1, fill=1, padding=3)
        destbox = gtk.HBox()
        destbox.set_border_width(1)
        destinationframe.add(destbox)

        self.destwidget = outputdestinationwidget.TextDestinationWidget(
            name="Destination", framed=False)
        destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)
        
        # Go button
        self.go_button = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go")
        self.go_button.set_border_width(2)
        gtklogger.setWidgetName(self.go_button, 'Go')
        gtklogger.connect(self.go_button, "clicked", self.go_buttonCB)
        tooltips.set_tooltip_text(self.go_button,
                             "Send the output to the destination.")
        hbox.pack_start(self.go_button, fill=1, expand=1, padding=2)
Esempio n. 17
0
    def __init__(self):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(oofname)
        initial_width, initial_height = map(int,
                                            runtimeflags.geometry.split('x'))
        self.gtk.set_default_size(initial_width, initial_height)
        gtklogger.newTopLevelWidget(self.gtk, oofname)
        gtklogger.connect(self.gtk, "delete-event", self.deleteEventCB)
        gtklogger.connect_passive(self.gtk, "configure-event")
        self.gtk.connect("destroy", self.destroyCB)
        guitop.setTop(self)

        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        self.menubar = gtk.MenuBar()
        self.mainbox.pack_start(self.menubar, expand=0, fill=0)
        accelgrp = gtk.AccelGroup()
        self.gtk.add_accel_group(accelgrp)

        self.mainmenu = mainmenu.OOF
        self.oofmenu = gfxmenu.gtkOOFMenuBar(self.mainmenu,
                                             bar=self.menubar,
                                             accelgroup=accelgrp)
        gtklogger.setWidgetName(self.oofmenu, "MenuBar")
        self.pageChooserFrame = gtk.Frame()
        self.pageChooserFrame.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageChooserFrame,
                                expand=0,
                                fill=0,
                                padding=2)

        align = gtk.Alignment(xalign=0.5)
        self.pageChooserFrame.add(align)
        chooserBox = gtk.HBox()
        chooserBox.set_border_width(2)
        gtklogger.setWidgetName(chooserBox, 'Navigation')
        align.add(chooserBox)

        self.historian = historian.Historian(self.historianCB,
                                             self.sensitizeHistory)

        label = gtk.Label('Task: ')
        label.set_alignment(1.0, 0.5)
        chooserBox.pack_start(label, expand=0, fill=0)

        self.prevHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST)
        chooserBox.pack_start(self.prevHistoryButton,
                              expand=0,
                              fill=0,
                              padding=3)
        gtklogger.setWidgetName(self.prevHistoryButton, 'PrevHist')
        gtklogger.connect(self.prevHistoryButton, 'clicked',
                          self.historian.prevCB)
        tooltips.set_tooltip_text(
            self.prevHistoryButton,
            "Go to the chronologically previously page.")

        self.prevPageButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        chooserBox.pack_start(self.prevPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevPageButton, 'Prev')
        gtklogger.connect(self.prevPageButton, 'clicked', self.prevPageCB)
        self.pageChooser = chooser.ChooserWidget([],
                                                 callback=self.pageChooserCB,
                                                 name="PageMenu")
        chooserBox.pack_start(self.pageChooser.gtk, expand=0, fill=0)
        self.currentPageName = None

        self.nextPageButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        chooserBox.pack_start(self.nextPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextPageButton, 'Next')
        gtklogger.connect(self.nextPageButton, 'clicked', self.nextPageCB)

        self.nextHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST)
        chooserBox.pack_start(self.nextHistoryButton,
                              expand=0,
                              fill=0,
                              padding=3)
        gtklogger.setWidgetName(self.nextHistoryButton, 'NextHist')
        gtklogger.connect(self.nextHistoryButton, 'clicked',
                          self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextHistoryButton,
                                  "Go to the chronologically next page.")

        # Find the font size, so widgets can be sized appropriately.
        #  digitsize and charsize are in pixels.

        self.digitsize, self.charsize = gtkutils.widgetFontSizes(self.gtk)

        # Add a GUI callback to the "OOF2" windows item.
        oof2_item = self.mainmenu.Windows.OOF2
        oof2_item.add_gui_callback(self.menu_raise)

        # Frame around main pages.  GUI pages are added and removed
        # from it by installPage().
        self.pageframe = gtk.Frame()
        self.pageframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageframe, expand=1, fill=1)

        # Add pages that may have been created before the main GUI was built.
        for pagename, i in zip(pagenames, range(len(allPages))):
            self.addPage(allPages[pagename], i)