当前位置: 首页>>代码示例>>Python>>正文


Python ScrolledText.see方法代码示例

本文整理汇总了Python中ScrolledText.see方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.see方法的具体用法?Python ScrolledText.see怎么用?Python ScrolledText.see使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScrolledText的用法示例。


在下文中一共展示了ScrolledText.see方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class App(Thread):
  server = socket()
  server.bind(('localhost', input("Port: ")))
  server.listen(5)
  client,addr = server.accept()
  def __init__(self, master):
    Thread.__init__(self)
    frame = Frame(master)
    frame.pack()
    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.insert(END,'Welcome to Chat\n')
    self.gettext.configure(state=DISABLED)
  def Send(self, args):
    self.gettext.configure(state=NORMAL)
    text = self.sendtext.get()
    if text=="": text=" "
    self.gettext.insert(END,'Me >> %s \n'%text)
    self.sendtext.delete(0,END)
    self.client.send(text)
    self.sendtext.focus_set()
    self.gettext.configure(state=DISABLED)
    self.gettext.see(END)
  def run(self):
    Receive(self.client, self.gettext)
开发者ID:praven0894,项目名称:Chat-with-tkinter-and-socket,代码行数:35,代码来源:Server.py

示例2: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class App(Thread):
  client = socket()
  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='Connect', command=self.Connect).pack(side=LEFT)
    
    self.gettext = ScrolledText(frame, height=10,width=100)    
    self.gettext.pack()    
    self.gettext.configure(state=DISABLED)
    
    sframe = Frame(frame)
    sframe.pack(anchor='w')
    self.pro = Label(sframe, text="Client>>")
    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)

  def Connect(self):     
    try:      
      self.client.connect((str(self.txtserver.get()), int(self.txtport.get())))
      self.gettext.configure(state=NORMAL)
      self.gettext.insert(END,'Start to Chat\n')
      self.gettext.configure(state=DISABLED)
      self.start()      
    except:      
      tkMessageBox.showinfo("Error", "Unconnected")
    
  def Send(self, args):
    self.gettext.configure(state=NORMAL)
    text = self.sendtext.get()
    if text=="": text=" "
    self.gettext.insert(END,'Me >> %s\n'%text)
    self.sendtext.delete(0,END)
    self.client.send(text)
    self.sendtext.focus_set()
    self.gettext.configure(state=DISABLED)
    self.gettext.see(END)
    
  def run(self):
    Receive(self.client, self.gettext)

  def __del__(self):
    self.client.close()
开发者ID:harissaint,项目名称:Tugas-OOP1,代码行数:60,代码来源:client.py

示例3: Application

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class Application(Frame):
	
	def __init__(self, master=None):
		Frame.__init__(self, master)
		self.pack()
		self.createWidgets()

	def getnew(self,event): 
	# When press ENTER, write diary to local file
	# and print out it in Text frame
	# and also clear the Entry box
		line = self.newlog.get()
		f = open('diary log.txt','a+')
		f.write('%s\n' % line)
		f.close()
		self.t.insert(END,"%s\n" %line)
		self.t.see(END)
		self.e.delete(0,END)

	def createWidgets(self):   
		self.newlog = StringVar(self) # define StringVar
		
		self.l = Label(self, text = "Input here: ") # Label Widget 提示输入
		self.l.grid(row = 0, column = 0, sticky = W)
		
		self.e = Entry(self, textvariable = self.newlog, width = 80) # Entry box 输入框
		self.e.bind("<Return>", self.getnew) # bind ENTER to function getnew
		self.e.grid(row = 0, column = 1, sticky = W)
		self.e.focus_set() # make the mouse focus on the entry box
		
		self.t = ScrolledText(self) # ScrolledText 打印出文档的框
		self.t.grid(columnspan = 2, sticky = W)
		f = open('diary log.txt','a+') 
		self.t.insert(END,f.read()) 
		self.t.see(END)
		
		self.b = Button(self, text="QUIT", fg="red", command=self.quit) # 退出的button
		self.b.grid(row = 2, column = 0, sticky = W)
开发者ID:PythonNing,项目名称:OMOOC2py,代码行数:40,代码来源:diarygui.py

