def __init__(self):
     self.root = Tk()
     self.root.title('untitled')
     self.menubar = Menu(self.root)
     # file menu
     self.file_menu = Menu(self.menubar)
     self.file_menu.add_command(label='打开', command=self.openfile)
     self.file_menu.add_command(label='保存', command=self.savefile)
     self.file_menu.add_separator()
     self.file_menu.add_command(label='退出', command=self.exit)
     # help menu
     self.help_menu = Menu(self.menubar)
     self.help_menu.add_command(label='关于', command=self.about)
     # menu
     self.menubar.add_cascade(label='文件', menu=self.file_menu)
     self.menubar.add_cascade(label='帮助', menu=self.help_menu)
     self.root.config(menu=self.menubar)
     # frame
     self.frame = Frame(width=512)
     self.frame.pack(expand=1, fill=BOTH)
     # scrolled text
     ft = tkFont.Font(family='Consolas', size=12, weight=tkFont.NORMAL)
     self.st = ScrolledText(self.frame, bg='navyblue', fg='white', font=ft)
     self.st.pack(side=LEFT, fill=BOTH, expand=1)
     # run
     self.root.mainloop()
Ejemplo n.º 2
0
    def __init__(self, master):
        def saisie():
            myref = pyP2B()
            resultBox.insert('end', myref.getPubmedReference(valeur.get()))

        valeur = StringVar()

        frame = Frame(master)
        frame.pack()

        queryFrame = Frame(frame)
        queryFrame.pack(fill=X)

        label = Label(queryFrame, text="PMID: ")
        label.pack(side=LEFT)

        entry = Entry(queryFrame, textvariable=valeur, text='        ')
        entry.pack(side=LEFT)

        okButton = Button(queryFrame, text="OK", command=saisie)
        okButton.pack(side=LEFT)

        resultFrame = Frame(frame)
        resultFrame.pack(fill=X)

        resultBox = ScrolledText(resultFrame)
        resultBox.pack(side=LEFT)
Ejemplo n.º 3
0
def gui():

    global top, E1, T1, B2, E2
    top = Tk()
    top.minsize(width=560, height=500)

    L1 = Label(top, text="To: ")
    L1.place(x=20, y=20)

    E1 = Entry(top, width=50)
    E1.place(x=50, y=20)

    L2 = Label(top, text='Enter message: ')
    L2.place(x=20, y=70)

    T1 = ScrolledText(top, width=63, wrap=WORD, height=17)
    T1.place(x=20, y=100)

    B1 = Button(top, text='Choose Media', command=sendMedia)
    B1.place(x=20, y=400)

    E2 = Entry(top, width=40)
    E2.place(x=150, y=400)

    B2 = Button(top, text='Send', command=enc)
    B2.place(x=100, y=450)

    B3 = Button(top, text='Quit', command=top.destroy)
    B3.place(x=200, y=450)

    top.mainloop()
Ejemplo n.º 4
0
 def __init__(self,rt):
  if rt==None:
   self.t=Tk()
  else:
   self.t=Toplevel(rt)
  self.t.title("Tkeditor %d"%len(t1))
  self.bar=Menu(rt)
   
  self.filem=Menu(self.bar)
  self.filem.add_command(label="打开",command=self.openfile)
  self.filem.add_command(label="新建",command=neweditor)
  self.filem.add_command(label="保存",command=self.savefile)
  self.filem.add_command(label="关闭",command=self.close)
  self.filem.add_separator()
  self.filem.add_command(label="退出",command=die)
   
  self.helpm=Menu(self.bar)
  self.helpm.add_command(label="关于",command=about)
  self.bar.add_cascade(label="文件",menu=self.filem)
  self.bar.add_cascade(label="帮助",menu=self.helpm)
  self.t.config(menu=self.bar)
   
  self.f=Frame(self.t,width=512)
  self.f.pack(expand=1,fill=BOTH)
   
  self.st=ScrolledText(self.f,background="white")
  self.st.pack(side=LEFT,fill=BOTH,expand=1)
  
  self.open = Button(self)
  self.open["text"] = "open"   
  self.open["fg"] = "Blue"
  self.open["command"] = self.openfile
  self.open.pack({"side":"left"})
  self.open.pack({"anchor":"nw"})
Ejemplo n.º 5
0
    def create_widgets(self, parent, controller):

        self.info = tk.Label(self, text="Enter a stock ticker")
        self.info.pack()

        self.e = ttk.Entry(self)    # entry form for stock symbol
        self.e.pack()

        self.info2 = tk.Label(self, text="Enter timespan (6m, 1y, 3y)")
        self.info2.pack()

        self.span = tk.Entry(self)
        self.span.pack(side=tk.TOP)
        self.span.focus_set()

        self.b = ttk.Button(self, text='Submit', command=lambda: self.get_input())
        # self.b.grid(row=3, column=1, sticky=tk.N)
        self.b.pack(side=tk.TOP)

        self.info3 = tk.Label(self, text="Results")
        self.info3.pack(side=tk.LEFT)

        global text
        text = ScrolledText(self, font=("Consolas",10), padx=10, pady=10)
        text.insert(tk.INSERT, "\n")
        text.pack(side=tk.BOTTOM, expand=True)

        self.b1 = tk.Button(self, text='Event Plot', command=lambda: self.chart_events())
        self.b1.pack(side=tk.RIGHT)
	def __init__(self,rt):
		if rt==None:
			self.t=Tk()
		else:
			self.t=Toplevel(rt)
		self.t.title("汇编器")#("汇编器 %d"%len(t1))
		self.t.geometry("550x600")  
		self.bar=Menu(rt)
		
		self.filem=Menu(self.bar, tearoff=0)
		self.filem.add_command(label="打开",command=self.openfile)
		#self.filem.add_command(label="新建",command=neweditor)
		self.filem.add_command(label="保存",command=self.savefile)
		#self.filem.add_command(label="关闭",command=self.close)
		self.filem.add_separator()
		self.filem.add_command(label="退出",command=die)
		
		self.compilem=Menu(self.bar, tearoff=0)
		self.compilem.add_command(label="编译生成Bin文件",command=self.compile)

		self.bar.add_cascade(label="文件",menu=self.filem)
		self.bar.add_cascade(label="编译",menu=self.compilem)
		self.t.config(menu=self.bar)
		
		self.f=Frame(self.t,width=512)
		self.f.pack(expand=1,fill=BOTH)
		
		self.st=ScrolledText(self.f,background="white", font=('courier', 20, 'normal'))
		self.st.pack(side=LEFT,fill=BOTH,expand=1)
Ejemplo n.º 7
0
    def __init__(self, root):
        self.active_filename = None
        self.filename_label = Label(root, text='No file specified!', fg='purple', font=('times', 18, 'italic'))
        self.filename_label.pack()
        frame = Frame(root)
        frame.pack()
        frame.configure(background='black')
        root.title("Editor")
        # Create a text frame
        self.textPad = ScrolledText(root, width=60, height=30)
        self.textPad.pack()

        # Create an open button
        self.open_button = Button(frame, text='Open', width=15, fg='blue', command=self.open_command)
        self.open_button.pack(padx=5, pady=5, side=LEFT)

        # Create a create button
        self.edit_button = Button(frame, text='Create', width=15, fg='blue', command=self.create_command)
        self.edit_button.pack(padx=5, pady=5, side=LEFT)

        # Create a save button
        self.save_button = Button(frame, text='Save', width=15, fg='blue', command=self.save_command)
        self.save_button.pack(padx=5, pady=5, side=LEFT)

        # Create a close button
        self.close_button = Button(frame, text='Close', width=15, fg='blue', command=self.exit_command)
        self.close_button.pack(padx=5, pady=5, side=LEFT)
Ejemplo n.º 8
0
    def converse(self, quit="quit"):
        self.root = Tk(className=" NLP To SQL (QA)")

        # --- put frame in canvas ---
        width_window, height_window = self.root.winfo_screenwidth(
        ), self.root.winfo_screenheight()
        self.root.geometry('%dx%d+0+0' % (width_window, height_window))

        # Scroll text Model
        self.entry = Entry(self.root, width=width_window)

        self.entry.bind("<Return>", self.get_input)
        self.entry.pack(side=BOTTOM, ipady=10)

        self.textPad = ScrolledText(self.root,
                                    width=width_window,
                                    height=height_window)
        self.textPad.pack(side="left", fill="both", expand=True)

        self.textPad.insert(INSERT, "SQL Chatbot database QA System\n--------")
        self.textPad.insert(
            INSERT,
            "\nTalk to the program by typing in plain English, using normal upper-"
        )
        self.textPad.insert(
            INSERT,
            "\nand lower-case letters and punctuation.  Enter 'quit' when done.\n"
        )
        self.textPad.insert(INSERT, '=' * 72)
        self.textPad.insert(
            INSERT,
            "\n\nChatbot >Please Enter your name using the format name {your name}. Example: name John Due"
        )

        self.root.mainloop()
