Example #1
1
class ChatWindow(object):
    def __init__(self, parent, line_sender):
        self.parent = parent
        self.main = self.build_window()
        self.line_sender = line_sender

    def build_window(self):
        self.toplevel = tk.Toplevel(self.parent)
        f = tk.Frame(self.toplevel)
        f.pack()
        
        self.area = ScrolledText(f)
        self.area.pack(side=tk.TOP)
        self.area.config(state=tk.DISABLED)

        self.line = tk.Entry(f)
        self.line.pack(side=tk.BOTTOM, padx=10, pady=10)
        self.line.focus_force()

        self.toplevel.bind('<Return>', self.send_line)
        return f

    def send_line(self, _evt):
        line = self.line.get()
        self.line.delete(0, tk.END)
        self.line_sender(line)

    def add_message(self, msg):
        self.area.config(state=tk.NORMAL)
        self.area.insert(tk.END, '%s\n' % msg)
        self.area.config(state=tk.DISABLED)

    def set_dispose_callback(self, callback):
        self.toplevel.protocol('WM_DELETE_WINDOW', callback)
Example #2
0
def _bayestest():
  logging.basicConfig(level=logging.INFO,
                      stream=sys.stdout)
  logging.basicConfig(level=logging.DEBUG,
                      stream=sys.stdout)
  logging.root.level = 30
  tk = Tk.Tk()
  tk.title('BayesTest')
  stopper = make_stopper(tk)
  tk.protocol("WM_DELETE_WINDOW", stopper)
  tk.info = Tk.Label(tk, text="BayesTest Main Window")
  tk.info.pack(expand=Tk.NO, fill=Tk.BOTH)
  time.sleep(0.1)
  ip = ScrolledText(tk, relief=Tk.SUNKEN, border=2)
  ip.pack(expand=Tk.YES, fill=Tk.BOTH)
  tk.info_pane = ip
  tk.status = Tk.Label(tk, text="...")
  tk.status.pack(expand=Tk.NO, fill=Tk.BOTH)
  tk.subprog = Tk.Label(tk, text="")
  tk.subprog.pack(expand=Tk.NO, fill=Tk.BOTH)
  Tk.Button(tk, text="Quit", command=stopper).pack()
  docalcs(tk)
  tk.tkraise()
  tk.update_idletasks()
  tk.mainloop()
Example #3
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)
Example #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)
Example #5
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)
Example #6
0
class ErrDialog(Dialog):
    def __init__(self,master=None, Title="Error", Short="",Msg=""):
        self.Title=Title
        self.Msg=Msg
        self.Short = Short
        Dialog.__init__(self,parent=master,title=Title)
        
        
    def body(self,unused):
        self.text = ScrolledText(self)
        self.text["height"] = "8"
        self.text["width"] = "50"
        
        self.text.pack(side="top",expand="yes",fill="both")
        self.text.insert("0.0", self.Msg)
        self.text["state"] = "disabled"
        self.result = False

    def buttonbox(self):
        box = Frame(self)

        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
        w.pack(side=LEFT, padx=5, pady=5)

        self.bind("<Return>", self.ok)

        box.pack()
Example #7
0
    def __init__(self, master=None):
        """Elemente der Form kreieren"""
        Frame.__init__(self, master)
        self.pack()
        #self.createWidgets()
        self.text_label = Label(self,
            height=1, width=80, anchor=NW, text="Play-Out-Logging Nr: ")
        self.text_label.pack()

        self.text_label_1 = Label(self,
            height=1, width=80, text="Titel aktuell")
        self.text_label_1.pack()

        self.textBox = ScrolledText(self, height=5, width=80)
        self.textBox.pack()
        self.textBox.insert(END, "In the Beginning...\n")

        self.text_label_2 = Label(self,
            height=1, width=80, text="Rueckmeldung von Webserver")
        self.text_label_2.pack()

        self.textBox1 = ScrolledText(self, height=10, width=80)
        self.textBox1.pack()
        self.textBox1.insert(END, "...and the End\n")

        # registering callback
        self.listenID = self.after(500, self.lets_rock)
Example #8
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
Example #9
0
def run(event):
    """Run the script and shows the resulting HTML code in a
    new window
    If started with the "Make HTML" button, saves HTML output in
    a file"""
    pythonCode=pythonText.get(1.0,END)
    lines=pythonCode.split('\n')
    lines=map(lambda x:x[5:],lines)
    pythonCode='\n'.join(lines)
    execWindow=Toplevel()
    execText=ScrolledText(execWindow,width=40,height=40,bg="white",
        font=FONT)
    execText.pack()
    s=sys.stdout
    sys.stdout=Output(execText)
    try:
        exec(pythonCode) in globals()
        if event.widget is bRunHTML:
            htmlFilename=os.path.splitext(pihText.filename)[0]+".htm"
            if os.path.exists(htmlFilename):
                override=tkMessageBox.askyesno("Override ?",
                    "File %s already exists - Override ?" \
                    %os.path.basename(htmlFilename))
                if not override:
                    return
            f=open(htmlFilename,"w")
            f.write(execText.get(1.0,END))
            f.close()
            path=os.path.join(os.getcwd(),htmlFilename)
            webbrowser.open_new("file://"+path)
    except:
        traceback.print_exc(file=sys.stdout)
    sys.stdout=s
Example #10
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)
Example #11
0
    def __init__(self, grammar, text, title='Input Grammar'):
        self.root = None
        try:
            self._root = Tkinter.Tk()
            self._root.title(title)

            level1 = Tkinter.Frame(self._root)
            level1.pack(side='top', fill='none')
            Tkinter.Frame(self._root).pack(side='top', fill='none')
            level2 = Tkinter.Frame(self._root)
            level2.pack(side='top', fill='x')            
            buttons = Tkinter.Frame(self._root)
            buttons.pack(side='top', fill='none')

            self.sentence = Tkinter.StringVar()            
            Tkinter.Label(level2, text="Sentence:").pack(side='left')
            Tkinter.Entry(level2, background='white', foreground='black',
                          width=60, textvariable=self.sentence).pack(
                side='left')

            lexiconFrame = Tkinter.Frame(level1)
            Tkinter.Label(lexiconFrame, text="Lexicon:").pack(side='top',
                                                              fill='x')
            Tkinter.Label(lexiconFrame, text="  ex. 'dog N':").pack(
                side='top', fill='x')
            self.lexicon = ScrolledText(lexiconFrame, background='white',
                                              foreground='black', width=30)
            self.lexicon.pack(side='top')


            grammarFrame = Tkinter.Frame(level1)
            Tkinter.Label(grammarFrame, text="Grammar:").pack(side='top',
                                                              fill='x')
            Tkinter.Label(grammarFrame,
                          text="  ex. 'S -> NP VP':").pack(side='top',fill='x')
            self.grammarRules = ScrolledText(grammarFrame, background='white',
                                              foreground='black', width=30)
            self.grammarRules.pack(side='top')
            
            lexiconFrame.pack(side='left')
            grammarFrame.pack(side='left')


            Tkinter.Button(buttons, text='Clear',
                           background='#a0c0c0', foreground='black',
                           command=self.clear).pack(side='left')
            Tkinter.Button(buttons, text='Parse',
                           background='#a0c0c0', foreground='black',
                           command=self.parse).pack(side='left')

            self.init_menubar()
            
            # Enter mainloop.
            Tkinter.mainloop()
        except:
            print 'Error creating Tree View'
            self.destroy()
            raise
