tkinter-entry

Make Tkinter Entry widget readonly but selectable

若如初见. 提交于 2020-07-03 07:56:25
问题 Is there any way to make the Tkinter Entry widget so that text can be highlighted and copied, but not changed? 回答1: Use the state option "readonly" : state= The entry state: NORMAL, DISABLED, or “readonly” (same as DISABLED, but contents can still be selected and copied). Default is NORMAL. Note that if you set this to DISABLED or “readonly”, calls to insert and delete are ignored. (state/State) 来源: https://stackoverflow.com/questions/3680301/make-tkinter-entry-widget-readonly-but-selectable

Showing a greyed out default text in a tk.Entry

半城伤御伤魂 提交于 2020-06-10 02:06:14
问题 I was wondering how I would add some sort of background text in the input box defined in the code attached here under: The box could say "Example: Joe Bloggs" but greyed out and then remove when the user clicks inside the box? Hope this isn't too tricky. # ************ Retrieve user's Full name ************ tk.Label(self, text='First and last name:').grid(sticky='e') # Label self.full_name_entry = tk.Entry(self, bg='white', width=30) # Entry box self.full_name_entry.grid(row=1, column=1, pady

How do I get this validation code to limit the character length and only allow numbers

你离开我真会死。 提交于 2020-05-07 09:28:21
问题 I am creating a date of birth entry form for my application, and want to make it so that they can only enter numbers, and to limit the numbers inputted to the maximum amount needed e.g. 2 for day. When I tried to implement this, it doesn't even let me do anything in the entry widgets. How can I limit the character length and only accept numbers? def onlyNumbers(char): if (len(dayE.get()) >= 2): return False elif (len(monthE.get()) >= 2): return False elif (len(yearE.get()) >= 4): return False

How do I get this validation code to limit the character length and only allow numbers

偶尔善良 提交于 2020-05-07 09:24:22
问题 I am creating a date of birth entry form for my application, and want to make it so that they can only enter numbers, and to limit the numbers inputted to the maximum amount needed e.g. 2 for day. When I tried to implement this, it doesn't even let me do anything in the entry widgets. How can I limit the character length and only accept numbers? def onlyNumbers(char): if (len(dayE.get()) >= 2): return False elif (len(monthE.get()) >= 2): return False elif (len(yearE.get()) >= 4): return False

Entry Widget Justification - text longer than widget

我的未来我决定 提交于 2020-02-08 08:42:01
问题 I have an entry widget with a width of 60 chars. The widget is right justified. When the textvariable associated with the entry widget contains less than 60 chars, the entry widget shows the text right justified. When the textvariable is longer than 60 characters the text is left justified. I cannot insert the text from a position before the start, i.e. -34, so is this impossible to achieve? I want to be able to display the end of the text if it's longer than the entry widget. self.infile_var

Entry Widget Justification - text longer than widget

无人久伴 提交于 2020-02-08 08:38:22
问题 I have an entry widget with a width of 60 chars. The widget is right justified. When the textvariable associated with the entry widget contains less than 60 chars, the entry widget shows the text right justified. When the textvariable is longer than 60 characters the text is left justified. I cannot insert the text from a position before the start, i.e. -34, so is this impossible to achieve? I want to be able to display the end of the text if it's longer than the entry widget. self.infile_var