Ejemplo n.º 9
0
 def __init__(self):
     self.root = Tk()
     self.lowerBound = DoubleVar(value=0.8)
     self.fileName = "No files imported yet"
     self.statusBar = Label(self.root, bd=2, text=self.fileName, anchor=W)
     self.statusBar.pack(side=BOTTOM, fill=X)
     self.textBox = ScrolledText(self.root, height=18, width=47, bg="white", wrap=WORD, )
     self.textBox.pack(side=RIGHT, fill=X)
     self.root.title('NLTK Text Summarizer - Brian Dinh')
     self.root.minsize(width=550, height=350) # fixed height and width
     self.root.maxsize(width=550, height=350)
     self.leftFrame = Frame(self.root)
     self.leftFrame.pack(side=LEFT)
     self.entryBoxLabel = Label(self.leftFrame, text='Percentage Lower Bound:', anchor=W)
     self.entryBoxLabel.pack(side=TOP)
     self.entryBox = Entry(self.leftFrame, textvariable=self.lowerBound, width=15, justify=CENTER)
     self.entryBox.pack(side=TOP)
     self.importButton = Button(self.leftFrame, text="Import Text", height=5, width=20, command=self.importText)
     self.importButton.pack(side=TOP, pady=7)
     self.generateButton = Button(self.leftFrame, text="Generate Text", height=5, width=20, command=self.generateSummary)
     self.generateButton.pack(side=TOP)
     # list of stopwords from nltk library
     self.stopWords = set(stopwords.words('english'))
     self.stemmer = SnowballStemmer('english')
     self.contents = '' # the original text
Ejemplo n.º 10
0
class GUI(Frame):
    def __init__(self, master=None, app=None, title=''):

        self.engine = app

        Frame.__init__(self, master)
        self.master.title(title)
        self.grid()
        self.createWidgets()

    def createWidgets(self):

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

        self.nextButton = Button(self, text="next", command=self.next)
        self.nextButton.grid(row=0, column=0, sticky=S)

        self.quitButton = Button(self, text="quit", command=self.quit)
        self.quitButton.grid(row=0, column=1, sticky=S)

        self.inWindow = Text()
        self.inWindow.grid(row=1, column=0, sticky=N + E + S + W)

        self.outWindow = ScrolledText()
        self.outWindow.grid(row=2, column=0, sticky=N + E + S + W)

    def next(self):
        if self.engine <> None:
            self.engine.next()
        else:
            self.clearInput()

    def quit(self):
        self.master.destroy()
        self.engine.quit()

    def write(self, s):
        write(s, outstream=None, widget=self.outWindow)

    def writeln(self, s):
        writeln(s, outstream=None, widget=self.outWindow)

    def get(self):
        return self.inWindow.get(1.0, END)

    def userMultiLineInput(self):
        return self.get()

    def clearOutput(self):
        self.outWindow.delete(1.0, END)

    def clearInput(self):
        self.inWindow.delete(1.0, END)

    def clearInput(self):
        self.inWindow.delete(1.0, END)
Ejemplo n.º 11
0
    def __init__(self, root):
        frame1 = Frame(root)
        frame2 = Frame(root)
        frame3 = Frame(root)

        frame1.grid(row=0, column=0)
        frame3.grid(row=0, column=1)
        frame2.grid(row=0, column=2)

        self.inputText = ScrolledText.ScrolledText(frame1, bg='lightgray')
        loadButton = Button(frame1, text="load", command=self.load_file)
        loadButton.grid(row=0, column=0)
        self.inputText.grid(row=1, column=0)

        self.outputText = ScrolledText.ScrolledText(frame2, bg='orange')

        saveButton = Button(frame2, text="save", command=self.save_file)
        saveButton.grid(row=0, column=0)
        self.outputText.grid(row=1, column=0)

        self.degree = StringVar()
        degreeEntry = Entry(frame3, textvariable=self.degree)
        degreeEntry.insert(1, '4')

        generate = Button(frame3, text=">>>", command=self.generate)
        degreeEntry.grid(row=0, column=0)
        generate.grid(row=1, column=0)
Ejemplo n.º 12
0
 def body(self, master):
     self.resizable(0, 0)
     self.catIconImage = PhotoImage(data=GatoIcons.gato)  # statt file=
     self.catIcon = Label(master, image=self.catIconImage)
     self.catIcon.pack(side=TOP)
     label = Label(master, text=crnotice1)
     label.pack(side=TOP)
     label = Label(master,
                   font="Helvetica 10",
                   text=crnotice2,
                   justify=CENTER)
     label.pack(side=TOP)
     color = self.config("bg")[4]
     self.infoText = ScrolledText(
         master,
         relief=FLAT,
         padx=3,
         pady=3,
         background=color,
         #foreground="black",
         wrap='word',
         width=60,
         height=12,
         font="Times 10")
     self.infoText.pack(expand=0, fill=X, side=BOTTOM)
     self.infoText.delete('0.0', END)
     self.infoText.insert('0.0', GatoGlobals.gLGPLText)
     self.infoText.configure(state=DISABLED)
     self.title("Gato - About")
Ejemplo n.º 13
0
 def compilePythonCode(self):
     if(self.currentFile):
         self.saveFile()
         original_stdout = sys.stdout
         try:
             a = compiler.compile(self.currentText, self.currentFile, 
                                 mode = "exec")
             # (http://stackoverflow.com/questions/4904079/
             # execute-a-block-of-python-code-with-exec-capturing-all-its-output)
             # captures stdout in temp stringIO buffer to get output
             # and then reverts changes
             buffer = StringIO()
             sys.stdout = buffer
             eval(a)
             sys.stdout = original_stdout
             val = buffer.getvalue()
             rt = Tk()
             outputText = ScrolledText(rt, width = 50)
             outputText.insert(END, val)
             outputText.pack()
             rt.mainloop()
         except:
             print "Error!"
             self.displayMessageBox("Error","There is an error in the code.")
             sys.stdout = original_stdout
     else:
         self.saveAs()
Ejemplo n.º 14
0
    def __init__(self):
        self.master = Tk()

        frame = Frame(self.master)
        frame.pack()

        bottom_frame = Frame(self.master)
        bottom_frame.pack(side=BOTTOM)

        right_frame = Frame(self.master)
        right_frame.pack(side=RIGHT)

        self.send_entry = Entry(bottom_frame)
        self.send_entry.pack()

        self.name_entry = Entry(right_frame)
        self.name_entry.pack()

        self.gettext = ScrolledText(frame, height=10, width=100)
        self.gettext.pack()
        self.gettext.insert(END, 'Welcome to the Chat Server')

        b = Button(bottom_frame, text="Send", width=8, command=self.callback)
        b.pack()

        qb = Button(right_frame, text="Quit", width=8, command=self.quit)
        qb.pack()

        self.cb = Button(right_frame,
                         text="Connect",
                         width=8,
                         command=self.connect)
        self.cb.pack()
Ejemplo n.º 15
0
    def createWidget(self, master):

        self.device_helper = DeviceHelper()
        self.device_helper.find_all_devices(self)
        self.menu = Frame(master, height=10, background="#f2f2f2")
        self.menu.pack(side=TOP, fill=X, pady=5)

        self.display_board = Frame(master, background="#f2f2f2")
        self.display_board.pack(side=TOP, fill=X)

        self.lb_port_list = Label(self.menu, text="Port:", width=4, background="#f2f2f2")
        self.lb_port_list.pack(side=LEFT, anchor="n", padx=5, pady=5)
        self.port_item = StringVar()
        self.cb_port_list = ttk.Combobox(self.menu, width=20, textvariable=self.port_item, state="readonly", background="#f2f2f2")
        self.cb_port_list["values"] = self.serial_list or ("Empty")
        self.cb_port_list.current(0)
        self.cb_port_list.pack(side=LEFT, anchor="w", pady=5)

        self.btn_select = Button(self.menu, text="Select", height=1, width=13, command=self.select_firmware, bg="#f2f2f2")
        self.btn_select.pack(side=LEFT, anchor="w", padx=10)


        self.btn_upgrade = Button(self.menu, text="Upgrade", height=1, width=13, command=self.create_upgrade_thread, bg="#f2f2f2")
        self.btn_upgrade.pack(side=LEFT, anchor="w", padx=10)

        self.btn_clear = Button(self.menu, text="Clear", height=1, width=8, command=self.clear_info_text, bg="#f2f2f2")
        self.btn_clear.pack(side=LEFT, anchor="w", padx=10)

        self.info_text = ScrolledText(self.display_board, state="normal", width=93)
        self.info_text.bind("<KeyPress>", lambda e: "break")
        self.info_text.pack(side=LEFT, anchor="n", padx=5, fill=Y)
Ejemplo n.º 16
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master.title("Network Simulator Log")
        self.text = ScrolledText(self)
        self.text.pack(fill=BOTH, expand=1)
        self.pack(fill=BOTH, expand=1)
        self.text.config(
            background="black",
            foreground="white",
            font=Font(family="Courier", weight="bold"),
            # state=DISABLED,
            wrap=NONE,
        )

        self.text.tag_config("DEBUG", foreground="green")
        self.text.tag_config("ERROR", foreground="red")
        self.text.tag_config("CRITICAL", foreground="red")
        self.text.tag_config("EXCEPTION", foreground="red")
        self.text.tag_config("WARNING", foreground="yellow")
        self.text.tag_config("INFO", foreground="white")

        self.text.bind("<Key>", lambda e: 'break')
        self.text.bind("<Return>", self._clear)
        self.queue = Queue()
        self._update()
Ejemplo n.º 17
0
 def __init__(self):
     self.root = Tk()
     self.inter = Frame(self.root, width=700, height=600, bg='bisque3')
     self.inter.grid(row=0, column=0, sticky='news')
     Label(self.inter, text="Interact", font=('Courier', 13),
           fg='salmon4').place(relx=0.02, rely=0.02)
     Label(self.inter, text="Folder name", bg='bisque3').place(relx=0.6,
                                                               rely=0.22)
     self.txt = ScrolledText(self.inter, width=40, height=25)
     self.fname = Entry(self.inter, width=42)
     self.fname.place(relx=0.6, rely=0.25)
     self.refresh = Button(self.inter,
                           text="Refresh",
                           width=15,
                           command=lambda: self.do_refresh())
     self.refresh.place(relx=0.8, rely=0.62)
     self.submit = Button(self.inter,
                          text="Submit",
                          width=15,
                          command=lambda: self.do_submit())
     self.submit.place(relx=0.8, rely=0.72)
     """self.scroll = Scrollbar(self.inter, orient='vertical', command=self.txt.yview)
     self.txt.config(xscrollcommand=self.scroll.set)
     self.txt.place(relx=0.1, rely=0.1)
     self.scroll.pack(side='right', fill='y')"""
     self.txt.place(relx=0.05, rely=0.15)
     self.raise_frame(self.inter)
     self.root.mainloop()