Example #12
0
class Toplevel_ScolledText(tk.Toplevel):
    def __init__(self, master=None, cnf={}, **kw):
        tk.Toplevel.__init__(self, master=None, cnf={}, **kw)
        self.__ShowText = ScrolledText(self,height = 20,width=40)
        self.__ShowText.pack(expand=1,fill='both')
        
    def addtext(self,Text_output=''):
        self.__ShowText.insert('end',Text_output)
        print(Text_output)
class App(object):

    def __init__(self):
        self.root = tki.Tk()

    # create a Text widget with a Scrollbar attached
        self.txt = ScrolledText(self.root, undo=True)
        self.txt['font'] = ('consolas', '12')
        self.txt.pack(expand=True, fill='both')
Example #14
0
 def setUpClipArea(self, frame):
     '''
     @summary: 
         クリップボートの表示エリアを作成します
     '''
     xscrollbar = Tk.Scrollbar(frame, orient=Tk.HORIZONTAL)
     st = ScrolledText(frame, bg="GRAY", xscrollcommand=xscrollbar.set, height=10)
     st.config(state=Tk.DISABLED)
     return st
Example #15
0
class App(object):

  def __init__(self):
    self.window = tk.Tk()
    self.window.attributes("-fullscreen",True)
    self.window.minsize(width=320, height=240)
    self.window.maxsize(width=320, height=240)

    self.buttonFrame = tk.Frame(self.window)

    self.printButton=tk.Button(self.buttonFrame, text='PRINT!', height=2, command=self.printTxt)
    self.printButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5)

    self.loadButton=tk.Button(self.buttonFrame, text='LOAD', height=2, command=self.load)
    self.loadButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5, expand=1)

    self.exitButton=tk.Button(self.buttonFrame, text='EXIT', height=2, command=self.exitWin)
    self.exitButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5, expand=1)

    self.buttonFrame.pack(side=tk.TOP)

    self.filename = '/home/pi/Desktop/fly.txt'

    self.txt = ScrolledText(self.window)
    self.txt.vbar.config(width=18)
    self.txt.pack(expand=True, fill=tk.BOTH)

    self.loadFile()

    self.poll()

  def poll(self):
    if(float(self.txt.vbar.get()[1])==1):
      self.txt.see(1.0) #goto top
    else:
      self.txt.yview(tk.SCROLL,1,tk.UNITS)
    self.window.after(1000, self.poll)

  def load(self):
    self.filename = askopenfilename(initialdir="/home/pi/Desktop", title="SELECT TXT", filetypes=(("txt files","*.txt"),("all files","*.*")) )
    self.loadFile()

  def loadFile(self):
    self.txt.delete(1.0,tk.END)
    fly = open(self.filename,'r')
    self.txt.insert(1.0, fly.read())
    fly.close()

  def printTxt(self):
    call(["lp", self.filename])
    tkMessageBox.showinfo("PRINT", "it's printing!")

  def exitWin(self):
    result = tkMessageBox.askquestion("EXIT?!", "zomg, u sure?", icon='warning')
    if result == 'yes':
      self.window.quit()
Example #16
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
Example #17
0
class Autotyper:
    """
  Autotyper class, it generates the autotyper window, waits for entering text
  and then calls a function to work with the text.
  """

    def __init__(self, master, sendfunc):
        """
    Initializes the autotyper.
    
    @param master: the main tk window
    @type  master: Tk

    @param sendfunc: the callback function
    @type  sendfunc: function
    """
        self._sendfunc = sendfunc

        self._frame = Toplevel(master)

        # self._frame.geometry("400x300")
        self._frame.title("Lyntin -- Autotyper")

        self._frame.protocol("WM_DELETE_WINDOW", self.cancel)

        if os.name == "posix":
            fontname = "Courier"
        else:
            fontname = "Fixedsys"
        fnt = tkFont.Font(family=fontname, size=12)

        self._txt = ScrolledText(self._frame, fg="white", bg="black", font=fnt, height=20)
        self._txt.pack(side=TOP, fill=BOTH, expand=1)

        self._send_btn = Button(self._frame, text="Send", command=self.send)
        self._send_btn.pack(side=LEFT, fill=X, expand=0)

        self._cancel_btn = Button(self._frame, text="Cancel", command=self.cancel)
        self._cancel_btn.pack(side=RIGHT, fill=X, expand=0)

    def send(self):
        """
    Will be called when the user clicks on the 'Send' button.
    """
        text = fix_unicode(self._txt.get(1.0, END))
        self._sendfunc(text)
        self._frame.destroy()

    def cancel(self):
        """
    Will be called when the user clicks on the 'Cancel' button.
    """
        self._sendfunc(None)
        self._frame.destroy()
Example #18
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
class PopupScrolledText(PopupWindow):
    """
    Scrolled text output window with 'Save As...'
    """

    def __init__(self, title="", kind="", iconfile=None, var=None):
        PopupWindow.__init__(self, title=title, kind=kind, iconfile=iconfile)
        if var:
            self._var = var
        else:
            self._var = BooleanVar()
        self._var.trace_variable("w", self._visibility_control)
        self._text = ScrolledText(self)
        self._text.pack()
        self._text.config(font=FONT)
        self._make_menu()
        self._visibility_control()

    def on_close(self, *args):
        self._var.set(False)

    def _visibility_control(self, *args):
        if self._var.get():
            self.deiconify()
        else:
            self.withdraw()

    def _make_menu(self):
        topmenu = Menu(self)
        self.config(menu=topmenu)
        file = Menu(topmenu, tearoff=0)
        file.add_command(label="Save as...", command=self.on_save_as)
        file.add_command(label="Hide", command=self.on_close)
        topmenu.add_cascade(label="File", menu=file)
        edit = Menu(topmenu, tearoff=0)
        edit.add_command(label="Clear text", command=self.on_clear)
        topmenu.add_cascade(label="Edit", menu=edit)

    def on_save_as(self):
        filename = asksaveasfilename()
        if filename:
            alltext = self.gettext()
            f = open(filename, "w")
            f.write(alltext)
            f.close()

    def on_clear(self):
        self._text.delete("0.0", END)
        self._text.update()

    def gettext(self):
        return self._text.get("1.0", END + "-1c")

    def hide(self):
        self._var.set(False)

    def show(self):
        self._var.set(True)
