Python Forum
How to print out the wisget structure in shell
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print out the wisget structure in shell
#1
I'm playing around with building a generic frame and I was wondering if there was a way to see the structure in shell. To see if the widgets are going in the frames. This is what I'm seeing when printing.
Thanks

#! /usr/bin/env python3.8
'''Docstring'''

import tkinter as tk
from tkinter import ttk


class RootWindow:
    '''Docstring'''
    #pylint: disable=R0903
    def __init__(self, master):
        print('RootWindow init')
        self.master = master
        self.master.columnconfigure(0, weight=1)
        self.master.rowconfigure(0, weight=1)

        bbb = FrameBuild(self.master).frame_skeleton(self.master)
        BuildHeader(master='logo_frame').header(bbb)


class FrameBuild:
    '''Docstring'''
    #pylint: disable=R0903
    def __init__(self, master):
        pass

    def frame_skeleton(self, master, colspan=1, column=0, row=0, sticky='news'):
        '''Frames'''
        #pylint: disable=R0201, R0913
        print('I am builder')
        frame = ttk.Frame(master)
        frame.grid(columnspan=colspan, column=column, row=row, sticky=sticky)
        return frame

class BuildHeader:
    '''Header'''
    #pylint: disable=R0903
    def __init__(self, master):
        pass

    def header(self, master, column=0, row=0, sticky='news'):
        '''Docstring'''
        #pylint: disable=R0201
        print('I am header')

        logo = ttk.Label(master, text='I am a label')
        logo.grid(column=column, row=row, sticky=sticky)
        print(logo)
        return logo



def main():
    '''Docstring'''
    root = tk.Tk()
    RootWindow(root)
    root.mainloop()

if __name__ == '__main__':
    main()
Output:
RootWindow init I am builder I am header .!frame.!label
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter Shell Terminal Or Shell Output sweetthdevil 5 8,761 Feb-03-2024, 02:51 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020