def __init__(self, message): debug.mainthreadTest() self.gtk = gtklogger.Dialog() gtklogger.newTopLevelWidget(self.gtk, "Warning") self.gtk.set_title("%s Warning"%subWindow.oofname()) self.gtk.vbox.set_spacing(3) self.gtk.vbox.pack_start(gtk.Label("WARNING")) self.gtk.vbox.pack_start(gtk.Label(message)) self.gtk.add_button("OK", self.OK) disable_button = self.gtk.add_button("Disable warnings", self.NO_MORE) tooltips.set_tooltip_text(disable_button, "Warnings can be re-enabled in the Help menu of the main window.") self.gtk.vbox.show_all()
def __init__(self, message): debug.mainthreadTest() self.gtk = gtklogger.Dialog() gtklogger.newTopLevelWidget(self.gtk, "Warning") self.gtk.set_title("%s Warning" % subWindow.oofname()) self.gtk.vbox.set_spacing(3) self.gtk.vbox.pack_start(gtk.Label("WARNING")) self.gtk.vbox.pack_start(gtk.Label(message)) self.gtk.add_button("OK", self.OK) disable_button = self.gtk.add_button("Disable warnings", self.NO_MORE) tooltips.set_tooltip_text( disable_button, "Warnings can be re-enabled in the Help menu of the main window.") self.gtk.vbox.show_all()
def __init__(self): debug.mainthreadTest() self.menu_name = "MessageWindow_%d" % MessageWindow.count self.title = "%s Messages %d" % (subWindow.oofname(),MessageWindow.count) self.windows_menu_name = "Message_%d" % MessageWindow.count subWindow.SubWindow.__init__( self, title=self.title, menu=self.menu_name) # We are locally responsible for the windows submenu items. self.gtk.connect("destroy", self.destroy) # raise_window function is provided by the SubWindow class. OOF.Windows.Messages.addItem( oofmenu.OOFMenuItem( self.windows_menu_name, help="Raise Message window %d." % MessageWindow.count, cli_only=0, no_log=1, gui_callback=self.raise_window) ) MessageWindow.count += 1 allMessageWindows.add(self) # Control box, with buttons. These could be menu items. controlbox = gtk.Frame() controlbox.set_shadow_type(gtk.SHADOW_OUT) self.mainbox.pack_start(controlbox, expand=0, fill=0) controlinnards = gtk.VBox() controlbox.add(controlinnards) buttonbox = gtk.HBox() controlinnards.pack_start(buttonbox, expand=0, padding=2) savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...") tooltips.set_tooltip_text(savebutton, "Save the contents of this window to a file.") buttonbox.pack_start(savebutton, expand=0, fill=0, padding=2) gtklogger.setWidgetName(savebutton, "Save") gtklogger.connect(savebutton, 'clicked', self.saveButtonCB) self.button_dict = {} self.signal_dict = {} for m in reporter.messageclasses: button = gtk.CheckButton(m) gtklogger.setWidgetName(button, m) buttonbox.pack_end(button, fill=0, expand=0, padding=2) self.signal_dict[m] = gtklogger.connect(button, "clicked", self.button_click) self.button_dict[m] = button tooltips.set_tooltip_text(button, "Show or hide "+ reporter.messagedescriptions[m]) messagepane = gtk.ScrolledWindow() ## The ScrolledWindow's scrollbars are *not* logged in the ## gui, because blocking the adjustment "changed" signals in ## the write_message function, below, doesn't work to suppress ## logging. This means that programmatic changes to the ## scrollbars are logged along with user changes, which fills ## up the log file with extraneous lines. messagepane.set_border_width(4) messagepane.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.mainbox.add(messagepane) self.messages = gtk.TextView() gtklogger.setWidgetName(self.messages, "Text") self.messages.set_editable(False) self.messages.set_cursor_visible(False) self.messages.set_wrap_mode(gtk.WRAP_WORD) self.changeFont(mainmenuGUI.getFixedFont()) self.gtk.set_default_size( 90*gtkutils.widgetCharSize(self.messages), 200) # Get two marks to be used for automatic scrolling bfr = self.messages.get_buffer() enditer = bfr.get_end_iter() self.endmark = bfr.create_mark(None, enditer, False) self.midmark = bfr.create_mark(None, enditer, False) messagepane.add(self.messages) self.state_dict = {} for m in reporter.messageclasses: self.state_dict[m]=1 self.sbcbs = [ switchboard.requestCallbackMain("write message", self.write_message), switchboard.requestCallbackMain("change fixed font", self.changeFont) ] self.draw()
def __init__(self, e_type, value, tbacklist): debug.mainthreadTest() errorstrings = [] # list of strings self.tracebacks = [] # list of lists of \n-terminated strings # If there are previous unprocessed exceptions, print them # too. The oldest exception is the first in the # _savedExceptions list. global _savedExceptions _savedExceptions.append((e_type, value, tbacklist)) for e_type, value, tbacklist in _savedExceptions: # format_exception_only returns a list of string, each # terminated whith a newline. The list has length 1, # except for syntax errors. errorstrings.extend( [line.rstrip() for line in traceback.format_exception_only(e_type, value)]) if isinstance(value, ooferror.ErrErrorPtr): moreinfo = value.details() if moreinfo: errorstrings.append(moreinfo) errorstrings.append("") # blank line if tbacklist: self.tracebacks.append(traceback.format_list(tbacklist)) _savedExceptions = [] self.answer = None self.datestampstring = time.strftime("%Y %b %d %H:%M:%S %Z") self.gtk = gtklogger.Dialog() self.gtk.set_keep_above(True) # self.gtk = gtk.Dialog() gtklogger.newTopLevelWidget(self.gtk, "Error") self.gtk.set_title("%s Error"%subWindow.oofname()) self.gtk.vbox.set_spacing(3) classname = string.split(str(e_type),'.')[-1] self.gtk.vbox.pack_start(gtk.Label("ERROR"), expand=0, fill=0) self.errframe = gtk.Frame() self.errframe.set_border_width(6) self.errframe.set_shadow_type(gtk.SHADOW_IN) self.gtk.vbox.pack_start(self.errframe, expand=1, fill=1) fd = pango.FontDescription(mainmenuGUI.getFixedFont()) errscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(errscroll, "ErrorScroll") errscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.errframe.add(errscroll) self.errbox = gtk.TextView() # error text goes here gtklogger.setWidgetName(self.errbox, "ErrorText") errscroll.add(self.errbox) self.errbox.set_editable(0) self.errbox.set_wrap_mode(gtk.WRAP_WORD) self.errbox.get_buffer().set_text("\n".join(errorstrings)) self.errbox.modify_font(fd) self.gtk.add_button(gtk.STOCK_OK, self.OK) self.gtk.add_button("Abort", self.ABORT) self.gtk.set_default_response(self.OK) self.tracebutton = gtk.Button("View Traceback") gtklogger.setWidgetName(self.tracebutton, "ViewTraceback") gtklogger.connect(self.tracebutton, "clicked", self.trace) self.gtk.action_area.add(self.tracebutton) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save Traceback") gtklogger.setWidgetName(self.savebutton, "SaveTraceback") gtklogger.connect(self.savebutton, "clicked", self.savetrace) self.gtk.action_area.add(self.savebutton) self.scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.scroll, "TraceScroll") self.scroll.set_border_width(3) self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scroll.set_shadow_type(gtk.SHADOW_IN) self.tracepane = gtk.TextView() self.tracepane.set_editable(0) self.tracepane.set_wrap_mode(gtk.WRAP_WORD) self.tracepane.modify_font(fd) self.traceframe = gtk.Frame() self.traceframe.set_shadow_type(gtk.SHADOW_NONE) self.gtk.vbox.pack_start(self.traceframe, expand=0, fill=0) # Scroll is not added to the frame until the traceback button # is pressed. self.scroll.add(self.tracepane) if self.tracebacks: tbtext = "" for err, tb in zip(errorstrings, self.tracebacks): if tbtext: tbtext += '\n----------\n\n' tbtext += err + '\n' tbtext += "".join(tb) self.tracepane.get_buffer().set_text(tbtext) else: self.savebutton.set_sensitive(0) self.tracebutton.set_sensitive(0) self.gtk.show_all()
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, 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): debug.mainthreadTest() self.listofgtkbars = [] self.makeMenus() # Sets self.menu. # SubWindow init sets self.gtk and self.mainbox. subWindow.SubWindow.__init__(self, title="%s Activity Viewer" % subWindow.oofname(), menu=self.menu) self.gtk.connect('destroy', self.closeCB) self.gtk.set_default_size(400, 300) # Area at the top containing the editor widget for the line self.control_area = gtk.HBox() # editor widget goes in here self.mainbox.pack_start(self.control_area, expand=0, fill=0, padding=2) ## Dismiss All bars self.dismissall = gtkutils.StockButton(gtk.STOCK_CANCEL, "Dismiss All") gtklogger.setWidgetName(self.dismissall, "DismissAll") gtklogger.connect(self.dismissall, "clicked", self.dismissAllCB) self.control_area.pack_start(self.dismissall, expand=1, fill=0, padding=2) ## stop-all-threads self.stopall = gtkutils.StockButton(gtk.STOCK_STOP, "Stop All") gtklogger.setWidgetName(self.stopall, "StopAll") gtklogger.connect(self.stopall, "clicked", self.stopAll) self.control_area.pack_start(self.stopall, expand=1, fill=0, padding=2) # Create a scrolled window to pack the bars into scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) gtklogger.logScrollBars(scrolled_window, "Scroll") self.mainbox.pack_start(scrolled_window, expand=1, fill=1, padding=2) ## Create VBox where the progressbars can live happily ever after self.bars_play_area = gtk.VBox() # homogeneous=True? scrolled_window.add_with_viewport(self.bars_play_area) self.proglock = lock.SLock() self.proglock.acquire() try: for worker in threadmanager.threadManager.allWorkers(): worker.threadstate.acquireProgressLock() try: progressnames = worker.threadstate.getProgressNames() for pname in progressnames: try: prgrss = worker.threadstate.findProgress(pname) except ooferror.ErrNoProgress: # Progress object already finished pass else: if prgrss.started(): self.installBar(prgrss) finally: worker.threadstate.releaseProgressLock() finally: self.proglock.release() self.gtk.show_all() self.sensitizeButtons()
def __init__(self): debug.mainthreadTest() self.built = False layereditor.LayerEditor.__init__(self) gtklogger.checkpoint("layereditor layerset changed") self.suppressCallbacks = 0 widgetscope.WidgetScope.__init__(self, None) self.setData("gfxwindow", None) # widgetscope data, that is self.sbcallbacks = [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged) ] self.menu.File.Quit.gui_callback = quit.queryQuit subWindow.SubWindow.__init__(self, title="%s Graphics Layer Editor" % subWindow.oofname(), menu=self.menu) ## self.gtk.set_policy(1, 1, 0) self.gtk.set_default_size(600, 250) self.gtk.connect('destroy', self.destroyCB) mainpane = gtk.HPaned() mainpane.set_border_width(3) mainpane.set_position(300) self.mainbox.pack_start(mainpane, expand=1, fill=1) # The left side of the layer editor is for choosing the object # being drawn. whoframe = gtk.Frame('Displayed Object') mainpane.pack1(whoframe, resize=1, shrink=0) wscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(wscroll, "ObjectScroll") wscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) whoframe.add(wscroll) vbox = gtk.VBox() wscroll.add_with_viewport(vbox) cmd = self.menu.LayerSet.DisplayedObject # This creates a table containing a WhoClassWidget and a WhoWidget: ptable = parameterwidgets.ParameterTable( [cmd.get_arg('category'), cmd.get_arg('object')], scope=self) vbox.pack_start(ptable.gtk, expand=0, fill=0) # The right side of the layer editor lists the display methods # for the object on the left side. methframe = gtk.Frame('Display Methods') gtklogger.setWidgetName(methframe, "DisplayMethods") mainpane.pack2(methframe, resize=1, shrink=0) mvbox = gtk.VBox() methframe.add(mvbox) mhbox = gtk.HBox() mvbox.pack_start(mhbox, expand=1, fill=1) self.methodList = chooser.ScrolledChooserListWidget( callback=self.singleClickMethodCB, dbcallback=self.doubleClickMethodCB, comparator=lambda x, y: (not x.inequivalent(y)), name="List") mhbox.pack_start(self.methodList.gtk, expand=1, fill=1, padding=3) # The who widget is replaced each time the who class widget is # activated, so its switchboard callback must be reset often, # and is done in findWidget(). self.whowidgetsignal = None self.findWhoWidget() buttonbox = gtk.HBox() mvbox.pack_start(buttonbox, expand=0, fill=0, padding=3) self.newMethodButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') buttonbox.pack_start(self.newMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.newMethodButton, "New") gtklogger.connect(self.newMethodButton, 'clicked', self.newMethodButtonCB) self.editMethodButton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Edit...') buttonbox.pack_start(self.editMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.editMethodButton, "Edit") gtklogger.connect(self.editMethodButton, 'clicked', self.editMethodButtonCB) self.copyMethodButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy') buttonbox.pack_start(self.copyMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.copyMethodButton, "Copy") gtklogger.connect(self.copyMethodButton, 'clicked', self.copyMethodButtonCB) self.deleteMethodButton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') buttonbox.pack_start(self.deleteMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.deleteMethodButton, "Delete") gtklogger.connect(self.deleteMethodButton, 'clicked', self.deleteMethodButtonCB) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0) # Buttons at the bottom governing LayerSet operations: # New LayerSet, Send to Gfx Window, etc. mainbuttonbox = gtk.HBox() self.mainbox.pack_start(mainbuttonbox, expand=0, fill=0, padding=3) newLayerButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New Layer') mainbuttonbox.pack_start(newLayerButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(newLayerButton, "NewLayer") gtklogger.connect(newLayerButton, 'clicked', self.newLayerButtonCB) self.sendButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, 'Send', reverse=1) ## self.sendButton.set_usize(80, -1) mainbuttonbox.pack_end(self.sendButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(self.sendButton, "Send") gtklogger.connect(self.sendButton, 'clicked', self.sendCB) self.destinationMenu = chooser.ChooserWidget([], name="Destination") mainbuttonbox.pack_end(self.destinationMenu.gtk, expand=0, fill=0) self.updateDestinationMenu() label = gtk.Label('Destination=') tooltips.set_tooltip_text( label, 'The graphics window(s) that will display the layer(s).') label.set_alignment(1.0, 0.5) mainbuttonbox.pack_end(label, expand=0, fill=0) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3) # When the lhs widgets change state the rhs might have to # change too. The widgets referred to here are inside the # ParameterTable constructed above. self.whoclasswidget = self.findWidget( lambda w: isinstance(w, whowidget.WhoClassParameterWidget)) self.whoclasswidgetsignal = switchboard.requestCallbackMain( self.whoclasswidget, self.whoClassChangedCB) self.sbcallbacks.append(self.whoclasswidgetsignal) self.built = True self.sensitize() self.gtk.show_all()
def __init__(self): debug.mainthreadTest() self.listofgtkbars = [] self.makeMenus() # Sets self.menu. # SubWindow init sets self.gtk and self.mainbox. subWindow.SubWindow.__init__( self, title="%s Activity Viewer"%subWindow.oofname(), menu=self.menu) self.gtk.connect('destroy', self.closeCB) self.gtk.set_default_size(400, 300) # Area at the top containing the editor widget for the line self.control_area = gtk.HBox() # editor widget goes in here self.mainbox.pack_start(self.control_area, expand=0, fill=0, padding=2) ## Dismiss All bars self.dismissall = gtkutils.StockButton(gtk.STOCK_CANCEL, "Dismiss All") gtklogger.setWidgetName(self.dismissall, "DismissAll") gtklogger.connect(self.dismissall, "clicked", self.dismissAllCB) self.control_area.pack_start(self.dismissall, expand=1, fill=0, padding=2) ## stop-all-threads self.stopall = gtkutils.StockButton(gtk.STOCK_STOP, "Stop All") gtklogger.setWidgetName(self.stopall, "StopAll") gtklogger.connect(self.stopall, "clicked", self.stopAll) self.control_area.pack_start(self.stopall, expand=1, fill=0, padding=2) # Create a scrolled window to pack the bars into scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) gtklogger.logScrollBars(scrolled_window, "Scroll") self.mainbox.pack_start(scrolled_window, expand=1, fill=1, padding=2) ## Create VBox where the progressbars can live happily ever after self.bars_play_area = gtk.VBox() # homogeneous=True? scrolled_window.add_with_viewport(self.bars_play_area) self.proglock = lock.SLock() self.proglock.acquire() try: for worker in threadmanager.threadManager.allWorkers(): worker.threadstate.acquireProgressLock() try: progressnames = worker.threadstate.getProgressNames() for pname in progressnames: try: prgrss = worker.threadstate.findProgress(pname) except ooferror.ErrNoProgress: # Progress object already finished pass else: if prgrss.started(): self.installBar(prgrss) finally: worker.threadstate.releaseProgressLock() finally: self.proglock.release() self.gtk.show_all() self.sensitizeButtons()
def __init__(self): debug.mainthreadTest() self.menu_name = "MessageWindow_%d" % MessageWindow.count self.title = "%s Messages %d" % (subWindow.oofname(), MessageWindow.count) self.windows_menu_name = "Message_%d" % MessageWindow.count subWindow.SubWindow.__init__(self, title=self.title, menu=self.menu_name) # We are locally responsible for the windows submenu items. self.gtk.connect("destroy", self.destroy) # raise_window function is provided by the SubWindow class. OOF.Windows.Messages.addItem( oofmenu.OOFMenuItem(self.windows_menu_name, help="Raise Message window %d." % MessageWindow.count, cli_only=0, no_log=1, gui_callback=self.raise_window)) MessageWindow.count += 1 allMessageWindows.add(self) # Control box, with buttons. These could be menu items. controlbox = gtk.Frame() controlbox.set_shadow_type(gtk.SHADOW_OUT) self.mainbox.pack_start(controlbox, expand=0, fill=0) controlinnards = gtk.VBox() controlbox.add(controlinnards) buttonbox = gtk.HBox() controlinnards.pack_start(buttonbox, expand=0, padding=2) savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...") tooltips.set_tooltip_text( savebutton, "Save the contents of this window to a file.") buttonbox.pack_start(savebutton, expand=0, fill=0, padding=2) gtklogger.setWidgetName(savebutton, "Save") gtklogger.connect(savebutton, 'clicked', self.saveButtonCB) self.button_dict = {} self.signal_dict = {} for m in reversed(reporter.messageclasses): button = gtk.CheckButton(m) gtklogger.setWidgetName(button, m) buttonbox.pack_end(button, fill=0, expand=0, padding=2) self.signal_dict[m] = gtklogger.connect(button, "clicked", self.button_click) self.button_dict[m] = button tooltips.set_tooltip_text( button, "Show or hide " + reporter.messagedescriptions[m]) buttonbox.pack_end(gtk.Label("Show:"), fill=0, expand=0, padding=2) messagepane = gtk.ScrolledWindow() ## The ScrolledWindow's scrollbars are *not* logged in the ## gui, because blocking the adjustment "changed" signals in ## the write_message function, below, doesn't work to suppress ## logging. This means that programmatic changes to the ## scrollbars are logged along with user changes, which fills ## up the log file with extraneous lines. messagepane.set_border_width(4) messagepane.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.mainbox.add(messagepane) self.messages = gtk.TextView() gtklogger.setWidgetName(self.messages, "Text") self.messages.set_editable(False) self.messages.set_cursor_visible(False) self.messages.set_wrap_mode(gtk.WRAP_WORD) self.changeFont(mainmenuGUI.getFixedFont()) self.gtk.set_default_size(90 * gtkutils.widgetCharSize(self.messages), 200) # Get two marks to be used for automatic scrolling bfr = self.messages.get_buffer() enditer = bfr.get_end_iter() self.endmark = bfr.create_mark(None, enditer, False) self.midmark = bfr.create_mark(None, enditer, False) messagepane.add(self.messages) self.state_dict = {} for m in reporter.messageclasses: self.state_dict[m] = 1 self.sbcbs = [ switchboard.requestCallbackMain("write message", self.write_message), switchboard.requestCallbackMain("change fixed font", self.changeFont) ] self.draw()
def __init__(self, e_type, value, tbacklist): debug.mainthreadTest() errorstrings = [] # list of strings self.tracebacks = [] # list of lists of \n-terminated strings # If there are previous unprocessed exceptions, print them # too. The oldest exception is the first in the # _savedExceptions list. global _savedExceptions _savedExceptions.append((e_type, value, tbacklist)) for e_type, value, tbacklist in _savedExceptions: # format_exception_only returns a list of string, each # terminated whith a newline. The list has length 1, # except for syntax errors. errorstrings.extend([ line.rstrip() for line in traceback.format_exception_only(e_type, value) ]) if isinstance(value, ooferror.ErrErrorPtr): moreinfo = value.details() if moreinfo: errorstrings.append(moreinfo) errorstrings.append("") # blank line if tbacklist: self.tracebacks.append(traceback.format_list(tbacklist)) _savedExceptions = [] self.answer = None self.datestampstring = time.strftime("%Y %b %d %H:%M:%S %Z") self.gtk = gtklogger.Dialog() self.gtk.set_keep_above(True) # self.gtk = gtk.Dialog() gtklogger.newTopLevelWidget(self.gtk, "Error") self.gtk.set_title("%s Error" % subWindow.oofname()) self.gtk.vbox.set_spacing(3) classname = string.split(str(e_type), '.')[-1] self.gtk.vbox.pack_start(gtk.Label("ERROR"), expand=0, fill=0) self.errframe = gtk.Frame() self.errframe.set_border_width(6) self.errframe.set_shadow_type(gtk.SHADOW_IN) self.gtk.vbox.pack_start(self.errframe, expand=1, fill=1) fd = pango.FontDescription(mainmenuGUI.getFixedFont()) errscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(errscroll, "ErrorScroll") errscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.errframe.add(errscroll) self.errbox = gtk.TextView() # error text goes here gtklogger.setWidgetName(self.errbox, "ErrorText") errscroll.add(self.errbox) self.errbox.set_editable(0) self.errbox.set_wrap_mode(gtk.WRAP_WORD) self.errbox.get_buffer().set_text("\n".join(errorstrings)) self.errbox.modify_font(fd) self.gtk.add_button(gtk.STOCK_OK, self.OK) self.gtk.add_button("Abort", self.ABORT) self.gtk.set_default_response(self.OK) self.reportbutton = gtk.Button("Report") gtklogger.setWidgetName(self.reportbutton, "ReportFromError") gtklogger.connect(self.reportbutton, "clicked", self.report) self.gtk.action_area.add(self.reportbutton) self.tracebutton = gtk.Button("View Traceback") gtklogger.setWidgetName(self.tracebutton, "ViewTraceback") gtklogger.connect(self.tracebutton, "clicked", self.trace) self.gtk.action_area.add(self.tracebutton) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save Traceback") gtklogger.setWidgetName(self.savebutton, "SaveTraceback") gtklogger.connect(self.savebutton, "clicked", self.savetrace) self.gtk.action_area.add(self.savebutton) self.scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.scroll, "TraceScroll") self.scroll.set_border_width(3) self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scroll.set_shadow_type(gtk.SHADOW_IN) self.tracepane = gtk.TextView() self.tracepane.set_editable(0) self.tracepane.set_wrap_mode(gtk.WRAP_WORD) self.tracepane.modify_font(fd) self.traceframe = gtk.Frame() self.traceframe.set_shadow_type(gtk.SHADOW_NONE) self.gtk.vbox.pack_start(self.traceframe, expand=0, fill=0) # Scroll is not added to the frame until the traceback button # is pressed. self.scroll.add(self.tracepane) if self.tracebacks: tbtext = "" for err, tb in zip(errorstrings, self.tracebacks): if tbtext: tbtext += '\n----------\n\n' tbtext += err + '\n' tbtext += "".join(tb) self.tracepane.get_buffer().set_text(tbtext) else: self.savebutton.set_sensitive(0) self.tracebutton.set_sensitive(0) self.gtk.show_all()
def __init__(self): debug.mainthreadTest() self.built = False layereditor.LayerEditor.__init__(self) gtklogger.checkpoint("layereditor layerset changed") self.suppressCallbacks = 0 widgetscope.WidgetScope.__init__(self, None) self.setData("gfxwindow", None) # widgetscope data, that is self.sbcallbacks = [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged) ] self.menu.File.Quit.gui_callback = quit.queryQuit subWindow.SubWindow.__init__( self, title="%s Graphics Layer Editor"%subWindow.oofname(), menu=self.menu) ## self.gtk.set_policy(1, 1, 0) self.gtk.set_default_size(600, 250) self.gtk.connect('destroy', self.destroyCB) mainpane = gtk.HPaned() mainpane.set_border_width(3) mainpane.set_position(300) self.mainbox.pack_start(mainpane, expand=1, fill=1) # The left side of the layer editor is for choosing the object # being drawn. whoframe = gtk.Frame('Displayed Object') mainpane.pack1(whoframe, resize=1, shrink=0) wscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(wscroll, "ObjectScroll") wscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) whoframe.add(wscroll) vbox = gtk.VBox() wscroll.add_with_viewport(vbox) cmd = self.menu.LayerSet.DisplayedObject # This creates a table containing a WhoClassWidget and a WhoWidget: ptable = parameterwidgets.ParameterTable( [cmd.get_arg('category'), cmd.get_arg('object')], scope=self) vbox.pack_start(ptable.gtk, expand=0, fill=0) # The right side of the layer editor lists the display methods # for the object on the left side. methframe = gtk.Frame('Display Methods') gtklogger.setWidgetName(methframe, "DisplayMethods") mainpane.pack2(methframe, resize=1, shrink=0) mvbox = gtk.VBox() methframe.add(mvbox) mhbox = gtk.HBox() mvbox.pack_start(mhbox, expand=1, fill=1) self.methodList = chooser.ScrolledChooserListWidget( callback=self.singleClickMethodCB, dbcallback=self.doubleClickMethodCB, comparator=lambda x, y: (not x.inequivalent(y)), name="List") mhbox.pack_start(self.methodList.gtk, expand=1, fill=1, padding=3) # The who widget is replaced each time the who class widget is # activated, so its switchboard callback must be reset often, # and is done in findWidget(). self.whowidgetsignal = None self.findWhoWidget() buttonbox = gtk.HBox() mvbox.pack_start(buttonbox, expand=0, fill=0, padding=3) self.newMethodButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') buttonbox.pack_start(self.newMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.newMethodButton, "New") gtklogger.connect(self.newMethodButton, 'clicked', self.newMethodButtonCB) self.editMethodButton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Edit...') buttonbox.pack_start(self.editMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.editMethodButton, "Edit") gtklogger.connect(self.editMethodButton, 'clicked', self.editMethodButtonCB) self.copyMethodButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy') buttonbox.pack_start(self.copyMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.copyMethodButton, "Copy") gtklogger.connect(self.copyMethodButton, 'clicked', self.copyMethodButtonCB) self.deleteMethodButton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') buttonbox.pack_start(self.deleteMethodButton, expand=0, fill=0) gtklogger.setWidgetName(self.deleteMethodButton, "Delete") gtklogger.connect(self.deleteMethodButton, 'clicked', self.deleteMethodButtonCB) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0) # Buttons at the bottom governing LayerSet operations: # New LayerSet, Send to Gfx Window, etc. mainbuttonbox = gtk.HBox() self.mainbox.pack_start(mainbuttonbox, expand=0, fill=0, padding=3) newLayerButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New Layer') mainbuttonbox.pack_start(newLayerButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(newLayerButton, "NewLayer") gtklogger.connect(newLayerButton, 'clicked', self.newLayerButtonCB) self.sendButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, 'Send', reverse=1) ## self.sendButton.set_usize(80, -1) mainbuttonbox.pack_end(self.sendButton, expand=0, fill=0, padding=3) gtklogger.setWidgetName(self.sendButton, "Send") gtklogger.connect(self.sendButton, 'clicked', self.sendCB) self.destinationMenu = chooser.ChooserWidget([], name="Destination") mainbuttonbox.pack_end(self.destinationMenu.gtk, expand=0, fill=0) self.updateDestinationMenu() label=gtk.Label('Destination=') tooltips.set_tooltip_text(label, 'The graphics window(s) that will display the layer(s).') label.set_alignment(1.0, 0.5) mainbuttonbox.pack_end(label, expand=0, fill=0) self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3) # When the lhs widgets change state the rhs might have to # change too. The widgets referred to here are inside the # ParameterTable constructed above. self.whoclasswidget = self.findWidget( lambda w: isinstance(w, whowidget.WhoClassParameterWidget)) self.whoclasswidgetsignal = switchboard.requestCallbackMain( self.whoclasswidget, self.whoClassChangedCB) self.sbcallbacks.append(self.whoclasswidgetsignal) self.built = True self.sensitize() self.gtk.show_all()