Example #20
0
class GuiShuffler(shuffle.Shuffler):
    def __init__(self):
        shuffle.Shuffler.__init__(self, 20, 10, 2)

        self.frmMain = Tk()
        self.blockStr = StringVar()
        self.blockSizeStr = StringVar()
        self.groupStr = StringVar()
        self.results = ScrolledText(self.frmMain)

        self.blockStr.set(str(self.blocks))
        self.blockSizeStr.set(str(self.blockSize))
        self.groupStr.set(str(self.groups))

        Label(self.frmMain, text="Blocks").grid(row=0, sticky=E)
        blockEntry = Entry(self.frmMain, textvariable=self.blockStr)
        blockEntry.grid(column=1, row=0)

        Label(self.frmMain, text="Block Size").grid(row=1, sticky=E)
        blockSizeEntry = Entry(self.frmMain, textvariable=self.blockSizeStr)
        blockSizeEntry.grid(column=1, row=1)

        Label(self.frmMain, text="Groups").grid(row=2, sticky=E)
        groupEntry = Entry(self.frmMain, textvariable=self.groupStr)
        groupEntry.grid(column=1, row=2)

        self.results.grid(columnspan=2, row=3, sticky=W+E)

        genBtn = Button(self.frmMain, text="Generate", command=self.generate, anchor=SE)
        genBtn.grid(columnspan=2, row=4, sticky=S)

    def generate(self):
        try:
            self.blocks = int(self.blockStr.get())
            self.blockSize = int(self.blockSizeStr.get())
            self.groups = int(self.groupStr.get())
        except ValueError:
            tkMessageBox.showwarning("Not a Number", "All values must be numbers.\n")
            return

        if not self.is_valid_group_size():
            tkMessageBox.showwarning("Group Size", "Block Size must be evenly divisible by groups to get an even grouping.\n")
        else:
            self.results.delete(1.0, END)       # clear previous entries
            self.print_results(self.results)

    def print_results(self, results):
        for i in  range(self.blocks):
            results.insert(END, ' '.join([str(i) for i in self.shuffle()]))
            results.insert(END, "\n")

    def run(self):
        self.frmMain.mainloop()
Example #21
0
def tk_scroll(text, title = 'Help'):
  win = Tk()

  fnt = tkFont.Font(family="Fixedsys", size=12)
  fnt = tkFont.Font(family="Courier", size=12)
  
  scroll = ScrolledText(win, fg='white', bg='black', font=fnt, height=20)
  scroll.pack(side=BOTTOM, fill=BOTH, expand=1)
  scroll.insert('end', text)
  Button(win, text='OK', command=win.destroy).pack(side=BOTTOM)
  win.title(title)
  return win
def onViewMail():
    # view selected message
    msgnum = selectedMsg()
    if not (1 <= msgnum <= len(msgList)):
        showerror('PyMail', 'No message selected')
    else:
        text = msgList[msgnum-1]                # or put in a TextEditor
        from ScrolledText import ScrolledText
        window  = Toplevel()
        window.title('PyMail message viewer #' + str(msgnum))
        browser = ScrolledText(window)
        browser.insert('0.0', text)
        browser.pack(expand=YES, fill=BOTH)
Example #23
0
class Credits(tkSimpleDialog.Dialog):
    def body(self, master):
        self.image = Tk.PhotoImage(file=GIFFILE)
        self.icon = Tk.Label(master, image=self.image)
        self.icon.pack(side=Tk.TOP)
        label = Tk.Label(master, text=crnotice1)
        label.pack(side=Tk.TOP)
        font = "Helvetica " + TITLEFONTSIZE
        label = Tk.Label(master,
                         font=font,
                         text="Credits",
                         justify=Tk.CENTER,
                         foreground='blue')
        label.pack(side=Tk.TOP)
        font = "Helvetica " + AXISFONTSIZE
        self.infoText = ScrolledText(master,
                                     relief=Tk.FLAT,
                                     padx=3,
                                     pady=3,
                                     background='white',
                                     foreground="blue",
                                     wrap='word',
                                     width=70,
                                     height=12,
                                     font=font,
                                     tabs=("4c"))
        self.infoText.pack(expand=0, fill=Tk.X, side=Tk.BOTTOM)
        self.infoText.delete('0.0', Tk.END)
        self.infoText.insert('0.0', getCredits())
        self.infoText.configure(state=Tk.DISABLED)
Example #24
0
class NoAnnDialog(Dialog):
    result = None

    def __init__(self,master=None, Title="No Annotation File Found", Filename="",
                 Msg="The file you have loaded does not have an associated annotation file"):
        self.Title=Title
        self.Msg=Msg
        self.filename = Filename
        
        #self.Short = Short
        
        Dialog.__init__(self,master,title=self.Title)
        
        
    def body(self,unused):
        self.text = ScrolledText(self)
        
        self.text["height"] = "6"
        self.text["width"] = "50"
        
        self.text.pack(side="top",expand="yes",fill="both")
        self.text.insert("1.0", self.Msg)
        self.text["state"] = "disabled"
        self.result = False

    def ok(self, unused=None):
    	self.result = True
        Dialog.ok(self)
        return True
    

    def buttonbox(self):
        box = Frame(self)

        w = Button(box, text="Simple BTA", width=10, command=lambda :self.click("simple"), default=ACTIVE)
        w1 = Button(box, text="Reset File", width=10, command=lambda :self.click("reset"), default=ACTIVE)
        w2 = Button(box, text="Mark Unknown", width=10, command=lambda :self.click("unknown"), default=ACTIVE)        

        w.pack(side=LEFT, padx=5, pady=5)
        w1.pack(side=LEFT, padx=5, pady=5)
        w2.pack(side=LEFT, padx=5, pady=5)

        #self.bind("<Return>", self.ok)


        box.pack()

    def click(self, value):
        self.result = value        
        Dialog.ok(self)
def onViewRawMail():
    # view selected message - raw mail text with header lines
    msgnum = selectedMsg()
    if not (1 <= msgnum <= len(msgList)):
        showerror("PyMail", "No message selected")
    else:
        text = msgList[msgnum - 1]  # put in ScrolledText
        from ScrolledText import ScrolledText

        window = Toplevel()
        window.title("PyMail raw message viewer #" + str(msgnum))
        browser = ScrolledText(window)
        browser.insert("0.0", text)
        browser.pack(expand=YES, fill=BOTH)
Example #26
0
    def __init__(self):
        Tk.__init__(self)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # 2 rows: firts with settings, second with registrar data
        self.main_frame = Frame(self)
        # Commands row doesn't expands
        self.main_frame.rowconfigure(0, weight=0)
        # Logs row will grow
        self.main_frame.rowconfigure(1, weight=1)
        # Main frame can enlarge
        self.main_frame.columnconfigure(0, weight=1)
        self.main_frame.columnconfigure(1, weight=1)
        self.main_frame.grid(row=0, column=0)

        # Run/Stop button
        self.server_button = Button(self.main_frame, text="Connect", command=self.start_server)
        self.server_button.grid(row=0, column=0)

        # Clear button
        self.clear_button = Button(self.main_frame, text="Clear Log", command=self.clear_log)
        self.clear_button.grid(row=0, column=1)

        # Logs Widget
        self.log_widget = ScrolledText(self.main_frame)
        self.log_widget.grid(row=1, column=0, columnspan=2)
        # made not editable
        self.log_widget.config(state='disabled')

        # Queue where the logging handler will write
        self.log_queue = Queue.Queue()

        # Setup the logger
        self.uilogger = logging.getLogger('SigBridgeUI')
        self.uilogger.setLevel(logging.INFO)
        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

        # Use the QueueLogger as Handler
        hl = QueueLogger(queue=self.log_queue)
        hl.setFormatter(formatter)
        self.uilogger.addHandler(hl)

        # self.log_widget.update_idletasks()
        self.set_geometry()

        # Setup the update_widget callback reading logs from the queue
        self.start_log()
Example #27
0
 def __init__(self, master, text):
     Frame.__init__(self, master)
     text_field = ScrolledText(self)
     text_field.insert(At(0, 0), text)
     text_field.pack(side=TOP)
     text_field.config(state=DISABLED)
     ButtonBar(self, [], [('Close', self.master.destroy)]).pack(side=BOTTOM,
                                                                fill=X)
Example #28
0
 def browser(self, filename):
     new = Toplevel()  # make new window
     text = ScrolledText(new, height=30, width=90)  # Text with scrollbar
     text.config(font=('courier', 10, 'normal'))  # use fixed-width font
     text.pack()
     new.title("Text Viewer")  # set window mgr attrs
     new.iconname("browser")
     text.insert('0.0', open(filename, 'r').read())  # insert file's text
    def makeWidgets(self):
        middle = Frame(self)
        middle.pack(expand=YES, fill=BOTH)

        Label(middle, text='Candidate Passwords').grid(row=0,
                                                       column=0,
                                                       sticky=NSEW)
        self.candidatesView = ScrolledText(middle, height=15, width=45)
        self.candidatesView.config(font=('courier', 10, 'normal'))
        self.candidatesView.grid(row=1, column=0, sticky=NSEW)

        Label(middle, text='Try It!').grid(row=0, column=1, sticky=NSEW)
        self.scratchPadView = ScrolledText(middle, height=15, width=45)
        self.scratchPadView.config(font=('courier', 10, 'normal'))
        self.scratchPadView.grid(row=1, column=1, sticky=NSEW)
Example #30
0
    def build_window(self):
        self.toplevel = tk.Toplevel(self.parent)
        f = tk.Frame(self.toplevel)
        f.pack()

        self.area = ScrolledText(f)
        self.area.pack(side=tk.TOP)
        self.area.config(state=tk.DISABLED)

        self.line = tk.Entry(f)
        self.line.pack(side=tk.BOTTOM, padx=10, pady=10)
        self.line.focus_force()

        self.toplevel.bind('<Return>', self.send_line)
        return f
 def browser(self, file):
     new = Toplevel()
     text = ScrolledText(new, height=30, width=90)
     text.config(font=('Courier', 9, 'normal'))
     text.pack()
     new.title("Poor-man's Text Editor")
     new.iconname("PyBrowser")
     text.insert('0.0', open(file, 'r').read())
Example #32
0
def main():
    root = Tk()
    root.title('test')
    root.geometry('+1000+400')
    global text
    text = ScrolledText(root, font=('微软雅黑', 10))
    text.grid()
    button = Button(root, text='开始爬取', font=('微软雅黑', 10), command=start())
    button.grid()
    global varl
    varl = StringVar()

    label = Label(root, font=('微软雅黑', 10), fg='red', textvar=varl)
    label.grid()
    varl.set('已准备好...')
    root.mainloop()
    def __init__(self, master=None):
        """create elements of form"""
        Frame.__init__(self, master)
        self.pack()
        #self.createWidgets()

        self.textBox = ScrolledText(self, height=15, width=100)
        self.textBox.pack()
        self.textBox.tag_config("b", foreground="blue")
        self.textBox.tag_config("r", foreground="red")
        # insert the msg from lets_rock will display when finished,
        # that's to late
        if os.getenv('LANG')[0:2] == "de":
            self.textBox.insert(END,
                "Es kann eine Weile dauern, "
                + "vielleicht eine Tasse Kaffee geniessen...")
        else:
            self.textBox.insert(END,
            "Working, this can take a while, enjoy a cup of coffee...\n")
        self.pressButton = Button(self,
                text="ID3 easyTAG Editor", command=self.call_id3_editor)
        # the button will appear when finished
        #self.pressButton.pack()

        # registering callback
        self.listenID = self.after(400, self.lets_rock)
Example #34
0
 def preview_report(self, report_data, callback):
     self.report_dialog = Toplevel()
     self.report_dialog.title("Preview Report")
     Button(self.report_dialog, text="Send Report", command=callback).pack()
     self.text_boxes[report_data['text_box']] = ScrolledText(
         self.report_dialog)
     self.text_boxes[report_data['text_box']].pack()
Example #35
0
 def __init__(self, parent):
     Frame.__init__(self, master=parent)
     parent.title('Liar\'s Dice')
     self.canvas = Canvas(self, width=550, height=500)
     self.canvas.pack(fill='both', expand=True)
     self.canvas.place(x=0, y=0)
     self.bid_logs = ScrolledText(self, undo=True, width=100, height=100)
     self.bid_logs.pack(fill='both', expand=True)
     self.bid_logs['font'] = ('consolas', '12')
     self.bid_logs.place(x=350, y=0)
     self.input_box = Text(self, undo=True, width=100, height=100)
     self.input_box.pack(fill='both', expand=True)
     self.input_box['font'] = ('consolas', '12')
     self.input_box.place(x=350, y=450)
     self.pack(fill='both', expand=True)
     self.insert_to_log()
def showhelp(helptext=helptext, appname='PyMail'):  # show helptext in
    from ScrolledText import ScrolledText  # a non-modal dialog
    new = Toplevel()  # make new popup window
    bar = Frame(new)  # pack first=clip last
    bar.pack(side=BOTTOM, fill=X)
    code = Button(bar, bg='beige', text="Source", command=showsource)
    quit = Button(bar, bg='beige', text="Cancel", command=new.destroy)
    code.pack(pady=1, side=LEFT)
    quit.pack(pady=1, side=LEFT)
    text = ScrolledText(new)  # add Text + scrollbar
    text.config(font='system', width=70)  # too big for showinfo
    text.config(bg='steelblue', fg='white')  # erase on btn or return
    text.insert('0.0', helptext)
    text.pack(expand=YES, fill=BOTH)
    new.title(appname + " Help")
    new.bind("<Return>", (lambda event, new=new: new.destroy()))
