My basic issue is trying to get my background to show.
It loads and shows when not including extra code but as soon as i try and run some other processes in the loop the background stops loading/showing
A bit of further background is that i've produced code to run a batch process for my degree project. When trying to now incorporate a GUI to this im trying Tkinter, bearing in mind this is all new to me so maybe i've missed a few points when searching for similar issues/rectifications.
As i'm trying to build the GUI learning as i go i've tried a very basic thing to build upon that looks like the following:
import time
from tkinter import *
import tkinter as Tk ## notice lowercase 't' in tkinter here
root = Tk.Tk()
root.wm_geometry("1024x768")
root.title('Rpi Automated MicroBrewery')
a = StringVar()
a.set("1234")
text1 = StringVar()
text1.set("Header Full")
def startBrew():
print('brew has started')
def a():
print('a')
def b():
print('b')
def c():
print('c')
def main():
a()
b()
c()
class Application(Tk.Frame):
def __init__(self, master=None):
Tk.Frame.__init__(self, master)
self.createWidgets()
def createWidgets(self):
background_image = Tk.PhotoImage(file="C:\\Users\\chris\\Documents\\Uni\\Year Four\\Final Year Project\\bg.png")
self.background_label = Tk.Label(root, image=background_image).place(x=0, y=0, relwidth=1, relheight=1)
self.startButton = Tk.Button(root, text="Start Brewing!", command=startBrew).place(x=200,y=200)
self.parametersButton = Tk.Button(root, text="Brewing Parameters", command=Application.parametersWindow).place(x=300,y=300)
self.headerTemp = Tk.Label(root, textvariable=a).place(x=500,y=500)
self.headerLev = Tk.Label(root, textvariable=text1).place(x=500,y=600)
self.onUpdate()
def parametersWindow():
top = Toplevel()
top.maxsize(400,400)
top.title("Adjust Brew Parameters")
about_message = "put some parameters in here"
msg = Message(top, text=about_message).place(x=0,y=0)
button = Button(top, text="Dismiss", command=top.destroy)
def onUpdate(self):
main()
self.after(1000, self.onUpdate)
app = Application(master=root)
root.mainloop()
please scrutinise and correct where neccessary. but please keep in mind it is all new to me, may go over my head if the answer is too complex. Also any idea why text1 string var displays and yet i cannot get 'a' to display at all.
I've since tried this but it runs main() until cancelled and then allows the background and GUI to be displayed. please help im sure its a simple rule i'm not following:
import time
from tkinter import *
import tkinter as tk ## notice lowercase 't' in tkinter here
root = tk.Tk()
root.wm_geometry("1024x768")
root.title('Rpi Automated MicroBrewery')
a = StringVar()
a.set("1234")
text1 = StringVar()
text1.set("Header Full")
def startBrew():
print('brew has started')
def a():
print('a')
def b():
print('b')
def c():
print('c')
def main():
a()
b()
c()
root.after(5000, main())
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.createWidgets()
def createWidgets(self):
self.startButton = tk.Button(root, text="Start Brewing!", command=startBrew).place(x=200,y=200)
self.parametersButton = tk.Button(root, text="Brewing Parameters", command=Application.parametersWindow).place(x=300,y=300)
self.headerTemp = tk.Label(root, textvariable=a).place(x=500,y=500)
self.headerLev = tk.Label(root, textvariable=text1).place(x=500,y=600)
self.onUpdate()
def parametersWindow():
top = Toplevel()
top.maxsize(400,400)
top.title("Adjust Brew Parameters")
about_message = "put some parameters in here"
msg = Message(top, text=about_message).place(x=0,y=0)
button = Button(top, text="Dismiss", command=top.destroy)
def onUpdate(self):
main()
self.after(5000,onUpdate)
background_image = tk.PhotoImage(file="C:\\Users\\chris\\Documents\\Uni\\Year Four\\Final Year Project\\bg.png")
background_label = tk.Label(root, image=background_image).place(x=0, y=0, relwidth=1, relheight=1)
app = Application(master=root)
root.mainloop()
Thanks