Exemplo n.º 1
0
Arquivo: gui.py Projeto: moleculea/ess
 def __init__(self, master=None, **kwargs):
     # get default settings from user's IDLE configuration
     currentTheme = idleConf.CurrentTheme()
     textcf = dict(padx=5,
                   wrap='word',
                   undo='True',
                   foreground=idleConf.GetHighlight(currentTheme,
                                                    'normal',
                                                    fgBg='fg'),
                   background=idleConf.GetHighlight(currentTheme,
                                                    'normal',
                                                    fgBg='bg'),
                   highlightcolor=idleConf.GetHighlight(currentTheme,
                                                        'hilite',
                                                        fgBg='fg'),
                   highlightbackground=idleConf.GetHighlight(currentTheme,
                                                             'hilite',
                                                             fgBg='bg'),
                   insertbackground=idleConf.GetHighlight(currentTheme,
                                                          'cursor',
                                                          fgBg='fg'),
                   width=idleConf.GetOption('main', 'EditorWindow',
                                            'width'),
                   height=idleConf.GetOption('main', 'EditorWindow',
                                             'height'))
     fontWeight = 'normal'
     if idleConf.GetOption('main', 'EditorWindow', 'font-bold',
                           type='bool'):
         fontWeight = 'bold'
     textcf['font'] = (idleConf.GetOption('main', 'EditorWindow', 'font'),
                       idleConf.GetOption('main', 'EditorWindow',
                                          'font-size'), fontWeight)
     # override defaults with any user-specified settings
     textcf.update(kwargs)
     ScrolledText.__init__(self, master, **textcf)
Exemplo n.º 2
0
  def __init__(self, main_ui, **opts):
    # check our options, removing them from the dict
    self.handles_other_events = opts.pop('transfer_events_to', None)
    self.gets_our_focus = opts.pop('transfer_focus_to', None)
    self.open_url_command = opts.pop('open_url_command', None)

    # setup the tk call options
    # first setup our defaults
    tkdefaults = {'fg':'white', 'bg':'black', 'height':20}
    if os.name == 'posix':
      self.font = tkFont.Font(family="Courier", size=12)
    else:
      self.font = tkFont.Font(family="Fixedsys", size=12)
    # then update from the passed in options, these will overwrite our defaults
    tkdefaults['font'] = self.font
    tkdefaults.update(opts)
    
    ScrolledText.__init__(self, main_ui, **tkdefaults)

    # setup our default color and our ansi parsing object
    TkColor.setup_tk_color_tags(self)
    default_color = TkColor(fg='white', bg='black')
    self.ansistream = ansi.ANSIStream(default_color, TkColor)

    # DEBUG, remove this crud
    self.bind("<KeyPress>", self._ignoreThis)
    return
Exemplo n.º 3
0
 def __init__(self, master=None, **kwargs):
     # get default settings from user's IDLE configuration
     currentTheme = idleConf.CurrentTheme()
     textcf = dict(
         padx=5,
         wrap="word",
         undo="True",
         foreground=idleConf.GetHighlight(currentTheme, "normal", fgBg="fg"),
         background=idleConf.GetHighlight(currentTheme, "normal", fgBg="bg"),
         highlightcolor=idleConf.GetHighlight(currentTheme, "hilite", fgBg="fg"),
         highlightbackground=idleConf.GetHighlight(currentTheme, "hilite", fgBg="bg"),
         insertbackground=idleConf.GetHighlight(currentTheme, "cursor", fgBg="fg"),
         width=idleConf.GetOption("main", "EditorWindow", "width"),
         height=idleConf.GetOption("main", "EditorWindow", "height"),
     )
     fontWeight = "normal"
     if idleConf.GetOption("main", "EditorWindow", "font-bold", type="bool"):
         fontWeight = "bold"
     textcf["font"] = (
         idleConf.GetOption("main", "EditorWindow", "font"),
         idleConf.GetOption("main", "EditorWindow", "font-size"),
         fontWeight,
     )
     # override defaults with any user-specified settings
     textcf.update(kwargs)
     ScrolledText.__init__(self, master, **textcf)
