예제 #1
0
    def __init__(self):
        debug.mainthreadTest()
        self.menu_name = "MessageWindow_%d" % MessageWindow.count
        self.title = "%s Messages %d" % (subWindow.oofname(),MessageWindow.count)
        self.windows_menu_name = "Message_%d" % MessageWindow.count
        
        subWindow.SubWindow.__init__(
            self, title=self.title, menu=self.menu_name)

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

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

        allMessageWindows.add(self)

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

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

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

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

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

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

        messagepane.add(self.messages)

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

        self.draw()
예제 #2
0
    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()
예제 #3
0
    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()
예제 #4
0
파일: console.py 프로젝트: shkeshavarz/OOF2
    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()
예제 #5
0
    def __init__(self):
        debug.mainthreadTest()
        self.menu_name = "MessageWindow_%d" % MessageWindow.count
        self.title = "%s Messages %d" % (subWindow.oofname(),
                                         MessageWindow.count)
        self.windows_menu_name = "Message_%d" % MessageWindow.count

        subWindow.SubWindow.__init__(self,
                                     title=self.title,
                                     menu=self.menu_name)

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

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

        MessageWindow.count += 1

        allMessageWindows.add(self)

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

        self.button_dict = {}
        self.signal_dict = {}
        for m in 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()