#🔒 Object Oriented Programming Issues
9 messages · Page 1 of 1 (latest)
@quaint spade
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
import tkinter as tk
from tkinter import ttk
self = tk.Tk()
class outlast(tk.Tk):
def __init__(self):
super().__init__()
frame = tk.Frame(self, width = 350, height = 700)
frame.pack()
class HomePage:
def __init__Page1(self, text):
title = Label(self, text = "Outlast")
title.place(x=10, y=10)
track_w = Button(self, text="Track Weights")
track_w.place(x=125,y=400)
track_c=Button(self,text="Track Cardio")
track_c.place(x=130,y=300)
stats=Button(self,text="Stats")
stats.place(x=150,y=500)
for F in (mainPage, cardioPage, weightsPage, statsPage):
frame = F(frame, self)
def cardioPage():
self.destroy()
import cardio
def weightsPage():
self.destroy()
import weights
def statsPage():
self.destroy()
import stats
app = outlast()
self.mainloop()
when i call outlast it opens two frames, one is the right size but doesn't contain the buttons that are in the homepage class, and the second is just the default 100x100 frame that tkinter has when you create a canvas/frame. first question is why does it open two frames and second is how can i fix it to display the buttons? (I REALLY DO NOT WANT TO USE CHAT GPT and have not learned any of this in class pls help)
It looks like you make an instance of your outlast class, which in its init makes a Frame.
But nothing makes use of your HomePage class, which is where the buttons seem to be made.
I think the first Frame might somehow be to do with your opening self = tk.Tk() line. And the second Frame might be the one made in the outlast class.
@quaint spade ^^
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.