Exemplo n.º 4
0
 def __init__(self, master=None, **kwargs):
     # get default settings from user's IDLE configuration
     currentTheme=idleConf.CurrentTheme()
     textcf = dict(padx=5, wrap='word', undo='True',
                   foreground=idleConf.GetHighlight(currentTheme,
                     'normal', fgBg='fg'),
                   background=idleConf.GetHighlight(currentTheme,
                     'normal', fgBg='bg'),
                   highlightcolor=idleConf.GetHighlight(currentTheme,
                     'hilite', fgBg='fg'),
                   highlightbackground=idleConf.GetHighlight(currentTheme,
                     'hilite', fgBg='bg'),
                   insertbackground=idleConf.GetHighlight(currentTheme,
                     'cursor', fgBg='fg'),
                   width=idleConf.GetOption('main','EditorWindow','width'),
                   height=idleConf.GetOption('main','EditorWindow','height')
                 )
     fontWeight = 'normal'
     if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'):
         fontWeight='bold'
     textcf['font']=(idleConf.GetOption('main', 'EditorWindow', 'font'),
                     idleConf.GetOption('main', 'EditorWindow', 'font-size'),
                     fontWeight)
     # override defaults with any user-specified settings
     textcf.update(kwargs)
     ScrolledText.__init__(self, master, **textcf)
Exemplo n.º 5
0
    def __init__(self, root, change_hook = None):
        ScrolledText.__init__(self,root,wrap=NONE,bd=0,width=80,height=25,undo=1,maxundo=50,padx=0,pady=0,background="white",foreground="black")
        # Non-wrapping, no border, undo turned on, max undo 50
        self.text = self # For the methods taken from IDLE
        self.root = root
        self.change_hook = change_hook
        self.characters = ascii_letters + digits + punctuation
        self.tabwidth = 8    # for IDLE use, must remain 8 until Tk is fixed
        self.indentwidth = 4 
        self.indention = 0   # The current indention level
        self.set_tabwidth(self.indentwidth) # IDLE...
        self.previous_line = "0"

        # create a popup menu
        self.menu = Menu(root, tearoff=0)
        self.menu.add_command(label="Undo", command=self.edit_undo)
        self.menu.add_command(label="Redo", command=self.edit_redo)
        #self.menu.add_command(type="separator")
        self.menu.add_command(label="Cut", command=self.cut)
        self.menu.add_command(label="Copy", command=self.copy)
        self.menu.add_command(label="Paste", command=self.paste)

        self.bind('<KeyRelease>', self.key_release)      # For scanning input
        self.bind('<Return>',self.autoindent)   # Overides default binding
        #self.bind('<Tab>',self.autoindent) # increments self.indention
        #self.bind('<BackSpace>',self.autoindent) # decrements self.indention
        self.bind('<Button-3>', self.popup) # right mouse button opens popup
        self.bind('<Button-1>', self.recolorCurrentLine) # left mouse can reposition cursor, so recolor (e.g. bracket highlighting necessary)
        self.bind('<Control-Any-KeyPress>', self.ctrl)
        
        # sets up the tags
        for tag, settings in self.tags.items():
            self.tag_config(tag, **settings)
Exemplo n.º 6
0
    def __init__(self, name, close_func, parent=None, **kwargs):
        self.parent = parent
        frame = LabelFrame(parent, text=name)
        ScrolledText.__init__(self, frame, **kwargs)
        self.bind('<Escape>', lambda e: close_func(e))

        self.pack(fill='both', expand=True)
        frame.pack(fill='both', expand=True)
Exemplo n.º 7
0
    def __init__(self, name, close_func, parent=None, **kwargs):
        frame = LabelFrame(parent, text=name)
        self.parent = parent
        ScrolledText.__init__(self, frame, **kwargs)
        self.bind('<Escape>', lambda event: close_func(event))

        self.pack(fill='both', expand=True)
        frame.pack(fill='both', expand=True)
