Beispiel #1
0
    def cell_layout_data_func(self, cell_view, cell_renderer, model, iter):
        # This adds tooltips to the menu items.  It's a bit of a hack
        # and doesn't do a great job: the tips flicker if the mouse is
        # moved.  Thanks to Phil Dumont on the pygtk mailing list for
        # this code.  If you figure out how to get rid of the flicker,
        # please tell Phil.

        debug.mainthreadTest()
        idx = model.get_path(iter)[0]
        item_text = model.get_value(iter, 0)
        cell_renderer.set_property('text', item_text)
        try:
            tip_text = self.helpdict[item_text]
        except KeyError:
            pass
        else:
            # When navigating using the arrow keys, cell_view is
            # sometimes a TreeViewColumn instead of a CellView.
            # TreeViewColumns aren't widgets and don't have
            # get_parent(), so we just ignore them.
            try:
                cv_parent = cell_view.get_parent()
            except AttributeError:
                pass
            else:
                if isinstance(cv_parent, gtk.MenuItem) \
                       and (cv_parent not in self.tipmap or
                            self.tipmap[cv_parent] != tip_text):
                    self.tipmap[cv_parent] = tip_text
                    tooltips.set_tooltip_text(cv_parent,tip_text)
Beispiel #2
0
    def setByRegistration(self, registration, interactive=0):
        debug.mainthreadTest()
        # setByRegistration() is almost the same as optionCB(), except
        # that it makes no attempt to set the new parameters from the
        # old ones, since it's not being used to switch between
        # convertible classes.  In fact, it may be used to switch to a
        # new instance of the same class, so it's important to throw
        # out the old parameter values.
        if self.includeRegistration(registration):
            if self.paramWidget is not None:
                self.paramWidget.destroy()
                self.options.set_state(registration.name())
                
            self.getBase(registration)

            self.options.set_state(registration.name())
            self.currentOption = registration

            self.paramWidget = self.makeWidget(registration)
            if self.readonly:
                self.makeUneditable()

            ## After the widget has once been set interactively, its
            ## default value isn't used.
            self.useDefault = self.useDefault and not interactive
            self.widgetChanged(self.paramWidget.isValid(), interactive)

            self.box.pack_start(self.paramWidget.gtk, fill=self.fill,
                                expand=self.expand)
            self.show()
            if hasattr(registration, 'tip'):
                tooltips.set_tooltip_text(self.options.gtk,registration.tip)
Beispiel #3
0
    def makeSingleWidget(self, param, tablepos, scope):
        debug.mainthreadTest()
        widget = param.makeWidget(scope=scope)
        self.widgets.append(widget)

        self.sbcallbacks += [
            switchboard.requestCallbackMain(('validity', widget), self.vcheck,
                                            tablepos),
            switchboard.requestCallbackMain(widget, self.widgetChangeCB)
            ]
        self.validities[tablepos] = widget.isValid()
        
        label = gtk.Label(param.name + ' =')
        label.set_alignment(1.0, 0.5)
        self.labels.append(label)
        if param.tip:
            tooltips.set_tooltip_text(label,param.tip)
        if widget.expandable:
            yoptions = gtk.EXPAND | gtk.FILL
            self.expandable = True
        else:
            yoptions = 0
        if self.showLabels:
            self.gtk.attach(label, 0, 1, tablepos, tablepos+1, xpadding=5,
                            xoptions=gtk.FILL, yoptions=yoptions)
        self.gtk.attach(widget.gtk, 1, 2, tablepos, tablepos+1, xpadding=5,
                        xoptions=gtk.EXPAND|gtk.FILL, yoptions=yoptions)
Beispiel #4
0
 def setFieldActiveTip(self, button, field):
     if button.get_active():
         verb = "Deactivate"
     else:
         verb = "Activate"
     tooltips.set_tooltip_text(button,
         "%s the %s field on the subproblem. The solver finds the values of the active fields by solving the active equations."
         % (verb, field.name()))
Beispiel #5
0
 def setFieldDefineTip(self, button, field):
     if button.get_active():
         verb = "Undefine"
     else:
         verb = "Define"
     tooltips.set_tooltip_text(button,
         "%s the %s field on the mesh.  Only defined fields have values."
         % (verb, field.name()))
Beispiel #6
0
 def setFieldInPlaneTip(self, button, field):
     debug.mainthreadTest()
     if button.get_active():
         verb = "Do not constrain"
     else:
         verb = "Constrain"
     tooltips.set_tooltip_text(button,
         "%s the derivatives of the %s field to lie in the x-y plane."
         % (verb, field.name()))
Beispiel #7
0
 def __init__(self, param, scope=None, name=None):
     AutoWidget.__init__(self, param, scope=scope, name=name)
     # Avoid querying param.value here, as it will trigger the
     # autoname resolution process if the parameter is an
     # AutomaticNameParameter or ContextualNameParameter.
     if param.automatic():
         self.set_value(automatic.automatic)
         self.widgetChanged(1, interactive=0)
     else:
         self.set_value(param.truevalue)
         self.widgetChanged(self.validText(param.truevalue), interactive=0)
     tooltips.set_tooltip_text(self.autocheck,
         'Switch between typed names and automatically generated names.')
Beispiel #8
0
    def optionFinish(self, registration, interactive):
        debug.mainthreadTest()
        self.paramWidget = self.makeWidget(registration)
        if self.readonly:
            self.makeUneditable()
        self.widgetChanged(self.paramWidget.isValid(), interactive)
        
        self.box.pack_start(self.paramWidget.gtk, fill=0, expand=0)
        self.show()
        if hasattr(registration, 'tip'):
            tooltips.set_tooltip_text(self.options.gtk,registration.tip)

        self.useDefault = False
        if self.callback:
            self.callback(registration, *self.callbackargs,
                          **self.callbackkwargs)
Beispiel #9
0
def _gtklabel(self, gtkitem):
    debug.mainthreadTest()
    name = utils.underscore2space(self.name)
    # Add ellipsis automatically if there's an automatically generated
    # gui_callback.
    if self.ellipsis or (self.params and not self.gui_callback):
        name = name + '...'
    if self.accel:
        label = gtk.AccelLabel(name)
        label.set_accel_widget(gtkitem)
    else:
        label = gtk.Label(name)
    label.set_alignment(0.0, 0.5)
    tooltips.set_tooltip_text(label,self.helpstr)
    label.show_all()
    return label
Beispiel #10
0
    def sensitize(self):
        debug.mainthreadTest()
        # If currentPageName is None, then the GUI hasn't been shown yet.
        if self.currentPageName is not None:
            which = pagenames.index(self.currentPageName)
            self.nextPageButton.set_sensitive(which != len(pagenames) - 1)
            self.prevPageButton.set_sensitive(which != 0)

            if which < len(pagenames) - 1:
                tooltips.set_tooltip_text(
                    self.nextPageButton, "Go to the %s page" % allPages[pagenames[which + 1]].name
                )
            if which > 0:
                tooltips.set_tooltip_text(
                    self.prevPageButton, "Go to the %s page" % allPages[pagenames[which - 1]].name
                )
        self.sensitizeHistory()
Beispiel #11
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()
Beispiel #12
0
    def __init__(self, param, scope=None, name=None):
        debug.mainthreadTest()
        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        self.table = gtk.Table(rows=1, columns=3)
        self.table.set_row_spacings(0)
        self.table.set_col_spacings(0)
        frame.add(self.table)
        gtklogger.setWidgetName(self.table, 'GroupTable')

        addbutton = gtk.Button('+')
        gtklogger.setWidgetName(addbutton, "Add")
        gtklogger.connect(addbutton, 'clicked', self.addCB)
        self.table.attach(addbutton, 0,1, 0,1, xoptions=gtk.FILL, yoptions=0,
                     xpadding=0, ypadding=0)
        tooltips.set_tooltip_text(addbutton, "Add a new group definition.")

        clabel = gtk.Label("Column")
        clabel.set_alignment(0.0, 0.5)
        cframe = gtk.Frame()
        cframe.set_shadow_type(gtk.SHADOW_OUT)
        cframe.add(clabel)
        self.table.attach(cframe, 1,2, 0,1,
                          xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL,
                          xpadding=0, ypadding=0)

        nlabel = gtk.Label("Name")
        nlabel.set_alignment(0.0, 0.5)
        nframe = gtk.Frame()
        nframe.set_shadow_type(gtk.SHADOW_OUT)
        nframe.add(nlabel)
        self.table.attach(nframe, 2,3, 0,1,
                          xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL,
                          xpadding=0, ypadding=0)

        self.rows = []          #  list of GCWidgetRow objects

        parameterwidgets.ParameterWidget.__init__(self, frame, scope=scope,
                                                  name=name)
        if param.value is not None:
            self.set_value(param.value)
        self.widgetChanged(self.checkValue(), interactive=0)