Example #37
0
    def __init__(self, master, sendfunc):
        """
    Initializes the autotyper.
    
    @param master: the main tk window
    @type  master: Tk

    @param sendfunc: the callback function
    @type  sendfunc: function
    """
        self._sendfunc = sendfunc

        self._frame = Toplevel(master)

        # self._frame.geometry("400x300")
        self._frame.title("Lyntin -- Autotyper")

        self._frame.protocol("WM_DELETE_WINDOW", self.cancel)

        if os.name == "posix":
            fontname = "Courier"
        else:
            fontname = "Fixedsys"
        fnt = tkFont.Font(family=fontname, size=12)

        self._txt = ScrolledText(self._frame, fg="white", bg="black", font=fnt, height=20)
        self._txt.pack(side=TOP, fill=BOTH, expand=1)

        self._send_btn = Button(self._frame, text="Send", command=self.send)
        self._send_btn.pack(side=LEFT, fill=X, expand=0)

        self._cancel_btn = Button(self._frame, text="Cancel", command=self.cancel)
        self._cancel_btn.pack(side=RIGHT, fill=X, expand=0)
Example #38
0
 def body(self, master):
     self.resizable(0,0)
     self.catIconImage = Tk.PhotoImage(file=GIFFILE) # statt file=
     self.catIcon = Tk.Label(master, image=self.catIconImage)
     self.catIcon.pack(side=Tk.TOP)
     label = Tk.Label(master, text=crnotice1)
     label.pack(side=Tk.TOP)
     font = "Helvetica "+TITLEFONTSIZE
     label = Tk.Label(master, font=font, text=crnotice2,
             justify=Tk.CENTER)
     label.pack(side=Tk.TOP)
     color = 'green'
     font = "Helvetica "+AXISFONTSIZE
     self.infoText = ScrolledText(master, relief=Tk.FLAT, 
                      padx=3, pady=3,
                      background=color, 
                      #foreground="black",
                      wrap='word',
                      width=60, height=12,
                      font=font)
     self.infoText.pack(expand=0, fill=X, side=Tk.BOTTOM)
     self.infoText.delete('0.0', Tk.END)
     self.infoText.insert('0.0', getLicense())	
     self.infoText.configure(state=Tk.DISABLED)
     self.title("STARS - About")
Example #39
0
    def __init__(self, parent, day, day_index = None):
        # Create a new Chore object, loading day_index from Day
        # If day_index is not set, create blank Chore
        self.check_state = BooleanVar()
        #self.description = StringVar()
        self.this = self

        self.parent = parent
        self.frame = Frame(parent, borderwidth = 1, relief = RAISED)
                
        self.check = Checkbutton(self.frame, variable=self.check_state, 
                                 text = "Done",
                                 onvalue = True, offvalue = False)
        
        self.textb = ScrolledText(self.frame, 
                                 wrap=WORD, width = 40, height = 3,
                                 selectbackground ="#ff5500")
        
        if(day_index != None):
            self.textb.insert("1.0", day.get_index(day_index)[1])
            self.check_state.set(day.get_index(day_index)[0])
        
            print day.get_index(day_index)[0].__class__
        else:
            self.check_state.set(0)

            
        self.check.pack(side = LEFT)
        self.textb.pack(side = LEFT)
        self.delete = Button(self.frame, width = 6,text = "Delete", command = 
                            lambda: self.seppuku()).pack(side = TOP)
        self.clear = Button(self.frame, width = 6, text = "Clear", command =
                            lambda: self.text.delete("1.0", END))
        self.clear.pack(side = BOTTOM)
        self.frame.pack()
    def editor(self):
        """ combine some Widgets to an enhanced editor (incl. Scrollbar)

        --> self.text
                the text widget itself

        --> self.opened_file_label
                Label on top of the editfield to show the name of the current
                opened File
                It can be used to show textchanges
        """
        # build widgets
        self.txtfrm = tk.Frame(self)
        self.txtfrm.pack(fill=tk.BOTH, side=tk.LEFT, expand=tk.YES)
        self.opened_file_label = tk.Label(self.txtfrm, text="No File chosen")
        self.opened_file_label.pack(fill=tk.X)
        self.text = ScrolledText(self.txtfrm, bg="white",
                                undo=1, maxundo=30,
                                wrap=tk.WORD)
        self.text.pack(fill=tk.BOTH, expand=tk.YES, side=tk.LEFT)
        self.text.insert(1.0, u"Please open a File to edit")

        # build first(reference -- new name??) hash for comparison on changes
        self.hash_opened_filename = hash(self.text.get(1.0,tk.END))

        # Set focus on textwidget and move cursor to the upper left
        self.text.focus_set()
        self.text.mark_set(tk.INSERT, '0.0')      # goto line
        self.text.see(tk.INSERT)                  # scroll to line
Example #41
0
 def __init__(self, parent, text, title="Phoshare Help"):
     Toplevel.__init__(self, parent)
     self.transient(parent)
     self.title(title)
     self.parent = parent
     t = ScrolledText(self)
     t.insert(END, text)
     t.config(state=DISABLED)
     t.pack()
Example #42
0
    def __init__(self, master):
        frame = tkinter.Frame(master,width=500,height=220)
        frame.grid(row=0, column=0)
        frame.pack()
        #self.repWin = repWin

        self.labelFile = tkinter.Label(frame,
                                       text='文件',
                                       font=('黑体'),
                                       justify='left',
                                       )
        self.labelFile.place(x=35, y=30)

        self.fileVar = tkinter.Variable()
        self.fileEntry = tkinter.Entry(frame,textvariable=self.fileVar, width=45)
        #self.fileEntry.delete(0, 'end')
        self.fileEntry.place(x=90,y=30)
        
        self.buttonOpenFile = tkinter.Button(frame, text='打开', width=5, height=1, command=self.openFile)
        self.buttonOpenFile.place(x=430, y=30) 
        
        self.labelPic = tkinter.Label(frame,
                                       text='图片',
                                       font=('黑体'),
                                       justify='left',
                                       )
        self.labelPic.place(x=35, y=90)
        
        self.picVar = tkinter.Variable()
        self.picEntry = tkinter.Entry(frame,textvariable=self.picVar, width=45)
        self.picEntry.place(x=90,y=90)
        
        self.buttonOpenPic = tkinter.Button(frame, text='打开', width=5, height=1, command=self.openPic)
        self.buttonOpenPic.place(x=430, y=90)
        
        self.labelPic = tkinter.Label(frame,
                                       text='过滤词',
                                       font=('黑体'),
                                       justify='left',
                                       )
        self.labelPic.place(x=20, y=150)
        
        self.st = ScrolledText(frame, width=43, height=3)
        self.st.place(x=90,y=150)
        
        self.buttonAddWords = tkinter.Button(frame, text='添加', width=5, height=1, command=self.addWords)
        self.buttonAddWords.place(x=430, y=150)        
