tkinter-entry

Python Tkinter Entry validate

寵の児 提交于 2019-12-24 19:36:51
问题 I am writing a program in Python 3.6 using Tkinter where a customer has multiple(11) entry fields. I want these entry fields to only accept integers and also be able to define the maximum amount of characters. I already have a function that does this. But this function only works for one entry field. I have tried entering variables with calling the function so it changes another entry field for example. I was not able to do this. This is the function I have that works with 1 entry field. def

Tkinter .set and .get not working in a window inside a window

試著忘記壹切 提交于 2019-12-24 18:13:12
问题 from tkinter import * def fun(): trywindow=Tk() s=StringVar() entry=Entry(trywindow, textvariable=s) s.set("print") entry.pack() trywindow.mainloop() root=Tk() fun() root.mainloop() According to me after executing this code 2nd window should show enter block with text written in it "PRINTED" but it is blank. 回答1: As mentioned in the comments, using multiple instances of Tk() is discouraged. It leads to behavior that people don't expect, of which this question is a great example. As explained

how increase font size in text widget?

99封情书 提交于 2019-12-24 01:05:06
问题 When I increase the size of the font using following code, it also increase the size of the widget. Is it possitlbe to increase font size by keeping the size of the text widget constant? Thank You A11 = tkinter.Text(top, height=28, width=70,background = "#02e0a1") labelfont = ('times', 20, 'bold') A11.config(font = labelfont) 回答1: If you force the GUI window to be a specific size, then changing the font of a text widget won't cause the text widget to grow*. It usually helps to set the width

Using Entry box with Tkinter in Grid manager?

依然范特西╮ 提交于 2019-12-23 22:08:00
问题 I'm trying to make a basic GUI using Tkinter and have an entry box next to my label using a Grid manager, but the window is not showing when I run my program if I use .grid() with my Entry object. It does work when I use .pack(), which is strange because I heard not to use .pack() when I have other things using .grid() in the same widget. But I do want to use .grid() because I want to be able to organize it how I want to. Code is below, I'm having trouble with Entry object showName. The

Python get focused entry name

北战南征 提交于 2019-12-23 13:21:18
问题 I'm trying to make a entry value increase or decrease whenever the up or down arrow key is pressed. To do this i need to first find which entry that's in focus, and i'm trying to do that " .focus_get() ". The problem is that i can't figure out how it works or what its returning. It is returning 1 unique number for each entry, something like: ".45191744" but this number changes each time i run the program. The following numbers is for the last 5 attempts, when running the code. ".50518728" "

Python 3: Tkinter: How to change Entry.get() into an integer

三世轮回 提交于 2019-12-22 09:10:56
问题 I am coding a simple program which converts imperial units into metric units . However, when I use an Entry.get() command, I need to convert it to an integer and when I try to do that I get this error: Traceback (most recent call last): File "C:/Users/Bill/converter.py", line 18, in <module> conversion=int(e.get()) ValueError: invalid literal for int() with base 10: '' I tried running an extremely basic version of what I was doing (which is written below), but that still caused the same error

How to get the text of Checkbuttons?

亡梦爱人 提交于 2019-12-20 07:55:21
问题 Checkbuttons gets generated dynamically and they are getting text from a python list. I need a logic for capturing selected checkbuttons text . As per my research everywhere they are returning the state of checkbox instead of text. Please help. cb_list =['pencil','pen','book','bag','watch','glasses','passport','clothes','shoes','cap'] try: r = 0 cl = 1 for op in cb_list: cb = Checkbutton(checkbutton_frame, text=op, relief=RIDGE) cb.grid(row=r, column=cl, sticky="W") r = r + 1 except Exception

How to get the text of Checkbuttons?

岁酱吖の 提交于 2019-12-20 07:54:06
问题 Checkbuttons gets generated dynamically and they are getting text from a python list. I need a logic for capturing selected checkbuttons text . As per my research everywhere they are returning the state of checkbox instead of text. Please help. cb_list =['pencil','pen','book','bag','watch','glasses','passport','clothes','shoes','cap'] try: r = 0 cl = 1 for op in cb_list: cb = Checkbutton(checkbutton_frame, text=op, relief=RIDGE) cb.grid(row=r, column=cl, sticky="W") r = r + 1 except Exception

Why does calling entry.get() give me “invalid command name”?

a 夏天 提交于 2019-12-19 10:07:08
问题 This is my code: def ask(what,why): root=Tk() root.title(why) label=Label(root,text=what) label.pack() entry=Entry(root) entry.pack() button=Button(root,text='OK',command=root.destroy) button.pack() root.mainloop() return entry.get() And when I call the code: print(ask('Name:','Hello!')) I get: Traceback (most recent call last): File "C:\gui.py", line 16, in <module> ask('Name:','Hello!') File "C:\gui.py", line 15, in ask return entry.get() File "C:\Python34\lib\tkinter\__init__.py", line

How to connect a variable to Entry widget?

安稳与你 提交于 2019-12-18 04:47:15
问题 I'm trying to associate a variable with a Tkinter entry widget, in a way that: Whenever I change the value (the "content") of the entry, mainly by typing something into it, the variable automatically gets assigned the value of what I've typed. Without me having to push a button "Update value " or something like that first. Whenever the variable gets changed (by some other part of the programm), I want the entry value displayed to be adjusted automatically. I believe that this could work via