Ejemplo n.º 18
0
    def __init__(self, master):

        def saisie():
            myref = pyP2B()
            resultBox.insert('end', myref.getPubmedReference(valeur.get()))

        valeur = StringVar()
        
        frame = Frame(master)
        frame.pack()

        queryFrame = Frame(frame)
        queryFrame.pack(fill=X)
        
        label = Label(queryFrame, text="PMID: ")
        label.pack(side=LEFT)
        
        entry = Entry(queryFrame, textvariable=valeur, text='        ')
        entry.pack(side=LEFT)
        
        okButton = Button(queryFrame, text="OK", command=saisie)
        okButton.pack(side=LEFT)

        resultFrame = Frame(frame)
        resultFrame.pack(fill=X)

        resultBox = ScrolledText(resultFrame)
        resultBox.pack(side=LEFT)
Ejemplo n.º 19
0
	def __init__(self, parent, app):
		Frame.__init__(self, parent)
		self.parent = parent
		self.app = app

		#Frame to hold Keyword Group new Entry and new keywords text box
		addKGFrame = Frame(parent, bg="#E8E8E8", relief=RAISED)
		addKGFrame.pack(fill=BOTH, expand=True, side=LEFT, padx=10, pady=10)

		#Label for Entry Box
		addGroupLabel = Label(addKGFrame, text="Enter New Group Name",bg="#E8E8E8")
		addGroupLabel.pack(side=TOP)

		#Entry Box for new Keyword Group
		self.addGroup = Entry(addKGFrame, width=30, relief=SUNKEN)
		self.addGroup.pack(side=TOP, fill=X, expand=True, pady=5)

		#Label for New Keywords for Group Text Box
		addKGLabel = Label(addKGFrame, text="Enter New Keywords (Optional)",bg="#E8E8E8")
		addKGLabel.pack(side=TOP, fill=X, expand=True, pady=5)

		#Canvas for Text Box to Enter New Keywords for New Group
		addKGCanvas = Canvas(addKGFrame, bg="#E8E8E8", relief=SUNKEN)
		addKGCanvas.pack(side=TOP, fill=BOTH, expand=True, pady=5)

		#Keywords for new group scrollable text box
		self.addKGText = ScrolledText(addKGCanvas, wrap=WORD, width=25, 
			height=15, relief=SUNKEN, highlightthickness=0, bd=1, padx=1, pady=1)
		self.addKGText.pack(fill=BOTH, side=TOP, expand=True)

		#Button to add new Keyword Group and Keywords
		addKGButton = Button(addKGFrame, text="Add Group", 
			width=30, highlightbackground='#E8E8E8', command=self.group_add)
		addKGButton.pack(side=TOP, fill=BOTH, expand=True)
Ejemplo n.º 20
0
class editor:
	def __init__(self,rt):
		if rt == None:
			self.t = Tk(rt)
		else:
			self.t = Toplevel(rt)
		self.t.title("Taposh's Editor %d" %len(t1))
		self.bar = Menu(rt)

		self.filem = Menu(self.bar)
		self.filem.add_command(label ="Open..", command =openfile)
		self.filem.add_command(label ="New..", command =newwin)
		self.filem.add_command(label ="Save..", command =savefile)
		self.filem.add_command(label ="Save as..", command =savefile)
		self.filem.add_separator()
		self.filem.add_command(label ="Exit..", command = die)
		self.helpm = Menu(bar)
		self.helpm.add_command(label ="Index..", command =callee)
		self.helpm.add_separator()
		self.helpm.add_command(label ="About..", command =about)
		self.bar.add_cascade(label="File",menu=filem)
		self.bar.add_cascade(label="Help",menu=helpm)
		self.t.config(menu=bar)
		self.f = Frame(self.t,width=512)
		self.f.pack(expand=1,fill=BOTH)

		self.st = ScrolledText(self.f,background="white")
		self.st.pack(side=LEFT, fill=BOTH, expand=1)
Ejemplo n.º 21
0
    def __init__(self):
        self.root = tk.Tk(className="PyNestML IDE")
        self.after_id = None

        self.text_frame = tk.Frame(self.root,
                                   width=self.root.winfo_screenwidth(),
                                   height=self.root.winfo_screenheight() *
                                   0.70)
        self.text_frame.pack_propagate(False)
        self.textPad = ScrolledText(self.text_frame,
                                    height=1,
                                    width=1,
                                    undo=True)
        self.textPad.pack(side="top", fill="both", expand=True)
        self.text_frame.pack(side="top", fill="both", expand=True)

        self.line_nr_frame = tk.Frame(self.root,
                                      width=self.root.winfo_screenwidth())
        self.line_nr_frame.pack_propagate(False)
        self.line_nr = tk.Text(self.root,
                               width=self.root.winfo_screenwidth(),
                               height=1)
        self.line_nr.pack(side="top", fill="both", expand=True)
        self.line_nr_frame.pack(side="top", fill="both", expand=True)

        self.console_frame = tk.Frame(self.root,
                                      width=self.root.winfo_screenwidth(),
                                      height=self.root.winfo_screenheight() *
                                      0.20)
        self.console_frame.pack_propagate(False)
        self.console = ScrolledText(self.console_frame, width=1, height=1)
        self.console.pack(side="top", fill="both", expand=True)
        self.console_frame.pack(side="top", fill="both", expand=True)

        self.menu = Menu(root=self.root, text_pad=self.textPad, editor=self)
        self.highlighter = Highlighter(self.textPad, self)

        # insert empty model
        self.textPad.insert('1.0', 'PyNestML             \n')
        self.textPad.insert('2.0', '         Model       \n')
        self.textPad.insert('3.0', '               Editor\n')
        self.textPad.tag_add("l1", "%s.%s" % (1, 0),
                             "%s.%s" % (1, len('PyNestML')))
        self.textPad.tag_add("l2", "%s.%s" % (2, 0),
                             "%s.%s" % (2, len('         Model')))
        self.textPad.tag_add("l3", "%s.%s" % (3, 0),
                             "%s.%s" % (3, len('               Editor')))
        self.textPad.tag_config("l1", background="white", foreground="blue")
        self.textPad.tag_config("l2", background="white", foreground="red")
        self.textPad.tag_config("l3", background="white", foreground="green")
        self.last = self.textPad.get('0.0', tk.END)
        # insert start position of cursor
        self.console.pack(side=tk.BOTTOM)
        self.console.configure(state='disabled')
        self.line_nr.insert('1.0', 'Position: 0:0')
        self.line_nr.configure(state='disabled')
        # bind keys
        self.bind_keys()
        self.root.mainloop()
Ejemplo n.º 22
0
    def createTextItem(self, frame, sname, name, eid, w, h, cspan=1, rspan=1, txt=""):
        stxt = ScrolledText(frame, width=int(w), height=int(h))
        stxt.insert(END, txt.strip())
        stxt.tag_config("csel", background="blue",foreground="white")
	self.stext[sname+":"+eid] = stxt
	key = name+":gui:"+eid

	return [stxt, cspan, rspan]
Ejemplo n.º 23
0
def new():
    newwindow = Tkinter.Toplevel()
    newwindow.geometry("1280x600")
    newwindow.title("T-Edit S")
    textPad2 = ScrolledText(
        newwindow,
        width=100,
        height=80,
        bg="#383838",
        fg="white",
        font="sans",
        insertbackground="#006eef",
    )

    def open_command2():
        file = tkFileDialog.askopenfile(parent=newwindow,
                                        mode='rb',
                                        title='Select a file')
        if file != "":
            contents = file.read()
            textPad.insert('1.0', contents)
            file.close()

    def save_command2(*arga):
        file = tkFileDialog.asksaveasfile(mode='w', )
        if file != "":
            data = textPad.get('1.0', END + '-1c')
            file.write(data)
            file.close()

    def exit_command2():
        if tkMessageBox.askokcancel("Quit", "Do you really want to quit?"):
            root.destroy()

    def about_command2():
        label = tkMessageBox.showinfo("About",
                                      "T-Edit Slim\nMadeBy:TudorTeodorescu")

    def clear2():
        textPad2.delete("0.0", "end")

    def undo2():
        textPad2.edit_modified()
        textPad2.edit_undo()

    def redo2():
        textPad2.edit_modified()
        textPad2.edit_redo()

    newwindow.bind("<Control-s>", save_command2)
    newwindow.bind("<Control-c>", clear2)
    newwindow.bind("<Control-k>", )
    newwindow.bind("<Control-i>", )
    newwindow.bind("<Control-x>", exit_command2)
    newwindow.bind("<Control-z>", undo2)
    newwindow.bind("<Control-y>", redo2)

    textPad2.pack(fill="both")