Example #43
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)
Example #44
0
    def __init__(self, master):

        self.filename = ""
        self.confg = ""
        self.master = master
        #setting color.
        bkc = "floral white"
        fgc = "RosyBrown4"
        bgc = "misty rose"

        self.FontForButton = tkFont.Font(family="Verdana", size=12)
        self.FontForLabel = tkFont.Font(family="Verdana", weight="bold")
        self.frame = tk.Frame(self.master, bg=bkc)
        self.frame.pack()
        self.chose_button = tk.Button(self.frame,
                                      text=u"選擇檔案",
                                      command=self.open_file,
                                      font=self.FontForButton,
                                      width=20,
                                      bg=bgc,
                                      fg=fgc)
        self.chose_button.pack(padx=5, pady=10, side=tk.TOP)
        self.chose_confg_button = tk.Button(self.frame,
                                            text=u"選擇設定檔",
                                            command=self.get_confg,
                                            font=self.FontForButton,
                                            width=20,
                                            bg=bgc,
                                            fg=fgc)
        self.chose_confg_button.pack(padx=5, pady=10, side=tk.TOP)
        self.run_button = tk.Button(self.frame,
                                    text=u"執行",
                                    command=self.run,
                                    font=self.FontForButton,
                                    width=20,
                                    bg=bgc,
                                    fg=fgc)
        self.run_button.pack(padx=5, pady=10, side=tk.TOP)
        self.text = ScrolledText(self.frame)
        self.text.pack()
        self.mdby = tk.Label(self.frame,
                             text="\nPowered By MITLab",
                             font=self.FontForLabel,
                             fg="SkyBlue1",
                             bg=bkc)
        self.mdby.pack(side='bottom')
Example #45
0
    def chat_screen(self):
        """
        Using a loop is infesible because the value of i will always be used and generate the phrases of the last buddies in the array
        best fix for right now is to use a finite number of buddies
        TODO make a class for these different screens
        """
        #destroy old frame and add new one
        self.destroy()
        self.Pychat_newScreen("PyChat")
        #making copies of global variables
        userName = self.userName
        userColor = self.userColor

        self.PyChat_Chat_Screen_profilePicture(
            10, 2, "You Have No Profile Picture Yet")
        #username label
        self.userNameLabel = Label(self, text=userName)
        self.userNameLabel.grid(row=9, column=2)
        #profile button
        self.profileButton = Button(self,
                                    text="Profile",
                                    command=self.userProfileScreen)
        self.profileButton.grid(row=9, column=0)
        #chatbox
        self.chatbox = ScrolledText(self,
                                    wrap='word',
                                    width=50,
                                    height=20,
                                    bg='beige')
        self.chatbox.grid(row=0, column=0, rowspan=8, columnspan=7)
        #input field
        self.inputField = Entry(self)
        self.inputField.grid(row=9, column=6)
        self.inputField.bind('<Return>', self.chatThink)
        #friends list
        self.PyChat_Chat_Screen_friendsList(0, 8, 8, 8, self.buddies)

        #add friend
        #self.addFriendButton = Button(self, text = "Add friend", command = self.addFriendScreen)
        #self.addFriendButton.grid(row = 9, column = 8)
        #remove friend
        self.removeFriendButton = Button(
            self,
            text="Remove friend",
            command=lambda self=self: self.removeFriend(userName))
        self.removeFriendButton.grid(row=9, column=9)
