def __init__(self): oofGUI.MainPage.__init__(self, name="Introduction", ordering=0, tip="Welcome to %s!" % name) vbox = gtk.VBox() self.gtk.add(vbox) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "Scroll") scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) vbox.pack_start(scroll, expand=1, fill=1) self.textarea = fixedwidthtext.FixedWidthTextView() scroll.set_shadow_type(gtk.SHADOW_IN) scroll.add(self.textarea) self.textarea.set_editable(0) self.textarea.set_cursor_visible(0) self.textarea.set_wrap_mode(gtk.WRAP_WORD) buttonbox = gtk.HBox(homogeneous=1, spacing=2) buttonbox.set_border_width(2) vbox.pack_start(buttonbox, expand=0, fill=0) self.labels = ['Welcome', 'Credits', 'Copyright', 'Disclaimer'] self.buttons = [gtk.ToggleButton(x) for x in self.labels] for button, label in zip(self.buttons, self.labels): buttonbox.pack_start(button, expand=1, fill=1) gtklogger.setWidgetName(button, label) gtklogger.connect(button, 'clicked', self.buttonCB, label) self.buttons[0].set_active(1)
def __init__(self, locals): global _console_menu debug.mainthreadTest() code.InteractiveConsole.__init__(self, locals=locals) subWindow.SubWindow.__init__( self, title="%s Python Console"%subWindow.oofname(), menu=_console_menu) self.history_list = [] self.history_pos = 0 self.raw = None self.raw_result = None frame = gtk.Frame() frame.set_border_width(2) frame.set_shadow_type(gtk.SHADOW_IN) self.mainbox.pack_start(frame, expand=1, fill=1) scroll = gtk.ScrolledWindow() frame.add(scroll) scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.text = fixedwidthtext.FixedWidthTextView() scroll.add(self.text) self.text.set_wrap_mode(gtk.WRAP_WORD) self.text.set_cursor_visible(0) # *mouse* cursor is invisible self.gtk.set_default_size(90*gtkutils.widgetCharSize(self.text), -1) self.bfr = self.text.get_buffer() # beginmark stays at the beginning of the last line of text self.beginmark = self.bfr.create_mark("beginmark", self.bfr.get_end_iter(), left_gravity=True) self.cursormark = self.bfr.create_mark("cursor", self.bfr.get_end_iter(), left_gravity=False) # The rvTag is used to show the text cursor in reverse video textattrs = self.text.get_default_attributes() self.rvTag = self.bfr.create_tag("reverse", background_gdk= textattrs.fg_color, foreground_gdk=textattrs.bg_color, #family="Monospace" ) self.editableTag = self.bfr.create_tag("editable", editable=True, #family="Monospace" ) self.uneditableTag = self.bfr.create_tag("uneditable", editable=False, #family="Monospace" ) self.text.connect("key-press-event", self.key_press) self.gtk.connect("destroy", self.local_destroy) # File emulation attributes. self.old_stdout = sys.stdout sys.stdout = self self.softspace = 0 self.mode="a" # try: self.prompt1=sys.ps1 except AttributeError: self.prompt1=">>> " try: self.prompt2=sys.ps2 except AttributeError: self.prompt2="... " # Do the banner manually, since we don't have "interact". The # extra space at the end is where the cursor will be drawn. self.textout(subWindow.oofname() + " Console:\n" + self.prompt1 + ' ') self.gtk.show_all()
def __init__(self): self.built = False oofGUI.MainPage.__init__( self, name="FE Mesh", ordering=200, tip="Create a Finite Element Mesh from a Skeleton.") 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) 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) # Centered box of buttons align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) bbox = gtk.HBox(homogeneous=1, spacing=3) align.add(bbox) self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, "New...") gtklogger.setWidgetName(self.newbutton, 'New') gtklogger.connect(self.newbutton, 'clicked', self.newCB) tooltips.set_tooltip_text( self.newbutton, "Create a new mesh from the current skeleton.") bbox.pack_start(self.newbutton, expand=0, fill=1) self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Rename...") gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, 'clicked', self.renameCB) tooltips.set_tooltip_text(self.renamebutton,"Rename the current mesh.") bbox.pack_start(self.renamebutton, expand=0, fill=1) self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.copyCB) tooltips.set_tooltip_text(self.copybutton,"Copy the current mesh.") bbox.pack_start(self.copybutton, expand=0, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete") gtklogger.setWidgetName(self.deletebutton, 'Delete') gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB) tooltips.set_tooltip_text(self.deletebutton,"Delete the current mesh.") bbox.pack_start(self.deletebutton, expand=0, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...") gtklogger.setWidgetName(self.savebutton, 'Save') gtklogger.connect(self.savebutton, 'clicked', self.saveCB) tooltips.set_tooltip_text(self.savebutton, "Save the current mesh to a file.") bbox.pack_start(self.savebutton, expand=0, fill=1) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') leftbox = gtk.VPaned() mainpane.pack1(leftbox, resize=1, shrink=0) infoframe = gtk.Frame('Mesh Information') infoframe.set_shadow_type(gtk.SHADOW_IN) leftbox.pack1(infoframe, resize=1, shrink=1) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "MeshInfo") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) infoframe.add(scroll) self.infoarea = fixedwidthtext.FixedWidthTextView() gtklogger.setWidgetName(self.infoarea, 'info') self.infoarea.set_cursor_visible(False) self.infoarea.set_editable(False) scroll.add(self.infoarea) ### ## Subproblem creation, deletion, etc. #subprobframe = gtk.Frame('Subproblems') #gtklogger.setWidgetName(subprobframe, 'Subproblems') #subprobframe.set_shadow_type(gtk.SHADOW_IN) #leftbox.pack2(subprobframe, resize=1, shrink=1) #subpbox = gtk.VBox() #subprobframe.add(subpbox) #self.subpchooser = chooser.ScrolledChooserListWidget( #callback=self.subpchooserCB, #dbcallback=self.subprobEditCB, #name="subprobChooser") #subpbox.pack_start(self.subpchooser.gtk, expand=1, fill=1) #subpbuttons1 = gtk.HBox(homogeneous=True, spacing=2) #subpbuttons2 = gtk.HBox(homogeneous=True, spacing=2) #subpbox.pack_start(subpbuttons1, expand=0, fill=0) #subpbox.pack_start(subpbuttons2, expand=0, fill=0) # Subproblem creation, deletion, etc. subprobframe = gtk.Frame('Subproblems') gtklogger.setWidgetName(subprobframe, 'Subproblems') subprobframe.set_shadow_type(gtk.SHADOW_IN) leftbox.pack2(subprobframe, resize=1, shrink=1) subpbox = gtk.VBox() subprobframe.add(subpbox) innerframe = gtk.Frame() innerframe.set_shadow_type(gtk.SHADOW_IN) subpbox.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.subprobEditCB) # Subproblem name in the column 1 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) # Subproblem consistency in the column 2 consistencycell = gtk.CellRendererText() consistencycol = gtk.TreeViewColumn("Consistent?") consistencycol.set_resizable(True) consistencycol.pack_start(consistencycell, expand=True) consistencycol.set_cell_data_func(consistencycell, self.renderSubproblemConsistency) self.subpListView.append_column(consistencycol) # Subproblem type in the column 3 typecell = gtk.CellRendererText() typecol = gtk.TreeViewColumn("Type") typecol.set_resizable(True) typecol.pack_start(typecell, expand=True) typecol.set_cell_data_func(typecell, self.renderSubproblemType) self.subpListView.append_column(typecol) # Buttons at the bottom of the subproblem pane subpbuttons1 = gtk.HBox(homogeneous=True, spacing=2) subpbuttons2 = gtk.HBox(homogeneous=True, spacing=2) subpbox.pack_start(subpbuttons1, expand=0, fill=0) subpbox.pack_start(subpbuttons2, expand=0, fill=0) ### self.subprobNew = gtkutils.StockButton(gtk.STOCK_NEW, "New...") gtklogger.setWidgetName(self.subprobNew, "New") gtklogger.connect(self.subprobNew, "clicked", self.subprobNewCB) tooltips.set_tooltip_text(self.subprobNew,"Create a new subproblem.") subpbuttons1.pack_start(self.subprobNew, expand=1, fill=1) self.subprobRename = gtk.Button("Rename...") gtklogger.setWidgetName(self.subprobRename, "Rename") gtklogger.connect(self.subprobRename, "clicked", self.subprobRenameCB) tooltips.set_tooltip_text(self.subprobRename, "Rename the selected subproblem") subpbuttons1.pack_start(self.subprobRename, expand=1, fill=1) self.subprobEdit = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...") gtklogger.setWidgetName(self.subprobEdit, "Edit") gtklogger.connect(self.subprobEdit, 'clicked', self.subprobEditCB) tooltips.set_tooltip_text(self.subprobEdit, "Edit the selected subproblem.") subpbuttons1.pack_start(self.subprobEdit, expand=1, fill=1) self.subprobCopy = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.subprobCopy, "Copy") gtklogger.connect(self.subprobCopy, "clicked", self.subprobCopyCB) tooltips.set_tooltip_text(self.subprobCopy, "Copy the selected subproblem.") subpbuttons2.pack_start(self.subprobCopy, expand=1, fill=1) ## subpbuttons2.pack_start(gtk.HBox(), expand=1, fill=1) # filler self.subprobInfo = gtk.Button("Info") gtklogger.setWidgetName(self.subprobInfo, "Info") gtklogger.connect(self.subprobInfo, 'clicked', self.subprobInfoCB) tooltips.set_tooltip_text(self.subprobInfo, "Print information about the selected subproblem") subpbuttons2.pack_start(self.subprobInfo, expand=1, fill=1) self.subprobDelete = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete") gtklogger.setWidgetName(self.subprobDelete, "Delete") gtklogger.connect(self.subprobDelete, "clicked", self.subprobDeleteCB) tooltips.set_tooltip_text(self.subprobDelete, "Delete the selected subproblem.") subpbuttons2.pack_start(self.subprobDelete, expand=1, fill=1) # Right hand side for element operations elementopsframe = gtk.Frame(label="Mesh Operations") gtklogger.setWidgetName(elementopsframe, 'ElementOps') elementopsframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack2(elementopsframe, resize=0, shrink=0) elementopsbox = gtk.VBox(spacing=3) elementopsframe.add(elementopsbox) self.elementops = regclassfactory.RegisteredClassFactory( meshmod.MeshModification.registry, title="Method:", callback=self.elementopsCB, expand=0, fill=0, scope=self, name="Method") elementopsbox.pack_start(self.elementops.gtk, expand=1, fill=1) self.historian = historian.Historian(self.elementops.set, self.sensitizeHistory, setCBkwargs={'interactive':1}) # Prev, OK, Next hbox = gtk.HBox() elementopsbox.pack_start(hbox, expand=0, fill=0, padding=2) self.prevbutton = gtkutils.prevButton() gtklogger.connect(self.prevbutton, 'clicked', self.prevCB) tooltips.set_tooltip_text(self.prevbutton, "Recall the previous mesh element operation.") hbox.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', self.okCB) tooltips.set_tooltip_text(self.okbutton, 'Perform the mesh operation defined above.') hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5) self.nextbutton = gtkutils.nextButton() gtklogger.connect(self.nextbutton, 'clicked', self.nextCB) tooltips.set_tooltip_text(self.nextbutton, 'Recall the next mesh element operation.') hbox.pack_start(self.nextbutton, expand=0, fill=0, padding=2) self.built = True # lastStatus is used to prevent update_info() from being # called when a nominal status change hasn't really changed # anything. self.lastStatus = None switchboard.requestCallbackMain("Mesh modified", self.recordModifier) switchboard.requestCallbackMain("mesh changed", self.meshchangeCB) switchboard.requestCallbackMain(("new who", "Microstructure"), self.newMSorSkeleton) switchboard.requestCallbackMain(("new who", "Skeleton"), self.newMSorSkeleton) switchboard.requestCallbackMain(("new who", "Mesh"), self.newMesh) switchboard.requestCallbackMain(("new who", "SubProblem"), self.newSubProblem) switchboard.requestCallbackMain(("rename who", "SubProblem"), self.renamedSubProblem) switchboard.requestCallbackMain(("remove who", "SubProblem"), self.removeSubProblem) switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB) switchboard.requestCallbackMain("equation activated", self.equationCB) switchboard.requestCallbackMain("mesh status changed", self.statusChanged) # switchboard.requestCallbackMain("mesh boundaries changed", # self.newMeshBoundaries) switchboard.requestCallbackMain(('validity', self.elementops), self.validityChangeCB)
def __init__(self): self.built = False oofGUI.MainPage.__init__(self, name="Skeleton Boundaries", ordering=150, tip="Create and orient boundaries.") 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.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'), 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) 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) gtklogger.connect_passive(mainpane, 'notify::position') boundarylistframe = gtk.Frame("Boundaries") gtklogger.setWidgetName(boundarylistframe, 'Boundaries') boundarylistframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack1(boundarylistframe, resize=0, shrink=0) boundarylistbox = gtk.VBox() boundarylistframe.add(boundarylistbox) # List of all the boundaries. self.boundarylist = chooser.ScrolledChooserListWidget( callback=self.boundarylistCB, dbcallback=self.modifyBoundaryCB, autoselect=0, name="BoundaryList", separator_func=self.chooserSepFunc) boundarylistbox.pack_start(self.boundarylist.gtk, expand=1, fill=1) boundarybuttonbox = gtk.HBox(homogeneous=1, spacing=2) boundarylistbox.pack_start(boundarybuttonbox, 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.newBoundaryCB) tooltips.set_tooltip_text( self.newbutton, "Construct a new boundary in the skeleton and associated meshes.") boundarybuttonbox.pack_start(self.newbutton, expand=1, fill=1) self.editbutton = gtk.Button("Modify...") gtklogger.setWidgetName(self.editbutton, 'Modify') gtklogger.connect(self.editbutton, "clicked", self.modifyBoundaryCB) tooltips.set_tooltip_text( self.editbutton, "Modify the attributes of the selected boundary.") boundarybuttonbox.pack_start(self.editbutton, expand=1, fill=1) self.renamebutton = gtk.Button("Rename...") gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, "clicked", self.renameBoundaryCB) tooltips.set_tooltip_text(self.renamebutton, "Rename the selected boundary.") boundarybuttonbox.pack_start(self.renamebutton, expand=1, fill=1) self.deletebutton = gtk.Button("Delete") gtklogger.setWidgetName(self.deletebutton, 'Delete') gtklogger.connect(self.deletebutton, "clicked", self.deleteBoundaryCB) tooltips.set_tooltip_text( self.deletebutton, "Delete the selected boundary from the skeleton and associated meshes." ) boundarybuttonbox.pack_start(self.deletebutton, expand=1, fill=1) # TODO LATER: Copying could be added here -- the scenario is # that a user may want to make a copy of a boundary, and then # edit one of the copies. Currently boundary editing is # primitive (one can only add/remove components), but when # visual pointy-clicky boundary editing is added, copying will # make sense. infoframe = gtk.Frame("Boundary data") 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 # Catches push events *after* the boundaries have been # propagated, and also undo/redo events. "who changed" is # too early. switchboard.requestCallbackMain("new boundary configuration", self.newBdyConfigCB) switchboard.requestCallbackMain("new boundary created", self.newBdyCB) switchboard.requestCallbackMain("boundary removed", self.newBdyCB) switchboard.requestCallbackMain("boundary renamed", self.newBdyCB), switchboard.requestCallbackMain(("new who", "Microstructure"), self.newMicrostructureCB) self.selectsignals = [ switchboard.requestCallbackMain("boundary selected", self.bdySelectedCB), switchboard.requestCallbackMain("boundary unselected", self.bdyUnselectedCB) ]
def __init__(self): self.postponed_update = False oofGUI.MainPage.__init__(self, name="Skeleton", ordering=120, tip='Construct and modify mesh skeletons') 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.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'), scope=self) 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=1, fill=1) 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=1, fill=1) # Centered box of buttons align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) bbox = gtk.HBox(homogeneous=1, spacing=3) align.add(bbox) self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') gtklogger.setWidgetName(self.newbutton, "New") gtklogger.connect(self.newbutton, 'clicked', self.new_skeleton_CB) tooltips.set_tooltip_text(self.newbutton,"Create a new skeleton from the current microstructure.") bbox.pack_start(self.newbutton, expand=1, fill=1) self.simplebutton = gtk.Button('Simple...') gtklogger.setWidgetName(self.simplebutton, "Simple") gtklogger.connect(self.simplebutton, 'clicked', self.simple_skeleton_CB) tooltips.set_tooltip_text(self.simplebutton,"Create a new skeleton from the current microstructure in a naive fashion, by creating one quadrilateral or two triangular elements per pixel. Material boundaries will be inherently jagged, which may cause errors in finite element solutions.") bbox.pack_start(self.simplebutton, expand=1, fill=1) self.autobutton = gtk.Button('Auto...') gtklogger.setWidgetName(self.autobutton, 'Auto') gtklogger.connect(self.autobutton, 'clicked', self.autoCB) tooltips.set_tooltip_text(self.autobutton,"Create and automatically refine a Skeleton.") bbox.pack_start(self.autobutton, expand=1, fill=1) self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...') gtklogger.setWidgetName(self.renamebutton, "Rename") gtklogger.connect(self.renamebutton, 'clicked', self.rename_skeleton_CB) tooltips.set_tooltip_text(self.renamebutton,"Rename the current skeleton.") bbox.pack_start(self.renamebutton, expand=1, fill=1) self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...') gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.copy_skeleton_CB) tooltips.set_tooltip_text(self.copybutton,"Copy the current skeleton.") bbox.pack_start(self.copybutton, expand=1, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') gtklogger.setWidgetName(self.deletebutton, 'Delete') gtklogger.connect(self.deletebutton, 'clicked', self.delete_skeletonCB) tooltips.set_tooltip_text(self.deletebutton,"Delete the current skeleton.") bbox.pack_start(self.deletebutton, expand=1, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...') gtklogger.setWidgetName(self.savebutton, "Save") gtklogger.connect(self.savebutton, 'clicked', self.save_skeletonCB) tooltips.set_tooltip_text(self.savebutton, "Save the current skeleton to a file.") bbox.pack_start(self.savebutton, expand=1, fill=1) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') self.skelframe = gtk.Frame(label="Skeleton Status") self.skelframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack1(self.skelframe, resize=1, shrink=0) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "StatusScroll") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) self.skelframe.add(scroll) self.skelinfo = fixedwidthtext.FixedWidthTextView() gtklogger.setWidgetName(self.skelinfo, "SkeletonText") self.skelinfo.set_wrap_mode(gtk.WRAP_WORD) self.skelinfo.set_editable(False) self.skelinfo.set_cursor_visible(False) self.boldTag = self.skelinfo.get_buffer().create_tag( "bold", weight=pango.WEIGHT_BOLD) scroll.add(self.skelinfo) # End of left-side of skeleton info frame. # Start of right-side skelmodframe = gtk.Frame(label="Skeleton Modification") gtklogger.setWidgetName(skelmodframe, 'Modification') skelmodframe.set_shadow_type(gtk.SHADOW_IN) skelmodbox = gtk.VBox(spacing=3) skelmodframe.add(skelmodbox) self.skelmod = regclassfactory.RegisteredClassFactory( skeletonmodifier.SkeletonModifier.registry, title="method: ", callback=self.skelmodCB, expand=0, fill=0, scope=self, name="Method") self.historian = historian.Historian(self.skelmod.set, self.sensitizeHistory, setCBkwargs={'interactive':1}) skelmodbox.pack_start(self.skelmod.gtk,expand=1,fill=1) # Buttons for "Previous", "OK", and "Next" hbox = gtk.HBox() self.prevskelmodbutton = gtkutils.prevButton() gtklogger.connect(self.prevskelmodbutton, 'clicked', self.prevskelmod) tooltips.set_tooltip_text(self.prevskelmodbutton, 'Recall the previous skeleton modification operation.') hbox.pack_start(self.prevskelmodbutton, expand=0, fill=0, padding=2) self.okbutton = gtk.Button(stock=gtk.STOCK_OK) gtklogger.setWidgetName(self.okbutton, 'OK') gtklogger.connect(self.okbutton, 'clicked', self.okskelmod) tooltips.set_tooltip_text(self.okbutton, 'Perform the skeleton modification operation defined above.') hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5) self.nextskelmodbutton = gtkutils.nextButton() gtklogger.connect(self.nextskelmodbutton, 'clicked', self.nextskelmod) tooltips.set_tooltip_text(self.nextskelmodbutton, 'Recall the next skeleton modification operation.') hbox.pack_start(self.nextskelmodbutton, expand=0, fill=0, padding=2) skelmodbox.pack_start(hbox, expand=0, fill=0, padding=2) # Buttons for "Undo", "Redo" hbox = gtk.HBox() self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) gtklogger.setWidgetName(self.undobutton, 'Undo') gtklogger.connect(self.undobutton, 'clicked', self.undoskelmod) tooltips.set_tooltip_text(self.undobutton, 'Undo the latest skeleton modification.') hbox.pack_start(self.undobutton, expand=1, fill=0, padding=10) self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.connect(self.redobutton, 'clicked', self.redoskelmod) tooltips.set_tooltip_text(self.redobutton, 'Redo the latest undone skeleton modification.') hbox.pack_start(self.redobutton, expand=1, fill=0, padding=10) skelmodbox.pack_start(hbox, expand=0, fill=0, padding=2) mainpane.pack2(skelmodframe, resize=0, shrink=0) # End of right-side self.sbcallbacks = [ switchboard.requestCallback("made reservation", self.update_ok_button), switchboard.requestCallback("cancelled reservation", self.update_ok_button), switchboard.requestCallback("skeleton homogeneity changed", self.homogeneityChangeCB), switchboard.requestCallbackMain("Skeleton modified", self.recordModifier), switchboard.requestCallback(('who changed', 'Skeleton'), self.changeSkeleton), switchboard.requestCallbackMain(SkeletonModifier, self.updateskelmod), switchboard.requestCallbackMain(("new who", "Microstructure"), self.newMicrostructure), switchboard.requestCallbackMain(("new who", 'Skeleton'), self.newSkeleton), # Pages should catch the signal from updates to the widget # which don't originate on this page, e.g. deletions via # menu command. switchboard.requestCallback(self.skelwidget, self.skel_update), switchboard.requestCallback(('validity', self.skelmod), self.validityChangeCB), # Node movements can change the homogeneity of elements, # thus changing the state. switchboard.requestCallback("skeleton nodes moved", self.nodesMoved) ]
def __init__(self, toolbox, table, row): debug.mainthreadTest() pixelinfoGUIplugin.PixelInfoGUIPlugIn.__init__(self, toolbox) self.refOrient = None # the current reference orientation self.sbcbs = [] # switchboard callbacks title = gtk.Label("Misorientation") title.set_alignment(0.5, 0.5) table.attach(title, 1,2, row, row+1, xpadding=5, ypadding=2, xoptions=gtk.FILL) label = gtk.Label("reference=") label.set_alignment(1.0, 0.5) table.attach(label, 0,1, row+1, row+2, xpadding=5, xoptions=gtk.FILL) frame = gtk.Frame() vbox = gtk.VBox() frame.add(vbox) table.attach(frame, 1,2, row+1,row+2, xpadding=5, xoptions=gtk.EXPAND|gtk.FILL) # refBox holds either the RCF for the reference orientation, # or a gtk.Entry saying that the reference orientation isn't # set. The only purpose of the box is to make it easy to swap # the RCF and the Entry. self.refBox = gtk.VBox() vbox.pack_start(self.refBox, fill=1, expand=0) refParam = self.getMenu().Set_Reference.get_arg("orientation") self.refWidget = refParam.makeWidget() # RegisteredClassFactory self.refWidget.makeReadOnly() # A table displaying the x, y coords of the reference point. # TODO: Should the coordinates be editable directly? It would # require a separate button to indicate that the user is done # editing. self.refPointTable = gtk.Table(rows=2, columns=2) xlabel = gtk.Label("x=") xlabel.set_alignment(1.0, 0.5) self.refPointTable.attach(xlabel, 0,1, 0,1, xpadding=3, ypadding=0, xoptions=gtk.FILL) self.xtext = gtk.Entry() gtklogger.setWidgetName(self.xtext, 'X') self.xtext.set_editable(False) self.refPointTable.attach(self.xtext, 1,2, 0,1, xpadding=3, ypadding=0, xoptions=gtk.FILL|gtk.EXPAND) ylabel = gtk.Label("y=") ylabel.set_alignment(1.0, 0.5) self.refPointTable.attach(ylabel, 0,1, 1,2, xpadding=3, ypadding=0, xoptions=gtk.FILL) self.ytext = gtk.Entry() gtklogger.setWidgetName(self.ytext, 'Y') self.ytext.set_editable(False) self.refPointTable.attach(self.ytext, 1,2, 1,2, xpadding=3, ypadding=0, xoptions=gtk.FILL|gtk.EXPAND) # Text displayed instead of the reference orientation and # location when no reference has been selected. self.refText = fixedwidthtext.FixedWidthTextView() self.refText.set_wrap_mode(gtk.WRAP_WORD) self.refText.set_editable(False) self.refText.set_cursor_visible(False) self.refText.get_buffer().set_text( 'Select a pixel and click "Set Reference Point" to make it the reference.') self.refBox.pack_start(self.refText, expand=0, fill=0) # The "Set Reference" button copies the orientation from the # OrientMapPixelInfoPlugIn to the reference widget in this # plug-in. self.setButton = gtk.Button("Set Reference Point") gtklogger.setWidgetName(self.setButton, "Set") align = gtk.Alignment(xalign=0.5) align.add(self.setButton) vbox.pack_start(align, fill=0, expand=0) gtklogger.connect(self.setButton, 'clicked', self.setButtonCB) tooltips.set_tooltip_text( self.setButton, 'Set the reference orientation to the' ' previously selected orientation.') label = gtk.Label("symmetry=") label.set_alignment(1.0, 0.5) table.attach(label, 0,1, row+2,row+3, xpadding=0, xoptions=gtk.FILL) symParam = self.getMenu().Set_Symmetry.get_arg('symmetry') self.symWidget = symParam.makeWidget() gtklogger.setWidgetName(self.symWidget.gtk, "Symmetry") table.attach(self.symWidget.gtk, 1,2, row+2,row+3, xpadding=5, xoptions=gtk.EXPAND|gtk.FILL) label = gtk.Label("misorientation=") label.set_alignment(1.0, 0.5) table.attach(label, 0,1, row+3,row+4, xpadding=0, xoptions=gtk.FILL) self.misorientationText = gtk.Entry() self.misorientationText.set_editable(0) table.attach(self.misorientationText, 1,2, row+3,row+4, xpadding=5, xoptions=gtk.EXPAND|gtk.FILL) self.sbcbs = [ # Changing the lattice symmetry requires an immediate # update of the misorientation. Connecting to the widget # via the switchboard catches all changes, not just # changes to the top chooser widget. switchboard.requestCallbackMain(self.symWidget, self.symChanged), # Messages indicating that the Microstructure has changed # in some possibly relevant way: switchboard.requestCallbackMain('OrientationMap changed', self.materialchanged), switchboard.requestCallbackMain( "materials changed in microstructure", self.materialchanged), switchboard.requestCallbackMain('material changed', self.materialchanged), switchboard.requestCallbackMain('prop_added_to_material', self.materialchanged), switchboard.requestCallbackMain('prop_removed_from_material', self.materialchanged), # Messages sent from the non-gui part of the toolbox: switchboard.requestCallbackMain("set reference orientation", self.setReference), switchboard.requestCallbackMain("set misorientation symmetry", self.setSymmetry) ] self.sensitize()
def __init__(self): oofGUI.MainPage.__init__(self, name="Image", ordering=50, tip='Manipulate Images') 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) label = gtk.Label('Microstructure=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) self.imagewidget = whowidget.WhoWidget(imagecontext.imageContexts) centerbox.pack_start(self.imagewidget.gtk[0], expand=0, fill=0) label = gtk.Label('Image=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.imagewidget.gtk[1], expand=0, fill=0) align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(homogeneous=1, spacing=3) align.add(centerbox) self.loadbutton = gtk.Button('Load...') gtklogger.setWidgetName(self.loadbutton, 'Load') centerbox.pack_start(self.loadbutton, expand=1, fill=1) gtklogger.connect(self.loadbutton, 'clicked', self.loadCB) tooltips.set_tooltip_text(self.loadbutton, 'Load a new image into an existing Microstructure') self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...') gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.copyCB) centerbox.pack_start(self.copybutton, expand=1, fill=1) tooltips.set_tooltip_text(self.copybutton, 'Copy the current image. The copy can be in the same or a different Microstructure.') self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...') gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, 'clicked', self.renameCB) tooltips.set_tooltip_text(self.renamebutton,'Rename the current image.') centerbox.pack_start(self.renamebutton, expand=1, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') gtklogger.setWidgetName(self.deletebutton, 'Delete') gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB) tooltips.set_tooltip_text(self.deletebutton,'Delete the current image.') centerbox.pack_start(self.deletebutton, expand=1, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...') gtklogger.setWidgetName(self.savebutton, 'Save') gtklogger.connect(self.savebutton, 'clicked', self.saveCB) tooltips.set_tooltip_text(self.savebutton,'Save the current image to a file.') centerbox.pack_start(self.savebutton, expand=1, fill=1) self.autogroupbutton = gtk.Button('Group...') gtklogger.setWidgetName(self.autogroupbutton, 'Group') gtklogger.connect(self.autogroupbutton, 'clicked', self.autogroupCB) centerbox.pack_start(self.autogroupbutton, expand=1, fill=1, padding=2) if config.dimension() == 2: tooltips.set_tooltip_text(self.autogroupbutton, "Create a pixel group in the current image's microstructure for each color pixel in the image.") elif config.dimension() == 3: tooltips.set_tooltip_text(self.autogroupbutton, "Create a voxel group in the current image's microstructure for each color voxel in the image.") mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') frame = gtk.Frame('Image Information') frame.set_shadow_type(gtk.SHADOW_IN) mainpane.pack1(frame, resize=True, shrink=False) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "StatusScroll") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) frame.add(scroll) self.infoarea = fixedwidthtext.FixedWidthTextView() self.infoarea.set_wrap_mode(gtk.WRAP_WORD) self.infoarea.set_editable(False) self.infoarea.set_cursor_visible(False) scroll.add_with_viewport(self.infoarea) frame = gtk.Frame('Image Modification') frame.set_shadow_type(gtk.SHADOW_IN) mainpane.pack2(frame, resize=False, shrink=False) vbox = gtk.VBox() frame.add(vbox) ## scroll = gtk.ScrolledWindow() # scroll window for image mod method ## scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) ## vbox.pack_start(scroll, expand=1, fill=1) self.imageModFactory = regclassfactory.RegisteredClassFactory( imagemodifier.ImageModifier.registry, title="Method:", name="Method") ## scroll.add_with_viewport(self.imageModFactory.gtk) vbox.pack_start(self.imageModFactory.gtk, expand=1, fill=1) self.historian = historian.Historian(self.imageModFactory.set, self.sensitizeHistory, setCBkwargs={'interactive':1}) self.imageModFactory.set_callback(self.historian.stateChangeCB) # Prev, OK, and Next buttons hbox = gtk.HBox() vbox.pack_start(hbox, expand=0, fill=0, padding=2) self.prevmethodbutton = gtkutils.prevButton() gtklogger.connect(self.prevmethodbutton, 'clicked', self.historian.prevCB) hbox.pack_start(self.prevmethodbutton, expand=0, fill=0, padding=2) tooltips.set_tooltip_text(self.prevmethodbutton, 'Recall the previous image modification operation.') self.okbutton = gtk.Button(stock=gtk.STOCK_OK) gtklogger.setWidgetName(self.okbutton, 'OK') hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5) gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB) tooltips.set_tooltip_text(self.okbutton, 'Perform the image modification operation defined above.') self.nextmethodbutton = gtkutils.nextButton() gtklogger.connect(self.nextmethodbutton, 'clicked', self.historian.nextCB) hbox.pack_start(self.nextmethodbutton, expand=0, fill=0, padding=2) tooltips.set_tooltip_text(self.nextmethodbutton, "Recall the next image modification operation.") # Undo and Redo buttons hbox = gtk.HBox() vbox.pack_start(hbox, expand=0, fill=0, padding=2) self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) gtklogger.setWidgetName(self.undobutton, 'Undo') gtklogger.connect(self.undobutton, 'clicked', self.undoCB) tooltips.set_tooltip_text(self.undobutton,'Undo the latest image modification.') hbox.pack_start(self.undobutton, expand=1, fill=0, padding=10) self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.connect(self.redobutton, 'clicked', self.redoCB) tooltips.set_tooltip_text(self.redobutton, 'Redo the latest undone image modification.') hbox.pack_start(self.redobutton, expand=1, fill=0, padding=10) self.sbcallbacks = [ switchboard.requestCallbackMain(('new who', 'Microstructure'), self.newMicrostructureCB), switchboard.requestCallbackMain(('new who', 'Image'), self.newImageCB), switchboard.requestCallbackMain(('remove who', 'Image'), self.rmWhoCB), switchboard.requestCallbackMain('modified image', self.modifiedImageCB), switchboard.requestCallbackMain(imagemodifier.ImageModifier, self.updateImageModifiers), switchboard.requestCallbackMain(self.imagewidget, self.iWidgetChanged), switchboard.requestCallbackMain(('validity', self.imageModFactory), self.validityChangeCB), switchboard.requestCallbackMain(('WhoDoUndo buffer change', 'Image'), self.whoBufChangeCB) ]
def __init__(self): debug.mainthreadTest() oofGUI.MainPage.__init__(self, name="%s Selection" % Pixstring, ordering=71, tip="Modify the set of selected %ss." % pixstring) mainbox = gtk.VBox(spacing=2) self.gtk.add(mainbox) # Microstructure widget, centered at the top of the page. align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(spacing=3) align.add(centerbox) label = gtk.Label('Microstructure=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) self.mswidget = whowidget.WhoWidget(microstructure.microStructures, scope=self) centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') # Pixel selection status in the left half of the main pane pssframe = gtk.Frame("%s Selection Status" % Pixstring) pssframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack1(pssframe, resize=1, shrink=0) self.datascroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.datascroll, "DataScroll") pssframe.add(self.datascroll) self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.psdata = fixedwidthtext.FixedWidthTextView() gtklogger.setWidgetName(self.psdata, 'DataView') self.psdata.set_editable(0) self.psdata.set_cursor_visible(False) self.psdata.set_wrap_mode(gtk.WRAP_WORD) self.datascroll.add_with_viewport(self.psdata) # Selection method in the right half of the main pane modframe = gtk.Frame("%s Selection Modification" % Pixstring) gtklogger.setWidgetName(modframe, "SelectionModification") modframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack2(modframe, resize=0, shrink=0) vbox = gtk.VBox() modframe.add(vbox) ## scroll = gtk.ScrolledWindow() ## scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) ## vbox.add(scroll) self.selectionModFactory = regclassfactory.RegisteredClassFactory( pixelselectionmod.SelectionModifier.registry, title="Method:", scope=self, name="Method") vbox.pack_start(self.selectionModFactory.gtk, expand=1, fill=1) ## scroll.add_with_viewport(self.selectionModFactory.gtk) self.historian = historian.Historian(self.selectionModFactory.set, self.sensitizeHistory, setCBkwargs={'interactive': 1}) self.selectionModFactory.set_callback(self.historian.stateChangeCB) # Prev, OK, and Next buttons hbox = gtk.HBox() vbox.pack_start(hbox, expand=0, fill=0, padding=2) self.prevmethodbutton = gtkutils.prevButton() gtklogger.connect(self.prevmethodbutton, 'clicked', self.historian.prevCB) hbox.pack_start(self.prevmethodbutton, expand=0, fill=0, padding=2) tooltips.set_tooltip_text( self.prevmethodbutton, 'Recall the previous selection modification operation.') self.okbutton = gtk.Button(stock=gtk.STOCK_OK) gtklogger.setWidgetName(self.okbutton, "OK") hbox.pack_start(self.okbutton, expand=1, fill=1, padding=2) gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB) tooltips.set_tooltip_text( self.okbutton, 'Perform the selection modification operation defined above.') self.nextmethodbutton = gtkutils.nextButton() gtklogger.connect(self.nextmethodbutton, 'clicked', self.historian.nextCB) hbox.pack_start(self.nextmethodbutton, expand=0, fill=0, padding=2) tooltips.set_tooltip_text( self.nextmethodbutton, "Recall the next selection modification operation.") # Undo, Redo, and Clear buttons hbox = gtk.HBox() vbox.pack_start(hbox, expand=0, fill=0, padding=2) self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) hbox.pack_start(self.undobutton, expand=1, fill=0) hbox.pack_start(self.redobutton, expand=1, fill=0) gtklogger.setWidgetName(self.undobutton, "Undo") gtklogger.setWidgetName(self.redobutton, "Redo") gtklogger.connect(self.undobutton, 'clicked', self.undoCB) gtklogger.connect(self.redobutton, 'clicked', self.redoCB) tooltips.set_tooltip_text( self.undobutton, "Undo the previous %s selection operation." % pixstring) tooltips.set_tooltip_text( self.redobutton, "Redo an undone %s selection operation." % pixstring) self.clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR) hbox.pack_start(self.clearbutton, expand=1, fill=0) gtklogger.setWidgetName(self.clearbutton, "Clear") gtklogger.connect(self.clearbutton, 'clicked', self.clearCB) tooltips.set_tooltip_text(self.clearbutton, "Unselect all %ss." % pixstring) self.sbcallbacks = [ switchboard.requestCallbackMain(self.mswidget, self.mswidgetCB), switchboard.requestCallbackMain('pixel selection changed', self.selectionChanged), switchboard.requestCallbackMain('modified pixel selection', self.updateHistory), switchboard.requestCallbackMain( pixelselectionmod.SelectionModifier, self.updateSelectionModifiers), switchboard.requestCallbackMain( ('validity', self.selectionModFactory), self.validityChangeCB) ]
def __init__(self): debug.mainthreadTest() self.built = False oofGUI.MainPage.__init__( self, name="Microstructure", ordering=10, tip="Define Microstructure and %s Group objects." % Pixstring) vbox = gtk.VBox(spacing=2) self.gtk.add(vbox) align = gtk.Alignment(xalign=0.5) vbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox() align.add(centerbox) label = gtk.Label('Microstructure=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) self.mswidget = whowidget.WhoWidget(microstructure.microStructures, callback=self.msCB) centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0) align = gtk.Alignment(xalign=0.5) # first row of ms buttons vbox.pack_start(align, expand=0, fill=0) self.newbuttonbox = gtk.HBox(homogeneous=0, spacing=3) align.add(self.newbuttonbox) self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') gtklogger.setWidgetName(self.newbutton, "New") gtklogger.connect(self.newbutton, 'clicked', self.newEmptyCB) tooltips.set_tooltip_text( self.newbutton, "Create a new microstructure that is NOT associated with images.") self.newbuttonbox.pack_start(self.newbutton, expand=1, fill=1) # Other buttons can be added to the row of "New" buttons by # other modules. When they're added, by addNewButton(), a # function can be specified for sensitizing the button. This # is the list of those functions: self.sensitizeFns = [] # Other modules can contribute strings to be displayed on the # info page. This is the list of # MicrostructurePageInfoPlugIns that retrieve those strings. self.infoplugins = [] align = gtk.Alignment(xalign=0.5) # second row of ms buttons vbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(homogeneous=1, spacing=3) align.add(centerbox) self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...') gtklogger.setWidgetName(self.renamebutton, "Rename") gtklogger.connect(self.renamebutton, 'clicked', self.renameMSCB) self.renamebutton.set_sensitive(0) tooltips.set_tooltip_text(self.renamebutton, "Rename the current microstructure.") centerbox.pack_start(self.renamebutton, expand=1, fill=1) self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...') gtklogger.setWidgetName(self.copybutton, "Copy") gtklogger.connect(self.copybutton, 'clicked', self.copyMSCB) self.copybutton.set_sensitive(0) tooltips.set_tooltip_text(self.copybutton, "Copy the current microstructure.") centerbox.pack_start(self.copybutton, expand=1, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') gtklogger.setWidgetName(self.deletebutton, "Delete") gtklogger.connect(self.deletebutton, 'clicked', self.deleteMSCB) self.deletebutton.set_sensitive(0) tooltips.set_tooltip_text(self.deletebutton, "Delete the current microstructure.") centerbox.pack_start(self.deletebutton, expand=1, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...') gtklogger.setWidgetName(self.savebutton, "Save") gtklogger.connect(self.savebutton, 'clicked', self.saveMSCB) self.savebutton.set_sensitive(0) tooltips.set_tooltip_text( self.savebutton, "Save the current microstructure to a file.") centerbox.pack_start(self.savebutton, expand=1, fill=1) pane = gtk.HPaned() gtklogger.setWidgetName(pane, "Pane") vbox.pack_start(pane, expand=1, fill=1, padding=2) gtklogger.connect_passive(pane, 'notify::position') ####### infoframe = gtk.Frame('Microstructure Info') infoframe.set_shadow_type(gtk.SHADOW_IN) pane.pack1(infoframe, resize=True, shrink=False) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "InfoFrameScroll") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) infoframe.add(scroll) self.infoarea = fixedwidthtext.FixedWidthTextView() self.infoarea.set_editable(0) self.infoarea.set_cursor_visible(False) self.infoarea.set_wrap_mode(gtk.WRAP_WORD) scroll.add(self.infoarea) ######## self.grouplock = lock.Lock() groupframe = gtk.Frame('%s Groups' % Pixstring) gtklogger.setWidgetName(groupframe, "%sGroups" % Pixstring) groupframe.set_shadow_type(gtk.SHADOW_IN) pane.pack2(groupframe, resize=True, shrink=False) hbox = gtk.HBox() groupframe.add(hbox) vbox = gtk.VBox(spacing=2) # buttons on L side of pixel group list hbox.pack_start(vbox, expand=0, fill=0, padding=2) frame = gtk.Frame() # frame for the list of groups frame.set_shadow_type(gtk.SHADOW_IN) hbox.pack_start(frame) grparea = gtk.VBox() frame.add(grparea) # only one of grplist and grpmsg is visible at a time self.grplist = chooser.ScrolledChooserListWidget( # list of pixel groups callback=self.listItemChosen, name="GroupList") grparea.add(self.grplist.gtk) self.grpmsg = gtk.Label() # helpful message when there are no grps grparea.add(self.grpmsg) self.newgroupbutton = gtk.Button('New...') gtklogger.setWidgetName(self.newgroupbutton, "New") vbox.pack_start(self.newgroupbutton, expand=0, fill=0) gtklogger.connect(self.newgroupbutton, 'clicked', self.newGroupButtonCB) self.newgroupbutton.set_sensitive(0) tooltips.set_tooltip_text( self.newgroupbutton, "Create a new empty %s group in the current microstructure." % pixstring) self.renamegroupbutton = gtk.Button('Rename...') gtklogger.setWidgetName(self.renamegroupbutton, "Rename") vbox.pack_start(self.renamegroupbutton, expand=0, fill=0) gtklogger.connect(self.renamegroupbutton, 'clicked', self.renameGroupButtonCB) self.renamegroupbutton.set_sensitive(0) tooltips.set_tooltip_text(self.renamegroupbutton, "Rename the selected %s group." % pixstring) self.copygroupbutton = gtk.Button('Copy...') gtklogger.setWidgetName(self.copygroupbutton, "Copy") vbox.pack_start(self.copygroupbutton, expand=0, fill=0) gtklogger.connect(self.copygroupbutton, 'clicked', self.copyGroupButtonCB) self.copygroupbutton.set_sensitive(0) tooltips.set_tooltip_text( self.copygroupbutton, "Create a new group containing the same %ss as the selected group." % pixstring) self.delgroupbutton = gtk.Button('Delete') gtklogger.setWidgetName(self.delgroupbutton, "Delete") vbox.pack_start(self.delgroupbutton, expand=0, fill=0) gtklogger.connect(self.delgroupbutton, 'clicked', self.deleteGroupButtonCB) self.delgroupbutton.set_sensitive(0) tooltips.set_tooltip_text( self.delgroupbutton, "Delete the selected %s group from the microstructure." % pixstring) self.meshablebutton = gtk.CheckButton('Meshable') gtklogger.setWidgetName(self.meshablebutton, "Meshable") vbox.pack_start(self.meshablebutton, expand=0, fill=0) self.meshablesignal = gtklogger.connect(self.meshablebutton, 'clicked', self.meshableGroupCB) self.meshablebutton.set_sensitive(0) tooltips.set_tooltip_text( self.meshablebutton, "Should adaptive meshes follow the boundaries of the selected %s group?" % pixstring) # buttons on rhs of pixelgroup list vbox = gtk.VBox(spacing=2) hbox.pack_start(vbox, expand=0, fill=0, padding=2) self.addbutton = gtk.Button('Add') gtklogger.setWidgetName(self.addbutton, "Add") vbox.pack_start(self.addbutton, expand=0, fill=0) gtklogger.connect(self.addbutton, 'clicked', self.addPixelsCB) self.addbutton.set_sensitive(0) tooltips.set_tooltip_text( self.addbutton, "Add the currently selected %ss to the selected group." % pixstring) self.removebutton = gtk.Button('Remove') gtklogger.setWidgetName(self.removebutton, "Remove") vbox.pack_start(self.removebutton, expand=0, fill=0) gtklogger.connect(self.removebutton, 'clicked', self.removePixelsCB) self.removebutton.set_sensitive(0) tooltips.set_tooltip_text( self.removebutton, "Remove the currently selected %ss from the selected group." % pixstring) self.clearbutton = gtk.Button('Clear') gtklogger.setWidgetName(self.clearbutton, "Clear") vbox.pack_start(self.clearbutton, expand=0, fill=0) gtklogger.connect(self.clearbutton, 'clicked', self.clearPixelsCB) self.clearbutton.set_sensitive(0) tooltips.set_tooltip_text( self.clearbutton, "Reset the selected group by removing all the %ss from the group." % pixstring) self.infobutton = gtk.Button('Info') gtklogger.setWidgetName(self.infobutton, "Info") vbox.pack_start(self.infobutton, expand=0, fill=0) gtklogger.connect(self.infobutton, 'clicked', self.queryPixelsCB) self.infobutton.set_sensitive(0) tooltips.set_tooltip_text( self.infobutton, "Display information about the selected group in the Messages window." ) self.built = True self.sbcallbacks = [ switchboard.requestCallback('new pixel group', self.newpixgrp), switchboard.requestCallback('destroy pixel group', self.destpixgrp), # switchboard.requestCallback('changed pixel group', self.destpixgrp), switchboard.requestCallback('changed pixel groups', self.chngdgrps), switchboard.requestCallback(('new who', 'Microstructure'), self.newwhoMS), switchboard.requestCallback(('new who', 'Image'), self.newwhoImage), switchboard.requestCallback(('rename who', 'Image'), self.displayMSInfo), switchboard.requestCallback('remove who', self.removewho), switchboard.requestCallback('renamed pixel group', self.renamepixgrp), switchboard.requestCallback('pixel selection changed', self.selectionchanged), switchboard.requestCallback('images changed in microstructure', self.displayMSInfo) ]
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) ]
def __init__(self): oofGUI.MainPage.__init__(self, name="Pin Nodes", ordering=120.1, tip='Pin and unpin nodes') 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.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'), callback=self.select_skeletonCB) 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) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') # Pinned nodes status in the left half of the main pane pnsframe = gtk.Frame("Pinned Nodes Status") pnsframe.set_shadow_type(gtk.SHADOW_IN) self.datascroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.datascroll, "StatusScroll") pnsframe.add(self.datascroll) self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.psdata = fixedwidthtext.FixedWidthTextView() self.psdata.set_editable(False) self.psdata.set_wrap_mode(gtk.WRAP_WORD) self.psdata.set_cursor_visible(False) self.datascroll.add_with_viewport(self.psdata) mainpane.pack1(pnsframe, resize=1, shrink=0) # Pin nodes method modframe = gtk.Frame("Pin Nodes Methods") gtklogger.setWidgetName(modframe, 'Modify') modframe.set_shadow_type(gtk.SHADOW_IN) modbox = gtk.VBox() # will have "methods" and "buttons" modframe.add(modbox) self.pinModFactory = regclassfactory.RegisteredClassFactory( pinnodesmodifier.PinNodesModifier.registry, title="Method:", scope=self, name="Method") modbox.pack_start(self.pinModFactory.gtk, expand=1, fill=1, padding=2) # buttons hbox1 = gtk.HBox() modbox.pack_start(hbox1, expand=0, fill=0, padding=2) self.okbutton = gtk.Button(stock=gtk.STOCK_OK) gtklogger.setWidgetName(self.okbutton, 'OK') gtklogger.connect(self.okbutton, "clicked", self.okCB) tooltips.set_tooltip_text(self.okbutton, "Pin nodes with the selected method.") self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) gtklogger.setWidgetName(self.undobutton, 'Undo') gtklogger.connect(self.undobutton, "clicked", self.undoCB) tooltips.set_tooltip_text(self.undobutton, "Undo the latest action.") self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.connect(self.redobutton, "clicked", self.redoCB) tooltips.set_tooltip_text(self.redobutton, "Redo the latest undone action.") hbox1.pack_start(self.undobutton, expand=0, fill=1, padding=2) hbox1.pack_start(self.okbutton, expand=1, fill=1, padding=2) hbox1.pack_end(self.redobutton, expand=0, fill=1, padding=2) hbox2 = gtk.HBox(homogeneous=1) modbox.pack_start(hbox2, expand=0, fill=0, padding=2) self.unpinallbutton = gtk.Button("Unpin All") gtklogger.setWidgetName(self.unpinallbutton, 'Unpin All') gtklogger.connect(self.unpinallbutton, "clicked", self.unpinallCB) tooltips.set_tooltip_text(self.unpinallbutton, "Unpin all the pinned nodes.") self.invertbutton = gtk.Button("Invert") gtklogger.setWidgetName(self.invertbutton, 'Invert') gtklogger.connect(self.invertbutton, "clicked", self.invertCB) tooltips.set_tooltip_text( self.invertbutton, "Invert - pin the unpinned and unpin the pinned.") hbox2.pack_start(self.unpinallbutton, expand=1, fill=1, padding=2) hbox2.pack_start(self.invertbutton, expand=1, fill=1, padding=2) mainpane.pack2(modframe, resize=0, shrink=0) # Switchboard callbacks switchboard.requestCallbackMain(('who changed', 'Skeleton'), self.changeSkeleton) switchboard.requestCallbackMain(('new who', 'Microstructure'), self.newMS) switchboard.requestCallbackMain("new pinned nodes", self.newNodesPinned) switchboard.requestCallbackMain(self.skelwidget, self.skel_update) switchboard.requestCallbackMain("made reservation", self.reservationChanged) switchboard.requestCallbackMain("cancelled reservation", self.reservationChanged)
def show(self): #the first report error window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_border_width(15) self.window.set_title("Report Error") self.box = gtk.VBox(False, 5) #contains all the widgets self.window.add(self.box) hbox = gtk.HBox() self.box.pack_start(hbox) label = gtk.Label( "Choose what information to include in the error report." " The more information you include, the easier it will be" " to pinpoint the cause of the error.") label.set_line_wrap(True) label.modify_font(pango.FontDescription("italic ")) label.set_alignment(0, 0) hbox.pack_start(label) label.show() hbox.show() # User chooses which logs to include label = gtk.Frame('Include:') self.box.pack_start(label, False, False, 0) self.box2 = gtk.VBox(False, 2) label.add(self.box2) self.pythonLogButton = gtk.CheckButton("Python Log") self.pythonLogButton.set_active(True) self.pythonplusLogButton = gtk.CheckButton("Python Log with Outputs") self.pythonplusLogButton.set_active(True) self.instalLogButton = gtk.CheckButton("Installation Log") self.instalLogButton.set_active(True) self.tracebackButton = gtk.CheckButton("Traceback file") self.tracebackButton.set_active(True) self.box2.pack_start(self.pythonLogButton) self.box2.pack_start(self.pythonplusLogButton) self.box2.pack_start(self.instalLogButton) self.box2.pack_start(self.tracebackButton) self.pythonLogButton.show() self.pythonplusLogButton.show() self.instalLogButton.show() self.tracebackButton.hide() self.box2.show() label.show() reporterror.parseFiles( reporterror.getPythonLog) # finds all the file calls in pythonlog #User input files to include self.box3 = gtk.HBox(False, 0) label = gtk.Frame('Input Files to Include:') self.add_file = gtk.Button(stock=gtk.STOCK_ADD) self.add_file.connect("clicked", self.add_button) #tooltips.set_tooltip_text(self.add_file, "Allow user to manually add input files.") self.box3.pack_start(label, True, True, 0) self.box3.pack_start(self.add_file, False, False, 0) self.add_file.show() self.box.pack_start(self.box3, True, True, 0) self.box31 = gtk.VBox(False, 2) label.add(self.box31) self.infilenames = reporterror.getInfiles() self.infilebuttons = [] for file in self.infilenames: self.infilebuttons.append(gtk.CheckButton(file)) for button in self.infilebuttons: self.box31.pack_start(button) button.set_active(True) button.show() self.box31.show() label.show() #show files box self.box3.show() #User output files to include label = gtk.Frame('Output Files to Include:') self.box.pack_start(label, False, False, 0) self.box4 = gtk.VBox(False, 2) label.add(self.box4) self.outfilenames = reporterror.getOutfiles() self.outfilebuttons = [] for file in self.outfilenames: self.outfilebuttons.append(gtk.CheckButton(file)) for button in self.outfilebuttons: self.box4.pack_start(button) button.set_active(True) button.show() self.box4.show() label.show() #show #Option to include files that have been deleted from the system label = gtk.Frame('') self.box.pack_start(label) self.delfiles = reporterror.getDelfiles() files = "( " i = 1 for file in self.delfiles: #Formatting the files list if (i % 2 == 0): file = file + '\n' files = files + '\'' + file + '\' ' i += 1 files = files + ')' self.deletedfilesbutton = gtk.CheckButton( "Include names of input/output files that are no longer in the system:\n" + files) self.deletedfilesbutton.set_active(True) label.add(self.deletedfilesbutton) if (self.delfiles != []): self.deletedfilesbutton.show() label.show() #Comments Sections label = gtk.Frame('Additional Comments:') self.box.pack_start(label) self.box5 = gtk.VBox(False, 2) hbox = gtk.HBox(False, 100) label.add(self.box5) self.box5.pack_start(hbox) text = gtk.Label("What did you do? What went wrong?") text.modify_font(pango.FontDescription("italic ")) text.set_alignment(0, 0) hbox.pack_start(text, False, False, 0) text.show() hbox.show() scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = fixedwidthtext.FixedWidthTextView() scroll.add(self.textview) scroll.show() self.textview.show() self.box5.pack_start(scroll) self.box5.show() label.show() self.window.set_default_size( 60 * gtkutils.widgetCharSize(self.textview), -1) # OK and CANCEL Buttons self.end = gtk.HBox(False, 100) self.button1 = gtk.Button(stock=gtk.STOCK_OK) self.button1.connect("clicked", self.okbutton1) self.end.pack_start(self.button1, True, True, 0) self.button1.show() self.button2 = gtk.Button(stock=gtk.STOCK_CANCEL) self.button2.connect("clicked", self.cancelbutton, self.window) self.end.pack_start(self.button2, True, True, 0) self.button2.show() self.box.pack_start(self.end, True, True, 0) self.end.show() self.box.show() self.window.show()
def __init__(self): self.built = False oofGUI.MainPage.__init__( self, name="FE Mesh", ordering=200, tip="Create a Finite Element Mesh from a Skeleton.") 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) 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) # Centered box of buttons align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) bbox = gtk.HBox(homogeneous=1, spacing=3) align.add(bbox) self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, "New...") gtklogger.setWidgetName(self.newbutton, 'New') gtklogger.connect(self.newbutton, 'clicked', self.newCB) tooltips.set_tooltip_text( self.newbutton, "Create a new mesh from the current skeleton.") bbox.pack_start(self.newbutton, expand=0, fill=1) self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Rename...") gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, 'clicked', self.renameCB) tooltips.set_tooltip_text(self.renamebutton, "Rename the current mesh.") bbox.pack_start(self.renamebutton, expand=0, fill=1) self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.copyCB) tooltips.set_tooltip_text(self.copybutton, "Copy the current mesh.") bbox.pack_start(self.copybutton, expand=0, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete") gtklogger.setWidgetName(self.deletebutton, 'Delete') gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB) tooltips.set_tooltip_text(self.deletebutton, "Delete the current mesh.") bbox.pack_start(self.deletebutton, expand=0, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...") gtklogger.setWidgetName(self.savebutton, 'Save') gtklogger.connect(self.savebutton, 'clicked', self.saveCB) tooltips.set_tooltip_text(self.savebutton, "Save the current mesh to a file.") bbox.pack_start(self.savebutton, expand=0, fill=1) mainpane = gtk.HPaned() gtklogger.setWidgetName(mainpane, 'Pane') mainbox.pack_start(mainpane, expand=1, fill=1) gtklogger.connect_passive(mainpane, 'notify::position') leftbox = gtk.VPaned() mainpane.pack1(leftbox, resize=1, shrink=0) infoframe = gtk.Frame('Mesh Information') infoframe.set_shadow_type(gtk.SHADOW_IN) leftbox.pack1(infoframe, resize=1, shrink=1) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "MeshInfo") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) infoframe.add(scroll) self.infoarea = fixedwidthtext.FixedWidthTextView() self.infoarea.set_cursor_visible(False) self.infoarea.set_editable(False) scroll.add(self.infoarea) # Subproblem creation, deletion, etc. subprobframe = gtk.Frame('Subproblems') gtklogger.setWidgetName(subprobframe, 'Subproblems') subprobframe.set_shadow_type(gtk.SHADOW_IN) leftbox.pack2(subprobframe, resize=1, shrink=1) subpbox = gtk.VBox() subprobframe.add(subpbox) self.subpchooser = chooser.ScrolledChooserListWidget( callback=self.subpchooserCB, dbcallback=self.subprobEditCB, name="subprobChooser") subpbox.pack_start(self.subpchooser.gtk, expand=1, fill=1) subpbuttons1 = gtk.HBox(homogeneous=True, spacing=2) subpbuttons2 = gtk.HBox(homogeneous=True, spacing=2) subpbox.pack_start(subpbuttons1, expand=0, fill=0) subpbox.pack_start(subpbuttons2, expand=0, fill=0) self.subprobNew = gtkutils.StockButton(gtk.STOCK_NEW, "New...") gtklogger.setWidgetName(self.subprobNew, "New") gtklogger.connect(self.subprobNew, "clicked", self.subprobNewCB) tooltips.set_tooltip_text(self.subprobNew, "Create a new subproblem.") subpbuttons1.pack_start(self.subprobNew, expand=1, fill=1) self.subprobRename = gtk.Button("Rename...") gtklogger.setWidgetName(self.subprobRename, "Rename") gtklogger.connect(self.subprobRename, "clicked", self.subprobRenameCB) tooltips.set_tooltip_text(self.subprobRename, "Rename the selected subproblem") subpbuttons1.pack_start(self.subprobRename, expand=1, fill=1) self.subprobEdit = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...") gtklogger.setWidgetName(self.subprobEdit, "Edit") gtklogger.connect(self.subprobEdit, 'clicked', self.subprobEditCB) tooltips.set_tooltip_text(self.subprobEdit, "Edit the selected subproblem.") subpbuttons1.pack_start(self.subprobEdit, expand=1, fill=1) self.subprobCopy = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.subprobCopy, "Copy") gtklogger.connect(self.subprobCopy, "clicked", self.subprobCopyCB) tooltips.set_tooltip_text(self.subprobCopy, "Copy the selected subproblem.") subpbuttons2.pack_start(self.subprobCopy, expand=1, fill=1) ## subpbuttons2.pack_start(gtk.HBox(), expand=1, fill=1) # filler self.subprobInfo = gtk.Button("Info") gtklogger.setWidgetName(self.subprobInfo, "Info") gtklogger.connect(self.subprobInfo, 'clicked', self.subprobInfoCB) tooltips.set_tooltip_text( self.subprobInfo, "Print information about the selected subproblem") subpbuttons2.pack_start(self.subprobInfo, expand=1, fill=1) self.subprobDelete = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete") gtklogger.setWidgetName(self.subprobDelete, "Delete") gtklogger.connect(self.subprobDelete, "clicked", self.subprobDeleteCB) tooltips.set_tooltip_text(self.subprobDelete, "Delete the selected subproblem.") subpbuttons2.pack_start(self.subprobDelete, expand=1, fill=1) # Right hand side for element operations elementopsframe = gtk.Frame(label="Mesh Operations") gtklogger.setWidgetName(elementopsframe, 'ElementOps') elementopsframe.set_shadow_type(gtk.SHADOW_IN) mainpane.pack2(elementopsframe, resize=0, shrink=0) elementopsbox = gtk.VBox(spacing=3) elementopsframe.add(elementopsbox) self.elementops = regclassfactory.RegisteredClassFactory( meshmod.MeshModification.registry, title="Method:", callback=self.elementopsCB, expand=0, fill=0, scope=self, name="Method") elementopsbox.pack_start(self.elementops.gtk, expand=1, fill=1) self.historian = historian.Historian(self.elementops.set, self.sensitizeHistory, setCBkwargs={'interactive': 1}) # Prev, OK, Next hbox = gtk.HBox() elementopsbox.pack_start(hbox, expand=0, fill=0, padding=2) self.prevbutton = gtkutils.prevButton() gtklogger.connect(self.prevbutton, 'clicked', self.prevCB) tooltips.set_tooltip_text( self.prevbutton, "Recall the previous mesh element operation.") hbox.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', self.okCB) tooltips.set_tooltip_text(self.okbutton, 'Perform the mesh operation defined above.') hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5) self.nextbutton = gtkutils.nextButton() gtklogger.connect(self.nextbutton, 'clicked', self.nextCB) tooltips.set_tooltip_text(self.nextbutton, 'Recall the next mesh element operation.') hbox.pack_start(self.nextbutton, expand=0, fill=0, padding=2) self.built = True switchboard.requestCallbackMain("Mesh modified", self.recordModifier) switchboard.requestCallbackMain("mesh changed", self.meshchangeCB) switchboard.requestCallbackMain(("new who", "Microstructure"), self.newMSorSkeleton) switchboard.requestCallbackMain(("new who", "Skeleton"), self.newMSorSkeleton) switchboard.requestCallbackMain(("new who", "Mesh"), self.newMesh) switchboard.requestCallbackMain(("new who", "SubProblem"), self.newSubProblem) switchboard.requestCallbackMain(("rename who", "SubProblem"), self.renamedSubProblem) switchboard.requestCallbackMain(("remove who", "SubProblem"), self.removeSubProblem) switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB) switchboard.requestCallbackMain("equation activated", self.equationCB) switchboard.requestCallbackMain("mesh status changed", self.statusChanged) # switchboard.requestCallbackMain("mesh boundaries changed", # self.newMeshBoundaries) switchboard.requestCallbackMain(('validity', self.elementops), self.validityChangeCB)