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, *args, **kwargs): gtk.TextView.__init__(self, *args, **kwargs) self.sbcb = switchboard.requestCallbackMain('change fixed font', self.changeFont) self.connect('destroy', self.destroyCB) self.changeFont(mainmenuGUI.getFixedFont())
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()