Exemplo n.º 8
0
    def __init__(self, parent, height=25):
        """Constructs the ConsoleBox object.

        Most of the heavy lifting is done by the superconstructor, but
        we also perform the shortcut binding here.
        """
        
        ScrolledText.__init__(self, parent, width=80, height=height)
        self.bindShortcuts()
        self.parent = parent
Exemplo n.º 9
0
	def __init__(self, master=None, cnf={}):
		# Initialize base class
		ScrolledText.__init__(self, master, cnf)

		# Define tags for formatting styles
		self.tag_config('X', {'font': BOLDFONT})
		self.tag_config('!', {'font': ITALICFONT})
		self.tag_config('_', {'underline': 1})

		# Set state to idle
		self.fp = None
		self.lineno = 0
Exemplo n.º 10
0
    def __init__(self, master=None, cnf={}):
        # Initialize base class
        ScrolledText.__init__(self, master, cnf)

        # Define tags for formatting styles
        self.tag_config('X', {'underline': 1})
        self.tag_config('!', {'font': BOLDFONT})
        self.tag_config('_', {'font': ITALICFONT})

        # Set state to idle
        self.fp = None
        self.lineno = 0
Exemplo n.º 11
0
 def __init__(self, root, change_hook=None):
     ScrolledText.__init__(self,
                           root,
                           wrap=NONE,
                           bd=0,
                           width=80,
                           height=25,
                           undo=1,
                           maxundo=50,
                           padx=0,
                           pady=0,
                           background="white",
                           foreground="black")
Exemplo n.º 12
0
    def __init__(self, root, change_hook=None):
        ScrolledText.__init__(self,
                              root,
                              wrap=NONE,
                              bd=0,
                              width=80,
                              height=25,
                              undo=1,
                              maxundo=50,
                              padx=0,
                              pady=0,
                              background="white",
                              foreground="black")
        # Non-wrapping, no border, undo turned on, max undo 50
        self.text = self  # For the methods taken from IDLE
        self.root = root
        self.change_hook = change_hook
        self.characters = ascii_letters + digits + punctuation
        self.tabwidth = 8  # for IDLE use, must remain 8 until Tk is fixed
        self.indentwidth = 4
        self.indention = 0  # The current indention level
        self.set_tabwidth(self.indentwidth)  # IDLE...
        self.previous_line = "0"

        # create a popup menu
        self.menu = Menu(root, tearoff=0)
        self.menu.add_command(label="Undo", command=self.edit_undo)
        self.menu.add_command(label="Redo", command=self.edit_redo)
        #self.menu.add_command(type="separator")
        self.menu.add_command(label="Cut", command=self.cut)
        self.menu.add_command(label="Copy", command=self.copy)
        self.menu.add_command(label="Paste", command=self.paste)

        self.bind('<KeyRelease>', self.key_release)  # For scanning input
        self.bind('<Return>', self.autoindent)  # Overides default binding
        #self.bind('<Tab>',self.autoindent) # increments self.indention
        #self.bind('<BackSpace>',self.autoindent) # decrements self.indention
        self.bind('<Button-3>', self.popup)  # right mouse button opens popup
        self.bind(
            '<Button-1>', self.recolorCurrentLine
        )  # left mouse can reposition cursor, so recolor (e.g. bracket highlighting necessary)
        self.bind('<Control-Any-KeyPress>', self.ctrl)

        # sets up the tags
        for tag, settings in self.tags.items():
            self.tag_config(tag, **settings)
