I am new to learning tkinter and I am trying to make a simple tkinter GUI to run EXIFTool.
problem 1) When I uncomment StatusBar I get the following error; cannot use geometry manager grid inside . which already has slaves managed by pack. What is the best way to format my code to prevent this problem.
problem 2) How can I keep column 0 from collapsing so it acts as a border?
#!/usr/bin/python3
import getpass
import subprocess
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk,Image
from datetime import datetime
from tkinter import filedialog
class MainFrame(ttk.Frame):
def __init__(self, container):
super().__init__(container)
# configure the grid
self.columnconfigure(0, weight=4)
self.columnconfigure(1, weight=2)
self.columnconfigure(2, weight=2)
self.columnconfigure(3, weight=2)
self.columnconfigure(4, weight=2)
self.columnconfigure(5, weight=4)
self.createwidgets()
def createwidgets(self):
### FILE
self.entry1_var = tk.StringVar()
#self.entry1_var.set('')
self.entry1=tk.Entry(self, textvariable=self.entry1_var, justify='center')
self.entry1.grid(row=0, column=1, columnspan=4, sticky=tk.EW, padx=0, pady=40, ipady=10 )
##--------------------------------------------------##
### SELECT BUTTON
self.button1=tk.Button(self, text='FILE', bg="#873600", bd=4, relief="raised")
#self.button1['command'] = self.openfile
self.button1.grid(column=1, row=1, padx=0, pady=0, ipadx=30)
### CLEAN BUTTON
self.button2=tk.Button(self, text='INFO', bg="#873600", bd=4, relief="raised")
#self.button2['command'] = self.exif_info
self.button2.grid(column=2, row=1, padx=0, pady=0, ipadx=30)
### VIEW EXIF DATA
self.button3=tk.Button(self, text='EXIF', bg="#873600", bd=4, relief="raised")
#self.button3['command'] = self.exif_clean
self.button3.grid(column=3, row=1, padx=0, pady=0, ipadx=30)
### EXIT
self.button4=tk.Button(self, text='EXIT', bg="#873600", bd=4, relief="raised")
#self.button4['command'] = container.exit
self.button4.grid(column=4, row=1, padx=0, pady=0, ipadx=30)
##--------------------------------------------------##
### EXIF INFO
self.text1=tk.Text(self, height=12)
self.text1.grid(row=3, column=1, columnspan=4, padx=0, pady=40, ipady=10)
self.grid()
#####################################################################################
class App(tk.Tk):
def __init__(self):
super().__init__()
bg_colour = "#4C4E52"
self.geometry("1400x870") # air
#self.configure(bg=bg_colour)
self.resizable(False, False)
self.title('EXIF CLEANER v1')
def exit(self):
self.destroy()
class StatusBar(tk.Frame):
def __init__(self, container):
super().__init__(container)
time_date = datetime.now().strftime('%I:%M:%S %p on %A, %B the %dth, %Y')
self.variable=tk.StringVar()
self.variable.set(time_date)
self.statusbar=tk.Label(self, bd=0, relief="solid", height="2", width="100",
textvariable=self.variable, foreground="red", background='#2f2f2f', font=('helvetica',8))
self.statusbar.pack(side=tk.BOTTOM, fill=tk.X)
self.pack(fill="x", side="bottom", ipady=0, padx=0, pady=0)
#self.parent1 = tk.Frame()
#self.parent1.pack(side=tk.TOP)
if __name__ == "__main__":
app = App()
#StatusBar(app)
MainFrame(app)
app.mainloop()
How to add StatusBar Class and Use Grid Column as Border
I get the following error; cannot use geometry manager grid inside . which already has slaves managed by pack
The problem can fixed:
On line 65, change this:
self.grid()
to:
self.pack()
On line 106, comment in StatusBar(app)
Screenshot: