Set width and height in text box

4

To expand knowledge, I decided to start a new programming language, Python, and I caught the following situation, I have a screen with some elements and a textbox of type Entry .

To set the text box, I used the following code:

self.form = Entry(self.frame2)
self.form.pack()

I've given a basic search, however, the staff changes Entry to Text and sets width and heigth . I tried to use it, however when I use form.get() to capture the text, an error appears:

  

TypeError: get () missing 1 required positional argument: 'index1'

Would you like to know how to set width and height of Entry ?

    
asked by anonymous 11.09.2016 / 21:52

2 answers

2

The tkinter.Entry only allows you to set the width. Alternatively, tkinter.Text is used to make these changes.

  

TypeError: get() missing 1 required positional argument: 'index1'

Other than tkinter.Entry.get that returns all contents of Entry , tkinter.Text.get returns characters that are within a range, start and end , if end is omitted, only one character is returned. The message indicates that you must enter at least one argument, start .

To get all the content, do so:

conteudo = texto.get(1.0, END)

See an example:

from tkinter import *

root = Tk()
root.title('Calculadora')
root.geometry('300x300')

texto = Text(root, height = 4, width = 15)
texto.insert(INSERT, 'foo bar')
texto.pack()

conteudo = texto.get(1.0, END)
print (conteudo)

root.mainloop()
    
12.09.2016 / 00:31
-1

To have a textbox that can increase height, you need to use tkinter.tix , it's an extension of tkinter , there are lots of other visual objects in it, LabelEntry I remember, allows entry of text and to increase its width and height.

    
10.01.2017 / 16:55