示例4: Application

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class Application(Frame):

	def __init__(self, master=None):
		Frame.__init__(self, master)
		self.pack()
		self.createWidgets()

	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 write(self,target): # 输入内容后,按<Return>消失,同时内容一能保存到txt文档,二能在文本框显示
		content = self.content.get()
		target = open('test.txt', 'a+')  # 打开test.txt,并进入读取与追加状态
		date = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime()) # 计算时间(年月日时分秒) 
		target.write(date) # 写入时间
		target.write("\n") # 给写入空一行
		target.write(content) # 写入输入的日记内容
		target.write("\n\n") # 重新开一行,保持每行只有一条日记内容
		target.close()
		self.text.insert(END,date)
		self.text.insert(END,"\n")
		self.text.insert(END,content) # 在文本框显示
		self.text.insert(END,"\n\n")
		self.text.see(END) # 指定位置
		self.enter.delete(0,END) # 清除输入框内容,需由bind的Return激活
开发者ID:junjielizero,项目名称:OMOOC2py,代码行数:38,代码来源:demo.py

示例5: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]

#.........这里部分代码省略.........
    def save_configuration(self):
        """
          Saves the configuration values and closes the window
        """
        self.port = int(self.port_entry_field.get())
        self.address = self.address_entry_field.get()
        self.configuration_menu.destroy()

    def about(self):
        """
          Calls the about window
        """
        tkMessageBox.showinfo("About", PROGRAM_NAME + " " + VERSION + "\n" + AUTHOR + "\n" + WEBSITE)

    def close(self):
        """
          Closes the whole application window
        """
        # Close the application
        if self.connected == True:
            self.clientSocket.sendmessage("/quit")
        if self.acting_as_server:
            self.serverSocket.close()
        self.root.destroy()

    def receiver(self, clientSocket, ADDR):
        """
          Receives the messages (called as a thread)
        """
        while 1:
            if self.connected == True:
                data = clientSocket.recv(1024)
                self.message_window.insert(END, "\n" + data)
                self.message_window.see(END)
                if data == "/quit":
                    self.connected = False
                    return 0

    def setup_server(self):
        """
          Calls the server setup menu
        """
        self.server_menu = Toplevel()
        self.server_menu.title(PROGRAM_NAME + " - Setup Server")

        self.server_port_label = Label(self.server_menu, text="Port:", width=40, anchor=W)
        self.server_port_entry_field = Entry(self.server_menu, width=40, background="white")
        self.server_address_label = Label(self.server_menu, text="Address:", width=40, anchor=W)
        self.server_address_entry_field = Entry(self.server_menu, width=40, background="white")
        self.start_server_button = Button(self.server_menu, text="Start", command=self.start_server)
        self.server_cancel_configuration_button = Button(self.server_menu, text="Cancel", command=self.cancel_server)

        self.server_port_label.grid(row=0, columnspan=2, sticky=W)
        self.server_port_entry_field.grid(row=1, columnspan=2, sticky=W, pady=5)
        self.server_address_label.grid(row=2, columnspan=2, sticky=W)
        self.server_address_entry_field.grid(row=3, columnspan=2, sticky=W, pady=5)
        self.start_server_button.grid(row=5, columnspan=2)
        self.server_cancel_configuration_button.grid(row=5, column=1, columnspan=2)

    def start_server(self):
        """
          Creates a server
        """
        try:
            self.serverSocket = Server(self.server_address_entry_field.get(), self.server_port_entry_field.get())
            self.serverSocket.listen()
开发者ID:dschneider,项目名称:ConnectR,代码行数:70,代码来源:SocketGUI.py

示例6: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]

