logo
down
shadow

Dependant widgets in tkinter


Dependant widgets in tkinter

Content Index :

Dependant widgets in tkinter
Tag : python , By : Dave M
Date : November 24 2020, 03:01 PM

To fix the issue you can do As the docs mention,
from tkinter.ttk import Labelframe
import tkinter as tk 

class FilterWidget(Labelframe):
    def __init__(self, parent, label):
        Labelframe.__init__(self, parent, text=label)
        self._entry = tk.Entry(self)
        self._entry.grid(row=0, column=0)

        self._var = tk.IntVar()
        callback = lambda: print(self._entry.get(), self._var.get())
        checkbox = tk.Checkbutton(self, variable=self._var, command=callback)
        checkbox.grid(row=0, column=1)

root = tk.Tk()

source_filter = FilterWidget(root, "Source")
source_filter.grid(row=0, column=0)
level_filter = FilterWidget(root, "Severity")
level_filter.grid(row=0, column=1)

root.mainloop()

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Widgets in a Tkinter popup taking Tab focus from widgets in another window


Tag : python , By : Joshua Johnson
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Solution: When creating the entry widgets in the popup, set their exportselection property to 0. Then selecting them won't affect any other selections.

Constantly Update Label Widgets From Entry Widgets TKinter


Tag : python , By : snk
Date : March 29 2020, 07:55 AM
I wish did fix the issue. while True will not work because mainloop() is some kind of while True loop and it works all the time till you stop program.
from Tkinter import *

#------------------------------------

def my_validater():
    new_text = e1.get() + e2.get()

    # different method to set label text (without StringVar)
    #t['text'] = new_text
    t.config(text=new_text)

    # validater have to return True or False
    return True 

#------------------------------------

top = Tk()

#---

t = Label(top)
t.pack()

#---

e1 = Entry(top, validate='key', validatecommand=my_validater) # validate every key
e1.pack()

#---

e2 = Entry(top, validate='key', validatecommand=my_validater) # validate every key
e2.pack()

#---

top.mainloop()

#------------------------------------
from Tkinter import *

#------------------------------------

def my_tracer(a, b, c): # trace send 3 arguments to my_tracer
    #print a, b, c

    # using StringVar to get and set text
    new_text = e1_var.get() + e2_var.get()
    t_var.set(new_text)

#------------------------------------

top = Tk()

#---

t_var = StringVar() # or StringVar(top) 

t = Label(top, textvariable=t_var)
t.pack()

#---

e1_var = StringVar() # or StringVar(top) 
e1_var.trace('w', my_tracer) # run my_tracer if value was changed (w = write)

e1 = Entry(top, textvariable=e1_var)
e1.pack()

#---

e2_var = StringVar() # or StringVar(top) 
e2_var.trace('w', my_tracer) # run my_tracer if value was changed (w = write)

e2 = Entry(top, textvariable=e2_var)
e2.pack()

#---

top.mainloop()

#------------------------------------
from Tkinter import *

#------------------------------------

def my_bind(event): # bind send 1 argument to my_bind
    # different type of event can have different atributes
    #print event, event.widget, event.char, event.keysym, event.keycode

    new_text = e1.get() + e2.get()
    t.config(text=new_text)

#------------------------------------

top = Tk()

#---

t = Label(top)
t.pack()

#---

e1 = Entry(top)
e1.pack()

e1.bind('<Key>', my_bind)

#---

e2 = Entry(top)
e2.pack()

e2.bind('<Key>', my_bind)

#---

top.mainloop()

#------------------------------------
from Tkinter import *

#------------------------------------

def my_after(): 
    new_text = e1.get() + e2.get()

    t.config(text=new_text)

    # call again after 100 ms
    top.after(100, my_after)

#------------------------------------

top = Tk()

#---

t = Label(top)
t.pack()

#---

e1 = Entry(top)
e1.pack()

#---

e2 = Entry(top)
e2.pack()

#---

# call first time 
my_after()

# call first time after 100 ms
#top.after(100, my_after)


#---

top.mainloop()

#------------------------------------

Tkinter treeview widgets not properly aligned/added space between widgets


Tag : python , By : johntynan
Date : March 29 2020, 07:55 AM
may help you . Put the style configuration in the __init__() function and the effect will go away. I'm not clear as to why this works.
def __init__(self):
...
    s = ttk.Style()
    s.configure('MyStyle.Treeview', rowheight=20)

Tkinter - Maximizing and minimizing the window before using any widgets, hides the widgets when I use them


Tag : python , By : Laques
Date : March 29 2020, 07:55 AM
it helps some times You will have exactly the same problem if you manually resize the window before clicking the button. The issue isn't tied to maximize/minimize per se, it's tied to the fact that the user has said "I want the window to be this size" and tkinter is trying to honor that by not resizing the window against the user's wishes.
The solution is to reset the size of the window before adding or removing widgets. Add the following line of code after your global statements in enterG:
homeP.geometry("")