Ejemplo n.º 24
0
    def create_widgets(self):
        self.search_box = Entry(self.parent, textvariable=self.search_str)
        self.search_str.set("New snippet")
        self.search_box.pack(fill=X)

        self.toolbar_f = Frame(self.parent, pady=5)
        self.toolbar_f.pack(fill=X)

        self.newbtn = Button(self.toolbar_f, text="New", command=self.on_new)
        self.newbtn.pack(side=LEFT)

        self.savebtn = Button(self.toolbar_f,
                              text="Save",
                              command=self.on_save)
        self.savebtn.pack(side=LEFT)

        self.updatebtn = Button(self.toolbar_f,
                                text="Update",
                                command=self.on_update)
        self.updatebtn.pack(side=LEFT)

        self.delbtn = Button(self.toolbar_f,
                             text="Delete",
                             command=self.on_delete)
        self.delbtn.pack(side=LEFT)

        self.copybtn = Button(self.toolbar_f,
                              text="Copy to clipboard",
                              command=self.on_copy)
        self.copybtn.pack(side=LEFT)

        self.quitbtn = Button(self.toolbar_f,
                              text="Quit",
                              command=self.on_quit)
        self.quitbtn.pack(side=LEFT)

        self.pwin = PanedWindow(self.parent, showhandle=True)
        self.pwin.pack(fill=BOTH, expand=1)

        self.list_f = Frame(self.pwin)
        self.list_sb = Scrollbar(self.list_f, orient=VERTICAL)
        self.snip_list = Listbox(self.list_f, yscrollcommand=self.list_sb.set)
        self.list_sb.config(command=self.snip_list.yview)
        self.snip_list.bind('<ButtonRelease-1>', self.on_snippet_selected)
        self.snip_list.pack(side=LEFT, fill=BOTH, expand=1)
        self.list_sb.pack(side=RIGHT, fill=Y)
        self.pwin.add(self.list_f)
        self.pwin.paneconfigure(self.list_f, minsize=177)

        self.snippetFont = Font(family="courier", size=11, weight=NORMAL)
        self.snip_content = ScrolledText(self.pwin,
                                         height=20,
                                         width=40,
                                         padx=5,
                                         pady=5,
                                         font=self.snippetFont)
        self.pwin.add(self.snip_content)
Ejemplo n.º 25
0
class editor:
 def __init__(self,rt):
  if rt==None:
   self.t=Tk()
  else:
   self.t=Toplevel(rt)
  self.t.title("Tkeditor %d"%len(t1))
  self.bar=Menu(rt)
   
  self.filem=Menu(self.bar)
  self.filem.add_command(label="打开",command=self.openfile)
  self.filem.add_command(label="新建",command=neweditor)
  self.filem.add_command(label="保存",command=self.savefile)
  self.filem.add_command(label="关闭",command=self.close)
  self.filem.add_separator()
  self.filem.add_command(label="退出",command=die)
   
  self.helpm=Menu(self.bar)
  self.helpm.add_command(label="关于",command=about)
  self.bar.add_cascade(label="文件",menu=self.filem)
  self.bar.add_cascade(label="帮助",menu=self.helpm)
  self.t.config(menu=self.bar)
   
  self.f=Frame(self.t,width=512)
  self.f.pack(expand=1,fill=BOTH)
   
  self.st=ScrolledText(self.f,background="white")
  self.st.pack(side=LEFT,fill=BOTH,expand=1)
  
  self.open = Button(self)
  self.open["text"] = "open"   
  self.open["fg"] = "Blue"
  self.open["command"] = self.openfile
  self.open.pack({"side":"left"})
  self.open.pack({"anchor":"nw"})
  
 def close(self):
  self.t.destroy()
  print "close"
  
 def openfile(self):
  p1=END
  oname=askopenfilename(filetypes=[("Python file","*.*")])
  if oname:
   for line in fileinput.input(oname):
    self.st.insert(p1,line)
   self.t.title(oname)
  
 def savefile(self):
  sname=asksaveasfilename()
  if sname:
   ofp=open(sname,"w")
   ofp.write(self.st.get(1.0,END))
   ofp.flush()
   ofp.close()
   self.t.title(sname)
Ejemplo n.º 26
0
def defaultcheck():
    global w3
    w3 = Toplevel()
    w3.wm_attributes('-fullscreen', 1)
    of = open('License.dat', 'r')
    for of2 in of:
        of2==of2
    root.iconify()
    if of2 == ugoku:
        p = open('Path.dat', 'r')
        for i in p:
            if not os.path.exists(i):
                Dialog.Dialog(root, title = 'alert', bitmap = 'info',
                              text = u'プログラムファイルが見つかりません。%s' % i,
                              strings = ['OK'], default = 0)
                sys.exit()
            else:
                actlog()
                w3.destroy()
    elif of2 == eke:
        actname.set(ids)
        os.chdir(currentdir)
        f1 = Frame(w3)
        f2 = Frame(w3)
        f3 = Frame(w3)
        f4 = Frame(w3)
        Label(w3, text = '%s' % osnam).pack()
        t0 = ScrolledText(w3)
        t0.pack()
        fi = open('README.txt')
        t0.delete('1.0', 'end')
        for x in fi:
            t0.insert('end', x.decode('shift_jis'))
        fi.close()
        t0.focus_set()
        Label(w3, text = u'管理者登録').pack()
        Label(w3, textvariable = pwcon).pack()
        Label(f1, textvariable = actname).pack(side = RIGHT)
        Label(f1, text = u'管理者名').pack(side = LEFT)
        Entry(f2, textvariable = actpw, show = '*').pack(side = RIGHT)
        Label(f2, text = u'パスワード(8文字)').pack(side = LEFT)
        Entry(f3, textvariable = actpwc, show = '*').pack(side = RIGHT)
        Label(f3, text = u'確認のためもう一度入力').pack(side = LEFT)
        Button(f4, text = u'作成', command = makeid).pack(side = LEFT)
        Button(f4, text = u'キャンセル', command = sys.exit).pack(side = RIGHT)
        f1.pack()
        f2.pack()
        f3.pack()
        f4.pack()
        root.lower()
    else:
        Dialog.Dialog(root, title = 'alert', bitmap = 'info',
                      text = u'ライセンス認証されていないため、本ソフトを起動できませんでした',
                      strings = ['OK'], default = 0)
        sys.exit()
Ejemplo n.º 27
0
class editor:
    def __init__(self,rt):

        self.top=Tk()
        self.top.title('记事本')
        self.top.geometry('300x400')
        self.bar=Menu(self.top)
  
        self.filem=Menu(self.bar)
        self.filem.add_command(label="打开",command=self.openfile)
        self.filem.add_command(label="新建",command=self.neweditor)
        self.filem.add_command(label="保存",command=self.savefile)
        self.filem.add_command(label="关闭",command=self.close)

        self.helpm=Menu(self.bar)
        self.helpm.add_command(label="Help",command=self.about)
        self.bar.add_cascade(label="文件",menu=self.filem)
        self.bar.add_cascade(label="帮助",menu=self.helpm)
        self.top.config(menu=self.bar)
  
        self.f=Frame(self.top,width=512)
        self.f.pack(expand=1,fill=BOTH)
  
        self.st=ScrolledText(self.f,background="white")
        self.st.pack(side=LEFT,fill=BOTH,expand=1)
        
    def close(self):
        self.top.destroy()
 
    def openfile(self):
        p1=END
        oname=askopenfilename()#filetypes=[("Python file","*.*")])
        if oname:
            for line in fileinput.input(oname):
                self.st.insert(p1,line)
                self.top.title(oname)
 
    def savefile(self):
        sname=asksaveasfilename()
        if sname:
            ofp=open(sname,"w")
            ofp.write(self.st.get(1.0,END).encode('utf-8'))
            ofp.flush()
            ofp.close()
            self.top.title(sname)
 
    def neweditor(self):
        global root
        self.top.append(editor(root))
        
        
    def about(self):
        tkMessageBox.showwarning("Tkeditor",'What?\n记事本也要帮助?')
Ejemplo n.º 28
0
 def create_script_pad(self):
     script_pad_label = Label(self.master,
                              text='SCRIPT BUILD (right-click for options)')
     script_pad_label.grid(row=0, column=1)
     self.script_pad = ScrolledText(self.master, width=75, height=32)
     self.script_pad.grid(row=1, column=1, sticky='nw')
     self.script_pad.bind('<KeyRelease>', self._scanfix_script_lines)
     self.print_button = Button(self.master,
                                text='Print Script Line Data To Terminal',
                                command=self._print_script_line_data)
     self.print_button.grid(row=2, column=1, sticky='nwes')
     return
Ejemplo n.º 29
0
    def notepad(self, file=None):
        # Add in a lightweight text editor to edit the .sfit file
        self.textPad = ScrolledText(self.root, width=60, height=50)
        self.open_filename = ''

        # Open the input file
        if self.finput != None:
            file = open(self.finput, 'r')
            contents = file.read()
            self.textPad.insert('1.0', contents)
            file.close()
            self.open_filename = self.finput

        self.root.title(self.open_filename.split('/')[-1])

        menu = Menu(self.root)
        self.root.config(menu=menu)
        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New", command=self.new_file)
        filemenu.add_command(label="Open...", command=self.open_command)
        filemenu.add_command(label='Save', command=self.save_command)
        filemenu.add_command(label="Save As", command=self.saveas_command)
        filemenu.add_separator()
        filemenu.add_command(label="Help", command=self.help)

        sfitmenu = Menu(menu)
        menu.add_cascade(label='SFIT', menu=sfitmenu)
        sfitmenu.add_command(label='Print Files', command=self.report_files)
        sfitmenu.add_command(
            label='Re-enter Files',
            command=lambda: self.get_files(finput=self.finput,
                                           fname=self.fname,
                                           flines=self.flines,
                                           idfile=self.idfile))
        sfitmenu.add_command(label='Save & Run SFIT',
                             command=self.save_and_run_sfit)
        sfitmenu.add_command(label='Kill SFIT', command=self.kill_sfit)

        idlinesmenu = Menu(menu)
        menu.add_cascade(label='IDlines', menu=idlinesmenu)
        idlinesmenu.add_command(label='Toggle labels',
                                command=self.enableLabel)
        idlinesmenu.add_separator()
        idlinesmenu.add_command(label='Label new element',
                                command=self.get_labels)
        idlinesmenu.add_command(label='Print label cache',
                                command=self.print_label_cache)
        idlinesmenu.add_command(label='Clear label cache',
                                command=self.clear_label_cache)

        self.textPad.pack(fill=BOTH, side=LEFT)
        self.root.mainloop()
