tkinter-entry

How do I paste the copied text from keyboard in python

笑着哭i 提交于 2020-02-05 05:13:04
问题 If I execute this code, it works fine. But if I copy something using the keyboard ( Ctrl + C ), then how can I paste the text present on clipboard in any entry box or text box in python? import pyperclip pyperclip.copy('The text to be copied to the clipboard.') spam = pyperclip.paste() 回答1: You will want to pass pyperclip.paste() the same place you would place a string for your entry or text widget inserts. Take a look at this example code. There is a button to copy what is in the entry field

No input possible after tk

岁酱吖の 提交于 2020-01-22 03:46:19
问题 If have this piece of code: import Tkinter as tk import tkFileDialog menu = tk.Tk() res = tkFileDialog.askopenfilename() # un-/comment this line label = tk.Label(None, text="abc") label.grid(row=0, column=0, sticky=tk.W) entry = tk.Entry(None) entry.grid(row=0, column=1, sticky=tk.EW) res = menu.mainloop() Note: the askopenfilename is just a dummy input. So Just close it to get to the (now blocked) main window of TK. When I comment the askopenfilename everything works fine. But with the it, I

Set default cursor position inside entry widget in Tkinter Python

吃可爱长大的小学妹 提交于 2020-01-20 07:47:10
问题 I want to set the default cursor location inside the entry widget when I run the program. So when I run it I don't have to click inside the widget to start typing. Can anyone help me with this? Actually I'm new at programming import tkinter as tk root = tk.Tk() e = tk.Entry(root) e.pack() tk.mainloop() 回答1: Simply call the focus method for the widget: import tkinter as tk root = tk.Tk() e = tk.Entry(root) e.pack() e.focus() tk.mainloop() 来源: https://stackoverflow.com/questions/59499960/set

How to align label, entry in tkinter

牧云@^-^@ 提交于 2020-01-16 14:10:43
问题 I am really frustrated, trying to align a label and entry buttons in tkinter. I wanted to create a GUI like below The above page developed using page tool. I written a code to get the same kind of page, but it has lot of misalignment. from Tkinter import * root = Tk() root.title("Nokia Performance") root.geometry("583x591+468+158") root.title("NOKIA _ANSI Performance") root.configure(borderwidth="1") root.configure(relief="sunken") root.configure(background="#dbd8d7") root.configure(cursor=

How to align label, entry in tkinter

和自甴很熟 提交于 2020-01-16 14:10:39
问题 I am really frustrated, trying to align a label and entry buttons in tkinter. I wanted to create a GUI like below The above page developed using page tool. I written a code to get the same kind of page, but it has lot of misalignment. from Tkinter import * root = Tk() root.title("Nokia Performance") root.geometry("583x591+468+158") root.title("NOKIA _ANSI Performance") root.configure(borderwidth="1") root.configure(relief="sunken") root.configure(background="#dbd8d7") root.configure(cursor=

object has no attribute get [duplicate]

谁说胖子不能爱 提交于 2020-01-14 06:28:44
问题 This question already has answers here : Tkinter: AttributeError: NoneType object has no attribute <attribute name> (2 answers) Closed 6 years ago . I am working with the tkinter module in python 3.3 I am relatively new to this and am working with entry boxes. for some reason when I run the following code I get an error message saying AttributeError: 'NoneType' object has no attribute 'get'. Could someone explain to me why? I did a similar program with a single entry that workded just fine.

Python: How to get an updated Entry text to use in a command binded to it?

吃可爱长大的小学妹 提交于 2020-01-11 12:05:58
问题 Consider the following code: text = Entry(); text.pack() def show(e): print text.get() text.bind('<Key>', show) Let's say I put the letters ABC in the Entry, one by one. The output would be: >>> >>> A >>> AB Note that when pressing A, it prints an empty string. When I press B, it prints A, not AB. If i don't press anything after C, it will never be shown. It seems that the Entry content is only updated after the binded command has returned, so I can't use the actual Entry value in that

How to get value from entry(Tkinter), use it in formula and print the result it in label

不打扰是莪最后的温柔 提交于 2020-01-07 15:20:21
问题 from Tkinter import * top=Tk() First Value A that user will input A = Entry(top) A.grid(row=1, column=1) Second value B that user also inputs B = Entry(top) B.grid(row=1, column=2) Calculation - Now I want to add those values (Preferably values with decimal points) A1=float(A.get()) B1=float(B.get()) C1=A1+B1 Result - I want python to calculate result and show it to user when I input the first two values C = Label(textvariable=C1) C.grid(row=1, column=3) top.mainloop() 回答1: First off, welcome

How can I implement an `input` method in a Tkinter parent script, with the displayed prompt and return value being sent back to a child script?

二次信任 提交于 2020-01-06 08:04:16
问题 I have two scripts: Processor_child.py : Its purpose is to perform a number of data analysis and cleaning operations. This must perform the same operations when run alone (without Tkinter_parent.py) as it does when packaged into a GUI with Tkinter_parent.py. Tkinter_parent.py : Its purpose is to provide a GUI for those who can't use Processor_child directly. Where I'm struggling is to reproduce the python input function from Processor_child.py in the instance where these two are used together

How can I implement an `input` method in a Tkinter parent script, with the displayed prompt and return value being sent back to a child script?

旧街凉风 提交于 2020-01-06 08:03:29
问题 I have two scripts: Processor_child.py : Its purpose is to perform a number of data analysis and cleaning operations. This must perform the same operations when run alone (without Tkinter_parent.py) as it does when packaged into a GUI with Tkinter_parent.py. Tkinter_parent.py : Its purpose is to provide a GUI for those who can't use Processor_child directly. Where I'm struggling is to reproduce the python input function from Processor_child.py in the instance where these two are used together