So I started creating GUI that I'll use for testbench for electrical engines. My question is why is everything displayed in master window like this?:
Instead of the two frames?
The first time I wrote it, it was working perfectly:
[
but then I wanted to rearrange the code using classes and the problem appeared. I'm using Python 3.7.
My code:
import tkinter as tk
from tkinter import *
from tkinter import messagebox
class Lintebench():
def __init__(self, master):
self.master = master
self.master.title("Linte^2 testbench")
self.master.geometry('1000x600')
#FRAMES
frame = Frame(master, bg='#3e646c').place(relwidth=0.2, relheight=0.4, rely=0.6)
frame2 = Frame(master, bg='#3e646c').place(relwidth=0.8, relheight=0.4, rely=0.6, relx=0.2)
#FRAME 1
self.start_button = Button(frame, text="Start", padx=50, pady=50, bg='green', activebackground='grey', command=self.start_engine).pack()
self.stop_button = Button(frame2, text="Stop", padx=50, pady=50, bg='red', activebackground='grey', command=self.stop_engine).pack()
#FRAME 2
self.parameters = Label(frame2, text="PARAMETERS", font=("Arial", 16), fg='white', bg='#3e646c').place(relx=0)
self.set_parameter = Label(frame2, text="SET", font=("Arial", 16), fg='white', bg='#3e646c').place(relx=0.8)
self.values = Label(frame2, text="VALUES", font=("Arial", 16), fg='white', bg='#3e646c').place(relx=0.4)
self.torque = Label(frame2, text="TORQUE", font=("Arial", 12), fg='white', bg='#3e646c').place(relx=0.7, rely=0.2)
self.velocity = Label(frame2, text="VELOCITY", font=("Arial", 12), fg='white', bg='#3e646c').place(relx=0.7, rely=0.6)
#parameters to set
self.set_torque = Scale(frame2, orient=HORIZONTAL, length=200).place(relx=0.7, rely=0.3)
self.set_velocity = Scale(frame2, orient=HORIZONTAL, length=200).place(relx=0.7, rely=0.7)
def start_engine(*args):
messagebox.showinfo('Information','Engine was started')
def stop_engine(*args):
messagebox.showinfo('Information','Engine was stopped')
def main():
root = Tk()
lintebench = Lintebench(root)
root.mainloop()
if __name__ == '__main__':
main()here