I really need to change the size of textbox
but I keep on getting nothing. Here is code:
import tkinter as tk
from tkinter import *
from tkinter import ttk
class App(object):
def __init__(self, master, **kwarg):
self.master = master #self.master is calling 1 argument from function. = master is giving some sort of name u can call later from this function and class
self.open_chat()
def open_chat(self):
self.textbox = tk.Text(self.master, wrap = WORD) #wrap = WPRD moves the text to a new line as soon as it is reaching the end of pannel
#pannel for entering the text adding self to make it global for all the functions in the class
self.chatbox = tk.Text(self.master, wrap = "word")#showing the text
scroll = ttk.Scrollbar(self.master)
send = ttk.Button(self.master, text = "Send", command = self.send_a_message)
scroll.config(command=self.chatbox.yview)
self.chatbox.config(yscrollcommand=scroll.set, state = "disabled")
self.chatbox.grid(column=0, row=0,sticky='NSWE')
self.textbox.grid(column=0, row=1,sticky='NSWE')
send.grid(column=1,row=1,sticky='NSW')
scroll.grid(column=1, row=0, sticky='NSW')
def send_a_message(self):
self.chatbox.config(state="normal")
content = self.textbox.get('1.0','end') #from 0 first char to the end
self.chatbox.insert(END, content) #insert(END, text) to append text to the widget.
self.chatbox.config(state="disabled")
self.textbox.delete('1.0',END)
win = tk.Tk()
win.title ('My program') #program name on the left top corner
win.minsize(1000,500)
app = App(win)
win.mainloop()
I tried changing height and width, but in the end i got my widget to disappear
textbox
?width
andheight
cannot be configured using.grid()
. It is better to post a minimal reproducible example.