Beispiel #13
0
 def __init__(self, registration, rclfactory):
     debug.mainthreadTest()
     self.registration = registration
     self.rclfactory = rclfactory
     self._button = gtk.CheckButton()
     gtklogger.setWidgetName(self._button, registration.name()+'Toggle')
     # We could use an Expander instead of a CheckButton here, but
     # it might be confusing.  The check button makes it clear that
     # a method is selected.  Just expanding an Expander might not
     # be so obvious, especially if a Registration has no
     # Parameters.  Also, the whole RegisteredClassListFactory
     # would have to be redone.
     self._signal = gtklogger.connect(self._button, 'clicked', self.buttonCB)
     self._box = gtk.VBox()
     self._label = gtk.Label(registration.name())
     self._label.set_alignment(0.0, 0.5)
     if hasattr(registration, 'tip'):
         tooltips.set_tooltip_text(self._label,registration.tip)
     self.sbcallback = None
     self.makeWidget()
Beispiel #14
0
 def sensitizeHistory(self):
     debug.mainthreadTest()
     self.nextHistoryButton.set_sensitive(self.historian.nextSensitive())
     self.prevHistoryButton.set_sensitive(self.historian.prevSensitive())
     next = self.historian.nextVal()
     if next is not None:
         tooltips.set_tooltip_text(self.nextHistoryButton, "Go to the chronologically next page, %s." % next)
     else:
         tooltips.set_tooltip_text(self.nextHistoryButton, "Go to the chronologically next page.")
     prev = self.historian.prevVal()
     if prev is not None:
         tooltips.set_tooltip_text(self.prevHistoryButton, "Go the chronologically previous page, %s." % prev)
     else:
         tooltips.set_tooltip_text(self.prevHistoryButton, "Go the chronologically previous page.")
Beispiel #15
0
    def __init__(self, table, row, parent):
        self.deleteButton = gtk.Button('-')
        table.attach(self.deleteButton, 0,1, row+1,row+2,
                     xoptions=gtk.FILL, yoptions=0, xpadding=0, ypadding=0)
        gtklogger.setWidgetName(self.deleteButton, 'Delete%d' % row)
        gtklogger.connect(self.deleteButton, 'clicked', parent.deleteRowCB, row)
        tooltips.set_tooltip_text(self.deleteButton,
                                  "Delete this group definition.")

        self.colEntry = gtk.Entry()
        table.attach(self.colEntry, 1,2, row+1,row+2,
                     xoptions=0, yoptions=0, xpadding=0, ypadding=0)
        self.colSignal = gtklogger.connect(self.colEntry, 'changed',
                                           parent.changedCB)
        gtklogger.setWidgetName(self.colEntry, 'Column%d' % row)
        tooltips.set_tooltip_text(
            self.colEntry,
            'A column number.  Points in the data file with different '
            'values in this column will be assigned to different pixel groups.'
            )

        self.nameEntry = gtk.Entry()
        self.nameEntry.set_text('group_%s')
        table.attach(self.nameEntry, 2,3, row+1,row+2,
                     xoptions=gtk.FILL|gtk.EXPAND, yoptions=0,
                     xpadding=0, ypadding=0)
        self.nameSignal = gtklogger.connect(self.nameEntry, 'changed',
                                            parent.changedCB)
        gtklogger.setWidgetName(self.nameEntry, 'Name%d' % row)
        tooltips.set_tooltip_text(
            self.nameEntry, 
            'The name to assign to the group. A "%s" in the name '
            'will be replaced by the contents of the column.'
            )
    def __init__(self, set_callback, ok_callback):
        debug.mainthreadTest()
        self.gtk = gtk.HBox()
        self.set_callback = set_callback
        self.historian = historian.Historian(self.setCB,
                                             self.sensitize)

        # Buttons:  Previous, OK, and next.
        self.prevbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevbutton, "clicked", self.historian.prevCB)
        tooltips.set_tooltip_text(self.prevbutton,
            "Recall the previous selection modification operation.")
        self.gtk.pack_start(self.prevbutton, expand=0, fill=0, padding=2)

        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        gtklogger.setWidgetName(self.okbutton, 'OK')
        gtklogger.connect(self.okbutton, "clicked", ok_callback)
        self.gtk.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        tooltips.set_tooltip_text(self.okbutton,
            "Perform the selection modification operation.")
        self.okbutton.set_sensitive(0)
        
        self.nextbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextbutton, "clicked", self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextbutton,
            "Recall the next selection modification operation.")
        self.gtk.pack_start(self.nextbutton, expand=0, fill=0, padding=2)
Beispiel #17
0
    def __init__(self, scope, name=None):
        debug.mainthreadTest()

        parameterwidgets.ParameterWidget.__init__(self, gtk.HBox(), scope=scope,
                                                  name=name)
        self.times = []
        self.signals = []
        self.sbcallbacks = []
        
        self.earliestButton = gtkutils.StockButton(gtk.STOCK_MEDIA_REWIND)
        gtklogger.setWidgetName(self.earliestButton, 'earliest')
        self.signals.append(gtklogger.connect(self.earliestButton, 'clicked',
                                              self.extremeCB, 
                                              placeholder.earliest))
        self.gtk.pack_start(self.earliestButton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.earliestButton,
                             "Use the earliest stored time.")

        self.prevButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        gtklogger.setWidgetName(self.prevButton, "Prev")
        self.signals.append(gtklogger.connect(self.prevButton, 'clicked', 
                                              self.prevCB))
        self.gtk.pack_start(self.prevButton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.prevButton,
                             "Go to an earlier time saved in the mesh.")

        self.text = gtk.Entry()
        gtklogger.setWidgetName(self.text, 'Text')
        self.signals.append(gtklogger.connect(self.text, 'changed',
                                              self.entryCB))
        self.gtk.pack_start(self.text, expand=1, fill=1)

        self.nextButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        gtklogger.setWidgetName(self.nextButton, "Next")
        gtklogger.connect(self.nextButton, 'clicked', self.nextCB)
        self.gtk.pack_start(self.nextButton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.nextButton,
                             "Go to a later time saved in the mesh.")

        self.latestButton = gtkutils.StockButton(gtk.STOCK_MEDIA_FORWARD)
        gtklogger.setWidgetName(self.latestButton, 'latest')
        self.signals.append(gtklogger.connect(self.latestButton, 'clicked',
                                              self.extremeCB,
                                              placeholder.latest))
        self.gtk.pack_start(self.latestButton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.latestButton,
                             "Use the latest stored time.")
        
        self.mode = placeholder.latest # 'earliest', 'latest', or None
Beispiel #18
0
 def build_eqnTable(self):
     debug.mainthreadTest()
     self.eqntable.foreach(gtk.Object.destroy) # clear the table
     self.eqnbuttons = {}
     eqlist = equation.allEquations
     self.eqntable.resize(len(eqlist), 3)
     row=0
     for eqn in eqlist:
         label = gtk.Label(utils.underscore2space(eqn.name()))
         label.set_alignment(1.0, 0.5)
         self.eqntable.attach(label, 0,1, row, row+1,
                              xoptions=gtk.FILL, yoptions=0)
         button = gtk.CheckButton('active')
         gtklogger.setWidgetName(button, eqn.name() + " active")
         signal = gtklogger.connect(button, 'clicked', self.eqnButtonCB, eqn)
         self.eqnbuttons[(eqn.name(), "active")] = ButtonSignal(button,
                                                                signal)
         tooltips.set_tooltip_text(button,'Active equations will be solved.')
         self.eqntable.attach(button, 2,3, row,row+1, xoptions=0,
                              yoptions=0)
         row += 1
     self.eqntable.attach(gtk.VSeparator(), 1,2, 0,len(eqlist),
                          xoptions=0, yoptions=gtk.EXPAND|gtk.FILL)
     self.eqntable.set_col_spacing(0, 3)
    def __init__(self, param=None, scope=None, name=None, framed=True):
        debug.mainthreadTest()
        vbox = gtk.VBox(spacing=2)
        if framed:
            parameterwidgets.ParameterWidget.__init__(self, gtk.Frame(),
                                                  scope=scope, name=name)
            self.gtk.add(vbox)
        else:
            parameterwidgets.ParameterWidget.__init__(self, vbox, scope=scope,
                                                      name=name)

        self.chooser = chooser.ChooserWidget([], callback=self.chooserCB,
                                             name='Chooser')
        vbox.pack_start(self.chooser.gtk, expand=False, fill=False)
        bbox = gtk.HBox(spacing=2, homogeneous=True)
        vbox.pack_start(bbox, expand=0, fill=0)

        newbutton = gtkutils.StockButton(gtk.STOCK_NEW, "New...")
        gtklogger.setWidgetName(newbutton, "New")
        bbox.pack_start(newbutton, expand=True, fill=True)
        gtklogger.connect(newbutton, 'clicked', self.newCB)
        tooltips.set_tooltip_text(newbutton,
                                  "Open a new file for output.")

        self.rewindbutton = gtkutils.StockButton(gtk.STOCK_MEDIA_REWIND,
                                                 "Rewind")
        gtklogger.setWidgetName(self.rewindbutton, "Rewind")
        bbox.pack_start(self.rewindbutton, expand=True, fill=True)
        gtklogger.connect(self.rewindbutton, 'clicked', self.rewindCB)
        tooltips.set_tooltip_text(
            self.rewindbutton,
            "Rewind the selected file.  Data will be lost.")

        self.clearbutton = gtkutils.StockButton(gtk.STOCK_CLEAR, "Clear")
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        bbox.pack_start(self.clearbutton, expand=True, fill=True)
        gtklogger.connect(self.clearbutton, 'clicked', self.clearCB)
        tooltips.set_tooltip_text(
            self.clearbutton,
            "Close all files and remove them from the list.")

        self.sbcallback = switchboard.requestCallbackMain(
            'output destinations changed', self.rebuild)

        self.rebuild()
        if param and param.value is not None:
            self.set_value(param.value)
        self.widgetChanged(True, interactive=False)