Ejemplo n.º 30
0
 def __init__(self, myParent):
     self.mylist = [i for i in range(1, 53)]
     self.display_cards(human_cards)
     self.button1 = Button(root)
     self.button1["text"] = "Fetch"  ### (2)
     self.button1.bind("<Button-1>", self.onFetchClick)
     self.button1.grid(row=1, column=10)
     self.scrollview = ScrolledText(root,
                                    width=10,
                                    height=10,
                                    state=DISABLED)
     self.scrollview.grid(row=200, column=5)
Ejemplo n.º 31
0
def start():
    global location, window, text
    location = ''
    window = Tk()
    window.title("Notetux")

    text = ScrolledText(window,
                        width="200",
                        height="200",
                        bg="#292929",
                        fg="#DEDEDE",
                        insertbackground='white',
                        font=("Helvetica", 20),
                        undo=True)
    text.pack()

    #Menu
    menubar = Menu(window)
    filemenu = Menu(menubar)
    filemenu.add_command(label="New File   Ctrl+N", command=newFile)
    filemenu.add_command(label="Open File...     Ctrl+Shift+O",
                         command=openFile)
    filemenu.add_command(label="Save   Ctrl+S", command=save)
    filemenu.add_command(label="Save As...   Ctrl+Shift+S", command=saveas)
    filemenu.add_separator()
    filemenu.add_command(label="Quit", command=exit)
    menubar.add_cascade(label="File", menu=filemenu)

    #Shortcut
    filemenu.bind_all('<Control-q>', exit)
    filemenu.bind_all('<Control-s>', save)
    filemenu.bind_all(
        '<Control-Shift-S>',
        saveas)  # upper S, because when you press Shift, it will be lowecase

    #-------------------------------------------------------------------------------------------------
    filemenu.bind_all(
        '<Control-Shift-O>',
        openFile)  # upper O, because when you press Shift, it will be lowecase
    # NOTE:  I know it must be Ctrl+O
    # But when user press Ctrl+O, it creates new line (I couldn't describe this try and see :D )

    filemenu.bind_all('<Control-n>', newFile)
    window.bind_all('<Control-a>', selectAll)
    #color
    more = Menu(menubar)
    more.add_command(label="Set Font Color", command=fontColor)
    more.add_command(label="Set Background Color", command=bgColor)
    menubar.add_cascade(label="More", menu=more)

    window.config(menu=menubar)
    window.mainloop()
Ejemplo n.º 32
0
    def createWidgets(self):  # 创建组件(包括文本框、输入框、)
        # 创建文本框
        self.text = ScrolledText(self)
        target = open('test.txt', 'a+')  # 打开test.txt,并进入读取与追加状态
        target.seek(0)
        self.text.insert(END, target.read())  # 打印文档记录
        self.text.pack(side=BOTTOM)

        # 创建输入框并可以输入
        self.content = StringVar(self)
        self.enter = Entry(self, textvariable=self.content)
        self.enter.bind("<Return>", self.write)  # bind第二参数可以调用函数
        self.enter.pack(side=TOP, fill=X)
 def __init__(self,filenames={}):
   self.a = Tk()
   self.a.wm_title("Makefile Module Summary Logs")
   self.n = notebook(self.a, LEFT)
   self.frames = {}
   for filename in filenames:
     f = Frame(self.n())
     st = ScrolledText(f, width=100, height=50)
     logfile = open(filenames[filename], 'r')
     st.insert(END, logfile.read())
     st.pack()
     self.frames[f] = st
     x = self.n.add_screen(f, filename)
Ejemplo n.º 34
0
class Add_Group(Frame):
	def __init__(self, parent, app):
		Frame.__init__(self, parent)
		self.parent = parent
		self.app = app

		#Frame to hold Keyword Group new Entry and new keywords text box
		addKGFrame = Frame(parent, bg="#E8E8E8", relief=RAISED)
		addKGFrame.pack(fill=BOTH, expand=True, side=LEFT, padx=10, pady=10)

		#Label for Entry Box
		addGroupLabel = Label(addKGFrame, text="Enter New Group Name",bg="#E8E8E8")
		addGroupLabel.pack(side=TOP)

		#Entry Box for new Keyword Group
		self.addGroup = Entry(addKGFrame, width=30, relief=SUNKEN)
		self.addGroup.pack(side=TOP, fill=X, expand=True, pady=5)

		#Label for New Keywords for Group Text Box
		addKGLabel = Label(addKGFrame, text="Enter New Keywords (Optional)",bg="#E8E8E8")
		addKGLabel.pack(side=TOP, fill=X, expand=True, pady=5)

		#Canvas for Text Box to Enter New Keywords for New Group
		addKGCanvas = Canvas(addKGFrame, bg="#E8E8E8", relief=SUNKEN)
		addKGCanvas.pack(side=TOP, fill=BOTH, expand=True, pady=5)

		#Keywords for new group scrollable text box
		self.addKGText = ScrolledText(addKGCanvas, wrap=WORD, width=25, 
			height=15, relief=SUNKEN, highlightthickness=0, bd=1, padx=1, pady=1)
		self.addKGText.pack(fill=BOTH, side=TOP, expand=True)

		#Button to add new Keyword Group and Keywords
		addKGButton = Button(addKGFrame, text="Add Group", 
			width=30, highlightbackground='#E8E8E8', command=self.group_add)
		addKGButton.pack(side=TOP, fill=BOTH, expand=True)

	#Function to add the keyword group
	def group_add(self):
		newGroup = self.addGroup.get()
		if newGroup != "":
			self.app.key_group.keyword_groups[newGroup] = []

			text = self.addKGText.get('1.0', 'end-1c').splitlines()
			for line in text:
				self.app.key_group.keyword_groups[newGroup].append(line)
			self.app.Groups.groupList.delete(0, END)
			for x in self.app.key_group.keyword_groups:
				self.app.Groups.groupList.insert(END, '%s' % x)

			self.addKGText.delete('1.0', END)
			self.addGroup.delete(0, END)
Ejemplo n.º 35
0
        def createWidgets(self):
                allframe = Frame(root, width=800, height =480)
                allframe.grid(row=0, column=0, padx=0, pady=0, sticky=N+S)
                
                backgroundFile = "rpi.jpg"
                bckImage = Image.open(backgroundFile)
                bckImage = bckImage.resize((self.width, self.height), resample=3)
                background = ImageTk.PhotoImage(bckImage)
                bckPanel = Label(allframe, image=background)
                bckPanel.grid(row=0, column=0, padx=0, pady=0, sticky=W)
                bckPanel.image = background

                openkeyBtn = Button(root, text="KeyBoard", command=self.openkey, bg="white") #create a button inside the btnFrame with the given features
                openkeyBtn.place(x=5,y=320)

                CameraBtn = Button(root, text="Camera", command=self.opencamera, bg="white")
                CameraBtn.place(x=280,y=320)

                startchatBtn = Button(root, text="Start chat", command=self.startchat, bg="white") #create a button inside the btnFrame with the given features
                startchatBtn.place(x=95,y=320)

                stopcameraBtn = Button(root, text="stop camera", command=self.closecamera, bg="white") #create a button inside the btnFrame with the given features
                stopcameraBtn.place(x=365,y=320)

                stopchatBtn = Button(root, text="Stop chat", command=self.stopchat, bg="white") #create a button inside the btnFrame with the given features
                stopchatBtn.place(x=190,y=320)

                self.chatLog = ScrolledText(root, width = 115, height = 20, takefocus=0, highlightthickness=1, highlightbackground="#333")
                self.chatLog.place(x=5, y=350)
                
                self.temperature = Label(root, textvariable=self.temp_data, bg="white", font=('Verdana', 15, 'bold'))
                self.temp_data.set("Temperature")
                self.temperature.place(x=80, y=0)

                self.tempLog = ScrolledText(root, width = 35, height = 20, takefocus=0, highlightthickness=1, highlightbackground="#333")
                self.tempLog.place(x=5, y=25)

                self.preasureLog = ScrolledText(root, width = 35, height = 20, takefocus=0, highlightthickness=1, highlightbackground="#333")
                self.preasureLog.place(x=285, y=25)

                self.heartLog = ScrolledText(root, width = 35, height = 20, takefocus=0, highlightthickness=1, highlightbackground="#333")
                self.heartLog.place(x=560, y=25)
                
                self.preasure = Label(root, textvariable=self.preasure_data, bg="white", font=('Verdana', 15, 'bold'))
                self.preasure_data.set("Preasure")
                self.preasure.place(x=370, y=0)

                self.heart_rate = Label(root, textvariable=self.heart_rate_data, bg="white", font=('Verdana', 15, 'bold'))
                self.heart_rate_data.set("Heart rate")
                self.heart_rate.place(x=630, y=0)
