logo
down
shadow

Receiveing input from Python's tkinter entry widget and displaying it in a label


Receiveing input from Python's tkinter entry widget and displaying it in a label

By : alphurdex
Date : November 18 2020, 01:01 AM
wish of those help I amended your code, so that it executes at least, and hopefully in a way you want.
code :
from Tkinter import *

class Input(Frame):
    def __init__(self, parent=None, **kw):
        Frame.__init__(self, parent, background="white")
        self.parent = parent
        self.entdat = StringVar()
        self.makeWidgets()

    def makeWidgets(self):
        self.ol = Label(text="Objective:")
        self.ol.pack(side=TOP)
        self.ew = Entry(textvariable=self.entdat)
        self.ew.pack(side=TOP)
        self.b = Button(text="OK", command=self.clicked)
        self.b.pack(side=TOP)

    def clicked(self):
        self.dat = Label(self, textvariable=self.entdat )
        self.dat.pack(side=TOP)
        self.distroy_Widget()


    def distroy_Widget(self):
        self.ew.destroy()
        self.ol.destroy()
        self.b.destroy()

def main():
    root = Tk()
    root.geometry("240x135+25+50")
    tm = Input(root)
    tm.pack(side=TOP)

    root.mainloop()

if __name__ == '__main__':
    main()


Share : facebook icon twitter icon
Tkinter, Python: How do I save text entered in the Entry widget? How do I move a label?

Tkinter, Python: How do I save text entered in the Entry widget? How do I move a label?


By : Divesh Otwani
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Part 1...
You are currently defining your entry widget as a local variable inside the ingredients method (i.e. these are variables that only exist inside the method). To maintain a reference to the entry widget you are creating, you can assign it as an instance attribute to your Recipie object.
code :
e = Tkinter.Entry(self)
e.pack()
e.focus_set()
self.e = Tkinter.Entry(self)
self.e.pack()
self.e.focus_set()
print e.get()
print self.e.get()
import Tkinter as tk