Beispiel #20
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)
Beispiel #21
0
    def __init__(self):
        debug.mainthreadTest()
        self.menu_name = "MessageWindow_%d" % MessageWindow.count
        self.title = "%s Messages %d" % (subWindow.oofname(),MessageWindow.count)
        self.windows_menu_name = "Message_%d" % MessageWindow.count
        
        subWindow.SubWindow.__init__(
            self, title=self.title, menu=self.menu_name)

        # We are locally responsible for the windows submenu items.
        self.gtk.connect("destroy", self.destroy)

        # raise_window function is provided by the SubWindow class.
        OOF.Windows.Messages.addItem(
            oofmenu.OOFMenuItem(
            self.windows_menu_name,
            help="Raise Message window %d." % MessageWindow.count,
            cli_only=0, no_log=1,
            gui_callback=self.raise_window) )
            
        MessageWindow.count += 1

        allMessageWindows.add(self)

        # Control box, with buttons.  These could be menu items.
        controlbox = gtk.Frame()
        controlbox.set_shadow_type(gtk.SHADOW_OUT)
        self.mainbox.pack_start(controlbox, expand=0, fill=0)
        controlinnards = gtk.VBox()
        controlbox.add(controlinnards)
        buttonbox = gtk.HBox()
        controlinnards.pack_start(buttonbox, expand=0, padding=2)
        savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...")
        tooltips.set_tooltip_text(savebutton,
            "Save the contents of this window to a file.")
        buttonbox.pack_start(savebutton, expand=0, fill=0, padding=2)
        gtklogger.setWidgetName(savebutton, "Save")
        gtklogger.connect(savebutton, 'clicked', self.saveButtonCB)

        self.button_dict = {}
        self.signal_dict = {}
        for m in reporter.messageclasses:
            button = gtk.CheckButton(m)
            gtklogger.setWidgetName(button, m)
            buttonbox.pack_end(button, fill=0, expand=0, padding=2)
            self.signal_dict[m] = gtklogger.connect(button, "clicked",
                                                    self.button_click)
            self.button_dict[m] = button
            tooltips.set_tooltip_text(button,
                "Show or hide "+ reporter.messagedescriptions[m])

        messagepane = gtk.ScrolledWindow()
        ## The ScrolledWindow's scrollbars are *not* logged in the
        ## gui, because blocking the adjustment "changed" signals in
        ## the write_message function, below, doesn't work to suppress
        ## logging.  This means that programmatic changes to the
        ## scrollbars are logged along with user changes, which fills
        ## up the log file with extraneous lines.
        messagepane.set_border_width(4)
        messagepane.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.mainbox.add(messagepane)

        self.messages = gtk.TextView()
        gtklogger.setWidgetName(self.messages, "Text")
        self.messages.set_editable(False)
        self.messages.set_cursor_visible(False)
        self.messages.set_wrap_mode(gtk.WRAP_WORD)
        self.changeFont(mainmenuGUI.getFixedFont())

        self.gtk.set_default_size(
            90*gtkutils.widgetCharSize(self.messages), 200)

        # Get two marks to be used for automatic scrolling
        bfr = self.messages.get_buffer()
        enditer = bfr.get_end_iter()
        self.endmark = bfr.create_mark(None, enditer, False)
        self.midmark = bfr.create_mark(None, enditer, False)

        messagepane.add(self.messages)

        self.state_dict = {}
        for m in reporter.messageclasses:
            self.state_dict[m]=1
            
        self.sbcbs = [
            switchboard.requestCallbackMain("write message",
                                            self.write_message),
            switchboard.requestCallbackMain("change fixed font",
                                            self.changeFont)
            ]

        self.draw()
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(
            self, name="Skeleton Selection",
            ordering = 135,
            tip = "Manipulate selectable skeleton objects.")

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

        self.skelwidgetbox = gtk.Alignment(xalign=0.5)
        self.mainbox.pack_start(self.skelwidgetbox, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        self.skelwidgetbox.add(centerbox)
        self.skelwidget = whowidget.WhoWidget(skeletoncontext.skeletonContexts,
                                              scope=self)
        self.skelwidget.verbose = True
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.skelwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label('Skeleton=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.skelwidget.gtk[1], expand=0, fill=0)

        self.modebox = gtk.Alignment(xalign=0.5)
        gtklogger.setWidgetName(self.modebox, 'Mode')
        self.mainbox.pack_start(self.modebox, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        self.modebox.add(centerbox)
        label = gtk.Label("Selection Mode:")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)

        # Construct buttons for switching between selection modes, and
        # the ModeData objects that contain the mode-specific data and
        # widgets.
        self.modedict = {}
        firstbutton = None
        for mode in skeletonselmodebase.SkeletonSelectionMode.modes:
            name = mode.name
            modedata = self.modedict[name] = ModeData(self, mode)
            if firstbutton:
                button = gtk.RadioButton(label=name+'s', group=firstbutton)
            else:
                button = gtk.RadioButton(label=name+'s')
                firstbutton = button
                self.activemode = modedata
            gtklogger.setWidgetName(button, name)
            modedata.button = button
            tooltips.set_tooltip_text(button,"Select " + name + "s")
            centerbox.pack_start(button, expand=0, fill=0)
            gtklogger.connect(button, 'clicked', self.pickerCB, modedata)
            switchboard.requestCallbackMain(
                modedata.mode.changedselectionsignal,
                self.newSelection, mode=modedata)
            switchboard.requestCallbackMain(
                modedata.mode.modifierappliedsignal,
                self.modifiedSelection, mode=modedata)
        firstbutton.set_active(1)

        self.mainpane = gtk.HPaned()
        gtklogger.setWidgetName(self.mainpane, 'Pane')
        self.mainbox.pack_start(self.mainpane, expand=1, fill=1)
        gtklogger.connect_passive(self.mainpane, 'notify::position')
        
        # Status and Group are on the left side of the page.
        self.leftbox = gtk.VBox(spacing=3)
        self.mainpane.pack1(self.leftbox, resize=1, shrink=0)

        # Status box.
        self.statusframe = gtk.Frame()
        self.leftbox.pack_start(self.statusframe, expand=0, fill=0)
        self.statusframe.set_shadow_type(gtk.SHADOW_IN)
        self.status = gtk.Label()
        gtklogger.setWidgetName(self.status, 'status')
        self.status.set_alignment(0.0, 0.5)
        self.statusframe.add(self.status)

        # Group operations.
        self.groupgui = GroupGUI(self)
        self.leftbox.pack_start(self.groupgui.gtk, expand=1, fill=1)

        # Selection operations on the right side of the page.
        self.selectiongui = SelectionGUI(self)
        self.mainpane.pack2(self.selectiongui.gtk, resize=0, shrink=0)

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.new_microstructure)
        switchboard.requestCallbackMain(self.skelwidget, self.skelwidgetCB)
        switchboard.requestCallbackMain("materials changed in skeleton",
                                        self.matchangedCB)

        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
    def __init__(self, parent):
        debug.mainthreadTest()
        self.parent = parent
        self.gtk = gtk.Frame()
        gtklogger.setWidgetName(self.gtk, 'Selection')
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        self.vbox = gtk.VBox()
        self.gtk.add(self.vbox)

        self.actionbox = gtk.VBox()
        self.vbox.pack_start(self.actionbox, expand=1, fill=1)

        self.historyline = gtk.VBox()
        self.vbox.pack_start(self.historyline, expand=0, fill=0, padding=4)

        for modeobj in parent.modedict.values():
            modeobj.factory = regclassfactory.RegisteredClassFactory(
                modeobj.mode.modifierclass.registry,
                title="Action: ",
                scope=parent, name=modeobj.name()+"Action")
            modeobj.historybox = HistoryBox(self.setCB, self.okCB)
            gtklogger.setWidgetName(modeobj.historybox.gtk,
                                    modeobj.name()+"History")
            modeobj.factory.set_callback(
                modeobj.historybox.historian.stateChangeCB)
            # Sensitize the history stuff when the selections are modified.
            switchboard.requestCallbackMain(modeobj.mode.modifierappliedsignal,
                                            modeobj.modifierApplied)
            switchboard.requestCallbackMain(('validity', modeobj.factory),
                                            modeobj.validityChangeCB)

        # Slightly misleading name, includes undo, redo and clear.
        self.undoredoline = gtk.HBox()
        
        self.undo_button = gtk.Button(stock=gtk.STOCK_UNDO)
        gtklogger.setWidgetName(self.undo_button, 'Undo')
        gtklogger.connect(self.undo_button, "clicked", self.undoCB)
        tooltips.set_tooltip_text(self.undo_button,
            "Undo the latest selection operation.")
        self.undoredoline.pack_start(self.undo_button, expand=1, fill=0)

        self.redo_button = gtk.Button(stock=gtk.STOCK_REDO)
        gtklogger.setWidgetName(self.redo_button, 'Redo')
        gtklogger.connect(self.redo_button, "clicked", self.redoCB)
        tooltips.set_tooltip_text(self.redo_button,
            'Redo the latest undone selection operation.')
        self.undoredoline.pack_start(self.redo_button, expand=1, fill=0)

        self.clear_button = gtk.Button(stock=gtk.STOCK_CLEAR)
        gtklogger.setWidgetName(self.clear_button, 'Clear')
        gtklogger.connect(self.clear_button, "clicked", self.clearCB)
        tooltips.set_tooltip_text(self.clear_button,
            'Reset selection by clearing the current selection.')        
        self.undoredoline.pack_start(self.clear_button, expand=1, fill=0)

        self.invert_button = gtk.Button("Invert")
        gtklogger.setWidgetName(self.invert_button, 'Invert')
        gtklogger.connect(self.invert_button, "clicked", self.invertCB)
        tooltips.set_tooltip_text(self.invert_button,'Toggle the current selection.')
        self.undoredoline.pack_start(self.invert_button, expand=1, fill=0)
        
        self.vbox.pack_start(self.undoredoline, expand=0, fill=0, padding=2)

        # Add all the action and history widgets.  They do not
        # all get shown, see this class's "show" routine for the drill.
        for modeobj in parent.modedict.values():
            self.actionbox.pack_start(modeobj.factory.gtk, expand=1, fill=1)
            self.historyline.pack_start(modeobj.historybox.gtk,
                                        expand=0, fill=0)

        self.sensitize()
    def __init__(self, parent):
        debug.mainthreadTest()
        self.parent = parent
        self.gtk = gtk.Frame()
        gtklogger.setWidgetName(self.gtk, 'Groups')
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        box = gtk.HBox(spacing=2)
        self.gtk.add(box)
        # Set in chooserCB, the widget callback for the chooser list.
        self.current_group_name = None
        # List of buttons which are sensitive only when a group is selected.
        self.groupbuttons = []
        # List of buttons which are sensitive when there is a group
        # and a selection.
        self.groupandselectionbuttons = []

        # Left-hand button box.  New/Auto/Rename/Copy/Delete/DeleteAll
        lbuttons = gtk.VBox(spacing=2)
        box.pack_start(lbuttons, fill=0, expand=0)

        self.new_button = gtk.Button("New...")
        gtklogger.setWidgetName(self.new_button, 'New')
        lbuttons.pack_start(self.new_button, fill=0, expand=0)
        gtklogger.connect(self.new_button, "clicked", self.newGroupCB)
        tooltips.set_tooltip_text(self.new_button,"Create a new empty group.")

        self.auto_button = gtk.Button("Auto")
        gtklogger.setWidgetName(self.auto_button, 'Auto')
        lbuttons.pack_start(self.auto_button, fill=0, expand=0)
        gtklogger.connect(self.auto_button, 'clicked', self.autoGroupCB)
        tooltips.set_tooltip_text(self.auto_button,
            "Automatically create groups from the current pixel groups.")
        
        self.rename_button = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.rename_button, 'Rename')
        lbuttons.pack_start(self.rename_button, fill=0, expand=0)
        self.groupbuttons.append(self.rename_button)
        gtklogger.connect(self.rename_button, "clicked", self.renameGroupCB)
        tooltips.set_tooltip_text(self.rename_button,"Rename the selected group.")

        self.copy_button = gtk.Button("Copy...")
        gtklogger.setWidgetName(self.copy_button, 'Copy')
        lbuttons.pack_start(self.copy_button, fill=0, expand=0)
        self.groupbuttons.append(self.copy_button)
        gtklogger.connect(self.copy_button, "clicked", self.copyGroupCB)
        tooltips.set_tooltip_text(self.copy_button,"Copy the selected group.")

        self.delete_button = gtk.Button("Delete")
        gtklogger.setWidgetName(self.delete_button, 'Delete')
        lbuttons.pack_start(self.delete_button, fill=0, expand=0)
        self.groupbuttons.append(self.delete_button)
        gtklogger.connect(self.delete_button, "clicked", self.deleteGroupCB)
        tooltips.set_tooltip_text(self.delete_button,"Deleted the selected group.")

        self.deleteAll_button = gtk.Button("Delete All")
        gtklogger.setWidgetName(self.deleteAll_button, 'DeleteAll')
        lbuttons.pack_start(self.deleteAll_button, fill=0, expand=0)
        gtklogger.connect(self.deleteAll_button, 'clicked', self.deleteAllCB)
        tooltips.set_tooltip_text(self.deleteAll_button,"Delete all groups.")
        
        # Groups list.
        self.grouplist = chooser.ScrolledChooserListWidget(
            callback=self.chooserCB, name="GroupList")
        box.pack_start(self.grouplist.gtk, fill=1, expand=1)
        
        # Right-hand button box.  Add/Remove/Clear/ClearAll/Info
        rbuttons = gtk.VBox(spacing=2)
        box.pack_start(rbuttons, fill=0, expand=0)

        self.add_button = gtk.Button("Add")
        gtklogger.setWidgetName(self.add_button, 'Add')
        rbuttons.pack_start(self.add_button, fill=0, expand=0)
        self.groupandselectionbuttons.append(self.add_button)
        gtklogger.connect(self.add_button, "clicked", self.addToGroupCB)
        tooltips.set_tooltip_text(self.add_button,
            "Add the currently selected pixels to the selected group.")

        self.remove_button = gtk.Button("Remove")
        gtklogger.setWidgetName(self.remove_button, 'Remove')
        rbuttons.pack_start(self.remove_button, fill=0, expand=0)
        self.groupandselectionbuttons.append(self.remove_button)
        gtklogger.connect(self.remove_button, "clicked", self.removeFromGroupCB)
        tooltips.set_tooltip_text(self.remove_button,
              "Remove the currently selected pixels from the selected group.")
        
        self.clear_button = gtk.Button("Clear")
        gtklogger.setWidgetName(self.clear_button, 'Clear')
        rbuttons.pack_start(self.clear_button, fill=0, expand=0)
        gtklogger.connect(self.clear_button, "clicked", self.clearGroupCB)
        tooltips.set_tooltip_text(self.clear_button,
            "Remove all pixels from the selected group.")

        self.clearAll_button = gtk.Button("Clear All")
        gtklogger.setWidgetName(self.clearAll_button, 'ClearAll')
        rbuttons.pack_start(self.clearAll_button, fill=0, expand=0)
        gtklogger.connect(self.clearAll_button, "clicked", self.clearAllCB)
        tooltips.set_tooltip_text(self.clearAll_button,
            "Remove all pixels from all groups.")

        self.info_button = gtk.Button("Info")
        gtklogger.setWidgetName(self.info_button, 'Info')
        rbuttons.pack_start(self.info_button, fill=0, expand=0)
        self.groupbuttons.append(self.info_button)
        gtklogger.connect(self.info_button, "clicked", self.queryGroupCB)
        tooltips.set_tooltip_text(self.info_button,
            "Display information about the selected group in the OOF Messages window.")
        
        ## TODO: Hide this frame when mode.materialsallowed is False.
        matframe = gtk.Frame("Material")