#.........这里部分代码省略.........
    def _onclick(self,event):
        print('button={:d}, x={:f}, y={:f}, xdata={:f}, ydata={:f}'.format(
        event.button, event.x, event.y, event.xdata, event.ydata))


    # call back functions -----------------------
    def _display(self):
        if self.fn is None:
            self._loadimage()

        # display image
        self.plt[0].imshow(self.IM, vmin=0)
        #rows, cols = self.IM.shape
        #r2 = rows/2
        #c2 = cols/2
        #self.a.plot((r2, r2), (0, cols), 'r--', lw=0.1)
        #self.a.plot((0, rows), (c2, c2),'r--', lw=0.1)
        #self.f.colorbar(self.a.get_children()[2], ax=self.f.gca())
        self.plt[0].set_title("raw image", fontsize=10)
        self.canvas.show()


    def _loadimage(self):

        if self.fn is not None:
            # clear old plot
            for i in range(4):
                self._clr_plt(i)
                self.plt[i].axis("off")

        self.fn = self.sample_image.get()
        # update what is occurring text box
        self.text.insert(tk.END, "\nloading image file {:s}".format(self.fn))
        self.text.see(tk.END)
        self.canvas.show()

        if self.fn == "from file":
            self.fn = askopenfilename()
            # read image file
            if ".txt" in self.fn:
                self.IM = np.loadtxt(self.fn)
            else:
                self.IM = imread(self.fn)
        elif self.fn == "from transform":
            self.IM = self.AIM
            self.AIM = None
            for i in range(1,4):
                self._clr_plt(i)
                self.plt[i].axis("off")
            self.direction.current(0)
        else:
            self.fn = self.fn.split(' ')[-1]
            self.IM = abel.tools.analytical.sample_image(n=1001, name=self.fn)
            self.direction.current(1) # raw images require 'forward' transform
            self.text.insert(tk.END,"\nsample image: (1) Abel transform 'forward', ")
            self.text.insert(tk.END,"              (2) load 'from transform', ") 
            self.text.insert(tk.END,"              (3) Abel transform 'inverse', ")
            self.text.insert(tk.END,"              (4) Speed")
            self.text.see(tk.END)


        # if even size image, make odd
        if self.IM.shape[0] % 2 == 0:
            self.IM = shift(self.IM, (-0.5, -0.5))[:-1,:-1]
    
        self.old_method = None
开发者ID:DhrubajyotiDas,项目名称:PyAbel,代码行数:70,代码来源:example_GUI.py

示例7: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class App(Thread):
  client = socket()
  print ("CLIENT")
  client.connect((input("IP Server: "), input("Port: ")))
  def __init__(self, master):
    Thread.__init__(self)
    frame = Frame(master)
    frame.pack()
    self.gettext = ScrolledText(frame, height=10,width=100)
    self.gettext.pack()
    self.gettext.insert(END,'Welcome to Chat\n')
    self.gettext.configure(state=DISABLED)
    sframe = Frame(frame)
    sframe.pack(anchor='w')
    self.pro = Label(sframe, text="Client>>");
    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)
    
  def Send(self, args):
    self.gettext.configure(state=NORMAL)
    text = self.sendtext.get()
    if text=="": text=" "
    self.gettext.insert(END,'Me >> %s\n'%text)
    self.sendtext.delete(0,END)
    self.client.send(text)
    self.sendtext.focus_set()
    self.gettext.configure(state=DISABLED)
    self.gettext.see(END)

    def sendFile(self,sock,file):
        sock.send(filFlag)
        user = os.environ['USER']
        command = filFlag
        size = os.stat(file)[6]
        f = open(file,'r')
        pos = 0
        while 1:
            if pos == 0:
                buffer = f.read(5000000-282)
                if not buffer: break
                count = sock.send(command + ':' + \
                string.rjust(os.path.basename(file),214) + ':' + \
                string.rjust(str(size).strip(),30) + ':' + \
                string.rjust(str(user).strip(),30) + \
                buffer)
                pos = 1
            else:
                buffer = f.read(5000000)
                if not buffer: break
                count = sock.send(buffer)

    def recvFile(self,sock):
        pjg = 0
        msg1 = sock.recv(283).split(':')
        flag = msg1[0].strip()
        namafile = msg1[1].strip()
        total = msg1[2].strip()
        user = msg1[3].strip()
        file = namafile

        if flag == filFlag:
            try:
                f = open(file,'w')
            except:
                ret = 0
                print 'Tidak dapat menyimpan file'
                sys.exit()
            else:
                try:
                    while 1:
                        leftToRead = int(total) - pjg
                        if not leftToRead: break
                        msg = sock.recv(5000000)
                        pjg = pjg + len(msg)
                        f.write(msg)
                        os.system('echo -n !')
                        f.close()
                except:
                    os.remove(file)
                    ret = 0
                else:
                    ret = 1

  def run(self):
    Receive(self.client, self.gettext)
开发者ID:janetoway,项目名称:Tugas-OOP2,代码行数:90,代码来源:client.py

