How do I display the file contents only when checkbox is checked? The 2019 Stack Overflow Developer Survey Results Are InHow do I check if a list is empty?How do I check whether a file exists without exceptions?How do I copy a file in Python?How do I check if a string is a number (float)?How do I list all files of a directory?How to read a file line-by-line into a list?How do you append to a file in Python?Disable Checkbutton Tkinter (grey out)Traceback from tkinter when I try to draw game boardgetting error of undefined variable while trying to write data into excel from gui in python

Understanding the implication of what "well-defined" means for the operation in quotient group

Is this food a bread or a loaf?

Is three citations per paragraph excessive for undergraduate research paper?

On the insanity of kings as an argument against monarchy

What is a mixture ratio of propellant?

Can distinct morphisms between curves induce the same morphism on singular cohomology?

A poker game description that does not feel gimmicky

What tool would a Roman-age civilization have to grind silver and other metals into dust?

Falsification in Math vs Science

Dual Citizen. Exited the US on Italian passport recently

Extreme, unacceptable situation and I can't attend work tomorrow morning

How to deal with fear of taking dependencies

I see my dog run

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

JSON.serialize: is it possible to suppress null values of a map?

Why is it "Tumoren" and not "Tumore"?

"To split hairs" vs "To be pedantic"

How come people say “Would of”?

Should I write numbers in words or as numerals when there are multiple next to each other?

Is flight data recorder erased after every flight?

Does it makes sense to buy a new cycle to learn riding?

How to make payment on the internet without leaving a money trail?

How was Skylab's orbit inclination chosen?

What is the meaning of Triage in Cybersec world?



How do I display the file contents only when checkbox is checked?



The 2019 Stack Overflow Developer Survey Results Are InHow do I check if a list is empty?How do I check whether a file exists without exceptions?How do I copy a file in Python?How do I check if a string is a number (float)?How do I list all files of a directory?How to read a file line-by-line into a list?How do you append to a file in Python?Disable Checkbutton Tkinter (grey out)Traceback from tkinter when I try to draw game boardgetting error of undefined variable while trying to write data into excel from gui in python



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















In the given code below, only when the "x" checkbox is checked, the "ChoosexFile" button should get enabled. Only when clicked upon the "ChoosexFile" button, the "file dialog box" must get opened. And the selected file contents must be displayed in the "Listbox" of the middle frame. The listbox of both middle frame & bottom frame must contain both "horizontal" & "vertical" scrollbar. And when clicked upon the "clear" button(top frame), the file contents being displayed in the "Listbox" of the middle frame must get cleared and the checkbox of it(either x or y) must get automatically unchecked. The same must get repeated for "y" checkbox(i.e the functionality must be same as "x"). And when clicked upon "reset" button of the middle frame, all the contents being displayed in the "listbox"(middle frame) must get cleared and also all the checkboxes must get unchecked automatically.



from tkinter import *
from tkinter import filedialog

def forButton1():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton2():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton7():
root.destroy()

root = Tk()
root.title("Spatialization of DSSAT")

root.grid_columnconfigure(0, weight=1)

topFrame = LabelFrame(root, text="Select input file")
topFrame.grid(row=0, column=0, padx=8, pady=8, sticky=N+E+S+W)
topFrame.grid_rowconfigure(0, weight=1)
topFrame.grid_rowconfigure(1, weight=1)
topFrame.grid_columnconfigure(0, weight=1)
topFrame.grid_columnconfigure(1, weight=1)
topFrame.grid_columnconfigure(2, weight=1)

middleFrame = LabelFrame(root, text="Input data")
middleFrame.grid(row=1, column=0, padx=8, pady=8, sticky=N+E+S+W)
middleFrame.grid_rowconfigure(0, weight=1)
middleFrame.grid_rowconfigure(1, weight=0)
middleFrame.grid_columnconfigure(0, weight=1)
middleFrame.grid_columnconfigure(1, weight=1)

bottomFrame = LabelFrame(root, text="Model Output")
bottomFrame.grid(row=2, column=0, padx=8, pady=8, sticky=N+E+S+W)
bottomFrame.grid_rowconfigure(0, weight=1)
bottomFrame.grid_columnconfigure(0, weight=1)

MyVar1 = IntVar()
MyVar2 = IntVar()

MyCheckbutton1 = Checkbutton(topFrame, text="x", variable=MyVar1)
MyCheckbutton1.grid(row=0, column=0, padx=4, pady=4)
Button1 = Button(topFrame, text="Choose xFile", command=forButton1)
Button1.grid(row=0, column=1, padx=4, pady=4)
Button3 = Button(topFrame, text="Clear")
Button3.grid(row=0, column=2, padx=4, pady=4)

