Python tkinter.scrolledtext() Examples
The following are 1
code examples of tkinter.scrolledtext().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: gui.py From Telethon with MIT License | 4 votes |
def __init__(self, client, *args, **kwargs): super().__init__(*args, **kwargs) self.cl = client self.me = None self.title(TITLE) self.geometry(SIZE) # Signing in row; the entry supports phone and bot token self.sign_in_label = tkinter.Label(self, text='Loading...') self.sign_in_label.grid(row=0, column=0) self.sign_in_entry = tkinter.Entry(self) self.sign_in_entry.grid(row=0, column=1, sticky=tkinter.EW) self.sign_in_entry.bind('<Return>', self.sign_in) self.sign_in_button = tkinter.Button(self, text='...', command=self.sign_in) self.sign_in_button.grid(row=0, column=2) self.code = None # The chat where to send and show messages from tkinter.Label(self, text='Target chat:').grid(row=1, column=0) self.chat = tkinter.Entry(self) self.chat.grid(row=1, column=1, columnspan=2, sticky=tkinter.EW) self.columnconfigure(1, weight=1) self.chat.bind('<Return>', self.check_chat) self.chat.bind('<FocusOut>', self.check_chat) self.chat.focus() self.chat_id = None # Message log (incoming and outgoing); we configure it as readonly self.log = tkinter.scrolledtext.ScrolledText(self) allow_copy(self.log) self.log.grid(row=2, column=0, columnspan=3, sticky=tkinter.NSEW) self.rowconfigure(2, weight=1) self.cl.add_event_handler(self.on_message, events.NewMessage) # Save shown message IDs to support replying with ".rN reply" # For instance to reply to the last message ".r1 this is a reply" # Deletion also works with ".dN". self.message_ids = [] # Save the sent texts to allow editing with ".s text/replacement" # For instance to edit the last "hello" with "bye" ".s hello/bye" self.sent_text = collections.deque(maxlen=10) # Sending messages tkinter.Label(self, text='Message:').grid(row=3, column=0) self.message = tkinter.Entry(self) self.message.grid(row=3, column=1, sticky=tkinter.EW) self.message.bind('<Return>', self.send_message) tkinter.Button(self, text='Send', command=self.send_message).grid(row=3, column=2) # Post-init (async, connect client) self.cl.loop.create_task(self.post_init())