示例8: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class App(Thread):
    server = socket()
    print("SERVER")
    server.bind((input("IP Client: "), input("Port: ")))
    server.listen(5)
    client, addr = server.accept()

    def __init__(self, master):
        Thread.__init__(self)
        frame = Frame(master)
        frame.pack()
        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.insert(END, "Welcome to Chat\n")
        self.gettext.configure(state=DISABLED)

    def Send(self, args):
        self.gettext.configure(state=NORMAL)
        text = self.sendtext.get()
        if text == "":
            text = " "
        self.gettext.insert(END, "Me >> %s \n" % text)
        self.sendtext.delete(0, END)
        self.client.send(text)
        self.sendtext.focus_set()
        self.gettext.configure(state=DISABLED)
        self.gettext.see(END)

        def sendFile(self, sock, file):
            sock.send(filFlag)
            user = os.environ["USER"]
            command = filFlag
            size = os.stat(file)[6]
            try:
                f = open(file, "r")
            except:
                ret = 0
            else:
                pos = 0
                while 1:
                    if pos == 0:
                        buffer = f.read(5000000 - 282)
                        if not buffer:
                            break
                        count = sock.send(
                            command
                            + ":"
                            + string.rjust(os.path.basename(file), 214)
                            + ":"
                            + string.rjust(str(size).strip(), 30)
                            + ":"
                            + string.rjust(str(user).strip(), 30)
                            + buffer
                        )
                        pos = 1
                    else:
                        buffer = f.read(5000000)
                        if not buffer:
                            break
                        count = sock.send(buffer)
                    ret = 1
                return ret

            def recvFile(self, sock):
                pjg = 0
                msg1 = sock.recv(283).split(":")
                flag = msg1[0].strip()
                namafile = msg1[1].strip()
                total = msg1[2].strip()
                user = msg1[3].strip()
                file = namafile
                if flag == filFlag:
                    try:
                        f = open(file, "w")
                    except:
                        ret = 0
                    else:
                        try:
                            while 1:
                                leftToRead = int(total) - pjg
                                if not leftToRead:
                                    break
                                msg = sock.recv(5000000)
                                pjg = pjg + len(msg)
                                f.write(msg)
                            f.close()
                        except:
                            os.remove(file)
                            ret = 0
                        else:
                            ret = 1
                        ret = 1
#.........这里部分代码省略.........
开发者ID:janetoway,项目名称:Tugas-OOP2,代码行数:103,代码来源:server.py

示例9: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class Textee:
    def __init__(self, master):
        self.master = master
        self.theme = 'dark' # the startup will always be opposite
        self.options = TexteeOptions()
        self.status_bar = TexteeStatusBar(master)
        self.create_menu(master)
        self.create_ui(master)
        self.set_bindings(master)
        self.file = None
        self.find_text = ''
        self.font_dialog = None
        self.find_and_replace_dialog = None
        self.windows = []
        
    def create_menu(self, master):
        self.menu = Menu(master)
        master.config(menu=self.menu)
        
        filemenu = Menu(self.menu)
        self.menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New", command=self.new_file)
        filemenu.add_command(label="Open...", command=self.open_file)
        filemenu.add_command(label="Save", command=self.save_file)
        filemenu.add_command(label="Save As", command=lambda: self.save_file(save_as=True))
        filemenu.add_separator()
        filemenu.add_command(label="New window", command=self.new_window)
        filemenu.add_separator()
        filemenu.add_command(label="Print", command=self.printer)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.exit)

        editmenu = Menu(self.menu)
        self.menu.add_cascade(label='Edit', menu=editmenu)
        editmenu.add_command(label='Copy', command=lambda: event_generate(self.editor, 'Copy'))
        editmenu.add_command(label='Paste', command=lambda: event_generate(self.editor, 'Paste'))
        editmenu.add_command(label='Undo', command=lambda: event_generate(self.editor, 'Undo'))
        editmenu.add_separator()
        editmenu.add_command(label='Goto', command=self.goto_line) # need to develop custom find with regex
        editmenu.add_command(label='Find', command=self.find) # need to develop custom find with regex
        editmenu.add_command(label='Find & Replace', command=self.find_and_replace) # need to test the replace logic in separate playground
        editmenu.add_separator()
        editmenu.add_command(label='Check spelling', command=self.spell_check) # need to see how to use system's grammer check.. if not possible remove it.

        formatmenu = Menu(self.menu)
        self.menu.add_cascade(label='Format', menu=formatmenu)
        formatmenu.add_command(label='Font', command=self.select_font) # pop-up to select system fonts
        formatmenu.add_checkbutton(label='Wrap', onvalue=True, offvalue=False, variable=self.options.wrap, command=self.toggle_wrap)
        
        viewmenu = Menu(self.menu)
        self.menu.add_cascade(label='View', menu=viewmenu)
        viewmenu.add_checkbutton(label='Status bar', onvalue=True, offvalue=False, variable=self.options.status_bar, command=lambda: self.status_bar.display(self.options.status_bar.get()))
        viewmenu.add_command(label='Toggle theme', command=self.toggle_theme)
        
        helpmenu = Menu(self.menu)
        self.menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About", command=lambda : self.about())

    def create_ui(self, master):
        self.editor = ScrolledText(master, width=100, height=50, highlightthickness=0)
        self.editor.config(undo=True)
        self.editor.pack(expand=YES, fill='both', padx=0, pady=0)
        self.toggle_theme()
        #print_configs(self.editor)
        
        # Create pop-menu for the entire editor.. do some cool stuff with it
        self.editor.popmenu = Menu(self.master, tearoff=0)
        # TODO : later need to do smart copy/paste i.e. selected text copy of entire line copy
        self.editor.popmenu.add_command(label='Copy', command=lambda: event_generate(self.editor, 'Copy'))
        self.editor.popmenu.add_command(label='Paste', command=lambda: event_generate(self.editor, 'Paste'))
        # TODO : disable undo when not available, not sure if its possible. Need to check research later
        self.editor.popmenu.add_command(label='Undo', command=lambda: event_generate(self.editor, 'Undo'))
        self.editor.popmenu.add_separator()
        # TODO : 'share' this will be the best feature in the editor, share the file with the future textee sharing api
        self.editor.popmenu.add_command(label='Share', command=do_nothing)

        # add status bar by default, it can be hidden from menu
        self.status_bar.update_status('Hi there')
        
    def set_bindings(self, master):
        master.bind_class('Text', '<Control-a>', select_all)
        master.bind_class('Text', '<Control-s>', lambda event: self.save_file())
        master.bind_class('Text', '<Control-o>', lambda event: self.open_file())
        master.bind_class('Text', '<Control-n>', lambda event: self.new_file())
        master.bind_class('Text', '<Control-g>', lambda event: self.goto_line())
        master.bind_class('Text', '<Control-f>', lambda event: self.find())
        master.bind_class('Text', '<Control-p>', lambda event: self.printer())
        master.bind_class('Text', '<Control-;>', lambda event: self.find_and_replace()) # this function is only for temporoy use - for dev purpose only

        # editor section bindings only
        self.editor.bind('<Button-2>', self.show_right_click_menu) # for right-click
        self.editor.bind('<Button-3>', self.show_right_click_menu) # for middle-click (scroll press)

        #display the current cursor position
        self.display_current_position()


    def new_file(self):
        self.file = None
        self.editor.delete('1.0', END+'-1c') # clear all the contents
#.........这里部分代码省略.........
开发者ID:rajeshvaya,项目名称:playground-textee,代码行数:103,代码来源:Textee.py

示例10: MainWindow

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]
class MainWindow(Toplevel, pb.Referenceable):

    shortcuts = {"n":"go north",
                 "s":"go south",
                 "e":"go east",
                 "w":"go west",
                 "l":"look",
                 "ne":"go northeast",
                 "nw":"go northwest",
                 "sw":"go southwest",
                 "se":"go southeast",
                 "u":"go up",
                 "d":"go down"}
    
    def __init__(self, *args,**kw):
        self.descriptions = {}
        self.items = {}
        self.exits = []
        apply(Toplevel.__init__,(self,)+args,kw)
        self.title("Reality Faucet")
        self.happenings = ScrolledText(self, height=6, width=72, wrap='word')
        
        midf = Frame(self)
        ddf = Frame(midf)
        idf = Frame(midf)
        
        a = self.descriptionField = ScrolledText(ddf, height=12, width=72, wrap='word')
        b = self.itemsField = ScrolledText(idf, height=12, width=36, wrap='word')

        a.pack(fill=BOTH, expand=YES)
        b.pack(fill=BOTH, expand=YES)
        ddf.pack(side=LEFT, fill=BOTH, expand=YES)
        idf.pack(side=LEFT, fill=BOTH, expand=NO)
        
        f=Frame(self)
        self.entry=Entry(f)
        self.bind("<Return>",self.doSend)
        # self.bind("<KP-1>", self.doSend)
        self.button=Button(f,text=".",command=self.doSend)
        self.entry.pack(side=LEFT,expand=YES,fill=BOTH)
        self.button.pack(side=LEFT)

        self.nameLabel = Label(self, text="hellO")
        
        f.pack(side=BOTTOM, expand=NO, fill='x')
        self.happenings.pack(side=BOTTOM, expand=YES, fill=BOTH)
        midf.pack(side=BOTTOM, expand=YES, fill=BOTH)
        self.nameLabel.pack(side=TOP, expand=NO)
        
        self.protocol("WM_DELETE_WINDOW",self.close)

    def close(self):
        self.tk.quit()
        self.destroy()

    def loggedIn(self, m):
        self.remote = m
        login.withdraw()
        self.deiconify()
        
    def tryAgain(self, er):
        print 'oops',er
        showerror('Oops', er)
        
    def disco(self):
        print 'disconnected'


    def verbSuccess(self, nne):
        self.verbDone()

    def verbFailure(self, nne):
        if hasattr(nne, 'traceback'):
            self.seeEvent(nne.traceback)
        self.seeEvent(nne)
        self.verbDone()

    def verbDone(self):
        # unlock the text field
        pass 

    def doNow(self, verb):
        self.remote.execute(verb,
                            pbcallback = self.verbSuccess,
                            pberrback = self.verbFailure)

    def remote_seeEvent(self,text):
        self.happenings.insert('end',text+'\n')
        self.happenings.see('end')

    def reitem(self):
        self.itemsField.delete('1.0','end')
        self.itemsField.insert('end', string.join(self.items.values(), '\n'))

    def redesc(self):
        z = copy.copy(self.descriptions)
        m = z.get('__MAIN__','')
        e = z.get('__EXITS__','')

        try: del z['__MAIN__']