Example #46
0
class PageTwo(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        #print case_name
        #data = cursor.fetchall()
            #id = cursor.execute("SELECT case_name from poject.case where case_name=self.case_name")
        label = tk.Label(self,text='')
        label.pack(side="top", fill="x", pady=10)
        
        
        sidebar = Frame(self, width=200, bg='white', height=500, relief='sunken', borderwidth=2)
        sidebar.pack(expand=True, fill='y', side='left', anchor='nw')
        
        screen = Frame(self, width=200, bg='white', height=500, relief='sunken', borderwidth=2)
        screen.pack(expand=True, fill='y', side='left', anchor='nw')
        
        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        
        button = tk.Button(sidebar, text="Web Forensics",
                           command=lambda: controller.show_frame("WebPage"),width=20)
        button.pack()
        
        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        
        button = tk.Button(sidebar, text="Network Forensics",
                           command=lambda: controller.show_frame("NetworkPage"),width=20)
        button.pack()
        
        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        button = tk.Button(sidebar, text="Email Forensics",
                           command=lambda: controller.show_frame("EmailPage"),width=20)
        button.pack()
        
        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        
        self.text = ScrolledText(screen, undo=True)
        self.text['font'] = ('consolas', '12')
        self.text.grid(row=0,column=4)
        self.text.pack(expand=True, fill='both',side=RIGHT)
Example #47
0
	def __init__(self, master):
		Demo.__init__(self, master)
		self.text = ScrolledText(self, width=80, height=20,
								 font=self.font, background='gray65',
								 spacing1=1, spacing2=1, tabs='24')
		self.text.pack(side=TOP, expand=YES, fill=BOTH)

		content = open(sys.argv[0], 'r').read()
		self.text.insert(AtEnd(), content)

		reg = re.compile('([\t ]*).*\n')
		pos = 0
		indentTags = []
		while 1:
			match = reg.search(content, pos)
			if not match: break
			indent = match.end(1)-match.start(1)
			if match.end(0)-match.start(0) == 1:
				indent = len(indentTags)
			tagb = 'Tagb%08d' % match.start(0)
			tagc = 'Tage%08d' % match.start(0)
			self.text.tag_configure(tagc, background='', relief=FLAT, borderwidth=2)
			self.text.tag_add(tagb, Char( match.start(0)), Char(match.end(0)))
			self.text.tag_bind(tagb, '<Enter>',
							   lambda e,self=self,tagc=tagc: self.Enter(tagc))
			self.text.tag_bind(tagb, '<Leave>',
							   lambda e,self=self,tagc=tagc: self.Leave(tagc))
			del indentTags[indent:]
			indentTags.extend( (indent-len(indentTags))*[None] )
			indentTags.append(tagc)
			for tag in indentTags:
				if tag:
					self.text.tag_add(tag, Char(match.start(0)),
									  Char(match.end(0)))
			pos = match.end(0)

		for key,kw in self.Highlights.items():
			self.text.tag_configure(key, cnf=kw)
			reg = re.compile(key)
			pos = 0
			while 1:
				match = reg.search(content, pos)
				if not match: break
				self.text.tag_add(key, Char(match.start(0)),Char(match.end(0)))
				pos = match.end(0)
Example #48
0
    def __init__(self, root, options, main_logger):
        self.root = root
        self.options = options
        self.main_logger = main_logger

        self.frame = tk.Frame(self.root)
        self.frame.columnconfigure(0, weight=1)
        # first row doesn't expoands
        self.frame.rowconfigure(0, weight=0)
        # let the second row grow
        self.frame.rowconfigure(1, weight=1)

        self.log_commands_frame = tk.LabelFrame(self.frame,
                                                text="Controls",
                                                padx=5,
                                                pady=5)
        self.log_commands_frame.grid(row=0,
                                     column=0,
                                     sticky=tk.NSEW,
                                     padx=4,
                                     pady=5)

        self.log_messages_frame = tk.Frame(self.frame)
        self.log_messages_frame.grid(row=1, column=0, sticky=tk.NSEW)
        # let the SIP trace growing
        self.log_messages_frame.columnconfigure(0, weight=1)
        self.log_messages_frame.rowconfigure(0, weight=1)

        self.log_messages = ScrolledText(self.log_messages_frame)
        self.log_messages.grid(row=0, column=0, sticky=tk.NSEW)

        # Log Messages frame
        row = 0
        self.log_messages_clear_button = tk.Button(
            self.log_commands_frame,
            text="Clear",
            command=self.clear_log_messages)
        self.log_messages_clear_button.grid(row=row, column=0, sticky=tk.N)

        self.log_messages_pause_button = tk.Button(
            self.log_commands_frame,
            text="Pause",
            command=self.pause_log_messages)
        self.log_messages_pause_button.grid(row=row, column=1, sticky=tk.N)
        row = row + 1
Example #49
0
    def __init__(self, windowname, master, partk):
        """
    Initializes the window

    @param windowname: the name of the new window
    @type  windowname: string

    @param master: the main tk window
    @type  master: toplevel
    """
        self._parent = master
        self._tk = Toplevel(partk)
        self._windowname = windowname

        # map of session -> (bold, foreground, background)
        self._currcolors = {}

        # ses -> string
        self._unfinishedcolor = {}

        self._do_i_echo = 1

        self._tk.geometry("500x300")
        self._tk.title("Lyntin -- " + self._windowname)

        self._tk.protocol("WM_DELETE_WINDOW", self.close)

        if os.name == "posix":
            fontname = "Courier"
        else:
            fontname = "Fixedsys"
        fnt = tkFont.Font(family=fontname, size=12)

        self._txt = ScrolledText(self._tk,
                                 fg="white",
                                 bg="black",
                                 font=fnt,
                                 height=20)
        self._txt.pack(side=TOP, fill=BOTH, expand=1)

        # handles improper keypresses
        self._txt.bind("<KeyPress>", self._ignoreThis)

        # initialize color tags
        self._initColorTags()
Example #50
0
    def __init__(self, root, options, main_logger):
        self.root = root
        self.options = options
        self.main_logger = main_logger

        # SIP Trace tab with 2 rows: first with controls, second with SIP trace
        self.frame = tk.Frame(self.root)
        self.frame.columnconfigure(0, weight=1)
        # first row doesn't expoands
        self.frame.rowconfigure(0, weight=0)
        # let the second row grow
        self.frame.rowconfigure(1, weight=1)

        self.sip_commands_frame = tk.LabelFrame(self.frame,
                                                text="Controls",
                                                padx=5,
                                                pady=5)
        self.sip_commands_frame.grid(row=0,
                                     column=0,
                                     sticky=tk.NSEW,
                                     padx=4,
                                     pady=5)

        self.sip_trace_frame = tk.Frame(self.frame)
        self.sip_trace_frame.grid(row=1, column=0, sticky=tk.NSEW)
        # let the SIP trace growing
        self.sip_trace_frame.columnconfigure(0, weight=1)
        self.sip_trace_frame.rowconfigure(0, weight=1)

        self.sip_trace = ScrolledText(self.sip_trace_frame)
        self.sip_trace.grid(row=0, column=0, sticky=tk.NSEW)
        self.sip_trace.config(state='disabled')

        # SIP Trace frame
        row = 0
        self.sip_trace_clear_button = tk.Button(self.sip_commands_frame,
                                                text="Clear",
                                                command=self.clear_sip_trace)
        self.sip_trace_clear_button.grid(row=row, column=0, sticky=tk.N)

        self.sip_trace_pause_button = tk.Button(self.sip_commands_frame,
                                                text="Pause",
                                                command=self.pause_sip_trace)
        self.sip_trace_pause_button.grid(row=row, column=1, sticky=tk.N)
 def add_tab(self, text='new', dirty=True):
     f = ttk.Frame(self.nb)
     # see http://stackoverflow.com/questions/13832720/how-to-attach-a-scrollbar-to-a-text-widget
     t = ScrolledText(f, relief=tk.RAISED, wrap=tk.WORD)
     t.insert(tk.INSERT, text)
     t.pack(fill=tk.BOTH, expand=1)
     t.bind("<KeyRelease>", self.update)
     self.nb.add(f)
     self.tabs.append(t)
     self.nb.select(self.nb.tabs()[-1])
     self.update(dirty=dirty)
Example #52
0
class CopyableMessageWindow(basicWindow):
    """ Creates a modeless (non-modal) message window that allows the user to copy the presented text. """
    def __init__(self, topLevel, message, title, align, buttons, makeModal):
        self.guiRoot = topLevel

        basicWindow.__init__(self,
                             topLevel,
                             title,
                             resizable=True,
                             topMost=False)

        linesInMessage = len(message.splitlines())
        if linesInMessage > 17: height = 22
        else: height = linesInMessage + 5

        self.messageText = ScrolledText(self.mainFrame,
                                        relief='groove',
                                        wrap='word',
                                        height=height)
        self.messageText.insert('1.0', '\n' + message)
        self.messageText.tag_add('All', '1.0', 'end')
        self.messageText.tag_config('All', justify=align)
        self.messageText.pack(fill='both', expand=1)

        # Add the buttons
        self.buttonsFrame = Tk.Frame(self.mainFrame)
        ttk.Button(self.buttonsFrame, text='Close',
                   command=self.close).pack(side='right', padx=5)
        if buttons:
            for button in buttons:
                buttonText, buttonCommand = button
                ttk.Button(self.buttonsFrame,
                           text=buttonText,
                           command=buttonCommand).pack(side='right', padx=5)
        ttk.Button(self.buttonsFrame,
                   text='Copy text to Clipboard',
                   command=self.copyText).pack(side='right', padx=5)
        self.buttonsFrame.pack(pady=3)

        if makeModal:
            self.window.grab_set()
            self.guiRoot.wait_window(self.window)

    # Button functions
    def copyText(self):
        self.guiRoot.clipboard_clear()
        self.guiRoot.clipboard_append(
            self.messageText.get('1.0', 'end').strip())
Example #53
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')
Example #54
0
class CopyableMsg(basicWindow):
    """ Creates a modeless (non-modal) message window that allows the user to easily copy the given text. 
		If buttons are provided, they should be an iterable of tuples of the form (buttonText, buttonCallback). """
    def __init__(self,
                 root,
                 message='',
                 title='',
                 alignment='center',
                 buttons=None):
        super(CopyableMsg, self).__init__(root,
                                          title,
                                          resizable=True,
                                          topMost=False)
        self.root = root

        if alignment == 'left':
            height = 22  # Expecting a longer, more formal message
        else:
            height = 14

        # Add the main text display of the window
        self.messageText = ScrolledText(self.window,
                                        relief='groove',
                                        wrap='word',
                                        height=height)
        self.messageText.insert('1.0', message)
        self.messageText.tag_add('All', '1.0', 'end')
        self.messageText.tag_config('All', justify=alignment)
        self.messageText.pack(fill='both', expand=1)

        # Add the buttons
        self.buttonsFrame = Tkinter.Frame(self.window)
        ttk.Button(self.buttonsFrame, text='Close',
                   command=self.close).pack(side='right', padx=5)
        if buttons:
            for buttonText, buttonCommand in buttons:
                ttk.Button(self.buttonsFrame,
                           text=buttonText,
                           command=buttonCommand).pack(side='right', padx=5)
        ttk.Button(self.buttonsFrame,
                   text='Copy text to Clipboard',
                   command=self.copyToClipboard).pack(side='right', padx=5)
        self.buttonsFrame.pack(pady=3)

    def copyToClipboard(self):
        self.root.clipboard_clear()
        self.root.clipboard_append(self.messageText.get('1.0', 'end'))
    def __init__(self):
        self.root = tki.Tk()
        self.root.title("Loadshedding Schedule Parser")
        tki.Label(text='Copy Schedules from a table and paste it here:').pack()
        self.txt = ScrolledText(self.root, width="50", undo=True)
        self.txt['font'] = ('consolas', '12')
        self.txt.pack(expand=True, fill='both')

        def onok():

            dirname = tdog.askdirectory(parent=self.root,
                                        initialdir="/",
                                        title='Please select a directory')
            print dirname
            schFunc.parse(self.txt.get("1.0", "end"), dirname)
            tbox.showinfo(
                "Done",
                "Schedules have been parsed and converted to INI files")

        tki.Button(self.root, text='Parse Schedules', command=onok).pack()
class GuiOutput:
    def __init__(self, parent=None):
        self.text = None
        if parent: self.popupnow(parent)  # popup now or on first write

    def popupnow(self, parent=None):  # in parent now, Toplevel later
        if self.text: return
        self.text = ScrolledText(parent or Toplevel())
        self.text.config(font=('courier', 9, 'normal'))
        self.text.pack()

    def write(self, text):
        self.popupnow()
        self.text.insert(END, str(text))
        self.text.see(END)
        self.text.update()

    def writelines(self, lines):  # lines already have '\n'
        for line in lines:
            self.write(line)  # or map(self.write, lines)
Example #57
0
    def createWidgets(self):
        self.contentDest = tk.StringVar()
        self.contentDest.set(u'随意写个用户名')
        self.entryDest = tk.Entry(self, width=60)
        self.entryDest["textvariable"] = self.contentDest
        self.entryDest.grid(row=0)
        self.entryDest.focus()
        self.entryDest.bind('<Return>', lambda event: self.start())

        self.buttonStart = tk.Button(self, text='生成序列号', width=25)
        self.buttonStart['command'] = self.start
        self.buttonStart['fg'] = 'black'
        self.buttonStart.grid(row=1)

        self.text = ScrolledText(self,
                                 font=('Courier New', 13),
                                 fg='green',
                                 bg='black',
                                 width=50)
        self.text.grid(row=2, columnspan=1)
Example #58
0
	def __init__(self):
		Toplevel.__init__(self)
		self.geometry('500x400')
		Label(self, text = 'Read Me').pack()
		text= ScrolledText(self, bg="lightgray")
		text['font'] = ('console','10')
		text.insert(END,"			welcome to monitor tool\n\n \
Here is some notes which will help you use monitor tool\n\n\
1. About SMTP setting, please input your smtp user/passwd information, till now only QQ email smtp is varified\
for other smtp emails can not garantee. also you should open POP3/SMTP setting, the passwd is grant access passwd\
you can click verity email button to check the input smtp server is okay or not\n\n\
2. About server information, please input the target server ip/user/passwd and command keyword which will be used\
to search its pid, ps -ef | grep <command keyword>. also input the command log path, which will be used to fetch command\
result,  the frequency(mins), default value is 5 mins, means monitor will ssh to server every 5 mins to fetch pid status\n\n\
3. About the email to address, you can add more then one email address into this enty, like ***@qq.com;***@ericsson.com\n\n\
4. About Enable report progress, if want to know the script progress every certain period(30 mins, 1 hour...), you can select this checkbutton\
   the monitor will fetch script log and send out by email")
		text.see("end")
		text.pack()
		text.config(state=DISABLED)
Example #59
0
class StringViewer(Frame):
    def __init__(self, parent, get_func, title=None):
        Frame.__init__(self, parent)
        self.text = ScrolledText(parent)
        self.text.pack(fill=BOTH, expand="yes")
        self.prev = get_func()
        self.text.insert(END, self.prev)
        self.after(1000, self.poll)
        self.get_func = get_func
        parent.wm_title(title)

    def poll(self):

        str = self.get_func()
        if not str == self.prev:
            self.text.delete("1.0", END)
            self.text.insert(END, self.get_func())
            self.text.see(END)

        self.after(1000, self.poll)
    def __init__(self, parent):
        self.tab_delim = "\n=====++++++=====\n"
        self.tabs = []
        self.dirty = False

        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("Very Secret Things")
        self.style = ttk.Style()
        self.style.theme_use("default")
        self.pack(fill=tk.BOTH, expand=1)
        self.nb = ttk.Notebook(self)
        self.nb.pack(fill=tk.BOTH, expand=1)

        self.saveButton = ttk.Button(self, text="Close", command=self.save)
        self.saveButton.pack(side=tk.RIGHT, padx=5, pady=5)
        # I don't feel like making a rekey dialog atm
        #~ rekeyButton = ttk.Button(self, text="Re-Key", command=self.rekey)
        #~ rekeyButton.pack(side=tk.RIGHT, padx=5, pady=5)
        addButton = ttk.Button(self, text="Add Tab", command=self.add_tab)
        addButton.pack(side=tk.LEFT, padx=5, pady=5)
        delButton = ttk.Button(self, text="Delete Tab", command=self.rem_tab)
        delButton.pack(side=tk.LEFT, padx=5, pady=5)

        #add search tab
        f = ttk.Frame(self.nb)
        self.search = ttk.Entry(f)
        self.search.focus()
        self.search.pack(fill=tk.BOTH)
        self.search.bind("<KeyRelease>", self.search_key_press)
        self.search_result = ScrolledText(f,
                                          relief=tk.RAISED,
                                          wrap=tk.WORD,
                                          state=tk.DISABLED)
        self.search_result.pack(fill=tk.BOTH, expand=1)
        self.nb.add(f, text='search')

        #add other tabs
        for text in self.parent.secret.split(self.tab_delim):
            self.add_tab(text, dirty=False)
        self.nb.select(self.nb.tabs()[0])  #select search tab