-1
from tkinter import *

class page:
    def pageNext(self, pageNext):
        self.pageNext = pageNext
        pageNext.tkraise()
    def button(self, window, text, x, y, command = None):
        self.window = window
        self.text = text
        self.x = x
        self.y = y
        self.command = command
        button = Button(window, text = text, command = lambda:command)
        button.place(x = x, y = y)
    def label(self, window, text, x, y, header = False):
        self.window = window
        self.text = text
        self.x = x
        self.y = y
        self.header = header
        if header == True:
            label = Label(window, font = "Helvetica 16 bold italic", text = text)
        else:
            label = Label(window, text = text)
        label.place(x = x, y = y)
    def newPage(self, window):
        self.window = window
        pageNew = Frame(window)
        pageNew.grid(row = 0, column = 0, sticky = "News")
        return pageNew
root = Tk()
page = page()

Guys when I try to create a frame using pageWelcome = page.newPage(root) and place a button using page.button(pageWelcome) and say page.pageNext(pageWelcome) it doesn't place the button but when I place a button like page.button(root) it places the button to the screen. I can't see which part of my code is broken. Can someone help?

P.S: I made this class basing to my first GUI. In that times i couldn't use classes but my code was working fine.

My code

Miraj50
  • 4,257
  • 1
  • 21
  • 34
  • Are labels being displayed properly? –  Jan 05 '19 at 12:03
  • When i use it like `page.label(root, "start", 150, 300, True)` it does but when i use it like `page.label(pageWelcome, "start", 150, 300, True)` it doesn't works. – Ahmet Ertuğrul Kaya Jan 05 '19 at 12:46
  • Please post your code that isn't working. Ideally something runnable or as close to that as you can get. – martineau Jan 05 '19 at 14:00
  • Read [Best way to structure a tkinter application](https://stackoverflow.com/a/17470842/7414759) and use that pattern. – stovfl Jan 05 '19 at 14:49
  • "but when I place a button like page.button(root) it places the button to the screen" Really? You want tell us that you are able create the button like so without getting TypeError because of missing positional arguments??? – Module_art Jan 05 '19 at 16:38
  • @Turjak_art no, ofcourse i will get an error for that. I meant that when i fill the rest of the parts like `text`, `x` and `y` (`command` is optinal) it works normally. – Ahmet Ertuğrul Kaya Jan 05 '19 at 18:12

1 Answers1

0

Guys i couldn't find what was wrong with my code so i started for "how to change page tkinter". One of the results was very simple -easy to understand- and i changed all of my code according to that code. I am putting here the tutorial link and the credit link if there is anyone interested.