#.........这里部分代码省略.........
开发者ID:lhl,项目名称:songclub,代码行数:103,代码来源:tkfaucet.py

示例11: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import see [as 别名]

#.........这里部分代码省略.........
        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)
        
##################################################

    def open_command(self, event=None):
        file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Select a file')
        if file != None:
            contents = file.read()
            self.textWidget.insert("1.0",contents)
            file.close()

    def save_command(self, event=None):
        file = tkFileDialog.asksaveasfile(mode= 'w')
        if file != None:
            data = self.textWidget.get("1.0", END+'-1c')   #strip trailing \n at EOF
            file.write(data)
            file.close()

    def exit_program(self, event=None):
        if tkMessageBox.askokcancel("Quit", "Are you sure you want to quit?"):
            self.parent.destroy()
     
    #Opens up new text widget correctly but screws up closing the parent window via the menu       
    def new_command(self, event=None):
        win = Toplevel()
        SimpleTextEditor.__init__(self, win)
        
    #Currently under construction    
    def new_tab(self, event=None):
        #self.parent.add(self.textWidget, text="new tab", state='normal')
        new_frame = tk.Frame(self.parent)
        self.parent.add(new_frame, text='new', state='normal')
        
    def cut_command(self, event=None):
        text = self.textWidget.get(SEL_FIRST, SEL_LAST)
        self.textWidget.delete(SEL_FIRST, SEL_LAST)
        self.textWidget.clipboard_clear()
        self.textWidget.clipboard_append(text) 
        
    def copy_command(self, event=None):
        text = self.textWidget.get(SEL_FIRST, SEL_LAST)
        self.textWidget.clipboard_clear()
        self.textWidget.clipboard_append(text)
        
    def paste_command(self, event=None):
        try:
            text = self.textWidget.selection_get(selection= 'CLIPBOARD')
            self.textWidget.insert(INSERT, text)
        except TclError:
            pass
            
    def find_command(self):                  
        # Currently only works for highlighted text and will only find one match to the string, not all of the instances
        # Also does not work with key binding because of askstring hanging window bug :/
        target = askstring('SimpleEditor', 'Search String?')
        if target:
            where = self.textWidget.search(target, INSERT, END)
            if where:
                print where
                pastit = where + ('+%dc' % len(target))
                self.textWidget.tag_add(SEL, where, pastit)
                self.textWidget.mark_set(INSERT, pastit)
                self.textWidget.see(INSERT)
                self.textWidget.focus()       

    def about_command(self):
        label = tkMessageBox.showinfo("About", "A super duper simple text editor. It's now available through github, thanks to Jason!")                


    #dummy function as a place holder while constructing further functionality        
    def dummy_funct(self, event=None):
        print"The life of a function is often very lonely..."
开发者ID:austenLacy,项目名称:simple-OSX-text-editor,代码行数:104,代码来源:text_editor.py


注:本文中的ScrolledText.see方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。