Ejemplo n.º 36
0
class GredAboutBox(GatoDialogs.AboutBox):

    def body(self, master):
        self.resizable(0,0)
        self.catIconImage = PhotoImage(data=GatoIcons.gred)
        self.catIcon = Label(master, image=self.catIconImage)
        self.catIcon.pack(side=TOP)
        label = Label(master, text=GatoDialogs.crnotice1)
        label.pack(side=TOP)
        label = Label(master, font="Helvetica 10", 
                      text=GatoDialogs.crnotice2, justify=CENTER)
        label.pack(side=TOP)
        color = self.config("bg")[4]
        self.infoText = ScrolledText(master, relief=FLAT, 
                                     padx=3, pady=3,
                                     background=color, 
                                     #foreground="black",
                                     wrap='word',
                                     width=60, height=12,
                                     font="Times 10")
        self.infoText.pack(expand=0, fill=X, side=BOTTOM)
        self.infoText.delete('0.0', END)
        self.infoText.insert('0.0', GatoGlobals.gLGPLText)	
        self.infoText.configure(state=DISABLED)
        self.title("Gred - About")
Ejemplo n.º 37
0
    def __init__(self):
        self.window = Tk()
        self.window.title("n0t3py - Admin Finder")
        self.window.geometry("400x400")
        self.window.resizable(width=FALSE, height=FALSE)
        self.window.protocol("WM_DELETE_WINDOW", self.close)
        self.filePath = 0
        self.que = Queue()

        self.logoBar = Frame(self.window)
        self.logoBar.pack(side = BOTTOM)

        self.github = Label(self.logoBar,text = "http://github.com/n0t3py")
        self.github.pack(side = LEFT)
        self.github.bind("<Button-1>",lambda event = None:w.open_new_tab("http://github.com/n0t3py"))
        self.github.bind("<Enter>",lambda event = None:self.github.config(cursor="hand2"))
        self.website = Label(self.logoBar,text = "https://savecoder.blogspot.com")
        self.website.pack(side = RIGHT)
        self.website.bind("<Button-1>",lambda event = None:w.open_new_tab("https://savecoder.blogspot.com"))
        self.website.bind("<Enter>",lambda event = None:self.website.config(cursor="hand2"))
        self.label = Label(self.window, text="select wordlist,entry web adress and press Find!")
        self.label.place(x=10, y=0)

        self.webAdress = Entry(self.window)  # input web adress
        self.webAdress.place(x=10, y=20, width=200, height=20)

        self.searchButton = Button(self.window,
                                   text="Find!",
                                   command=lambda:Thread(target = self.conf,args = (),).start(),
                                   state = "disable")

        self.searchButton.place(x=210, y=20, width=90, height=20)

        self.fileSelect = Button(self.window,text = "Select Worlist",command = self.dialog)
        self.fileSelect.place(x = 300,y = 20,width = 90,height = 20)

        self.result = ScrolledText.ScrolledText(self.window,
                                                wrap="word",
                                                fg = "red",
                                                bg = "black")

        self.result.place(x=10, y=60, width=200, height=300)

        self.resultFind = ScrolledText.ScrolledText(self.window,
                                                    fg = "green",
                                                    bg = "black",
                                                    wrap = "word")
        self.resultFind.place(x=210, y=60, width=180, height=300)

        self.window.mainloop()
Ejemplo n.º 38
0
    def __init__(self, root, conf):
        self.conf = conf
        self.items = conf.get_top_level_items()
        self.tree = ttk.Treeview(root, selectmode="browse", columns=("name", "value", "type"), displaycolumns=("value", "type"), height=30)
        
        ysb = ttk.Scrollbar(orient=VERTICAL, command= self.tree.yview)
        xsb = ttk.Scrollbar(orient=HORIZONTAL, command= self.tree.xview)
        self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)
        
        self.tree.heading('#0', text='Configuration Tree', anchor='w')
        self.tree.column("#0", minwidth=0, width=800, stretch=True)

        self.tree.heading("name", text="Name")   
        self.tree.column("name", minwidth=0, width=200, stretch=True)
        
        self.tree.heading("value", text="Value")   
        self.tree.column("value", minwidth=0, width=50, stretch=True)
        
        self.tree.heading("type", text="Type")   
        self.tree.column("type", minwidth=0, width=50, stretch=True)

        self.add_root_items(self.items)
        
        self.help = ScrolledText(root, width=130, height=10)
        self.msg = StringVar()
        self.info = Label(root, fg="green", font=("Helvetica", 16), anchor=W, justify=LEFT, textvariable=self.msg)
        
        self.msg.set("Please set configurations, then you can save it!")
        
        self.tree.grid(row=0, column=0)
        self.help.grid(row=1, column=0)
        self.info.grid(row=2, column=0)
        ysb.grid(row=0, column=1, sticky='ns')
        xsb.grid(row=1, column=0, sticky='ew')
        
        root.grid()
        
        self.root = root
        
        # create a toplevel menu
        menubar = Menu(root)
        menubar.add_command(label="Save Config!", command=self.OnSaveConfig)
        menubar.add_command(label="Quit Config!", command=self.OnQuitConfig)

        # display the menu
        root.config(menu=menubar)
    
        self.tree.bind("<Double-1>", self.OnDoubleClick)
        self.tree.bind("<<TreeviewSelect>>", self.OnSelection)
Ejemplo n.º 39
0
def get_all_books():
	window = Toplevel()
	window.configure(bg='lightgrey')
	window.title("All Books From Library")
	window.resizable(0,0)
	window.geometry("680x400")

	dim.set_dimensions(window)
	cursor = mydb.get_all_books_from_db()
	global my_dict
	my_dict = {}
	for item in cursor:
		my_dict[item[0]] = [item[0],item[1],item[2],item[3],item[4],item[5],item[6]]
			
	print my_dict

	lbl1 = Label(window, text="Books List:", fg='black', font=("Helvetica", 16, "bold"))
	lbl2 = Label(window, text="Book Information:", fg='black', font=("Helvetica", 16,"bold"))
	lbl1.grid(row=0, column=0, sticky=W)
	lbl2.grid(row=0, column=1, sticky=W)

	frm = Frame(window)
	frm.grid(row=1, column=0, sticky=N+S)
	window.rowconfigure(1, weight=1)
	window.columnconfigure(1, weight=1)

	scrollbar = Scrollbar(frm, orient="vertical")
	scrollbar.pack(side=RIGHT, fill=Y)

	global bookList

	bookList = Listbox(frm, width=20, yscrollcommand=scrollbar.set, font=("Helvetica", 12), selectmode=SINGLE)
	bookList.pack(expand=True, fill=Y)
	scrollbar.config(command=bookList.yview)

	global bookInfo

	bookInfo = ScrolledText(window, height=20, wrap=WORD, font=("Helvetica", 12))
	bookInfo.grid(row=1, column=1, sticky=E+W+N)
	# scrollbar_1 = Scrollbar(bookInfo, orient="vertical")
	# scrollbar_1.pack(side=RIGHT, fill=Y)
	# bookInfo.config(yscrollcommand=scrollbar_1.set)
	# scrollbar_1.config(command=bookInfo.yview)

	for item in cursor:
		bookList.insert(END, item[0])

	bookList.bind('<<ListboxSelect>>',on_select)
	window.mainloop()
Ejemplo n.º 40
0
    def make_editAria(self, parent):
        self.text = ScrolledText( parent )
        self.text.pack(side=TOP, fill=BOTH)

        def updateTitle(evt):
            '''実験コード。まだ
            改行や行末改行の削除に弱いです
            '''
#            print self.text.index('1.end')
#            print self.text.index(INSERT)

            if self.text.index(INSERT).split('.')[0] == '1': # 1行目
                itemnum = self.memos.getSelectedIndex()

                self.memoList.delete(itemnum)
                self.memoList.insert(itemnum,
                             "%s | %s" % (self.memos[itemnum].getDatetime().strftime("%Y-%m-%d %H:%M"),
                                          u'%s%s%s' % ( self.text.get('1.0', INSERT), 
                                                        evt.char.decode('utf_8'),
                                                        self.text.get(INSERT, '1.end'))))
                self.memoList.selection_clear(0,END)
                self.memoList.selection_set(itemnum)
                self.memoList.see(itemnum)


        self.text.bind('<Key>', updateTitle )

        def ime_ctrl_m(evt):
            if evt.keycode == 0:
                self.text.insert( INSERT, evt.char )
        self.text.bind('<Control-Key>',ime_ctrl_m)
Ejemplo n.º 41
0
  def __init__(self, master):
    Thread.__init__(self)
    frame = Frame(master)
    frame.pack()

    gframe = Frame(frame)
    gframe.pack(anchor='w')
    self.lblserver = Label(gframe, text="IP Server :")
    self.txtserver =  Entry(gframe,width=40)
    self.lblserver.pack(side=LEFT)
    self.txtserver.pack(side=LEFT)
    self.lblport = Label(gframe, text="Port :")
    self.txtport =  Entry(gframe,width=40)
    self.lblport.pack(side=LEFT)
    self.txtport.pack(side=LEFT)
    self.koneksi = Button(gframe, text='Listen', command=self.Listen).pack(side=LEFT)
    
    self.gettext = ScrolledText(frame, height=10,width=100, state=NORMAL)
    self.gettext.pack()
    sframe = Frame(frame)
    
    sframe.pack(anchor='w')
    self.pro = Label(sframe, text="Server>>")
    self.sendtext = Entry(sframe,width=80)
    self.sendtext.focus_set()
    self.sendtext.bind(sequence="<Return>", func=self.Send)
    self.pro.pack(side=LEFT)
    self.sendtext.pack(side=LEFT)
    self.gettext.configure(state=DISABLED)
Ejemplo n.º 42
0
 def __init__(self,rt):
  if rt==None:
   self.t=Tk()
  else:
   self.t=Toplevel(rt)
  self.t.title("Tkeditor %d"%len(t1))
  self.bar=Menu(rt)
   
  self.filem=Menu(self.bar)
  self.filem.add_command(label="打开",command=self.openfile)
  self.filem.add_command(label="新建",command=neweditor)
  self.filem.add_command(label="保存",command=self.savefile)
  self.filem.add_command(label="关闭",command=self.close)
  self.filem.add_separator()
  self.filem.add_command(label="退出",command=die)
   
  self.helpm=Menu(self.bar)
  self.helpm.add_command(label="关于",command=about)
  self.bar.add_cascade(label="文件",menu=self.filem)
  self.bar.add_cascade(label="帮助",menu=self.helpm)
  self.t.config(menu=self.bar)
   
  self.f=Frame(self.t,width=512)
  self.f.pack(expand=1,fill=BOTH)
   
  self.st=ScrolledText(self.f,background="white")
  self.st.pack(side=LEFT,fill=BOTH,expand=1)
Ejemplo n.º 43
0
 def __init__(self, htmlcode, title, master=None):
 
     Toplevel.__init__(self, master)
     #self.protocol('WM_DELETE_WINDOW',self.withdraw)
     self.titleprefix = title
     color = self.config("bg")[4]
     borderFrame = Frame(self, relief=SUNKEN, bd=2) # Extra Frame
     self.text = ScrolledText(borderFrame, relief=FLAT, 
                              padx=3, pady=3,
                              background='white', 
                              #background=color, 
                              #foreground="black",
                              wrap='word',
                              width=60, height=20,
                              spacing1=3,
                              spacing2=2,
                              spacing3=3)
     self.text.pack(expand=1, fill=BOTH)
     #self.text.insert('0.0', text)
     self.text['state'] = DISABLED 
     borderFrame.pack(side=TOP,expand=1,fill=BOTH)
     box = Frame(self)
     w = Button(box, text="Dismiss", width=10, command=self.doWithdraw, default=ACTIVE)
     w.pack(side=RIGHT, padx=5, pady=5)
     self.bind("<Return>", self.doWithdraw)
     box.pack(side=BOTTOM,fill=BOTH)
     self.setStyle()
     self.insert(htmlcode)
Ejemplo n.º 44
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master.title("Network Simulator Log")
        self.text = ScrolledText(self)
        self.text.pack(fill=BOTH, expand=1)
        self.pack(fill=BOTH, expand=1)
        self.text.config(
            background="black",
            foreground="white",
            font=Font(
                family="Courier", weight="bold"),
            # state=DISABLED,
            wrap=NONE, )

        self.text.tag_config("DEBUG", foreground="green")
        self.text.tag_config("ERROR", foreground="red")
        self.text.tag_config("CRITICAL", foreground="red")
        self.text.tag_config("EXCEPTION", foreground="red")
        self.text.tag_config("WARNING", foreground="yellow")
        self.text.tag_config("INFO", foreground="white")

        self.text.bind("<Key>", lambda e: 'break')
        self.text.bind("<Return>", self._clear)
        self.queue = Queue()
        self._update()
Ejemplo n.º 45
0
    def create_widgets(self):
        self.content = ttk.Frame(self.master, padding=(5))

        self.b1 = ttk.Button(self.content, text='Clear Query')
        self.combo_value = StringVar()
        self.com = ttk.Combobox(self.content, textvariable=self.combo_value,
                                state='readonly')
        if not os.path.isdir(DATA_PAHT):
            os.mkdir(data_folder)
        self.com['values'] = os.listdir(DATA_PAHT)
        if len(self.com['values']) > 0:
            self.com.current(0)
        else:
            sys.stderr.write('Please put csv data file in data folder and '
                             'restart this program.')
        self.b2 = ttk.Button(self.content, text='Data Summary',
                             command=self.show_summary_of_data_file)
        self.b3 = ttk.Button(self.content, text='Query', style='exe.TButton')
        self.b4 = ttk.Button(self.content, text='Clear Log')
        self.st1 = ScrolledText(self.content)
        self.st2 = ScrolledText(self.content)

        self.b1.grid(row=0, column=0, sticky=(W))
        self.b2.grid(row=0, column=1, sticky=(E))
        self.com.grid(row=0, column=1, sticky=(W+E))
        self.b3.grid(row=0, column=2, sticky=(W))
        self.b4.grid(row=0, column=3, sticky=(E))
        self.st1.grid(row=1, column=0, columnspan=2, sticky=(W+E+S+N))
        self.st2.grid(row=1, column=2, columnspan=2, sticky=(W+E+S+N))
        self.content.grid(row=0, column=0, sticky=(W+E+S+N))

        self.b1['command'] = lambda: self.st1.delete('0.1', 'end')
        self.b3['command'] = self.parse_data
        self.b4['command'] = self.clear_output

        self.master.rowconfigure(0, weight=1)
        self.master.columnconfigure(0, weight=1)
        self.content.rowconfigure(0, weight=0)
        self.content.rowconfigure(1, weight=1)
        self.content.columnconfigure(0, weight=1)
        self.content.columnconfigure(1, weight=1)
        self.content.columnconfigure(2, weight=1)
        self.content.columnconfigure(3, weight=1)

        self.st1.focus()
Ejemplo n.º 46
0
def main():
    root = Tkinter.Tk(className=" TextPad")
    textPad = ScrolledText(root, width=100, height=50)
 
    # create a menu & define functions for each menu item
 
    def open_command():
        file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Select a file')
        if file != None:
            contents = file.read()
            textPad.insert('1.0',contents)
            file.close()

    def saving():
        save_command(textPad)
    def save_command(self):
        file = tkFileDialog.asksaveasfile(mode='w')
        if file != None:
        # slice off the last character from get, as an extra return is added
            data = self.get('1.0', END+'-1c')
            file.write(data)
            file.close()
         
    def exit_command():
        if tkMessageBox.askokcancel("Quit", "Do you really want to quit?"):
            root.destroy()
 
    def about_command():
        label=tkMessageBox.showinfo("About", "Just Another TextPad Judical CLAIR")

    menu = Menu(root)
    root.config(menu=menu)
    filemenu = Menu(menu)
    menu.add_cascade(label="File", menu=filemenu)
    filemenu.add_command(label="New", command=main)
    filemenu.add_command(label="Open...", command=open_command)
    filemenu.add_command(label="Save", command=saving)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=exit_command)
    helpmenu = Menu(menu)
    menu.add_cascade(label="Help", menu=helpmenu)
    helpmenu.add_command(label="About...", command=about_command)
    
    textPad.pack()
    root.mainloop()
Ejemplo n.º 47
0
 def search(self):
        global infowiki
        infowiki = StringVar()
        ttk.Labelframe(self.window, width=1350, height=600).grid(row=0, sticky = NW, pady=150, column=0)
        ttk.Labelframe(self.window, width=500, height=300).grid(row=0, sticky = NW, pady=174, column=0, padx=800)
        ttk.Labelframe(self.window, width=750, height=600).grid(row=0, sticky = NW, pady=174, column=0, padx=20)
        self.WikiInfo = ScrolledText(self.window, width=65,height=18, bd=7,font=("Helvetica",15))
        self.WikiInfo.grid(row=0, sticky = NW, pady=280, column=0, padx=20)
        self.WikiInfo.insert(END, "Please Search For Content\n")
Ejemplo n.º 48
0
    def createEditorWidgets(self):
        # Text Pad
        self.textPad = ScrolledText(self, width = 30, height = 10, font = "TkTextFont")
        self.textPad.grid(row = 0, column = 0, padx = 10, pady = 10, sticky = (N, S, W, E))
        self.columnconfigure(0, weight = 1)
        self.rowconfigure(0, weight = 1)

        self.save = Button(self, text = "Save", width = 6, command = lambda: self.saveFile())
        self.save.grid(row = 0, column = 1, padx = 10, pady = 10, sticky = N)
Ejemplo n.º 49
0
	def __init__(self, myParent):
                self.mylist = [i for i in range(1,53)]
                self.display_cards(human_cards)
                self.button1 = Button(root)
                self.button1["text"]= "Fetch"    ### (2)
                self.button1.bind("<Button-1>", self.onFetchClick)
                self.button1.grid(row=1,column=10)
                self.scrollview = ScrolledText(root,width=10,height = 10,state = DISABLED)
                self.scrollview.grid(row=200,column=5)
Ejemplo n.º 50
0
    def __init__(self):
        """ 
          Sets up the tkinter window and some attributes.
        """
        # Initialize Attributes
        self.port = 80
        self.address = "127.0.0.1"
        self.connected = False
        self.acting_as_server = False
        self.acting_as_client = True

        # Create Tkinter root window and set title
        self.root = Tk()
        self.root.title(PROGRAM_NAME + " " + VERSION)
        self.root.protocol("WM_DELETE_WINDOW", self.close)

        # Create frame
        self.fpopup = Frame(self.root, width=500)
        self.fpopup.pack(expand=1, fill=BOTH)

        # Create the menus
        self.menuobj = Menu(self.root)
        self.root.config(menu=self.menuobj)
        self.filemenu = Menu(self.menuobj, tearoff=0)
        self.menuobj.add_cascade(label="File", menu=self.filemenu)
        self.filemenu.add_command(label="Start Server", command=self.setup_server)
        self.filemenu.add_command(label="Stop Server", command=self.setup_server)
        self.filemenu.add_command(label="Connect", command=self.connect)
        self.filemenu.add_command(label="Disconnect", command=self.disconnect)
        self.filemenu.add_command(label="Exit", command=self.close)
        self.editmenu = Menu(self.menuobj, tearoff=0)
        self.menuobj.add_cascade(label="Edit", menu=self.editmenu)
        self.editmenu.add_command(label="Configuration", command=self.configuration)
        self.helpmenu = Menu(self.menuobj, tearoff=0)
        self.menuobj.add_cascade(label="Help", menu=self.helpmenu)
        self.helpmenu.add_command(label="About", command=self.about)

        # Create the message window
        self.message_window = ScrolledText(self.fpopup, width=90, height=24, background="white")
        self.message_window.pack(fill=BOTH, expand=YES)

        # Create the entry field
        self.entry_field = Entry(self.fpopup, width=60, background="white")
        self.entry_field.pack(side=LEFT, fill=BOTH, expand=YES)

        # Bindings
        self.entry_field.bind("<Return>", self.sendmessage_event)
        self.entry_field.bind("<Control-n>", self.connect_event)
        self.message_window.bind("<Control-n>", self.connect_event)

        # Create Buttons
        self.send_button = Button(self.fpopup, text="Send", command=self.sendmessage)
        self.send_button.pack(side=LEFT, expand=NO)

        # Start the Tk main routine
        self.root.mainloop()
Ejemplo n.º 51
0
 def __init__(self, width, height):
     self.labels = []
     self.convertedCode = ""
     self.st = ScrolledText(width=70, height=21)
     self.st.pack(side=RIGHT)
     self.code = ""
     self.width = width
     self.height = height
     self.cx, self.cy = self.width/2, self.height/2
     self.funcLine = self.cx + 100
Ejemplo n.º 52
0
 def _text_info_box(self):
     # text info box ---------------------
     self.text = ScrolledText(master=self.button_frame, height=4, 
                         fg="mediumblue",
                         bd=1, relief=tk.SUNKEN)
     self.text.insert(tk.END, "Work in progress, some features may"
                      " be incomplete\n\n")
     self.text.insert(tk.END, "To start load an image data file using"
                      " 'load image' button (or file menu)\n")
     self.text.insert(tk.END, "e.g. data/O2-ANU1024.txt.bz2\n")
     self.text.grid(row=3, column=1, columnspan=3, padx=5)
Ejemplo n.º 53
0
	def createWidgets(self): # 创建组件(包括文本框、输入框、)
		# 创建文本框
		self.text = ScrolledText(self) 
		target = open('test.txt', 'a+')  # 打开test.txt,并进入读取与追加状态
		target.seek(0)
		self.text.insert(END, target.read()) # 打印文档记录
		self.text.pack(side= BOTTOM)

		# 创建输入框并可以输入 
		self.content = StringVar(self)
		self.enter = Entry(self,textvariable=self.content)
		self.enter.bind("<Return>", self.write)  # bind第二参数可以调用函数
		self.enter.pack(side=TOP,fill = X)
Ejemplo n.º 54
0
class App(object):
    def __init__(self,master):
        topframe = Frame(master)
        topframe.pack()
        self.views = Frame(topframe)
        self.views.pack()
        self.controls = Frame(topframe)
        self.controls.pack()

        self.button = Button(self.controls, text='Quit', fg='red',
                command=topframe.quit)
        self.button.pack(side=RIGHT)
        self.hi_there = Button(self.controls, text='Hello',
                command=self.say_hi)
        self.hi_there.pack(side=RIGHT)

        self.textwindow = ScrolledText(self.views, width=90)
        self.textwindow.pack(side=TOP)
        self.chatline = Entry(self.controls)
        self.chatline.pack(side=BOTTOM)

    def say_hi(self):
        print 'Hi there, everyone!'
Ejemplo n.º 55
0
	def __init__(self, parent, app):
		Frame.__init__(self, parent)
		self.parent = parent
		parent.title = "Add Keywords"
		self.app = app

		#Frame to hold keyword list text
		kwTextFrame = Frame(self.parent, bg="#E8E8E8", relief=RAISED)
		kwTextFrame.pack(fill=BOTH, expand=True, side=LEFT, padx=10, pady=10)

		#Canvas for keyword list text
		kwgroupCanvas = Canvas(kwTextFrame, bg="#E8E8E8", width=100, relief=SUNKEN)
		kwgroupCanvas.pack(fill=BOTH, expand=True)

		#Keyword list test box
		kwText = ScrolledText(kwgroupCanvas, wrap=WORD, width=25, 
			height=15, relief=SUNKEN, highlightthickness=0, bd=1, padx=1, pady=1)
		kwText.pack(fill=BOTH, side=BOTTOM, expand=True)

		#@add_wrapper
		def add_kw():
			#Find current group selected
				current_word = self.app.group_select

				#Get text from add keywords text box
				text = kwText.get('1.0', 'end-1c').splitlines()
				for line in text:
					self.app.key_group.keyword_groups[current_word].append(line)

				kwText.delete('1.0',END)
				return text

		#Add Keyword Button
		add_key = Button(kwTextFrame, width=15, text="Add Keyword(s)", 
			highlightbackground="#E8E8E8", command=add_kw)
		add_key.pack(side=BOTTOM)
    def __init__(self, parent):
        self.parent = parent
        self.textWidget = ScrolledText(parent, width=80, height=50, font=(tkFont.Font(family= "Consolas", size= "12")))
        self.textWidget.pack()

        self.menuBar = tk.Menu(parent, tearoff=0)
        # About Menu
        self.about_menu = tk.Menu(self.menuBar, tearoff= 0)
        self.menuBar.add_cascade(label= "Text Perfect", menu= self.about_menu)
        self.about_menu.add_command(label= "About", command= self.about_command)

        # File Menu
        self.file_menu = tk.Menu(self.menuBar, tearoff = 0)
        self.menuBar.add_cascade(label = "File", menu=self.file_menu)
        self.file_menu.add_command(label="New", command=self.new_command, accelerator="Cmd+N")
        self.parent.bind_all("<Command-n>", self.new_command)
        self.parent.bind_all("<Command-N>", self.new_command)
        self.file_menu.add_command(label="New Tab", command=self.new_tab, accelerator="Cmd+Opt+N")
        self.parent.bind_all("<Command-Option-n>", self.new_tab)
        self.parent.bind_all("<Command-Option-N>", self.new_tab)
        self.file_menu.add_separator()
        self.file_menu.add_command(label="Open", command=self.open_command, accelerator="Cmd+O")
        self.parent.bind_all("<Command-o>", self.open_command)
        self.parent.bind_all("<Command-O>", self.open_command)
        self.file_menu.add_command(label="Save", command=self.save_command, accelerator="Cmd+S")
        self.parent.bind_all("<Command-s>", self.save_command)
        self.parent.bind_all("<Command-S>", self.save_command)
        self.file_menu.add_separator()
        self.file_menu.add_command(label= "Quit", command= self.exit_program, accelerator="Cmd+W")
        self.parent.bind_all("<Command-w>", self.exit_program)
        self.parent.bind_all("<Command-W>", self.exit_program)

        # Edit Menu
        self.edit_menu = tk.Menu(self.menuBar, tearoff=0)
        self.menuBar.add_cascade(label= "Edit", menu= self.edit_menu)
        self.edit_menu.add_command(label = "Cut", command = self.cut_command, accelerator="Cmd+X")
        self.parent.bind_all("<Command-Shift-x>", self.cut_command)
        self.parent.bind_all("<Command-Shift-X>", self.cut_command)
        self.edit_menu.add_command(label = "Copy", command = self.copy_command, accelerator="Cmd+C")
        self.parent.bind_all("<Command-Shift-c>", self.copy_command)
        self.parent.bind_all("<Command-Shift-C>", self.copy_command)
        self.edit_menu.add_command(label = "Paste", command = self.paste_command, accelerator="Cmd+V")
        self.parent.bind_all("<Command-Shift-v>", self.paste_command)
        self.parent.bind_all("<Command-Shift-V>", self.paste_command)
        self.edit_menu.add_separator()
        self.edit_menu.add_command(label= "Find", command= self.find_command)

        parent.config(menu=self.menuBar)
Ejemplo n.º 57
-1
class editor:
    def __init__(self, rt):
        if rt == None:
            self.t = Tk()
        else:
            self.t = Toplevel(rt)
        self.t.title("Tkeditor %d" % len(t1))
        self.bar = Menu(rt)

        self.filem = Menu(self.bar)
        self.filem.add_command(label="打开", command=self.openfile)
        self.filem.add_command(label="新建", command=neweditor)
        self.filem.add_command(label="保存", command=self.savefile)
        self.filem.add_command(label="关闭", command=self.close)
        self.filem.add_separator()
        self.filem.add_command(label="退出", command=die)

        self.helpm = Menu(self.bar)
        self.helpm.add_command(label="关于", command=about)
        self.bar.add_cascade(label="文件", menu=self.filem)
        self.bar.add_cascade(label="帮助", menu=self.helpm)
        self.t.config(menu=self.bar)

        self.f = Frame(self.t, width=512)
        self.f.pack(expand=1, fill=BOTH)

        self.st = ScrolledText(self.f, background="white")
        self.st.pack(side=LEFT, fill=BOTH, expand=1)

        self.open = Button(self)
        self.open["text"] = "open"
        self.open["fg"] = "Blue"
        self.open["command"] = self.openfile
        self.open.pack({"side": "left"})
        self.open.pack({"anchor": "nw"})

    def close(self):
        self.t.destroy()
        print "close"

    def openfile(self):
        p1 = END
        oname = askopenfilename(filetypes=[("Python file", "*.*")])
        if oname:
            for line in fileinput.input(oname):
                self.st.insert(p1, line)
            self.t.title(oname)

    def savefile(self):
        sname = asksaveasfilename()
        if sname:
            ofp = open(sname, "w")
            ofp.write(self.st.get(1.0, END))
            ofp.flush()
            ofp.close()
            self.t.title(sname)