Exemplo n.º 13
0
 def __init__(self,
              boss,
              baseFont="Courier 8 normal",
              bg='ivory',
              nZfill=4,
              nbcar=30,
              nbligne=30):
     ScrolledText.__init__(self, boss, bg=bg, width=nbcar, height=nbligne)
     self.nZfill = nZfill
     self.nbligne = nbligne
     self.lineCount = 0
     self.tag_configure("rouge", foreground="red", font=baseFont)
     self.tag_configure("bleu", foreground="blue", font=baseFont)
     self.tag_configure("noir", foreground="black", font=baseFont)
     self.tag_configure("vert", foreground="green", font=baseFont)
     self.tag_configure("gris",
                        foreground="gray",
                        font=baseFont,
                        background='gray95')
Exemplo n.º 14
0
    def __init__(self, master=None, shell=None, **cnf):
        if not shell:
            try:
                shell = os.environ['SHELL']
            except KeyError:
                shell = '/bin/sh'
            shell = shell + ' -i'
        args = string.split(shell)
        shell = args[0]

        ScrolledText.__init__(self, master, **cnf)
        self.pos = '1.0'
        self.bind('<Return>', self.inputhandler)
        self.bind('<Control-c>', self.sigint)
        self.bind('<Control-t>', self.sigterm)
        self.bind('<Control-k>', self.sigkill)
        self.bind('<Control-d>', self.sendeof)

        self.pid, self.fromchild, self.tochild = spawn(shell, args)
        self.tk.createfilehandler(self.fromchild, READABLE,
                                  self.outputhandler)
Exemplo n.º 15
0
	def __init__(self, master = None, cnf = {}):
		try:
			shell = cnf['shell']
			del cnf['shell']
		except KeyError:
			try:
				shell = os.environ['SHELL']
			except KeyError:
				shell = '/bin/sh'
			shell = shell + ' -i'
		args = string.split(shell)
		shell = args[0]

		ScrolledText.__init__(self, master, cnf)
		self.pos = '1.0'
		self.bind('<Return>', self.inputhandler)
		self.bind('<Control-c>', self.sigint)
		self.bind('<Control-t>', self.sigterm)
		self.bind('<Control-k>', self.sigkill)
		self.bind('<Control-d>', self.sendeof)

		self.pid, self.fromchild, self.tochild = spawn(shell, args)
		self.tk.createfilehandler(self.fromchild, TK_READABLE,
					  self.outputhandler)
 def __init__(self, master=None, **kwargs):
     ScrolledText.__init__(self, master=None, **kwargs)
     Diacritical.__init__(self)
Exemplo n.º 17
0
 def __init__(self, *args, **kwargs):
     text = kwargs.pop("defaulttext", "")
     self.autosize = kwargs.pop("autosize", False)
     TkScrolledText.__init__(self, *args, **kwargs)
     self.text = text
     self.bind('<Control-a>', self.select_all)
Exemplo n.º 18
0
 def __init__(self, root, change_hook = None):
     ScrolledText.__init__(self,root,wrap=NONE,bd=0,width=80,height=25,undo=1,maxundo=50,padx=0,pady=0,background="white",foreground="black")
Exemplo n.º 19
0
 def __init__(self, *args, **kwargs):
     ScrolledText.__init__(self, *args, **kwargs)
     self.redirector = WidgetRedirector(self)
     self.insert = self.redirector.register("insert", lambda *args, **kw: "break")
     self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
     self.config(wrap=tk.WORD)
Exemplo n.º 20
0
 def __init__(self, parent=None):
     ScrolledText.__init__(self, parent)
     self.pack()
     self.dataQueue = Queue.Queue()  # infinite size
     self.bind('<Button-1>', self.makethreads)  # on left mouse click
     self.consumer()  # queue loop in main thread
Exemplo n.º 21
0
 def __init__(self,*arg,**kw):
     ScrolledText.__init__(self,*arg,**kw)
Exemplo n.º 22
0
 def __init__(self, master=None, **kwargs):
     ScrolledText.__init__(self, master=None, **kwargs)
     Diacritical.__init__(self)
Exemplo n.º 23
0
 def __init__(self, master=None, **args):
     ScrolledText.__init__(self, master, **args)