Python(Tkinter): Is there a way by which we can bring the widgets down using pady without disturbing other widgets?


Tag : python-3.x , By : DicksGarage
Date : March 29 2020, 07:55 AM
To fix the issue you can do One approach is to have all the labels in a frame, gridded on the left, and the button gridded on th eright, in a lower row:
Something like this:
import tkinter as tk
from tkinter import ttk

root = tk.Tk()
root.geometry("1000x500")
root.title("Stock Manager")
root.resizable(False, False)

left_frame = tk.Frame(root, width=900, height=500)
tk.Label(left_frame, text="Image", font=20).grid(column=0, row=0, pady=5, padx=50)

tk.Label(left_frame, text="Product No.", font=20).grid(column=1, row=0, pady=5, padx=40)
prodnumempty = tk.Label(left_frame, text="00547", font=16).grid(column=1, row=1)
tk.Label(left_frame, text="Description", font=20).grid(column=2, row=0, pady=5, padx=40)
tk.Label(left_frame, text="Quantity", font=20).grid(column=3, row=0, pady=5, padx=40)
tk.Label(left_frame, text="Price", font=20).grid(column=4, row=0, pady=5, padx=40)

left_frame.grid(column=2, row=0)

historybtn = ttk.Button(root, text="See Product History").grid(column=5, row=1)

root.mainloop()
Related Posts Related QUESTIONS :
  • I have a regex statement to pull all numbers out of a text file, but it only finds 77 out of the 81 numbers in the file
  • How do I create a dataframe of jobs and companies that includes hyperlinks?
  • Detect if user has clicked the 'maximized' button
  • Does flask_login automatically set the "next" argument?
  • Indents in python 3
  • How to create a pool of threads
  • Pandas giving IndexError on one dataframe but not on another similar dataframe
  • Django Rest Framework - Testing client.login doesn't login user, ret anonymous user
  • Running dag without dag file in airflow
  • Filling across a specified dimension of a numpy array
  • Python populating dataframe in pandas from text files
  • How to interpolate a single ("non-piecewise") cubic spline from a set of data points?
  • Divide 2 integers (leetcode 29) - recursion issue
  • Can someone explain why do I get this output in Python?
  • How do I scrape pdf and html from search results without obvious url
  • Is there a way to automatically make a "collage" of plots with matplotlib?
  • How to combine multiple rows in pandas with shared column values
  • How do I get LOAD_CLASSDEREF instruction after dis.dis?
  • Django - How to add items to Bootstrap dropdown?
  • Linear Regression - Does the below implementation of ridge regression finding coefficient term using gradient method is
  • How to drop all rows in pandas dataframe with negative values?
  • Most Efficient Way to Find Closest Date Between 2 Dataframes
  • Execution error when Passing arguments to a python script using os.system. The script takes sys.argv arguments
  • Looping through a function
  • Create a plot for each unique ID
  • a thread python with 'while' got another thread never start
  • Solution from SciPy solve_ivp contains oscillations for a system of first-order ODEs
  • trigger python events driven by selenium controlled browser
  • Passing line-edits to a contextmanager to set validators
  • Python: globals().items() iterations try to change a dict
  • Is it possible to specify starting values for each parameter (instead of bounds) for scipy's differential evolution?
  • why datetime.now() and constructed datetime using all fields(like year,month...) of now has big timedelta?
  • MySQL multiple table UPDATE query using sqlalchemy core?
  • find if a semantic version is superset of of another version python
  • Type checking against dynamically created objects
  • Struggling with simple reverse function
  • Is there a function for finding the midpoint of n points on sklearn.neighbors.NearestNeighbors?
  • How to set max number of tweets to fetch
  • PYTHON 3.7.4 NOT USING SQLITE 3.29.0
  • How to replace Nan value with zeros in a numpy array?
  • How to speed up calculating variance among sparse matrix
  • cupy code is not fast enough compared with numpy
  • How to count frequency of select values in Python pandas dataframe
  • Scrape Span Text from Google
  • Python watchdog, watch a directory and rename file on event.modification
  • Filtering rows in DataFrame with dependent conditions
  • How to check if a character is a not a part of number or URL in string?
  • Compare corresponding elements of a list
  • Python misinterprets 3 character string as UTF-8 continuation byte
  • Merge two columns in Pandas
  • Side Effect error in Python in an online compiler
  • How to convert a navigation list with depth levels to a parent-child flat list?
  • Retrieving values from a paired key dictionary in Python
  • How to test the current text of a Tkinter text box widget before inserting new text after user clicks on a button?
  • computing the Cumulative Sum, where Sum can be reset by a condition
  • Where do you specify your API key when making a request with the Google API python library?
  • Pandas DataFrame, computing the Time Difference between one row and other row which satisfies a condition
  • Discord.py bot not reading other bot's messages
  • How do I write a Django query that finds words in a Postgres column?
  • Download S3 File Using Boto3
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com