Really inexperienced with python and still learning. I am trying to unzip a file with the click of a button. When I run this program the GUI does not show the button.
from zipfile import ZipFile
import Tkinter
top = Tkinter.Tk()
top.title("NAME of Program")
def Unzip():
with ZipFile ('Test.zip', 'r') as zipObj:
zipObj.extractall()
UnButton = Tkinter.Button(Text="Unzip", command = Unzip)
top.mainloop()
There are a few changes you need to implement.
First import "tkinter", not "Tkinter". Second, you need to change "Text" to be "text". Finally, you need to pack the button using "UnButton.pack()"
from zipfile import ZipFile
import tkinter # Changed
top = tkinter.Tk() # Changed
top.title("NAME of Program")
def Unzip():
with ZipFile ('Test.zip', 'r') as zipObj: # Adding a Tab (4 spaces)
zipObj.extractall()
UnButton = tkinter.Button(text="Unzip", command = Unzip) # Changed
UnButton.pack() # Added
top.mainloop()