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 + '...' # Add tooltip. if self.helpstr: label = gtk.EventBox() if self.accel: # add accelerator too l2 = gtk.AccelLabel(name) l2.set_accel_widget(gtkitem) else: l2 = gtk.Label(name) # don't add accelerator l2.set_alignment(0.0, 0.5) label.add(l2) tooltips.set_tooltip_text(label, self.helpstr) else: # don't add tooltip if self.accel: label = gtk.AccelLabel(name) label.set_accel_widget(gtkitem) else: label = gtk.Label(name) label.set_alignment(0.0, 0.5) label.show_all() return label
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) ## Moved to time dependence page # if eqn.get_kinetic()>0 and config.devel()>=1: # button = gtk.CheckButton('kinetic') # gtklogger.setWidgetName(button, eqn.name() + " kinetic") # signal = gtklogger.connect(button, 'clicked', self.eqnKineticCB, # eqn) # self.eqnbuttons[(eqn.name(), "kinetic")] = ButtonSignal(button, # signal) # self.eqntable.attach(button, 3,4, row, row+1, # xoptions=0, yoptions=0) # if eqn.get_dynamics()>0 and config.devel()>=1: # button = gtk.CheckButton('dynamic') # gtklogger.setWidgetName(button, eqn.name() + " dynamic") # signal = gtklogger.connect(button, 'clicked', # self.eqnDynamicCB, eqn) # self.eqnbuttons[(eqn.name(), "dynamic")] = ButtonSignal(button, # signal) # self.eqntable.attach(button, 4,5, 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 postinitialize(self, name, gfxmanager, clone): debug.mainthreadTest() # Add gui callbacks to the non-gui menu created by the GhostGfxWindow. filemenu = self.menu.File filemenu.Quit.add_gui_callback(quit.queryQuit) layermenu = self.menu.Layer layermenu.New.add_gui_callback(self.newLayer_gui) layermenu.Edit.add_gui_callback(self.editLayer_gui) layermenu.Delete.add_gui_callback(self.deleteLayer_gui) layermenu.Hide.add_gui_callback(self.hideLayer_gui) layermenu.Show.add_gui_callback(self.showLayer_gui) ## layermenu.Hide_Contour_Map.add_gui_callback( ## self.hideLayerContourmap_gui) ## layermenu.Show_Contour_Map.add_gui_callback( ## self.showLayerContourmap_gui) layermenu.Raise.One_Level.add_gui_callback(self.raiseLayer_gui) layermenu.Raise.To_Top.add_gui_callback(self.raiseToTop_gui) layermenu.Lower.One_Level.add_gui_callback(self.lowerLayer_gui) layermenu.Lower.To_Bottom.add_gui_callback(self.lowerToBottom_gui) settingmenu = self.menu.Settings toolboxmenu = self.menu.Toolbox # Construct gui's for toolboxes. This must be done after the # base class is constructed so that all non-gui toolboxes are # created before any of their gui versions. Some gui # toolboxes need to know about more than one non-gui toolbox. map(self.makeToolboxGUI, self.toolboxes) if self.toolboxGUIs: self.selectToolbox(self.toolboxGUIs[0].name()) self.toolboxchooser.set_state(self.toolboxGUIs[0].name()) # raise_window routine is in SubWindow class. getattr(mainmenu.OOF.Windows.Graphics, name).add_gui_callback( self.raise_window) # SubWindow initializer makes the menu bar, and sets up the # .gtk and .mainbox members. ".gtk" is the window itself, # and .mainbox is a gtk.VBox that holds the menu bar. windowname = utils.underscore2space("OOF3D " + name) subWindow.SubWindow.__init__( self, windowname, menu=self.menu) self.gtk.connect('destroy', self.destroyCB) self.gtk.connect_after('realize', self.realizeCB) self.gtk.set_default_size(GfxWindow3D.initial_width, GfxWindow3D.initial_height) self.mainbox.set_spacing(3) self.mainbox.pack_start(self.mainpane, fill=1, expand=1) self.gtk.show_all() self.updateToolboxChooser()
def postinitialize(self, name, gfxmanager, clone): debug.mainthreadTest() # Add gui callbacks to the non-gui menu created by the GhostGfxWindow. filemenu = self.menu.File filemenu.Quit.add_gui_callback(quit.queryQuit) layermenu = self.menu.Layer layermenu.New.add_gui_callback(self.newLayer_gui) layermenu.Edit.add_gui_callback(self.editLayer_gui) layermenu.Delete.add_gui_callback(self.deleteLayer_gui) layermenu.Hide.add_gui_callback(self.hideLayer_gui) layermenu.Show.add_gui_callback(self.showLayer_gui) ## layermenu.Hide_Contour_Map.add_gui_callback( ## self.hideLayerContourmap_gui) ## layermenu.Show_Contour_Map.add_gui_callback( ## self.showLayerContourmap_gui) layermenu.Raise.One_Level.add_gui_callback(self.raiseLayer_gui) layermenu.Raise.To_Top.add_gui_callback(self.raiseToTop_gui) layermenu.Lower.One_Level.add_gui_callback(self.lowerLayer_gui) layermenu.Lower.To_Bottom.add_gui_callback(self.lowerToBottom_gui) settingmenu = self.menu.Settings toolboxmenu = self.menu.Toolbox # Construct gui's for toolboxes. This must be done after the # base class is constructed so that all non-gui toolboxes are # created before any of their gui versions. Some gui # toolboxes need to know about more than one non-gui toolbox. map(self.makeToolboxGUI, self.toolboxes) if self.toolboxGUIs: self.selectToolbox(self.toolboxGUIs[0].name()) self.toolboxchooser.set_state(self.toolboxGUIs[0].name()) # raise_window routine is in SubWindow class. getattr(mainmenu.OOF.Windows.Graphics, name).add_gui_callback(self.raise_window) # SubWindow initializer makes the menu bar, and sets up the # .gtk and .mainbox members. ".gtk" is the window itself, # and .mainbox is a gtk.VBox that holds the menu bar. windowname = utils.underscore2space("OOF3D " + name) subWindow.SubWindow.__init__(self, windowname, menu=self.menu) self.gtk.connect('destroy', self.destroyCB) self.gtk.connect_after('realize', self.realizeCB) self.gtk.set_default_size(GfxWindow3D.initial_width, GfxWindow3D.initial_height) self.mainbox.set_spacing(3) self.mainbox.pack_start(self.mainpane, fill=1, expand=1) self.gtk.show_all() self.updateToolboxChooser()
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
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 gtkOOFMenu(menu, accelgroup=None): """ Function to turn an OOFMenu into GTK+. The leading GtkMenuItem is returned. """ debug.mainthreadTest() base = gtk.MenuItem(utils.underscore2space(menu.name)) gtklogger.setWidgetName(base, menu.name) new_gtkmenu = gtk.Menu() try: menu.gtkmenu.append(new_gtkmenu) except AttributeError: menu.gtkmenu = [new_gtkmenu] new_gtkmenu.connect("destroy", menu.gtkmenu_destroyed) gtklogger.set_submenu(base, new_gtkmenu) menu.setOption('accelgroup', accelgroup) for item in menu: if not (item.secret or item.getOption('cli_only')): item.construct_gui(menu, new_gtkmenu, accelgroup) return base
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, toolbox): toolboxGUI.GfxToolbox.__init__(self, utils.underscore2space(toolbox.name()), toolbox) mainbox = gtk.VBox() self.gtk.add(mainbox) sourceframe = gtk.Frame("Source") sourceframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(sourceframe, fill=0, expand=0) sourcescroll = gtk.ScrolledWindow() gtklogger.logScrollBars(sourcescroll, "Source") sourceframe.add(sourcescroll) sourcescroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER) datatable = gtk.Table(rows=2, columns=2) sourcescroll.add_with_viewport(datatable) meshlabel = gtk.Label("mesh = ") meshlabel.set_alignment(1.0, 0.5) self.meshname = gtk.Label() gtklogger.setWidgetName(self.meshname, "meshname") self.meshname.set_alignment(0.0, 0.5) datatable.attach(meshlabel, 0, 1, 0, 1) datatable.attach(self.meshname, 1, 2, 0, 1) layerlabel = gtk.Label("output = ") layerlabel.set_alignment(1.0, 0.5) self.layername = gtk.Label() gtklogger.setWidgetName(self.layername, "layername") self.layername.set_alignment(0.0, 0.5) datatable.attach(layerlabel, 0, 1, 1, 2) datatable.attach(self.layername, 1, 2, 1, 2) csframe = gtk.Frame("Cross Section") csframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(csframe, expand=0, fill=0) csbox = gtk.VBox() csframe.add(csbox) # Table contains the "current" and "points" widgets table = gtk.Table(rows=2, columns=2) csbox.pack_start(table, expand=0, fill=0) # Widget which shows the name of the current cross-section. label = gtk.Label("current: ") label.set_alignment(1.0, 0.5) table.attach(label, 0, 1, 0, 1, xoptions=0) self.csChooser = chooser.ChooserWidget([], callback=self.csChooserCB, name='csList') table.attach(self.csChooser.gtk, 1, 2, 0, 1, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) # Widget for how to sample the cross-section. label = gtk.Label("points: ") label.set_alignment(1.0, 0.5) table.attach(label, 0, 1, 1, 2, xoptions=0) self.cs_sample_widget = sampleregclassfactory.SampleRCF( name="Sampling", domainClass=analysisdomain.CrossSectionDomain, operationClass=analyze.DirectOutput) table.attach(self.cs_sample_widget.gtk, 1, 2, 1, 2, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) self.cs_sample_widget.update(analysissample.SampleSet.registry) self.int_valid_swcb = switchboard.requestCallbackMain( ('validity', self.cs_sample_widget), self.validCB) hbox = gtk.HBox() csbox.pack_start(hbox, expand=0, fill=0, padding=1) # Rename button. self.renamebutton = gtk.Button("Rename") gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, 'clicked', self.csrenameCB) tooltips.set_tooltip_text(self.renamebutton, "Rename the current cross-section.") hbox.pack_start(self.renamebutton, fill=1, expand=1, padding=1) # Edit button self.editbutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...") gtklogger.setWidgetName(self.editbutton, 'Edit') gtklogger.connect(self.editbutton, 'clicked', self.cseditCB) tooltips.set_tooltip_text(self.editbutton, "Edit the current cross-section.") hbox.pack_start(self.editbutton, fill=1, expand=1, padding=1) # Copy button self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.cscopyCB) tooltips.set_tooltip_text(self.copybutton, "Copy the current cross-section.") hbox.pack_start(self.copybutton, fill=1, expand=1, padding=1) # Delete button. self.csdeletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Remove") gtklogger.setWidgetName(self.csdeletebutton, 'Remove') gtklogger.connect(self.csdeletebutton, "clicked", self.csdeleteCB) tooltips.set_tooltip_text(self.csdeletebutton, "Remove the current cross-section.") hbox.pack_start(self.csdeletebutton, fill=1, expand=1, padding=1) goframe = gtk.Frame("Output") goframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(goframe, expand=0, fill=0) self.gobox = gtk.VBox() goframe.add(self.gobox) hbox = gtk.HBox() self.gobox.pack_start(hbox, expand=0, fill=0) label = gtk.Label("Destination: ") label.set_alignment(1.0, 0.5) hbox.pack_start(label, expand=0, fill=0) self.destwidget = outputdestinationwidget.TextDestinationWidget( name="Destination") self.dw_valid_swcb = switchboard.requestCallbackMain( ('validity', self.destwidget), self.validCB) hbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2) self.gobutton = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go!") gtklogger.setWidgetName(self.gobutton, 'Go') hbox.pack_start(self.gobutton, expand=1, fill=1, padding=2) tooltips.set_tooltip_text(self.gobutton, "Send the output to the destination.") gtklogger.connect(self.gobutton, "clicked", self.goCB) self.startpoint = None self.endpoint = None # Data needed by the "go" button. Set in "show_data", when # the state of all the widgets is examined. self.meshobj = None self.current_cs_name = None # Shut off non-GUI toolbox's switchboard callbacks. We will # take them over at activate-time. self.toolbox.stop_callbacks()
def __init__thread(self, gfxwindow, time, position, output): debug.mainthreadTest() allMeshDataWindows.append(self) widgetscope.WidgetScope.__init__(self, None) current_count = MeshDataGUI.count MeshDataGUI.count += 1 self._name = "Mesh_Data_%d" % current_count self.output = output self.time = time self.position = position self.sbcallbacks = [] self.gsbcallbacks = [] # callbacks from a specific gfx window self.updateLock = lock.Lock() self.outputparam = \ ooflib.engine.IO.output.AggregateOutputParameter('output') # Although it's not displayed, we need a mesh widget in the # widgetscope, or the OutputParameterWidget won't work. # TODO LATER: Is this ugly, or what? self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self, name="Godot") self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL) title = utils.underscore2space(self._name) self.gtk.set_title(title) gtklogger.newTopLevelWidget(self.gtk, title) gtklogger.connect_passive(self.gtk, 'delete-event') gtklogger.connect_passive(self.gtk, 'configure-event') self.mainbox = gtk.VBox() self.gtk.add(self.mainbox) # Put this window into the Windows menu. The menu item can't # be logged, since the creation and operation of the window # aren't logged, so scripts shouldn't refer to it at all. mainmenu.OOF.Windows.Mesh_Data.addItem( oofmenu.OOFMenuItem(self._name, no_log=1, help="Raise Mesh Data window %d." % current_count, threadable=oofmenu.UNTHREADABLE, callback=self.raiseWindow)) expander = gtk.Expander("Source") gtklogger.setWidgetName(expander, 'ViewSource') gtklogger.connect_passive_after(expander, 'activate') self.mainbox.pack_start(expander) expander.set_expanded(1) self.table = gtk.Table(rows=config.dimension() + 4, columns=2) expander.add(self.table) label = gtk.Label("Source Window:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 0, 1, xpadding=3, xoptions=gtk.FILL) tooltips.set_tooltip_text( label, "Display data for mouse clicks in this Graphics window.") self.gfxWindowChooser = chooser.ChooserWidget([], callback=self.chooserCB, name='GfxWindow') self.table.attach(self.gfxWindowChooser.gtk, 1, 2, 0, 1, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) label = gtk.Label("Mesh:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 1, 2, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text( label, "Data is displayed for values on this mesh.") self.meshText = gtk.Entry() gtklogger.setWidgetName(self.meshText, "meshname") self.meshText.set_editable(False) self.meshText.set_size_request(12 * guitop.top().charsize, -1) self.table.attach(self.meshText, 1, 2, 1, 2, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) # Position controls label = gtk.Label("position x:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 2, 3, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.xText = gtk.Entry() gtklogger.setWidgetName(self.xText, 'x') self.xText.set_size_request(12 * guitop.top().digitsize, -1) self.table.attach(self.xText, 1, 2, 2, 3, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) self.xsignal = gtklogger.connect(self.xText, 'changed', self.posChangedCB) label = gtk.Label("position y:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 3, 4, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.yText = gtk.Entry() gtklogger.setWidgetName(self.yText, 'y') self.yText.set_size_request(12 * guitop.top().digitsize, -1) self.table.attach(self.yText, 1, 2, 3, 4, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) self.ysignal = gtklogger.connect(self.yText, 'changed', self.posChangedCB) if config.dimension() == 3: label = gtk.Label("position z:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 4, 5, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.zText = gtk.Entry() gtklogger.setWidgetName(self.zText, 'z') self.zText.set_size_request(12 * guitop.top().digitsize, -1) self.table.attach(self.zText, 1, 2, 4, 5, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) self.zsignal = gtklogger.connect(self.zText, 'changed', self.posChangedCB) timerow = 5 else: timerow = 6 # Time controls. Typing in the time widget does not # immediately update the displayed data, because interpolating # to a new time is an expensive computation, and shouldn't be # done while the user is in the middle of typing. Instead, # the time widget is normally desensitized and uneditable. # When the user clicks the "Edit" button, the widget becomes # editable, the rest of the window is desensitized, and the # "Edit" button changes do a "Done" button. When the user # clicks "Done" the data is updated and the time widget # becomes uneditable again. label = gtk.Label("time:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, timerow, timerow + 1, xpadding=3, xoptions=gtk.FILL, yoptions=0) tBox = gtk.HBox(spacing=3) self.table.attach(tBox, 1, 2, timerow, timerow + 1, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) self.tText = gtk.Entry() self.tText.set_editable(False) self.tText.set_sensitive(False) tBox.pack_start(self.tText, expand=1, fill=1) gtklogger.setWidgetName(self.tText, 't') self.tText.set_size_request(12 * guitop.top().digitsize, -1) self.tEditButton = gtk.Button("Edit") tBox.pack_start(self.tEditButton, expand=0, fill=0) gtklogger.setWidgetName(self.tEditButton, "tEdit") gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB) self.tEditMode = False # Output selection label = gtk.Label("Output:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, timerow + 2, timerow + 3, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text(label, "Choose which data is displayed.") self.outputwidget = self.outputparam.makeWidget(scope=self) self.table.attach(self.outputwidget.gtk, 1, 2, timerow + 2, timerow + 3, xpadding=3, xoptions=gtk.EXPAND | gtk.FILL, yoptions=0) switchboard.requestCallback(self.outputwidget, self.outputwidgetCB) # Data display panel hbox = gtk.HBox() self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5) frame = gtk.Frame("Data") gtklogger.setWidgetName(frame, 'Data') frame.set_shadow_type(gtk.SHADOW_IN) hbox.pack_start(frame, expand=1, fill=1, padding=5) vbox = gtk.VBox() frame.add(vbox) self.databox = gtk.HBox() vbox.pack_start(self.databox, expand=1, fill=1, padding=3) self.datawidget = None # set by updateData # Buttons at the bottom of the window buttonbox = gtk.HBox() self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3) # Freeze buttons freezeframe = gtk.Frame("Freeze") gtklogger.setWidgetName(freezeframe, "Freeze") buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3) hbox = gtk.HBox() freezeframe.add(hbox) # Freeze Space button self.freezeSpaceFlag = False self.freezeSpaceButton = gtk.CheckButton('Space') gtklogger.setWidgetName(self.freezeSpaceButton, 'Space') hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0) self.freezeSpaceButton.set_active(self.freezeSpaceFlag) gtklogger.connect(self.freezeSpaceButton, 'clicked', self.freezeSpaceButtonCB) tooltips.set_tooltip_text( self.freezeSpaceButton, "Prevent the data in this window from being updated when the sample position changes." ) # Freeze Time button self.freezeTimeFlag = False self.freezeTimeButton = gtk.CheckButton('Time') gtklogger.setWidgetName(self.freezeTimeButton, "Time") hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0) self.freezeTimeButton.set_active(self.freezeTimeFlag) gtklogger.connect(self.freezeTimeButton, 'clicked', self.freezeTimeButtonCB) tooltips.set_tooltip_text( self.freezeTimeButton, "Prevent the data in this window from being updated when the Mesh's time changes." ) # Clone button self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone') gtklogger.setWidgetName(self.cloneButton, 'Clone') gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB) buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3) tooltips.set_tooltip_text( self.cloneButton, "Make a copy of this window with its current settings.") # Close button self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE) gtklogger.setWidgetName(self.closeButton, 'Close') gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB) buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3) self.gtk.connect('destroy', self.destroyCB) self.updateGfxWindowChooser() if gfxwindow: self.gfxWindowChooser.set_state(gfxwindow.name) if position is not None: self.updatePosition(position) self.currentMesh = None self.updateMesh() self.setupSwitchboard() # gfx window dependent callbacks self.sbcallbacks += [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('mesh data changed', self.meshDataChanged), switchboard.requestCallbackMain((gfxwindow, "time changed"), self.timeChanged) ] self.gtk.show_all()
def __init__(self, toolbox): toolboxGUI.GfxToolbox.__init__( self, utils.underscore2space(toolbox.name()), toolbox) mainbox = gtk.VBox() self.gtk.add(mainbox) sourceframe = gtk.Frame("Source") sourceframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(sourceframe, fill=0, expand=0) sourcescroll = gtk.ScrolledWindow() gtklogger.logScrollBars(sourcescroll, "Source") sourceframe.add(sourcescroll) sourcescroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER) datatable = gtk.Table(rows=2,columns=2) sourcescroll.add_with_viewport(datatable) meshlabel = gtk.Label("mesh = ") meshlabel.set_alignment(1.0, 0.5) self.meshname = gtk.Label() gtklogger.setWidgetName(self.meshname,"meshname") self.meshname.set_alignment(0.0, 0.5) datatable.attach(meshlabel, 0, 1, 0, 1) datatable.attach(self.meshname, 1, 2, 0, 1) layerlabel = gtk.Label("output = ") layerlabel.set_alignment(1.0, 0.5) self.layername = gtk.Label() gtklogger.setWidgetName(self.layername,"layername") self.layername.set_alignment(0.0, 0.5) datatable.attach(layerlabel, 0, 1, 1, 2) datatable.attach(self.layername, 1, 2, 1, 2) csframe = gtk.Frame("Cross Section") csframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(csframe, expand=0, fill=0) csbox = gtk.VBox() csframe.add(csbox) # Table contains the "current" and "points" widgets table = gtk.Table(rows=2, columns=2) csbox.pack_start(table, expand=0, fill=0) # Widget which shows the name of the current cross-section. label = gtk.Label("current: ") label.set_alignment(1.0, 0.5) table.attach(label, 0,1, 0,1, xoptions=0) self.csChooser = chooser.ChooserWidget([], callback=self.csChooserCB, name='csList') table.attach(self.csChooser.gtk, 1,2, 0,1, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) # Widget for how to sample the cross-section. label = gtk.Label("points: ") label.set_alignment(1.0, 0.5) table.attach(label, 0,1, 1,2, xoptions=0) self.cs_sample_widget = sampleregclassfactory.SampleRCF( name="Sampling", domainClass=analysisdomain.CrossSectionDomain, operationClass=analyze.DirectOutput) table.attach(self.cs_sample_widget.gtk, 1,2, 1,2, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.cs_sample_widget.update(analysissample.SampleSet.registry) self.int_valid_swcb = switchboard.requestCallbackMain( ('validity', self.cs_sample_widget), self.validCB) hbox = gtk.HBox() csbox.pack_start(hbox, expand=0, fill=0, padding=1) # Rename button. self.renamebutton = gtk.Button("Rename") gtklogger.setWidgetName(self.renamebutton, 'Rename') gtklogger.connect(self.renamebutton, 'clicked', self.csrenameCB) tooltips.set_tooltip_text(self.renamebutton, "Rename the current cross-section.") hbox.pack_start(self.renamebutton,fill=1,expand=1, padding=1) # Edit button self.editbutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...") gtklogger.setWidgetName(self.editbutton, 'Edit') gtklogger.connect(self.editbutton, 'clicked', self.cseditCB) tooltips.set_tooltip_text(self.editbutton,"Edit the current cross-section.") hbox.pack_start(self.editbutton, fill=1, expand=1, padding=1) # Copy button self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.copybutton, 'Copy') gtklogger.connect(self.copybutton, 'clicked', self.cscopyCB) tooltips.set_tooltip_text(self.copybutton,"Copy the current cross-section.") hbox.pack_start(self.copybutton, fill=1, expand=1, padding=1) # Delete button. self.csdeletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Remove") gtklogger.setWidgetName(self.csdeletebutton, 'Remove') gtklogger.connect(self.csdeletebutton, "clicked", self.csdeleteCB) tooltips.set_tooltip_text(self.csdeletebutton, "Remove the current cross-section.") hbox.pack_start(self.csdeletebutton,fill=1,expand=1, padding=1) goframe = gtk.Frame("Output") goframe.set_shadow_type(gtk.SHADOW_IN) mainbox.pack_start(goframe,expand=0,fill=0) self.gobox = gtk.VBox() goframe.add(self.gobox) hbox = gtk.HBox() self.gobox.pack_start(hbox, expand=0, fill=0) label = gtk.Label("Destination: ") label.set_alignment(1.0, 0.5) hbox.pack_start(label, expand=0, fill=0) self.destwidget = outputdestinationwidget.TextDestinationWidget( name="Destination") self.dw_valid_swcb = switchboard.requestCallbackMain( ('validity', self.destwidget), self.validCB ) hbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2) self.gobutton = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go!") gtklogger.setWidgetName(self.gobutton, 'Go') hbox.pack_start(self.gobutton,expand=1,fill=1, padding=2) tooltips.set_tooltip_text(self.gobutton, "Send the output to the destination.") gtklogger.connect(self.gobutton, "clicked", self.goCB) self.startpoint = None self.endpoint = None # Data needed by the "go" button. Set in "show_data", when # the state of all the widgets is examined. self.meshobj = None self.current_cs_name = None # Shut off non-GUI toolbox's switchboard callbacks. We will # take them over at activate-time. self.toolbox.stop_callbacks()
def postinitialize(self, name, gfxmanager, clone): debug.mainthreadTest() # Add gui callbacks to the non-gui menu created by the GhostGfxWindow. filemenu = self.menu.File filemenu.Quit.add_gui_callback(quit.queryQuit) layermenu = self.menu.Layer # There's no gui callback for layermenu.New. ## TODO OPT: Why are these added to the menu here, when the ## functions themselves are defined in gfxwindowbase.py? layermenu.Edit.add_gui_callback(self.editLayer_gui) layermenu.Delete.add_gui_callback(self.deleteLayer_gui) layermenu.Hide.add_gui_callback(self.hideLayer_gui) layermenu.Show.add_gui_callback(self.showLayer_gui) # layermenu.Raise.One_Level.add_gui_callback(self.raiseLayer_gui) # layermenu.Raise.To_Top.add_gui_callback(self.raiseToTop_gui) # layermenu.Lower.One_Level.add_gui_callback(self.lowerLayer_gui) # layermenu.Lower.To_Bottom.add_gui_callback(self.lowerToBottom_gui) settingmenu = self.menu.Settings toolboxmenu = self.menu.Toolbox # The toolbar must be constructed before the toolboxes, # because it contains the gtk.Adjustment that's used by the # Viewer toolbox. self.toolbar = toolbarGUI.ToolBar(self) self.toolbarBox.pack_start(self.toolbar.gtk, expand=False, fill=False) self.toolbar.gtk.show() self.timebox = self.makeTimeBox() self.toolbarBox.pack_start(self.timebox, expand=False, fill=False) # Construct gui's for toolboxes. This must be done after the # base class is constructed so that *all* non-gui toolboxes # are created before any of their gui versions. Some gui # toolboxes need to know about more than one non-gui toolbox. map(self.makeToolboxGUI, self.toolboxes) if self.toolboxGUIs: self.selectToolbox(self.toolboxGUIs[0].name()) self.toolboxchooser.set_state(self.toolboxGUIs[0].name()) # raise_window routine is in SubWindow class. getattr(mainmenu.OOF.Windows.Graphics, name).add_gui_callback( self.raise_window) # SubWindow initializer makes the menu bar, and sets up the # .gtk and .mainbox members. ".gtk" is the window itself, # and .mainbox is a gtk.VBox that holds the menu bar. windowname = utils.underscore2space("OOF3D " + name) subWindow.SubWindow.__init__(self, windowname, menu=self.menu) self.gtk.connect('destroy', self.destroyCB) self.gtk.connect_after('realize', self.realizeCB) self.gtk.set_default_size(GfxWindow3D.initial_width, GfxWindow3D.initial_height) self.mainbox.set_spacing(3) self.mainbox.pack_start(self.mainpane, fill=1, expand=1) self.oofcanvas.set_bgColor(self.settings.bgcolor) self.oofcanvas.setAntiAlias(self.settings.antialias) self.oofcanvas.setAxisLabelColor(self.settings.axislabelcolor) self.oofcanvas.setAxisLabelFontSize(self.settings.axisfontsize) self.oofcanvas.setAxisOffset(self.settings.axisoffset.resolve(self)) self.oofcanvas.setAxisLength(self.settings.axislength.resolve(self)) self.oofcanvas.setContourMapBGColor(self.settings.contourmap_bgcolor, self.settings.contourmap_bgopacity) self.oofcanvas.setContourMapTextColor( self.settings.contourmap_textcolor) self.oofcanvas.setContourMapSize(self.settings.contourmap_size[0], self.settings.contourmap_size[1]) self.oofcanvas.setContourMapPosition( self.settings.contourmap_position[0], self.settings.contourmap_position[1]) self.gtk.show_all() # calls realizeCB(), which calls drawAtTime() self.updateToolboxChooser()
def __init__thread(self, gfxwindow, time, position, output): debug.mainthreadTest() allMeshDataWindows.append(self) widgetscope.WidgetScope.__init__(self, None) current_count = MeshDataGUI.count MeshDataGUI.count += 1 self._name = "Mesh_Data_%d" % current_count self.output = output self.time = time self.position = position self.sbcallbacks = [] self.gsbcallbacks = [] # callbacks from a specific gfx window self.updateLock = lock.Lock() self.outputparam = \ ooflib.engine.IO.output.AggregateOutputParameter('output') # Although it's not displayed, we need a mesh widget in the # widgetscope, or the OutputParameterWidget won't work. # TODO LATER: Is this ugly, or what? self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self, name="Godot") self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL) title = utils.underscore2space(self._name) self.gtk.set_title(title) gtklogger.newTopLevelWidget(self.gtk, title) gtklogger.connect_passive(self.gtk, 'delete-event') gtklogger.connect_passive(self.gtk, 'configure-event') self.mainbox = gtk.VBox() self.gtk.add(self.mainbox) # Put this window into the Windows menu. The menu item can't # be logged, since the creation and operation of the window # aren't logged, so scripts shouldn't refer to it at all. mainmenu.OOF.Windows.Mesh_Data.addItem(oofmenu.OOFMenuItem( self._name, no_log=1, help="Raise Mesh Data window %d." % current_count, threadable=oofmenu.UNTHREADABLE, callback=self.raiseWindow)) expander = gtk.Expander("Source") gtklogger.setWidgetName(expander, 'ViewSource') gtklogger.connect_passive_after(expander, 'activate') self.mainbox.pack_start(expander) expander.set_expanded(1) self.table = gtk.Table(rows=config.dimension()+4, columns=2) expander.add(self.table) label = gtk.Label("Source Window:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 0,1, xpadding=3, xoptions=gtk.FILL) tooltips.set_tooltip_text(label, "Display data for mouse clicks in this Graphics window.") self.gfxWindowChooser = chooser.ChooserWidget([], callback=self.chooserCB, name='GfxWindow') self.table.attach(self.gfxWindowChooser.gtk, 1,2, 0,1, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) label = gtk.Label("Mesh:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 1,2, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text(label,"Data is displayed for values on this mesh.") self.meshText = gtk.Entry() gtklogger.setWidgetName(self.meshText, "meshname") self.meshText.set_editable(False) self.meshText.set_size_request(12*guitop.top().charsize, -1) self.table.attach(self.meshText, 1,2, 1,2, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) # Position controls label = gtk.Label("position x:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 2,3, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.xText = gtk.Entry() gtklogger.setWidgetName(self.xText, 'x') self.xText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.xText, 1,2, 2,3, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.xsignal = gtklogger.connect(self.xText, 'changed', self.posChangedCB) label = gtk.Label("position y:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 3,4, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.yText = gtk.Entry() gtklogger.setWidgetName(self.yText, 'y') self.yText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.yText, 1,2, 3,4, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.ysignal = gtklogger.connect(self.yText, 'changed', self.posChangedCB) if config.dimension() == 3: label = gtk.Label("position z:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 4,5, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.zText = gtk.Entry() gtklogger.setWidgetName(self.zText, 'z') self.zText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.zText, 1,2, 4,5, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.zsignal = gtklogger.connect(self.zText, 'changed', self.posChangedCB) timerow = 5 else: timerow = 6 # Time controls. Typing in the time widget does not # immediately update the displayed data, because interpolating # to a new time is an expensive computation, and shouldn't be # done while the user is in the middle of typing. Instead, # the time widget is normally desensitized and uneditable. # When the user clicks the "Edit" button, the widget becomes # editable, the rest of the window is desensitized, and the # "Edit" button changes do a "Done" button. When the user # clicks "Done" the data is updated and the time widget # becomes uneditable again. label = gtk.Label("time:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, timerow,timerow+1, xpadding=3, xoptions=gtk.FILL, yoptions=0) tBox = gtk.HBox(spacing=3) self.table.attach(tBox, 1,2, timerow,timerow+1, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.tText = gtk.Entry() self.tText.set_editable(False) self.tText.set_sensitive(False) tBox.pack_start(self.tText, expand=1, fill=1) gtklogger.setWidgetName(self.tText, 't') self.tText.set_size_request(12*guitop.top().digitsize, -1) self.tEditButton = gtk.Button("Edit") tBox.pack_start(self.tEditButton, expand=0, fill=0) gtklogger.setWidgetName(self.tEditButton, "tEdit") gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB) self.tEditMode = False # Output selection label = gtk.Label("Output:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, timerow+2,timerow+3, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text(label,"Choose which data is displayed.") self.outputwidget = self.outputparam.makeWidget(scope=self) self.table.attach(self.outputwidget.gtk, 1,2, timerow+2,timerow+3, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) switchboard.requestCallback(self.outputwidget, self.outputwidgetCB) # Data display panel hbox = gtk.HBox() self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5) frame = gtk.Frame("Data") gtklogger.setWidgetName(frame, 'Data') frame.set_shadow_type(gtk.SHADOW_IN) hbox.pack_start(frame, expand=1, fill=1, padding=5) vbox = gtk.VBox() frame.add(vbox) self.databox = gtk.HBox() vbox.pack_start(self.databox, expand=1, fill=1, padding=3) self.datawidget = None # set by updateData # Buttons at the bottom of the window buttonbox = gtk.HBox() self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3) # Freeze buttons freezeframe = gtk.Frame("Freeze") gtklogger.setWidgetName(freezeframe, "Freeze") buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3) hbox = gtk.HBox() freezeframe.add(hbox) # Freeze Space button self.freezeSpaceFlag = False self.freezeSpaceButton = gtk.CheckButton('Space') gtklogger.setWidgetName(self.freezeSpaceButton, 'Space') hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0) self.freezeSpaceButton.set_active(self.freezeSpaceFlag) gtklogger.connect(self.freezeSpaceButton, 'clicked', self.freezeSpaceButtonCB) tooltips.set_tooltip_text(self.freezeSpaceButton, "Prevent the data in this window from being updated when the sample position changes.") # Freeze Time button self.freezeTimeFlag = False self.freezeTimeButton = gtk.CheckButton('Time') gtklogger.setWidgetName(self.freezeTimeButton, "Time") hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0) self.freezeTimeButton.set_active(self.freezeTimeFlag) gtklogger.connect(self.freezeTimeButton,'clicked', self.freezeTimeButtonCB) tooltips.set_tooltip_text(self.freezeTimeButton, "Prevent the data in this window from being updated when the Mesh's time changes.") # Clone button self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone') gtklogger.setWidgetName(self.cloneButton, 'Clone') gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB) buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3) tooltips.set_tooltip_text(self.cloneButton, "Make a copy of this window with its current settings.") # Close button self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE) gtklogger.setWidgetName(self.closeButton, 'Close') gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB) buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3) self.gtk.connect('destroy', self.destroyCB) self.updateGfxWindowChooser() if gfxwindow: self.gfxWindowChooser.set_state(gfxwindow.name) if position is not None: self.updatePosition(position) self.currentMesh = None self.updateMesh() self.setupSwitchboard() # gfx window dependent callbacks self.sbcallbacks += [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('mesh data changed', self.meshDataChanged), switchboard.requestCallbackMain((gfxwindow, "time changed"), self.timeChanged) ] self.gtk.show_all()