class IngredientAdder(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.geometry("500x500+0+0")
        self.init_gui()

    # function to add new ingredients
    def add_ingredient_entry(self):
        entry = tk.Entry(self)
        entry.pack(side=tk.TOP)
        self.ingredient_entries.append(entry)

    # get contents of all entry boxes
    def save_recipe(self):
        for ingredient in self.ingredient_entries:
            print ingredient.get()
        print "[Recipe saved]"

    # build initial widgets 
    def init_gui(self):

        # this is a list of ingredients entry boxes
        self.ingredient_entries = []

        # put a label at the top of the window and anchor it there
        tk.Label(self,text="Ingredients").pack(anchor=tk.N,side=tk.TOP)

        # Put these two buttons at the bottom of the window and anchor them there
        tk.Button(self,text="Save recipe",command=self.save_recipe).pack(anchor=tk.S,side=tk.BOTTOM)
        tk.Button(self,text="Add ingredient",command=self.add_ingredient_entry).pack(anchor=tk.S,side=tk.BOTTOM)

        # new ingredients will be added between the label and the buttons 
        self.add_ingredient_entry()

cookbook = IngredientAdder()
cookbook.mainloop()
set Tkinter label widget below entry widget

set Tkinter label widget below entry widget


By : datocrats.org
Date : March 29 2020, 07:55 AM
To fix this issue I am relatively new to Tkinter and I am trying to create a GUI with three horizontally aligned entry widgets and three corresponding label widgets. I am struggling with how to put the label widgets below the entry widgets without disturbing the alignment of the entry boxes (i.e., pack side = LEFT). Here is an example snapshot of the GUI without the labels below the entry boxes: , You can use the grid geometry manager for this:
code :
from sys import exit
from Tkinter import *
from subprocess import Popen, PIPE
from time import sleep
from os.path import exists
import os, time, sys, ttk

#Initialize Tkinter by creating Tk root widget, which is a window with a
Root = Tk()
Root.title("VIZ TOOL")

class Command:
    def __init__(self, func, *args, **kw):
        self.func = func
        self.args = args
        self.kw = kw
    def __call__(self, *args, **kw):
        args = self.args+args
        kw.update(self.kw)
        self.func(*args, **kw)

 #Script definitions#

def quitter():
    exit(0)


#Button organization and layout#


Sub0 = Frame(Root)
Sub = Frame(Sub0)

#X mesh node
Label(Sub, text = "Create x mesh nodes").grid(columnspan=3)

#x min text box area
v1=StringVar()
#Create entry widge to get user input, in this case a text string for the x      

Entry(Sub, textvariable=v1).grid(row=1, column=0)
Label(Sub, text = "min").grid(row=2, column=0)


#x max text box area
v2=StringVar()
Entry(Sub, textvariable=v2).grid(row=1, column=1)
Label(Sub, text = "max").grid(row=2, column=1)
#x step text box area
v3=StringVar()
Entry(Sub, textvariable=v3).grid(row=1, column=2)
Label(Sub, text = "step increment").grid(row=2, column=2)

Sub.pack(side = TOP)
Frame(Sub0,height=1, relief = GROOVE, bg="black").pack(side = TOP, fill = 
BOTH, pady= 5)


#GUI Organization#


Sub0.pack(side = TOP, padx = 10)

Button(Root, text = "Quit", command = quitter).pack(side = TOP, pady = 5)

#The window will not appear until we enter the Tkinter event loop. Script

Root.mainloop()
Root.option_add("*Entry.Width", 5) #10 is default
Python 3 Tkinter appending label to print user input from entry label

Python 3 Tkinter appending label to print user input from entry label


By : DAldredge
Date : March 29 2020, 07:55 AM
This might help you Hey guys I have just started learning about GUI's and in particular just started using tkinter. I have spent hours searching forums for what I believe should be an obvious and simple solution and found a few people asking similar questions but i failed to understand the solutions. Basically I am just trying to get the user to input a letter with an entry widget and display that on a label when the go button is pressed. If anyone could explain to me how to do this I would be extremely grateful. , You should .get() what StringVar contains when button is clicked.
code :
def gobutton(): #if you don't plan to pass any parameters, *args is unnecesarry
    print_label['text'] += letter.get()
def getMethod():
    lbl.configure(text=ent.get())
    #or 
    #lbl["text"] = ent.get()

root = tk.Tk()

tk.Button(root, text="Get Entry", command=getMethod).pack()
ent = tk.Entry(root)
lbl = tk.Label(root, text = "Before click")
lbl.pack()
ent.pack()
root.mainloop()
Python/Tkinter: How to change Label widget with using Entry widget?

Python/Tkinter: How to change Label widget with using Entry widget?


By : HardyShah
Date : March 29 2020, 07:55 AM
Hope that helps Both Entry and Label accept a variable as a parameter. The entry will set the variable value and the Label will get it.
code :
import tkinter as tk


class App(tk.Frame):
    def __init__(self, master=None):
        tk.Frame.__init__(self, master)

        self.var = tk.StringVar()

        self.entry = tk.Entry(master=self, textvariable=self.var)
        self.entry.pack(side="left")

        self.label = tk.Label(master=self, textvariable=self.var)
        self.label.pack(side="left")

        self.configure_widgets()
        self.pack()

    def configure_widgets(self):
        self.label.configure(textvariable=self.var)


if __name__ == "__main__":
    root = tk.Tk()
    example = App(master=root)
    example.mainloop()
Replace python tkinter label widget with entry widget

Replace python tkinter label widget with entry widget


By : Hard_boildu
Date : March 29 2020, 07:55 AM
it fixes the issue The simplest solution is not to replace it, but to instead overlay it. This is one circumstance where place is very useful.
For example:
code :
def replace_with_entry(self, event):
    widget = event.widget
    entry_widget = Entry(widget)
    entry_widget.place(x=0, y=0, anchor="nw", relwidth=1.0, relheight=1.0)
    entry_widget.bind("<Return>", self.remove_entry)
    entry_widget.focus_set()

def remove_entry(self, event):
    entry = event.widget
    label = entry.place_info()["in"]
    label.configure(text=entry.get())
    entry.destroy()
Related Posts Related Posts :
  • ModuleNotFoundError: No module named 'users'
  • Interpolating with multiple y-values
  • Import warning PACKAGE.egg is added to sys.path
  • Is there a key for the default namespace when creating dictionary for use with xml.etree.ElementTree.findall() in Python
  • Using fill_between() with a Pandas Data Series
  • How to build a lookup table for tri-linear interpolation in NumPy?
  • Matrix vector multiplication along array axes
  • Can a cookiejar object be pickled?
  • __init__.py in project folder breaks nose tests
  • Comparing times with sub-second accuracy
  • advanced search using HayStack + Solr in Django?
  • Base test case class for python unittest
  • The PyData Ecosystem
  • Finding unique entries with oldest time stamp
  • Custom filesize format with Python Humanize?
  • Use `tf.image.resize_image_with_crop_or_pad` to resize numpy array
  • Sum number of occurences of string per row
  • Calculating 'Diagonal Distance' in 3 dimensions for A* path-finding heuristic
  • porting PyGST app to GStreamer1.0 + PyGI
  • Connection refused in Tornado test
  • How much time does take train SVM classifier?
  • Turning a string into list of positive and negative numbers
  • Python lists get specific length of elements from index
  • python.exe version 3.3.2 64 & 32 crash while creating .exe file on win 7 64 & 32 with cx_Freeze
  • Efficient nearest neighbour search for sparse matrices
  • django filter_horizontal can't display
  • How to install FLANN and pyflann on Windows
  • How can I plot the same figure standalone and in a subplot in Matplotlib?
  • read-only cells in ipython notebook
  • filling text file with dates
  • error:AttributeError: 'super' object has no attribute 'db_type' when run "python manage.py syncdb" in django
  • python imblearn make_pipeline TypeError: Last step of Pipeline should implement fit
  • Write to csv: columns are shifted when item in row is empty (Python)
  • DuckDuckGo search returns 'List Index out of range'
  • Python function which can transverse a nested list and print out each element
  • Python installing xlwt module error
  • Python mayavi: Adding points to a 3d scatter plot
  • Making a basic web scraper in Python with only built in libraries - Python
  • How to calculate the angle of the sun above the horizon using pyEphem
  • Fix newlines when writing UTF-8 to Text file in python
  • How to convert backward slash command in python to run on Linux
  • PyCharm Code Inspection doesn't include PEP 8
  • How can I use Python namedtuples to insert rows into mySQL database
  • Increase / Decrease Mac Address in Python from String
  • Scrollable QLabel image in PyQt5
  • (Python 2.7) Access variable from class with accessor/mutator
  • Why does "from [Module] import [Something]" takes more time than "import [Module"
  • jira python oauth: how to get the parameters for authentication?
  • Python - How to specify a relative path by jumping a subdirectory?
  • Extract scientific number from string
  • Scrapy: Python cannot find the spider
  • get the values in a given radius from numpy array
  • Is it possible to duplicate a pipe in Python, so that it has one write end but two read ends?
  • Why does wget use Firefox cookies to login on an authenticated webpage?
  • python import behaviour: different objects from same file?
  • Create YoY Graph with Matplotlib
  • Safe use of eval() or alternatives - python
  • Unix change desktop background seamlessly
  • Profiling Python code that uses multiprocessing?
  • How to query a database after render_template
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org