#        matframe.set_shadow_type(gtk.SHADOW_IN)
        rbuttons.pack_start(matframe, expand=0, fill=0, padding=3)
        matbox = gtk.VBox(spacing=2)
        matframe.add(matbox)

        self.addmaterial_button = gtk.Button("Assign")
        gtklogger.setWidgetName(self.addmaterial_button, 'AddMaterial')
        matbox.pack_start(self.addmaterial_button, fill=0, expand=0)
        gtklogger.connect(self.addmaterial_button, "clicked",
                          self.addMaterialCB)
        tooltips.set_tooltip_text(self.addmaterial_button,
            "Assign a material to the members of the selected group.")

        self.removematerial_button = gtk.Button("Remove")
        matbox.pack_start(self.removematerial_button, fill=0, expand=0)
        gtklogger.connect(self.removematerial_button, "clicked",
                          self.removeMaterialCB)
        tooltips.set_tooltip_text(self.removematerial_button,
            "Remove an explicitly assigned material from the members of the selected group.")
        
        # Need to be notified when groupset memberships change.
        switchboard.requestCallback("groupset member added", self.group_added),
        switchboard.requestCallback("groupset member renamed",
                                    self.group_added),
        switchboard.requestCallback("groupset changed", self.groupset_changed),
        switchboard.requestCallback("groupset member resized",
                                    self.group_resized)
        switchboard.requestCallback("new pixel group", self.pxlgroup_added)
        switchboard.requestCallback("destroy pixel group", self.pxlgroup_added)