MyCheckbutton2 = Checkbutton(topFrame, text="y", variable=MyVar2)
MyCheckbutton2.grid(row=1, column=0, padx=4, pady=4)
Button2 = Button(topFrame, text="Choose yFile", command=forButton2)
Button2.grid(row=1, column=1, padx=4, pady=4)
Button4 = Button(topFrame, text="Clear")
Button4.grid(row=1, column=2, padx=4, pady=4)

innerMiddleFrame = Frame(middleFrame)
innerMiddleFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerMiddleFrame.grid_columnconfigure(0, weight=1)
innerMiddleFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerMiddleFrame)
myList = Listbox(innerMiddleFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button5 = Button(middleFrame, text="Reset")
Button5.grid(row=1, column=0, padx=4, pady=4)

Button6 = Button(middleFrame, text="Submit")
Button6.grid(row=1, column=1, padx=4, pady=4)

innerBottomFrame = Frame(bottomFrame)
innerBottomFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerBottomFrame.grid_columnconfigure(0, weight=1)
innerBottomFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerBottomFrame)
myList = Listbox(innerBottomFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button7 = Button(bottomFrame, text="Exit", command=forButton7)
Button7.grid(row=6, column=0, padx=4, pady=4)

root.geometry("400x590")
root.mainloop()









share|improve this question






















  • To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

    – Julia
    Mar 8 at 8:59












  • Where to add MyVar1.get() MyVar2.get() in the code?

    – user11108368
    Mar 8 at 9:02











  • And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

    – user11108368
    Mar 8 at 9:03











  • I got it about the checkbox activation.

    – user11108368
    Mar 8 at 9:09











  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:11

















0















In the given code below, only when the "x" checkbox is checked, the "ChoosexFile" button should get enabled. Only when clicked upon the "ChoosexFile" button, the "file dialog box" must get opened. And the selected file contents must be displayed in the "Listbox" of the middle frame. The listbox of both middle frame & bottom frame must contain both "horizontal" & "vertical" scrollbar. And when clicked upon the "clear" button(top frame), the file contents being displayed in the "Listbox" of the middle frame must get cleared and the checkbox of it(either x or y) must get automatically unchecked. The same must get repeated for "y" checkbox(i.e the functionality must be same as "x"). And when clicked upon "reset" button of the middle frame, all the contents being displayed in the "listbox"(middle frame) must get cleared and also all the checkboxes must get unchecked automatically.



from tkinter import *
from tkinter import filedialog

def forButton1():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton2():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton7():
root.destroy()

root = Tk()
root.title("Spatialization of DSSAT")

root.grid_columnconfigure(0, weight=1)

topFrame = LabelFrame(root, text="Select input file")
topFrame.grid(row=0, column=0, padx=8, pady=8, sticky=N+E+S+W)
topFrame.grid_rowconfigure(0, weight=1)
topFrame.grid_rowconfigure(1, weight=1)
topFrame.grid_columnconfigure(0, weight=1)
topFrame.grid_columnconfigure(1, weight=1)
topFrame.grid_columnconfigure(2, weight=1)

middleFrame = LabelFrame(root, text="Input data")
middleFrame.grid(row=1, column=0, padx=8, pady=8, sticky=N+E+S+W)
middleFrame.grid_rowconfigure(0, weight=1)
middleFrame.grid_rowconfigure(1, weight=0)
middleFrame.grid_columnconfigure(0, weight=1)
middleFrame.grid_columnconfigure(1, weight=1)

bottomFrame = LabelFrame(root, text="Model Output")
bottomFrame.grid(row=2, column=0, padx=8, pady=8, sticky=N+E+S+W)
bottomFrame.grid_rowconfigure(0, weight=1)
bottomFrame.grid_columnconfigure(0, weight=1)

MyVar1 = IntVar()
MyVar2 = IntVar()

MyCheckbutton1 = Checkbutton(topFrame, text="x", variable=MyVar1)
MyCheckbutton1.grid(row=0, column=0, padx=4, pady=4)
Button1 = Button(topFrame, text="Choose xFile", command=forButton1)
Button1.grid(row=0, column=1, padx=4, pady=4)
Button3 = Button(topFrame, text="Clear")
Button3.grid(row=0, column=2, padx=4, pady=4)

MyCheckbutton2 = Checkbutton(topFrame, text="y", variable=MyVar2)
MyCheckbutton2.grid(row=1, column=0, padx=4, pady=4)
Button2 = Button(topFrame, text="Choose yFile", command=forButton2)
Button2.grid(row=1, column=1, padx=4, pady=4)
Button4 = Button(topFrame, text="Clear")
Button4.grid(row=1, column=2, padx=4, pady=4)

innerMiddleFrame = Frame(middleFrame)
innerMiddleFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerMiddleFrame.grid_columnconfigure(0, weight=1)
innerMiddleFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerMiddleFrame)
myList = Listbox(innerMiddleFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button5 = Button(middleFrame, text="Reset")
Button5.grid(row=1, column=0, padx=4, pady=4)

Button6 = Button(middleFrame, text="Submit")
Button6.grid(row=1, column=1, padx=4, pady=4)

innerBottomFrame = Frame(bottomFrame)
innerBottomFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerBottomFrame.grid_columnconfigure(0, weight=1)
innerBottomFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerBottomFrame)
myList = Listbox(innerBottomFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button7 = Button(bottomFrame, text="Exit", command=forButton7)
Button7.grid(row=6, column=0, padx=4, pady=4)

root.geometry("400x590")
root.mainloop()









share|improve this question






















  • To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

    – Julia
    Mar 8 at 8:59












  • Where to add MyVar1.get() MyVar2.get() in the code?

    – user11108368
    Mar 8 at 9:02











  • And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

    – user11108368
    Mar 8 at 9:03











  • I got it about the checkbox activation.

    – user11108368
    Mar 8 at 9:09











  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:11













0












0








0








In the given code below, only when the "x" checkbox is checked, the "ChoosexFile" button should get enabled. Only when clicked upon the "ChoosexFile" button, the "file dialog box" must get opened. And the selected file contents must be displayed in the "Listbox" of the middle frame. The listbox of both middle frame & bottom frame must contain both "horizontal" & "vertical" scrollbar. And when clicked upon the "clear" button(top frame), the file contents being displayed in the "Listbox" of the middle frame must get cleared and the checkbox of it(either x or y) must get automatically unchecked. The same must get repeated for "y" checkbox(i.e the functionality must be same as "x"). And when clicked upon "reset" button of the middle frame, all the contents being displayed in the "listbox"(middle frame) must get cleared and also all the checkboxes must get unchecked automatically.



from tkinter import *
from tkinter import filedialog

def forButton1():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton2():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton7():
root.destroy()

root = Tk()
root.title("Spatialization of DSSAT")

root.grid_columnconfigure(0, weight=1)

topFrame = LabelFrame(root, text="Select input file")
topFrame.grid(row=0, column=0, padx=8, pady=8, sticky=N+E+S+W)
topFrame.grid_rowconfigure(0, weight=1)
topFrame.grid_rowconfigure(1, weight=1)
topFrame.grid_columnconfigure(0, weight=1)
topFrame.grid_columnconfigure(1, weight=1)
topFrame.grid_columnconfigure(2, weight=1)

middleFrame = LabelFrame(root, text="Input data")
middleFrame.grid(row=1, column=0, padx=8, pady=8, sticky=N+E+S+W)
middleFrame.grid_rowconfigure(0, weight=1)
middleFrame.grid_rowconfigure(1, weight=0)
middleFrame.grid_columnconfigure(0, weight=1)
middleFrame.grid_columnconfigure(1, weight=1)

bottomFrame = LabelFrame(root, text="Model Output")
bottomFrame.grid(row=2, column=0, padx=8, pady=8, sticky=N+E+S+W)
bottomFrame.grid_rowconfigure(0, weight=1)
bottomFrame.grid_columnconfigure(0, weight=1)

MyVar1 = IntVar()
MyVar2 = IntVar()

MyCheckbutton1 = Checkbutton(topFrame, text="x", variable=MyVar1)
MyCheckbutton1.grid(row=0, column=0, padx=4, pady=4)
Button1 = Button(topFrame, text="Choose xFile", command=forButton1)
Button1.grid(row=0, column=1, padx=4, pady=4)
Button3 = Button(topFrame, text="Clear")
Button3.grid(row=0, column=2, padx=4, pady=4)

MyCheckbutton2 = Checkbutton(topFrame, text="y", variable=MyVar2)
MyCheckbutton2.grid(row=1, column=0, padx=4, pady=4)
Button2 = Button(topFrame, text="Choose yFile", command=forButton2)
Button2.grid(row=1, column=1, padx=4, pady=4)
Button4 = Button(topFrame, text="Clear")
Button4.grid(row=1, column=2, padx=4, pady=4)

innerMiddleFrame = Frame(middleFrame)
innerMiddleFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerMiddleFrame.grid_columnconfigure(0, weight=1)
innerMiddleFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerMiddleFrame)
myList = Listbox(innerMiddleFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button5 = Button(middleFrame, text="Reset")
Button5.grid(row=1, column=0, padx=4, pady=4)

Button6 = Button(middleFrame, text="Submit")
Button6.grid(row=1, column=1, padx=4, pady=4)

innerBottomFrame = Frame(bottomFrame)
innerBottomFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerBottomFrame.grid_columnconfigure(0, weight=1)
innerBottomFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerBottomFrame)
myList = Listbox(innerBottomFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button7 = Button(bottomFrame, text="Exit", command=forButton7)
Button7.grid(row=6, column=0, padx=4, pady=4)

root.geometry("400x590")
root.mainloop()









share|improve this question














In the given code below, only when the "x" checkbox is checked, the "ChoosexFile" button should get enabled. Only when clicked upon the "ChoosexFile" button, the "file dialog box" must get opened. And the selected file contents must be displayed in the "Listbox" of the middle frame. The listbox of both middle frame & bottom frame must contain both "horizontal" & "vertical" scrollbar. And when clicked upon the "clear" button(top frame), the file contents being displayed in the "Listbox" of the middle frame must get cleared and the checkbox of it(either x or y) must get automatically unchecked. The same must get repeated for "y" checkbox(i.e the functionality must be same as "x"). And when clicked upon "reset" button of the middle frame, all the contents being displayed in the "listbox"(middle frame) must get cleared and also all the checkboxes must get unchecked automatically.



from tkinter import *
from tkinter import filedialog

def forButton1():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton2():
filename1 = filedialog.askopenfilename()

with open(filename1) as f:
for i in f:
myList.insert(END, i)

print(filename1)

def forButton7():
root.destroy()

root = Tk()
root.title("Spatialization of DSSAT")

root.grid_columnconfigure(0, weight=1)

topFrame = LabelFrame(root, text="Select input file")
topFrame.grid(row=0, column=0, padx=8, pady=8, sticky=N+E+S+W)
topFrame.grid_rowconfigure(0, weight=1)
topFrame.grid_rowconfigure(1, weight=1)
topFrame.grid_columnconfigure(0, weight=1)
topFrame.grid_columnconfigure(1, weight=1)
topFrame.grid_columnconfigure(2, weight=1)

middleFrame = LabelFrame(root, text="Input data")
middleFrame.grid(row=1, column=0, padx=8, pady=8, sticky=N+E+S+W)
middleFrame.grid_rowconfigure(0, weight=1)
middleFrame.grid_rowconfigure(1, weight=0)
middleFrame.grid_columnconfigure(0, weight=1)
middleFrame.grid_columnconfigure(1, weight=1)

bottomFrame = LabelFrame(root, text="Model Output")
bottomFrame.grid(row=2, column=0, padx=8, pady=8, sticky=N+E+S+W)
bottomFrame.grid_rowconfigure(0, weight=1)
bottomFrame.grid_columnconfigure(0, weight=1)

MyVar1 = IntVar()
MyVar2 = IntVar()

MyCheckbutton1 = Checkbutton(topFrame, text="x", variable=MyVar1)
MyCheckbutton1.grid(row=0, column=0, padx=4, pady=4)
Button1 = Button(topFrame, text="Choose xFile", command=forButton1)
Button1.grid(row=0, column=1, padx=4, pady=4)
Button3 = Button(topFrame, text="Clear")
Button3.grid(row=0, column=2, padx=4, pady=4)

MyCheckbutton2 = Checkbutton(topFrame, text="y", variable=MyVar2)
MyCheckbutton2.grid(row=1, column=0, padx=4, pady=4)
Button2 = Button(topFrame, text="Choose yFile", command=forButton2)
Button2.grid(row=1, column=1, padx=4, pady=4)
Button4 = Button(topFrame, text="Clear")
Button4.grid(row=1, column=2, padx=4, pady=4)

innerMiddleFrame = Frame(middleFrame)
innerMiddleFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerMiddleFrame.grid_columnconfigure(0, weight=1)
innerMiddleFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerMiddleFrame)
myList = Listbox(innerMiddleFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button5 = Button(middleFrame, text="Reset")
Button5.grid(row=1, column=0, padx=4, pady=4)

Button6 = Button(middleFrame, text="Submit")
Button6.grid(row=1, column=1, padx=4, pady=4)

innerBottomFrame = Frame(bottomFrame)
innerBottomFrame.grid(row=0, column=0, columnspan=2, padx=4, pady=4)
innerBottomFrame.grid_columnconfigure(0, weight=1)
innerBottomFrame.grid_columnconfigure(1, weight=0)

scrollbar = Scrollbar(innerBottomFrame)
myList = Listbox(innerBottomFrame, yscrollcommand=scrollbar.set)
myList.grid(row=0, column=0, sticky=N+E+S+W)
scrollbar.config(command=myList.yview)
scrollbar.grid(row=0, column=1, sticky=N+E+S+W)

Button7 = Button(bottomFrame, text="Exit", command=forButton7)
Button7.grid(row=6, column=0, padx=4, pady=4)

root.geometry("400x590")
root.mainloop()






python python-3.x tkinter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 8:37







user11108368



















  • To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

    – Julia
    Mar 8 at 8:59












  • Where to add MyVar1.get() MyVar2.get() in the code?

    – user11108368
    Mar 8 at 9:02











  • And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

    – user11108368
    Mar 8 at 9:03











  • I got it about the checkbox activation.

    – user11108368
    Mar 8 at 9:09











  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:11

















  • To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

    – Julia
    Mar 8 at 8:59












  • Where to add MyVar1.get() MyVar2.get() in the code?

    – user11108368
    Mar 8 at 9:02











  • And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

    – user11108368
    Mar 8 at 9:03











  • I got it about the checkbox activation.

    – user11108368
    Mar 8 at 9:09











  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:11
















To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

– Julia
Mar 8 at 8:59






To get the state of your checkboxes use MyVar1.get() and MyVar2.get(). It is 0 for unchecked and 1 for checked. But you need to add some logic to collect these states. Right now your code is executed once and you can't collect states if they've changed. Consider rewriting your code into functions and add logic that would listen to the changes.

– Julia
Mar 8 at 8:59














Where to add MyVar1.get() MyVar2.get() in the code?

– user11108368
Mar 8 at 9:02





Where to add MyVar1.get() MyVar2.get() in the code?

– user11108368
Mar 8 at 9:02













And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

– user11108368
Mar 8 at 9:03





And I want the "Choosexfile" button to get enabled only when the checkbox is checked.

– user11108368
Mar 8 at 9:03













I got it about the checkbox activation.

– user11108368
Mar 8 at 9:09





I got it about the checkbox activation.

– user11108368
Mar 8 at 9:09













May I please know how to display the file contents in the listbox of the second frame?

– user11108368
Mar 8 at 9:11





May I please know how to display the file contents in the listbox of the second frame?

– user11108368
Mar 8 at 9:11












1 Answer
1






active

oldest

votes


















0














Start out your buttons with a disabled state, and make a function to toggle their state by clicking the checkboxes.



Button1 = Button(topFrame, text="Choose xFile", command=forButton1, state="disabled")
Button2 = Button(topFrame, text="Choose yFile", command=forButton2, state="disabled")

...

def check_state(widget):
if widget["state"] == "normal":
widget["state"] = "disabled"
else:
widget["state"] = "normal"

MyCheckbutton1.config(command=lambda: check_state(Button1))
MyCheckbutton2.config(command=lambda: check_state(Button2))





share|improve this answer























  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:21











  • i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

    – user11108368
    Mar 8 at 9:27












  • And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

    – Henry Yik
    Mar 8 at 9:37











  • When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

    – user11108368
    Mar 8 at 9:40












  • I already told you that you defined both listbox in bottom and middle frame with the same variable name.

    – Henry Yik
    Mar 8 at 9:42











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059444%2fhow-do-i-display-the-file-contents-only-when-checkbox-is-checked%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Start out your buttons with a disabled state, and make a function to toggle their state by clicking the checkboxes.



Button1 = Button(topFrame, text="Choose xFile", command=forButton1, state="disabled")
Button2 = Button(topFrame, text="Choose yFile", command=forButton2, state="disabled")

...

def check_state(widget):
if widget["state"] == "normal":
widget["state"] = "disabled"
else:
widget["state"] = "normal"

MyCheckbutton1.config(command=lambda: check_state(Button1))
MyCheckbutton2.config(command=lambda: check_state(Button2))





share|improve this answer























  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:21











  • i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

    – user11108368
    Mar 8 at 9:27












  • And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

    – Henry Yik
    Mar 8 at 9:37











  • When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

    – user11108368
    Mar 8 at 9:40












  • I already told you that you defined both listbox in bottom and middle frame with the same variable name.

    – Henry Yik
    Mar 8 at 9:42















0














Start out your buttons with a disabled state, and make a function to toggle their state by clicking the checkboxes.



Button1 = Button(topFrame, text="Choose xFile", command=forButton1, state="disabled")
Button2 = Button(topFrame, text="Choose yFile", command=forButton2, state="disabled")

...

def check_state(widget):
if widget["state"] == "normal":
widget["state"] = "disabled"
else:
widget["state"] = "normal"

MyCheckbutton1.config(command=lambda: check_state(Button1))
MyCheckbutton2.config(command=lambda: check_state(Button2))





share|improve this answer























  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:21











  • i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

    – user11108368
    Mar 8 at 9:27












  • And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

    – Henry Yik
    Mar 8 at 9:37











  • When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

    – user11108368
    Mar 8 at 9:40












  • I already told you that you defined both listbox in bottom and middle frame with the same variable name.

    – Henry Yik
    Mar 8 at 9:42













0












0








0







Start out your buttons with a disabled state, and make a function to toggle their state by clicking the checkboxes.



Button1 = Button(topFrame, text="Choose xFile", command=forButton1, state="disabled")
Button2 = Button(topFrame, text="Choose yFile", command=forButton2, state="disabled")

...

def check_state(widget):
if widget["state"] == "normal":
widget["state"] = "disabled"
else:
widget["state"] = "normal"

MyCheckbutton1.config(command=lambda: check_state(Button1))
MyCheckbutton2.config(command=lambda: check_state(Button2))





share|improve this answer













Start out your buttons with a disabled state, and make a function to toggle their state by clicking the checkboxes.



Button1 = Button(topFrame, text="Choose xFile", command=forButton1, state="disabled")
Button2 = Button(topFrame, text="Choose yFile", command=forButton2, state="disabled")

...

def check_state(widget):
if widget["state"] == "normal":
widget["state"] = "disabled"
else:
widget["state"] = "normal"

MyCheckbutton1.config(command=lambda: check_state(Button1))
MyCheckbutton2.config(command=lambda: check_state(Button2))






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 9:06









Henry YikHenry Yik

1,4382413




1,4382413












  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:21











  • i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

    – user11108368
    Mar 8 at 9:27












  • And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

    – Henry Yik
    Mar 8 at 9:37











  • When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

    – user11108368
    Mar 8 at 9:40












  • I already told you that you defined both listbox in bottom and middle frame with the same variable name.

    – Henry Yik
    Mar 8 at 9:42

















  • May I please know how to display the file contents in the listbox of the second frame?

    – user11108368
    Mar 8 at 9:21











  • i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

    – user11108368
    Mar 8 at 9:27












  • And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

    – Henry Yik
    Mar 8 at 9:37











  • When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

    – user11108368
    Mar 8 at 9:40












  • I already told you that you defined both listbox in bottom and middle frame with the same variable name.

    – Henry Yik
    Mar 8 at 9:42
















May I please know how to display the file contents in the listbox of the second frame?

– user11108368
Mar 8 at 9:21





May I please know how to display the file contents in the listbox of the second frame?

– user11108368
Mar 8 at 9:21













i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

– user11108368
Mar 8 at 9:27






i.e in the middle frame. In my code, it is being displayed in the bottom frame. I dont want it to be displayed in the bottom frame of the listbox. I want the file contents which is selected to be displayed in the middle frame of the list box.

– user11108368
Mar 8 at 9:27














And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

– Henry Yik
Mar 8 at 9:37





And what's preventing you from doing so? You defined both listbox as MyList and obviously it will always display in the same middle frame.

– Henry Yik
Mar 8 at 9:37













When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

– user11108368
Mar 8 at 9:40






When I run the code, it is being displayed in the listbox of the bottom frame. But I want it to be displayed in the listbox of the middle frame.

– user11108368
Mar 8 at 9:40














I already told you that you defined both listbox in bottom and middle frame with the same variable name.

– Henry Yik
Mar 8 at 9:42





I already told you that you defined both listbox in bottom and middle frame with the same variable name.

– Henry Yik
Mar 8 at 9:42



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059444%2fhow-do-i-display-the-file-contents-only-when-checkbox-is-checked%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved