Python tkinter.WORD Examples
The following are 27
code examples of tkinter.WORD().
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_DesignPattern.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 14 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Monty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) self.createButtons()
Example #2
Source File: tkXianYu.py From XianyuSdd with MIT License | 6 votes |
def user(self): # 用户信息 User = tk.LabelFrame(self.window, text="关键字任务", padx=10, pady=5) # 水平,垂直方向上的边距均为 10 User.place(x=30, y=100) self.userListBox = Listbox(User, width=50, height=9, ) self.userListBox.pack(side=LEFT) userScroBar = Scrollbar(User) userScroBar.pack(side=RIGHT, fill=Y) self.userListBox['yscrollcommand'] = userScroBar.set self.insert_userListbox() userScroBar['command'] = self.userListBox.yview # userScrotext = scrolledtext.ScrolledText(User, width=30, height=6, padx=10, pady=10, wrap=tk.WORD) # userScrotext.grid(columnspan=2, pady=10) Useroption = tk.LabelFrame(self.window, text="", padx=10, pady=5) # 水平,垂直方向上的边距均为 10 Useroption.place(x=30, y=300) tk.Button(Useroption, text="添加关键字", command=self.add_user).grid(column=0, row=1, padx=57, pady=5) tk.Button(Useroption, text="删除关键字", command=self.delete_use).grid(column=1, row=1, padx=57, pady=5) tk.Button(Useroption, text="一键开启", command=self.all_start).grid(column=0, row=3, padx=55, pady=5) tk.Button(Useroption, text="一键关闭", command=self.all_stop).grid(column=1, row=3, padx=55, pady=5) self.startBtn = tk.Button(Useroption, text="单项开启", command=self.start_spider) self.startBtn.grid(column=0, row=2, padx=55, pady=5) self.stopBtn = tk.Button(Useroption, text="单项关闭", command=self.stop_spider) self.stopBtn.grid(column=1, row=2, padx=55, pady=5)
Example #3
Source File: gui_mgr.py From plex-mpv-shim with MIT License | 6 votes |
def run(self): root = tk.Tk() self.root = root root.title("Application Log") text = tk.Text(root) text.pack(side=tk.LEFT, fill=tk.BOTH, expand = tk.YES) text.config(wrap=tk.WORD) self.text = text yscroll = tk.Scrollbar(command=text.yview) text['yscrollcommand'] = yscroll.set yscroll.pack(side=tk.RIGHT, fill=tk.Y) text.config(state=tk.DISABLED) self.update() root.mainloop() self.r_queue.put(("die", None)) # Q: OK. So you put Tkinter in it's own process. # Now why is Pystray in another process too?! # A: Because if I don't, MPV and GNOME Appindicator # try to access the same resources and cause the # entire application to segfault. # # I suppose this means I can put the Tkinter GUI back # into the main process. This is true, but then the # two need to be merged, which is non-trivial.
Example #4
Source File: asktext.py From textext with BSD 3-Clause "New" or "Revised" License | 6 votes |
def cb_word_wrap(self, widget=None, data=None): self._text_box.configure(wrap=Tk.WORD if self._word_wrap_tkval.get() else Tk.NONE) self._gui_config["word_wrap"] = self._word_wrap_tkval.get()
Example #5
Source File: asktext.py From textext with BSD 3-Clause "New" or "Revised" License | 5 votes |
def word_wrap_toggled_cb(self, action, sourceview): sourceview.set_wrap_mode(Gtk.WrapMode.WORD if action.get_active() else Gtk.WrapMode.NONE) self._gui_config["word_wrap"] = action.get_active()
Example #6
Source File: GUI_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') self.action = ttk.Button(self.monty, text="Click Me!") self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #==========================
Example #7
Source File: recipe-577637.py From code with MIT License | 5 votes |
def __init__(self, master): super().__init__(master) # Get the username and save list of found files. self.__user = getpass.getuser() self.__dirlist = set() # Create widgets. self.__log = tkinter.Text(self) self.__bar = tkinter.ttk.Scrollbar(self, orient=tkinter.VERTICAL, command=self.__log.yview) self.__ent = tkinter.ttk.Entry(self, cursor='xterm') # Configure widgets. self.__log.configure(state=tkinter.DISABLED, wrap=tkinter.WORD, yscrollcommand=self.__bar.set) # Create binding. self.__ent.bind('<Return>', self.create_message) # Position widgets. self.__log.grid(row=0, column=0, sticky=tkinter.NSEW) self.__bar.grid(row=0, column=1, sticky=tkinter.NS) self.__ent.grid(row=1, column=0, columnspan=2, sticky=tkinter.EW) # Configure resizing. self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) # Focus entry. self.__ent.focus_set() # Schedule message discovery. self.after_idle(self.get_messages)
Example #8
Source File: GUI_Not_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(): tabControl = ttk.Notebook(win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") monty = ttk.LabelFrame(tab1, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') action = ttk.Button(monty, text="Click Me!") action.grid(column=2, row=1) ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #======================
Example #9
Source File: Tooltip.py From Endless-Sky-Mission-Builder with GNU General Public License v3.0 | 5 votes |
def _add_tooltip_text(self, tooltip_window): tooltip = tk.Text(tooltip_window, relief=tk.SOLID, width=40, wrap=tk.WORD) height = math.ceil(len(self.text) / 40) + self.text.count('\n') tooltip.insert(tk.END, self.text) tooltip.config(state=tk.DISABLED, height=height) tooltip.pack(ipadx=1) #end _add_tooltip_text #end class Tooltip
Example #10
Source File: GUI_OOP.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 5 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') self.action = ttk.Button(self.monty, text="Click Me!") self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #==========================
Example #11
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self, master, **kwargs): super().__init__(**kwargs) self.master = master self.config(wrap=tk.WORD) # CHAR NONE self.tag_configure('find_match', background="yellow") self.find_match_index = None self.find_search_starting_index = 1.0 self.bind_events()
Example #12
Source File: GUI_Not_OOP.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 5 votes |
def createWidgets(): tabControl = ttk.Notebook(win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") monty = ttk.LabelFrame(tab1, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') action = ttk.Button(monty, text="Click Me!") action.grid(column=2, row=1) ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #======================
Example #13
Source File: GUI_DesignPattern.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 5 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Monty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) self.createButtons()
Example #14
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def body(self, master): self.editor = TkUtil.TextEdit.TextEdit(master, takefocus=False, exportselection=False, width=self.width, height=self.height, undo=False, wrap=tk.WORD, relief=None, borderwidth=0, setgrid=True) self.text = self.editor.text self.create_tags() self.populate_text() self.text.config(state=tk.DISABLED) self.editor.pack(fill=tk.BOTH, expand=True) return self.editor
Example #15
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_central_area(self): self.editor = Editor.Editor(self.master, set_status_text=self.set_status_text, font=self.create_font(), maxundo=0, undo=True, wrap=tk.WORD) self.editor.grid(row=1, column=1, sticky=(tk.N, tk.S, tk.W, tk.E), padx=PAD, pady=PAD) self.editor.text.bind("<<Selection>>", self.on_selection) self.editor.text.bind("<<Modified>>", self.on_modified) self.editor.text.bind("<KeyRelease>", self.on_moved, "+") self.editor.text.bind("<ButtonRelease>", self.on_moved, "+") self.editor.text.focus()
Example #16
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_central_area(self): self.editor = Editor.Editor(self.master, set_status_text=self.set_status_text, font=self.create_font(), maxundo=0, undo=True, wrap=tk.WORD) self.editor.grid(row=1, column=1, sticky=(tk.N, tk.S, tk.W, tk.E), padx=PAD, pady=PAD) self.editor.text.bind("<<Selection>>", self.on_selection) self.editor.text.bind("<<Modified>>", self.on_modified) self.editor.text.bind("<KeyRelease>", self.on_moved, "+") self.editor.text.bind("<ButtonRelease>", self.on_moved, "+") self.editor.text.focus()
Example #17
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self, master, **kwargs): super().__init__(**kwargs) self.master = master self.config(wrap=tk.WORD) # CHAR NONE self.tag_configure('find_match', background="yellow") self.find_match_index = None self.find_search_starting_index = 1.0 self.bind_events()
Example #18
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 5 votes |
def __init__(self, master, **kwargs): super().__init__(**kwargs) self.master = master self.config(wrap=tk.WORD) # CHAR NONE self.bind_events()
Example #19
Source File: tkXianYu.py From XianyuSdd with MIT License | 5 votes |
def log(self): # 日志 self.logMessage.put('欢迎使用【闲鱼信息采集器】') logInformation = tk.LabelFrame(self.window, text="日志", padx=10, pady=10) # 水平,垂直方向上的边距均为10 logInformation.place(x=450, y=100) self.logInformation_Window = scrolledtext.ScrolledText(logInformation, width=77, height=22, padx=10, pady=10, wrap=tk.WORD) self.logInformation_Window.grid()
Example #20
Source File: tkXianYu.py From XianyuSdd with MIT License | 5 votes |
def error_log(self): # 系统日志 error_logInformation = tk.LabelFrame(self.window, text="系统日志", padx=10, pady=10) # 水平,垂直方向上的边距均为10 error_logInformation.place(x=450, y=460) self.errorInformation_Window = scrolledtext.ScrolledText(error_logInformation, width=77, height=5, padx=10, pady=10, wrap=tk.WORD) self.errorInformation_Window.grid() # 菜单说明
Example #21
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 4 votes |
def display_tab1(): # Container frame to hold all other widgets monty = ttk.LabelFrame(display_area, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) # Adding a Label ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (1, 2, 4, 42, 100) numberChosen.grid(column=1, row=1) numberChosen.current(0) # Adding a Button action = ttk.Button(monty, text="Click Me!", command= lambda: clickMe(action, name, number)) action.grid(column=2, row=1) # Using a scrolled Text control scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) # Adding a Spinbox widget using a set of values spin = Spinbox(monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command= lambda: _spin(spin, scr)) spin.grid(column=0, row=2, sticky='W') # Adding another Button clear = ttk.Button(monty, text="Clear Text", command= lambda: clearScrol(scr)) clear.grid(column=2, row=2) # Adding more Feature Buttons startRow = 4 for idx in range(12): if idx < 2: colIdx = idx col = colIdx else: col += 1 if not idx % 3: startRow += 1 col = 0 b = ttk.Button(monty, text="Feature " + str(idx+1)) b.grid(column=col, row=startRow) #------------------------------------------
Example #22
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 4 votes |
def display_tab1(): # Container frame to hold all other widgets monty = ttk.LabelFrame(display_area, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) # Adding a Label ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (1, 2, 4, 42, 100) numberChosen.grid(column=1, row=1) numberChosen.current(0) # Adding a Button action = ttk.Button(monty, text="Click Me!", command= lambda: clickMe(action, name, number)) action.grid(column=2, row=1) # Using a scrolled Text control scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) # Adding a Spinbox widget using a set of values spin = Spinbox(monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command= lambda: _spin(spin, scr)) spin.grid(column=0, row=2, sticky='W') # Adding another Button clear = ttk.Button(monty, text="Clear Text", command= lambda: clearScrol(scr)) clear.grid(column=2, row=2) # Adding more Feature Buttons startRow = 4 for idx in range(12): if idx < 2: col = idx else: col += 1 if not idx % 3: startRow += 1 col = 0 b = ttk.Button(monty, text="Feature " + str(idx+1)) b.grid(column=col, row=startRow) #------------------------------------------
Example #23
Source File: ULGT04.py From mcculw with MIT License | 4 votes |
def create_widgets(self): '''Create the tkinter UI''' self.info_groupbox = tk.LabelFrame(self, text="Installed Devices") self.info_groupbox.pack( fill=tk.BOTH, anchor=tk.NW, padx=3, pady=3, expand=True) scrollbar = tk.Scrollbar(self.info_groupbox) scrollbar.pack(side=tk.RIGHT, fill=tk.Y, padx=3, pady=3) self.info_text = tk.Text( self.info_groupbox, width=50, height=15, wrap=tk.WORD, yscrollcommand=scrollbar.set) self.info_text.pack( side=tk.LEFT, fill=tk.BOTH, padx=3, pady=3, expand=True) scrollbar.config(command=self.info_text.yview) upper_button_frame = tk.Frame(self) upper_button_frame.pack(fill=tk.BOTH, anchor=tk.S) upper_button_frame.grid_columnconfigure(0, weight=1) upper_button_frame.grid_columnconfigure(1, weight=1) list_installed_button = tk.Button(upper_button_frame) list_installed_button["text"] = "List Installed" list_installed_button["command"] = self.list_installed list_installed_button.grid( row=0, column=0, padx=3, pady=3, sticky=tk.NSEW) list_installed_button = tk.Button(upper_button_frame) list_installed_button["text"] = "List Supported" list_installed_button["command"] = self.list_supported list_installed_button.grid( row=0, column=1, padx=3, pady=3, sticky=tk.NSEW) button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=0, padx=3, pady=3) # Start the example if this module is being run
Example #24
Source File: debugwindow.py From ttkwidgets with GNU General Public License v3.0 | 4 votes |
def __init__(self, master=None, title="Debug window", stdout=True, stderr=False, width=70, autohidescrollbar=True, **kwargs): """ Create a Debug window. :param master: master widget :type master: widget :param stdout: whether to redirect stdout to the widget :type stdout: bool :param stderr: whether to redirect stderr to the widget :type stderr: bool :param width: window width (in characters) :type width: int :param autohidescrollbar: whether to use an :class:`~ttkwidgets.AutoHideScrollbar` or a :class:`ttk.Scrollbar` :type autohidescrollbar: bool :param kwargs: options to be passed on to the :class:`tk.Toplevel` initializer """ self._width = width tk.Toplevel.__init__(self, master, **kwargs) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.protocol("WM_DELETE_WINDOW", self.quit) self.wm_title(title) self._oldstdout = sys.stdout self._oldstderr = sys.stderr if stdout: sys.stdout = self if stderr: sys.stderr = self self.menu = tk.Menu(self) self.config(menu=self.menu) self.filemenu = tk.Menu(self.menu, tearoff=0) self.filemenu.add_command(label="Save file", command=self.save) self.filemenu.add_command(label="Exit", command=self.quit) self.menu.add_cascade(label="File", menu=self.filemenu) self.text = tk.Text(self, width=width, wrap=tk.WORD) if autohidescrollbar: self.scroll = AutoHideScrollbar(self, orient=tk.VERTICAL, command=self.text.yview) else: self.scroll = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.text.yview) self.text.config(yscrollcommand=self.scroll.set) self.text.bind("<Key>", lambda e: "break") self._grid_widgets()
Example #25
Source File: chatwindow.py From Tkinter-GUI-Programming-by-Example with MIT License | 4 votes |
def __init__(self, master, friend_name, friend_username, friend_avatar, **kwargs): super().__init__(**kwargs) self.master = master self.title(friend_name) self.geometry('540x640') self.minsize(540, 640) self.friend_username = friend_username self.right_frame = tk.Frame(self) self.left_frame = tk.Frame(self) self.bottom_frame = tk.Frame(self.left_frame) self.messages_area = tk.Text(self.left_frame, bg="white", fg="black", wrap=tk.WORD, width=30) self.scrollbar = ttk.Scrollbar(self.left_frame, orient='vertical', command=self.messages_area.yview) self.messages_area.configure(yscrollcommand=self.scrollbar.set) self.text_area = tk.Text(self.bottom_frame, bg="white", fg="black", height=3, width=30) self.text_area.smilies = [] self.send_button = ttk.Button(self.bottom_frame, text="Send", command=self.send_message, style="send.TButton") self.smilies_image = tk.PhotoImage(file="smilies/mikulka-smile-cool.png") self.smilie_button = ttk.Button(self.bottom_frame, image=self.smilies_image, command=self.smilie_chooser, style="smilie.TButton") self.profile_picture = tk.PhotoImage(file="images/avatar.png") self.friend_profile_picture = tk.PhotoImage(file=friend_avatar) self.profile_picture_area = tk.Label(self.right_frame, image=self.profile_picture, relief=tk.RIDGE) self.friend_profile_picture_area = tk.Label(self.right_frame, image=self.friend_profile_picture, relief=tk.RIDGE) self.left_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.messages_area.pack(side=tk.TOP, fill=tk.BOTH, expand=1) self.messages_area.configure(state='disabled') self.right_frame.pack(side=tk.LEFT, fill=tk.Y) self.profile_picture_area.pack(side=tk.BOTTOM) self.friend_profile_picture_area.pack(side=tk.TOP) self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X) self.smilie_button.pack(side=tk.LEFT, pady=5) self.text_area.pack(side=tk.LEFT, fill=tk.X, expand=1, pady=5) self.send_button.pack(side=tk.RIGHT, pady=5) self.configure_styles() self.bind_events() self.load_history() self.protocol("WM_DELETE_WINDOW", self.close) self.listening_thread = None self.listen()
Example #26
Source File: chatwindow.py From Tkinter-GUI-Programming-by-Example with MIT License | 4 votes |
def __init__(self, master, friend_name, friend_avatar, **kwargs): super().__init__(**kwargs) self.master = master self.title(friend_name) self.geometry('540x640') self.minsize(540, 640) self.right_frame = tk.Frame(self) self.left_frame = tk.Frame(self) self.bottom_frame = tk.Frame(self.left_frame) self.messages_area = tk.Text(self.left_frame, bg="white", fg="black", wrap=tk.WORD, width=30) self.scrollbar = ttk.Scrollbar(self.left_frame, orient='vertical', command=self.messages_area.yview) self.messages_area.configure(yscrollcommand=self.scrollbar.set) self.text_area = tk.Text(self.bottom_frame, bg="white", fg="black", height=3, width=30) self.text_area.smilies = [] self.send_button = ttk.Button(self.bottom_frame, text="Send", command=self.send_message, style="send.TButton") self.smilies_image = tk.PhotoImage(file="smilies/mikulka-smile-cool.png") self.smilie_button = ttk.Button(self.bottom_frame, image=self.smilies_image, command=self.smilie_chooser, style="smilie.TButton") self.profile_picture = tk.PhotoImage(file="images/avatar.png") self.friend_profile_picture = tk.PhotoImage(file=friend_avatar) self.profile_picture_area = tk.Label(self.right_frame, image=self.profile_picture, relief=tk.RIDGE) self.friend_profile_picture_area = tk.Label(self.right_frame, image=self.friend_profile_picture, relief=tk.RIDGE) self.left_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.messages_area.pack(side=tk.TOP, fill=tk.BOTH, expand=1) self.messages_area.configure(state='disabled') self.right_frame.pack(side=tk.LEFT, fill=tk.Y) self.profile_picture_area.pack(side=tk.BOTTOM) self.friend_profile_picture_area.pack(side=tk.TOP) self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X) self.smilie_button.pack(side=tk.LEFT, pady=5) self.text_area.pack(side=tk.LEFT, fill=tk.X, expand=1, pady=5) self.send_button.pack(side=tk.RIGHT, pady=5) self.configure_styles() self.bind_events()
Example #27
Source File: chatwindow.py From Tkinter-GUI-Programming-by-Example with MIT License | 4 votes |
def __init__(self, master, friend_name, friend_username, friend_avatar, **kwargs): super().__init__(**kwargs) self.master = master self.title(friend_name) self.geometry('540x640') self.minsize(540, 640) self.friend_username = friend_username self.right_frame = tk.Frame(self) self.left_frame = tk.Frame(self) self.bottom_frame = tk.Frame(self.left_frame) self.messages_area = tk.Text(self.left_frame, bg="white", fg="black", wrap=tk.WORD, width=30) self.scrollbar = ttk.Scrollbar(self.left_frame, orient='vertical', command=self.messages_area.yview) self.messages_area.configure(yscrollcommand=self.scrollbar.set) self.text_area = tk.Text(self.bottom_frame, bg="white", fg="black", height=3, width=30) self.text_area.smilies = [] self.send_button = ttk.Button(self.bottom_frame, text="Send", command=self.send_message, style="send.TButton") self.smilies_image = tk.PhotoImage(file="smilies/mikulka-smile-cool.png") self.smilie_button = ttk.Button(self.bottom_frame, image=self.smilies_image, command=self.smilie_chooser, style="smilie.TButton") self.profile_picture = tk.PhotoImage(file="images/avatar.png") self.friend_profile_picture = tk.PhotoImage(file=friend_avatar) self.profile_picture_area = tk.Label(self.right_frame, image=self.profile_picture, relief=tk.RIDGE) self.friend_profile_picture_area = tk.Label(self.right_frame, image=self.friend_profile_picture, relief=tk.RIDGE) self.left_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.messages_area.pack(side=tk.TOP, fill=tk.BOTH, expand=1) self.messages_area.configure(state='disabled') self.right_frame.pack(side=tk.LEFT, fill=tk.Y) self.profile_picture_area.pack(side=tk.BOTTOM) self.friend_profile_picture_area.pack(side=tk.TOP) self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X) self.smilie_button.pack(side=tk.LEFT, pady=5) self.text_area.pack(side=tk.LEFT, fill=tk.X, expand=1, pady=5) self.send_button.pack(side=tk.RIGHT, pady=5) self.configure_styles() self.bind_events() self.load_history()