Beispiel #25
0
 def set_tooltips(self, slider=None, entry=None):
     if slider:
         tooltips.set_tooltip_text(self.slider, slider)
     if entry:
         tooltips.set_tooltip_text(self.entry, entry)
Beispiel #26
0
    def __init__(self, movenodetoolbox):
        debug.mainthreadTest()
        self.downed = 0                 # is the mouse button down?
        self.moving = 0                 # in the middle of a move
        self.movingnode = None          # node being moved
        # writable should only be set by self.set_writable, which
        # issues a checkpoint.
        self.writable = True            # is the top most Skeleton writable?
        self.mode = "Mouse"
        self.mouselock = lock.Lock()
        
        toolboxGUI.GfxToolbox.__init__(self, "Move Nodes", movenodetoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        hbox = gtk.HBox()
        mainbox.pack_start(hbox, expand=0, fill=0)
        gtklogger.setWidgetName(hbox, "MoveWith")
        hbox.pack_start(gtk.Label("Move with: "), expand=0, fill=0)

        modes = [("Mouse", "Click and drag a node to move it."),
                 ("Keyboard",
                  "Select a node, type a position, and click the Move button")
                 ]
        self.modebuttons = []
        for mode, tip in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode,
                                         group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode)
            gtklogger.setWidgetName(button, mode)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(button,tip)
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.mode is mode)
            gtklogger.connect(button, 'clicked', self.changeMode, mode)

        # allow illegal move?
        self.allow_illegal = gtk.CheckButton("Allow illegal moves")
        gtklogger.setWidgetName(self.allow_illegal, "AllowIllegal")
        mainbox.pack_start(self.allow_illegal, expand=0, fill=0, padding=1)
        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        gtklogger.connect(self.allow_illegal, "clicked", self.illegal_status)
        if movenodetoolbox.allow_illegal:
            self.allow_illegal.set_active(1)
        else:
            self.allow_illegal.set_active(0)

        if config.dimension() == 2:
            self.table = gtk.Table(columns=2, rows=6)
            r = 2
        elif config.dimension() == 3:
            self.table = gtk.Table(columns=2, rows=8)
            r = 3
        mainbox.pack_start(self.table, expand=0, fill=0)

        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext, "x")
        self.xsignal = gtklogger.connect_passive(self.xtext, 'changed')
        self.xtext.set_size_request(12*guitop.top().digitsize, -1)
        self.xtext.set_editable(1)
        self.table.attach(self.xtext, 1,2, 0,1,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.xtext,"x position of the mouse")

        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext, 'y')
        self.ysignal = gtklogger.connect_passive(self.ytext, 'changed')
        self.ytext.set_size_request(12*guitop.top().digitsize, -1)        
        self.ytext.set_editable(1)
        self.table.attach(self.ytext, 1,2, 1,2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.ytext,"y position of the mouse")

        if config.dimension() == 3:
            label = gtk.Label('z=')
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 2,3, xpadding=5, xoptions=gtk.FILL)
            self.ztext = gtk.Entry()
            gtklogger.setWidgetName(self.ztext, 'z')
            self.zsignal = gtklogger.connect_passive(self.ztext, 'changed')
            self.ztext.set_size_request(12*guitop.top().digitsize, -1)        
            self.ztext.set_editable(1)
            self.table.attach(self.ztext, 1,2, 2,3,
                              xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
            tooltips.set_tooltip_text(self.ztext,"z position of the mouse")
        
        label = gtk.Label("Change in... ")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r,r+1, xpadding=4,
                          xoptions=gtk.EXPAND|gtk.FILL)

        label = gtk.Label("shape energy=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r+1,r+2, xpadding=5, xoptions=gtk.FILL)
        self.shapetext = gtk.Entry()
        self.shapetext.set_editable(0)
        gtklogger.setWidgetName(self.shapetext,"shape")
        self.shapetext.set_size_request(12*guitop.top().digitsize, -1)        
        self.table.attach(self.shapetext, 1,2, r+1,r+2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.shapetext,"total change in shape energy")

        label = gtk.Label("homogeneity=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r+2,r+3, xpadding=5, xoptions=gtk.FILL)
        self.homogtext = gtk.Entry()
        self.homogtext.set_editable(0)
        gtklogger.setWidgetName(self.homogtext,"homog")
        self.homogtext.set_size_request(12*guitop.top().digitsize, -1)        
        self.table.attach(self.homogtext, 1,2, r+2,r+3,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.homogtext,"total change in homogeneity")

        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        self.statusText = gtk.Label()
        gtklogger.setWidgetName(self.statusText, "Status")
        mainbox.pack_start(self.statusText, expand=0, fill=0, padding=3)
        
        bbox = gtk.HBox(homogeneous=1, spacing=2)
        mainbox.pack_end(bbox, expand=0, fill=0, padding=3)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        tooltips.set_tooltip_text(self.undobutton,"Undo the latest node move.")
        self.movebutton = gtk.Button('Move')
        tooltips.set_tooltip_text(self.movebutton,
                             "Move the selected node to the specified position.")
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        tooltips.set_tooltip_text(self.redobutton,"Redo the latest UNDO.")

        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.setWidgetName(self.redobutton, 'Redo')
        gtklogger.setWidgetName(self.movebutton, 'Move')
        bbox.pack_start(self.undobutton, expand=1, fill=1)
        bbox.pack_start(self.movebutton, expand=1, fill=1)
        bbox.pack_start(self.redobutton, expand=1, fill=1)
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        gtklogger.connect(self.movebutton, 'clicked', self.moveCB)
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)

        self.sbcallbacks = [
            switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                            self.skelChanged),
            switchboard.requestCallbackMain("made reservation",
                                            self.rsrvChanged,
                                            1),
            switchboard.requestCallbackMain("cancelled reservation",
                                            self.rsrvChanged, 0),
            switchboard.requestCallbackMain(("node selected",
                                             movenodetoolbox),
                                            self.nodeSelected),
            switchboard.requestCallbackMain(("illegal-move status changed",
                                             movenodetoolbox),
                                            self.illegal_status_changed),
            switchboard.requestCallbackMain(("skeleton changed", 
                                             movenodetoolbox),
                                            self.layersChanged)
            ]
        self.move_info(None, '---', '---', '')
Beispiel #27
0
from ooflib.common.IO.GUI import parameterwidgets
from ooflib.common.IO.GUI import tooltips
from ooflib.image.IO import imagemenu  # ensures that OOFMenuItems have been created.
from ooflib.image import imagecontext
import gtk

def newMSfromImage(button):
    menuitem = microstructuremenu.micromenu.Create_From_Image
    if parameterwidgets.getParameters(title='Create Microstructure from Image',
                                      *menuitem.params):
        menuitem.callWithDefaults()

newfromimagebutton = gtkutils.StockButton(gtk.STOCK_NEW, "New from Image")
gtklogger.setWidgetName(newfromimagebutton, "NewFromImage")
gtklogger.connect(newfromimagebutton, 'clicked', newMSfromImage)
tooltips.set_tooltip_text(newfromimagebutton,
    "Create a new Microstructure with an Image that has been loaded already.")
newfromimagebutton.set_sensitive(0)


def sensitizeNewFromImageButton():
    newfromimagebutton.set_sensitive(imagecontext.imageContexts.nActual() > 0)

microstructurePage.addNewButton(newfromimagebutton, sensitizeNewFromImageButton)

def newwhoCB(path):
    sensitizeNewFromImageButton()
    
switchboard.requestCallbackMain(('new who', 'Image'), newwhoCB)
switchboard.requestCallbackMain(('remove who', 'Image'), newwhoCB)

##############
Beispiel #28
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self, name="Solver",
            ordering=240,
            tip="Find solutions for static and time-dependent problems.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        switchboard.requestCallbackMain(self.meshwidget, self.meshCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)

        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)

        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        mainvpane = gtk.VPaned()
        gtklogger.setWidgetName(mainvpane, 'VPane')
        mainbox.pack_start(mainvpane, expand=1, fill=1)
        gtklogger.connect_passive(mainvpane, 'notify::position')

        # Subproblem pane

        ## TODO: Make it possible to reorder the subproblems by
        ## drag and drop.

        subprobframe = gtk.Frame('Solvers')
        gtklogger.setWidgetName(subprobframe, "Subproblems")
        subprobframe.set_shadow_type(gtk.SHADOW_IN)
        mainvpane.pack1(subprobframe, resize=1, shrink=0)
        subpvbox = gtk.VBox()   # contains scrolled list and buttons
        subpvbox.set_border_width(3)
        subprobframe.add(subpvbox)
        innerframe = gtk.Frame()
        innerframe.set_shadow_type(gtk.SHADOW_IN)
        subpvbox.pack_start(innerframe, expand=1, fill=1)
        self.subpScroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.subpScroll, "SubproblemScroll")
        self.subpScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        innerframe.add(self.subpScroll)

        self.subprobList = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.subpListView = gtk.TreeView(self.subprobList)
        gtklogger.setWidgetName(self.subpListView, "SubproblemList")
        self.subpScroll.add(self.subpListView)
        gtklogger.adoptGObject(self.subprobList, self.subpListView,
                               access_method=self.subpListView.get_model)
        # Catch selection changes
        gtklogger.adoptGObject(self.subpListView.get_selection(),
                               self.subpListView,
                               access_method=self.subpListView.get_selection)
        self.subpselsig = gtklogger.connect(self.subpListView.get_selection(),
                                            'changed', self.subpSelectCB)
        # Catch double clicks or returns
        gtklogger.connect(self.subpListView, 'row-activated',
                          self.subpActivateRowCB)

        # Order number in the first column
        ordercell = gtk.CellRendererText()
        ordercol = gtk.TreeViewColumn("Order")
        ordercol.set_resizable(False)
        ordercol.pack_start(ordercell, expand=False)
        ordercol.set_cell_data_func(ordercell, self.renderSubproblemOrder)
        self.subpListView.append_column(ordercol)
        # Checkbox in the second column
        solvecell = gtk.CellRendererToggle()
        solvecol = gtk.TreeViewColumn("Solve?")
        solvecol.pack_start(solvecell, expand=False)
        solvecol.set_cell_data_func(solvecell, self.renderSolveCell)
        self.subpListView.append_column(solvecol)
        gtklogger.adoptGObject(solvecell, self.subpListView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={'col':1, 'rend':0})
        gtklogger.connect(solvecell, 'toggled', self.solvecellCB)
        # Subproblem name in the third column
        namecell = gtk.CellRendererText()
        namecol = gtk.TreeViewColumn("Subproblem")
        namecol.set_resizable(True)
        namecol.pack_start(namecell, expand=True)
        namecol.set_cell_data_func(namecell, self.renderSubproblemName)
        self.subpListView.append_column(namecol)
        # Solver in the fourth column
        solvercell = gtk.CellRendererText()
        solvercol = gtk.TreeViewColumn("Solver")
        solvercol.set_resizable(True)
        solvercol.pack_start(solvercell, expand=True)
        solvercol.set_cell_data_func(solvercell, self.renderSubproblemSolver)
        self.subpListView.append_column(solvercol)

        # Buttons at the bottom of the subproblem pane
        subpbbox = gtk.HBox(homogeneous=True)
        subpvbox.pack_start(subpbbox, expand=0, fill=0)
        # Set Solver
        self.setSolverButton = gtkutils.StockButton(gtk.STOCK_ADD, "Set...")
        gtklogger.setWidgetName(self.setSolverButton, "Set")
        gtklogger.connect(self.setSolverButton, 'clicked', self.setSolverCB)
        subpbbox.pack_start(self.setSolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.setSolverButton,
            "Assign a solver to the selected subproblem.")
        # Copy Solver
        self.copySolverButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copySolverButton, "Copy")
        gtklogger.connect(self.copySolverButton, 'clicked', self.copySolverCB)
        subpbbox.pack_start(self.copySolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.copySolverButton,"Copy the selected solver to another subproblem, possibly in another mesh.")
        # Copy All Solvers
        self.copyAllSolversButton = gtkutils.StockButton(gtk.STOCK_COPY,
                                                         "Copy All...")
        gtklogger.setWidgetName(self.copyAllSolversButton, "CopyAll")
        gtklogger.connect(self.copyAllSolversButton, 'clicked',
                          self.copyAllSolversCB)
        subpbbox.pack_start(self.copyAllSolversButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.copyAllSolversButton,"Copy all solvers to identically named subproblems in another mesh.")
        # Remove Solver
        self.removeSolverButton = gtkutils.StockButton(gtk.STOCK_REMOVE,
                                                       "Remove")
        gtklogger.setWidgetName(self.removeSolverButton, "Remove")
        gtklogger.connect(self.removeSolverButton, 'clicked',
                          self.removeSolverCB)
        subpbbox.pack_start(self.removeSolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.removeSolverButton,
            "Delete the solver from the selected subproblem.")
        # Remove all solvers
        self.removeAllSolversButton = gtkutils.StockButton(gtk.STOCK_CLEAR,
                                                           "Remove All")
        gtklogger.setWidgetName(self.removeAllSolversButton, "RemoveAll")
        gtklogger.connect(self.removeAllSolversButton, 'clicked',
                          self.removeAllSolversCB)
        subpbbox.pack_start(self.removeAllSolversButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.removeAllSolversButton,
            "Remove the solver from all subproblems.")
        # Second row of buttons at the bottom of the subproblem pane
        subpbbox = gtk.HBox(homogeneous=True)
        subpvbox.pack_start(subpbbox, expand=0, fill=0)
        # Solve this subproblem first
        self.firstButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST, "First",
                                                align=0.0)
        gtklogger.setWidgetName(self.firstButton, "First")
        gtklogger.connect(self.firstButton, 'clicked', self.firstButtonCB)
        subpbbox.pack_start(self.firstButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.firstButton,"Solve the selected subproblem first when iterating over subproblems.")
        # Solve this subproblem earlier
        self.earlierButton = gtkutils.StockButton(gtk.STOCK_GO_BACK, "Earlier",
                                                  align=0.0)
        gtklogger.setWidgetName(self.earlierButton, "Earlier")
        gtklogger.connect(self.earlierButton, 'clicked', self.earlierButtonCB)
        subpbbox.pack_start(self.earlierButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.earlierButton,"Solve the selected subproblem before the one above it in the list when iterating over subproblems.")
        # Solve this subproblem later
        self.laterButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, "Later",
                                                reverse=True, align=1.0)
        gtklogger.setWidgetName(self.laterButton, "Later")
        gtklogger.connect(self.laterButton, 'clicked', self.laterButtonCB)
        subpbbox.pack_start(self.laterButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.laterButton,"Solve the selected subproblem after the next one in the list when iterating over subproblems.")
        # Solve this subproblem last
        self.lastButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST, "Last",
                                               reverse=True, align=1.0)
        gtklogger.setWidgetName(self.lastButton, "Last")
        gtklogger.connect(self.lastButton, 'clicked', self.lastButtonCB)
        subpbbox.pack_start(self.lastButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.lastButton,"Solve the selected subproblem last when iterating over subproblems.")

        # Field Initializers
        initframe = gtk.Frame('Initialization')
        gtklogger.setWidgetName(initframe, "FieldInit")
        initframe.set_shadow_type(gtk.SHADOW_IN)
        mainvpane.pack2(initframe, resize=1, shrink=0)
        ivbox = gtk.VBox()
        ivbox.set_border_width(3)
        initframe.add(ivbox)
        self.initscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.initscroll, "Scroll")
        self.initscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.initscroll.set_shadow_type(gtk.SHADOW_IN)
        ivbox.pack_start(self.initscroll, expand=1, fill=1)
        # The ListStore just contains the defined Fields.  The
        # TreeView displays their names and initializers.
        self.initlist = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.initview = gtk.TreeView(self.initlist)
        gtklogger.setWidgetName(self.initview, 'Initializers')
        self.initscroll.add(self.initview)
        self.initview.set_headers_clickable(False)
        fieldnamecell = gtk.CellRendererText()
        fieldnamecol = gtk.TreeViewColumn('Field or BC')
        self.initview.append_column(fieldnamecol)
        fieldnamecol.pack_start(fieldnamecell, expand=False)
        fieldnamecol.set_cell_data_func(fieldnamecell, self.renderFieldName)

        fieldinitcell = gtk.CellRendererText()
        fieldinitcol = gtk.TreeViewColumn('Initializer')
        self.initview.append_column(fieldinitcol)
        fieldinitcol.pack_start(fieldinitcell, expand=True)
        fieldinitcol.set_cell_data_func(fieldinitcell, self.renderFieldInit)

        selection = self.initview.get_selection()
        gtklogger.adoptGObject(selection, self.initview,
                               access_method=self.initview.get_selection)
        self.initselsignal = gtklogger.connect(selection, 'changed',
                                               self.initSelectCB)
        gtklogger.connect(self.initview, 'row-activated',
                          self.initActivateRowCB)

        bbox = gtk.HBox(homogeneous=True)
        ivbox.pack_start(bbox, expand=0, fill=0)
        # Set button
        self.fieldinitbutton=gtkutils.StockButton(gtk.STOCK_ADD, 'Set...')
        gtklogger.setWidgetName(self.fieldinitbutton, "Set")
        gtklogger.connect(self.fieldinitbutton, 'clicked',
                          self.fieldinitbuttonCB)
        tooltips.set_tooltip_text(self.fieldinitbutton,'Initialized the selected field.')
        bbox.pack_start(self.fieldinitbutton, expand=0, fill=1)
        # Copy button
        self.copyinitbutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copyinitbutton, 'CopyInit')
        gtklogger.connect(self.copyinitbutton, 'clicked', self.copyinitCB)
        bbox.pack_start(self.copyinitbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.copyinitbutton,
            "Copy field initializers from the current mesh to another mesh.")
        # Clear Initializer button
        self.clearinitbutton = gtkutils.StockButton(gtk.STOCK_REMOVE, "Clear")
        gtklogger.setWidgetName(self.clearinitbutton, "Clear")
        gtklogger.connect(self.clearinitbutton, 'clicked', self.clearinitCB)
        bbox.pack_start(self.clearinitbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.clearinitbutton,
            "Remove the selected field initializer from the current mesh.")
        # Clear All Initializers button
        self.clearallinitsbutton = gtkutils.StockButton(gtk.STOCK_CLEAR,
                                                        "Clear All")
        gtklogger.setWidgetName(self.clearallinitsbutton, 'ClearAll')
        gtklogger.connect(self.clearallinitsbutton, 'clicked',
                          self.clearallinitsCB)
        bbox.pack_start(self.clearallinitsbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.clearallinitsbutton,
            "Remove the field initializers from the current mesh.")

        # Second row of buttons in the Field Initialization pane
        bbox = gtk.HBox(homogeneous=True)
        ivbox.pack_start(bbox, expand=0, fill=1)
        # Apply button
        self.applyinitbutton = gtkutils.StockButton(gtk.STOCK_APPLY, "Apply")
        gtklogger.setWidgetName(self.applyinitbutton, "Apply")
        gtklogger.connect(self.applyinitbutton, 'clicked', self.applyinitCB)
        tooltips.set_tooltip_text(self.applyinitbutton,
            "Apply initializers to all fields at the current time.")
        bbox.pack_start(self.applyinitbutton, expand=0, fill=1)
        # Apply At button
        self.applyinitattimebutton = gtkutils.StockButton(gtk.STOCK_APPLY,
                                                          "Apply at time...")
        gtklogger.setWidgetName(self.applyinitattimebutton, "ApplyAt")
        gtklogger.connect(self.applyinitattimebutton, 'clicked',
                          self.applyinitatCB)
        tooltips.set_tooltip_text(self.applyinitattimebutton,
            "Reset the current time and apply all field initializers.")
        bbox.pack_start(self.applyinitattimebutton, expand=0, fill=1)

        # Table containing status, time entries and Solve button
        table = gtk.Table(rows=2, columns=4)
        mainbox.pack_start(table, expand=0, fill=1)

        # The start time isn't set directly by the user, except by
        # applying field initializers at a given time.  It's displayed
        # in a desensitized gtk.Entry.
        label = gtk.Label('current time=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 0,1, xpadding=3, xoptions=~gtk.EXPAND)
        self.currentTimeEntry = gtk.Entry()
        self.currentTimeEntry.set_sensitive(False) # never sensitive
        table.attach(self.currentTimeEntry, 1,2, 0,1, xpadding=3)
        
        # End time is set by the user.
        label = gtk.Label('end time=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 1,2, xpadding=3, xoptions=~gtk.EXPAND)
        self.endtimeEntry = gtk.Entry()
        gtklogger.setWidgetName(self.endtimeEntry, 'end')
        gtklogger.connect(self.endtimeEntry, 'changed', self.timeChangeCB)
        table.attach(self.endtimeEntry, 1,2, 1,2, xpadding=3)

        # # Step size is set by the user and changed by the program.
        # label = gtk.Label('step size=')
        # label.set_alignment(1.0, 0.5)
        # table.attach(label, 0,1, 2,3, xpadding=3, xoptions=~gtk.EXPAND)
        # self.stepsizeEntry = gtk.Entry()
        # gtklogger.setWidgetName(self.stepsizeEntry, 'stepsize')
        # self.stepsizeSig = gtklogger.connect(self.stepsizeEntry, 'changed',
        #                                      self.timeChangeCB)
        # table.attach(self.stepsizeEntry, 1,2, 2,3, xpadding=3)

        statusFrame = gtk.Frame("Status")
        statusFrame.set_shadow_type(gtk.SHADOW_IN)
        vbox = gtk.VBox()
        statusFrame.add(vbox)
        self.statusLabel = gtk.Label()
        self.statusLabel.set_alignment(0.5, 0.5)
        table.attach(statusFrame, 2,3, 0,3, xpadding=3)
        vbox.pack_start(self.statusLabel, expand=0, fill=0)
        align = gtk.Alignment(xalign=0.5)
        vbox.pack_start(align, expand=0, fill=0, padding=3)
        self.statusDetailButton = gtk.Button("Details...")
        gtklogger.setWidgetName(self.statusDetailButton, 'status')
        gtklogger.connect(self.statusDetailButton, 'clicked', self.statusCB)
        align.add(self.statusDetailButton)

        solveFrame0 = gtk.Frame()
        solveFrame0.set_shadow_type(gtk.SHADOW_OUT)
        solveFrame1 = gtk.Frame()
        solveFrame1.set_shadow_type(gtk.SHADOW_IN)
        solveFrame0.add(solveFrame1)
        table.attach(solveFrame0, 3,4, 0,3, xpadding=3,
                     xoptions=~gtk.EXPAND)
        self.solveButton = gtkutils.StockButton(gtk.STOCK_EXECUTE,
                                                '<b>Solve</b>', markup=True)
        self.solveButton.set_border_width(4)
        gtklogger.setWidgetName(self.solveButton, 'solve')
        gtklogger.connect(self.solveButton, 'clicked', self.solveCB)
        solveFrame1.add(self.solveButton)

        switchboard.requestCallbackMain("field defined", self.defineFldCB)
        switchboard.requestCallbackMain("field initializer set", self.initFldCB)
        switchboard.requestCallbackMain("subproblem changed",
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("mesh changed",
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("subproblem solvability changed",
                                        self.subpSolverChangedCB)
        switchboard.requestCallbackMain("subproblem solver changed",
                                        self.subpSolverChangedCB)
        switchboard.requestCallbackMain("subproblem solvers changed",
                                        self.subpSolversChangedCB),
        switchboard.requestCallbackMain("subproblems reordered",
                                        self.subproblemsChangedCB),
        switchboard.requestCallbackMain(("new who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain(("rename who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain(("remove who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("time changed",
                                        self.meshTimeChangedCB)
        switchboard.requestCallbackMain("mesh solved", self.meshSolvedCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.statusChangedCB)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationCB)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationCB)
Beispiel #29
0
    def __init__(self):
        self.built = False

        oofGUI.MainPage.__init__(self, name="Interfaces",
                                 ordering = 105,
                                 tip = "Create named one-dimensional interfaces.")

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

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)

        #skelwidget is really an mswidget
        self.skelwidget = whowidget.WhoWidget(whoville.getClass('Microstructure'),
                                              scope=self)
        switchboard.requestCallbackMain(self.skelwidget,
                                        self.widgetChanged)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.skelwidget.gtk[0], expand=0, fill=0)
        #We might want to include a skeleton in the widget, if an interface
        #is defined in terms of skeleton segments. For now the interface is
        #only associated with a microstructure
##        label = gtk.Label('Skeleton=')
##        label.set_alignment(1.0, 0.5)
##        centerbox.pack_start(label, expand=0, fill=0)
##        centerbox.pack_start(self.skelwidget.gtk[1], expand=0, fill=0)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)

        interfacelistframe = gtk.Frame("Interfaces")
        gtklogger.setWidgetName(interfacelistframe, 'Interfaces')
        gtklogger.connect_passive(interfacelistframe, 'size-allocate')
        interfacelistframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(interfacelistframe, resize=0, shrink=0)

        interfacelistbox = gtk.VBox()
        interfacelistframe.add(interfacelistbox)

        # List of all the named interfaces
        self.interfacelist = chooser.ScrolledChooserListWidget(
            callback=self.interfacelistCB,
##            dbcallback=self.modifyBoundaryCB,
            autoselect=0,
            name="InterfaceList"
            )
        interfacelistbox.pack_start(self.interfacelist.gtk, expand=1, fill=1)

        interfacebuttonbox = gtk.HBox(homogeneous=1, spacing=2)
        interfacelistbox.pack_start(interfacebuttonbox, expand=0, fill=0)

        # Buttons that actually do stuff.
        self.newbutton = gtk.Button("New...")
        gtklogger.setWidgetName(self.newbutton, 'New')
        gtklogger.connect(self.newbutton, "clicked", self.newInterfaceCB)
        tooltips.set_tooltip_text(self.newbutton,
                             "Construct a new interface in the microstructure and associated meshes.")
        interfacebuttonbox.pack_start(self.newbutton, expand=1, fill=1)

        self.renamebutton = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, "clicked", self.renameInterfaceCB)
        tooltips.set_tooltip_text(self.renamebutton,
                             "Rename the selected interface.")
        interfacebuttonbox.pack_start(self.renamebutton, expand=1, fill=1)

        self.deletebutton = gtk.Button("Delete")
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, "clicked", self.deleteInterfaceCB)
        tooltips.set_tooltip_text(self.deletebutton,
                             "Delete the selected interface from the microstructure and associated meshes.")
        interfacebuttonbox.pack_start(self.deletebutton, expand=1, fill=1)

        ########## Adding and removing interface materials
        materialbuttonbox = gtk.HBox(homogeneous=1, spacing=2)
        interfacelistbox.pack_start(materialbuttonbox, expand=0, fill=0)
        self.assignmatbutton = gtk.Button("Assign interface material...")
        gtklogger.setWidgetName(self.assignmatbutton, 'Assign material')
        gtklogger.connect(self.assignmatbutton, "clicked", self.assignmatCB)
        tooltips.set_tooltip_text(self.assignmatbutton,
                             "Assign material to interface.")
        materialbuttonbox.pack_start(self.assignmatbutton, expand=1, fill=1)

        self.removematbutton = gtk.Button("Remove material")
        gtklogger.setWidgetName(self.removematbutton, 'Remove material')
        gtklogger.connect(self.removematbutton, "clicked", self.removematCB)
        tooltips.set_tooltip_text(self.removematbutton,
                             "Remove material from interface.")
        materialbuttonbox.pack_start(self.removematbutton, expand=1, fill=1)
        ####################################

        infoframe = gtk.Frame("Interface details")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(infoframe, resize=1, shrink=1)

        infowindow = gtk.ScrolledWindow()
        gtklogger.logScrollBars(infowindow, "InfoScroll")
        infowindow.set_shadow_type(gtk.SHADOW_IN)
        infoframe.add(infowindow)
        infowindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        
        self.infotext = fixedwidthtext.FixedWidthTextView()
        self.infotext.set_wrap_mode(gtk.WRAP_WORD)
        gtklogger.setWidgetName(self.infotext, 'status')
        self.infotext.set_editable(False)
        infowindow.add(self.infotext)

        self.built = True

        switchboard.requestCallbackMain("new interface created",
                                        self.newInterfaceUpdatePageCB)
        switchboard.requestCallbackMain("interface removed",
                                        self.newInterfaceUpdatePageCB)
        switchboard.requestCallbackMain("interface renamed",
                                        self.newInterfaceUpdatePageCB),
##        switchboard.requestCallbackMain("remove_material",self.del_mat)
        #TODO: Enable something like this later?
##        switchboard.requestCallbackMain(("new who", "Microstructure"),
##                                        self.newMicrostructureCB)

        self.selectsignals = [
            switchboard.requestCallbackMain("interface selected",
                                            self.interfaceSelectedCB),
            switchboard.requestCallbackMain("interface unselected",
                                            self.interfaceUnselectedCB)
            ]
Beispiel #30
0
    def __init__(self, viewertoolbox):
        debug.mainthreadTest()

        toolboxGUI.GfxToolbox.__init__(self, "Viewer", viewertoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        infoframe = gtk.Frame("Position Information")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(infoframe, fill=0, expand=0)

        infotable = gtk.Table(columns=3, rows=2)
        infoframe.add(infotable)
        pixellabel = gtk.Label("Pixel: ")
        pixellabel.set_alignment(1.0, 0.5)
        self.pixel_x = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_x, "PixelX")
        self.pixel_x.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.pixel_x.set_editable(0)
        self.pixel_y = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_y, "PixelY")
        self.pixel_y.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.pixel_y.set_editable(0)
        physicallabel = gtk.Label("Physical: ")
        physicallabel.set_alignment(1.0, 0.5)
        self.physical_x = gtk.Entry()
        gtklogger.setWidgetName(self.physical_x, "PhysicalX")
        self.physical_x.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.physical_x.set_editable(0)
        self.physical_y = gtk.Entry()
        gtklogger.setWidgetName(self.physical_y, "PhysicalY")
        self.physical_y.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.physical_y.set_editable(0)
        infotable.attach(pixellabel, 0,1, 0,1, xpadding=5, ypadding=2,
                         xoptions=0)
        infotable.attach(self.pixel_x, 1,2, 0,1, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(self.pixel_y, 2,3, 0,1, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(physicallabel, 0,1, 1,2, xpadding=5, ypadding=2,
                         xoptions=0)
        infotable.attach(self.physical_x, 1,2, 1,2, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(self.physical_y, 2,3, 1,2, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)

        zoomframe = gtk.Frame("Zoom")
        gtklogger.setWidgetName(zoomframe, "Zoom")
        zoomframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(zoomframe, fill=0, expand=0)
        zoombox = gtk.VBox()
        zoomframe.add(zoombox)

        buttonrow = gtk.HBox(homogeneous=1, spacing=2)
        zoombox.pack_start(buttonrow, expand=0, fill=1, padding=2)
        inbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_IN, 'In')
        buttonrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.setWidgetName(inbutton, "In")
        gtklogger.connect(inbutton, 'clicked', self.inCB)
        outbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_OUT, 'Out')
        buttonrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.setWidgetName(outbutton, "Out")
        gtklogger.connect(outbutton, 'clicked', self.outCB)
        fillbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_FIT, 'Fill')
        buttonrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.setWidgetName(fillbutton, "Fill")
        gtklogger.connect(fillbutton, 'clicked', self.fillCB)

        factorrow = gtk.HBox()
        zoombox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Zoom Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_editable(1)
        self.zoomfactor.set_size_request(ndigits*guitop.top().digitsize, -1)
        gtklogger.setWidgetName(self.zoomfactor, "Factor")
        self.zfactorsignal = gtklogger.connect_passive(self.zoomfactor,"changed")
        factorrow.pack_start(self.zoomfactor, expand=1, fill=1)

        zoombox.pack_start(gtk.HSeparator(), fill=0, expand=0, padding=2)

        label0 = gtk.Label("Shift+Click: Zoom in\nCtrl+Click: Zoom out")
        label0.set_pattern("             _______\n            ________\n")
        label0.set_justify(gtk.JUSTIFY_LEFT)
        zoombox.pack_start(label0, fill=0, expand=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_end(align, expand=0, fill=0, padding=2)
        canvas_info = gtkutils.StockButton(gtk.STOCK_DIALOG_INFO, "Canvas Info")
        gtklogger.setWidgetName(canvas_info, "Info")
        gtklogger.connect(canvas_info, "clicked", self.canvas_infoCB)
        tooltips.set_tooltip_text(canvas_info,
            "Display canvas information in the message window.")
        align.add(canvas_info)

        self.currentZFactor = self.gfxwindow().zoomFactor()

        switchboard.requestCallbackMain("zoom factor changed",
                                        self.zfactorCB)

        # Make sure that the Zoom commands in the graphics windows
        # Settings menu use an up-to-date zoom factor.
        self.gfxwindow().menu.Settings.Zoom.In.add_gui_callback(
            self.wrapMenuZoom)
        self.gfxwindow().menu.Settings.Zoom.Out.add_gui_callback(
            self.wrapMenuZoom)