Star imports are bad.
You need also better names, a, b, com, com1 are meaningless names.
Better names are textbox_var or label_destroy.
What I did not know before, that you can let out the root and it still works, but it's bad.
Later if you work with Frames, you have to pass the right reference.
Here an example:
Later you want to isolate everything. But I guess you are not so far to use classes with inheritance.
You need also better names, a, b, com, com1 are meaningless names.
Better names are textbox_var or label_destroy.
What I did not know before, that you can let out the root and it still works, but it's bad.
Later if you work with Frames, you have to pass the right reference.
Here an example:
#/usr/env/bin python3 """ Description of program """ from tkinter import ( Tk, Button, Label, StringVar, Entry, END, ) def label_create(): """ Description ... """ text = textbox_var.get() # you need the reference of labels to destroy them later # using pack method on label, returns None label = Label(root, text=text, font=20, fg='green') label.pack() label_references.append(label) def label_destroy(): """ Description ... """ for label in label_references: label.destroy() label_references.clear() entry.delete(0, END) label_references = [] root = Tk() root.title('Window') root.geometry('500x500+300+100') textbox_var = StringVar() Label(root, text='Functionalityh to a button', font=30).pack() Button(root, text='Press to print', command=label_create).pack() Button(root, text='Clear', command=label_destroy).pack() Button(root, text='Exit', command=root.destroy).pack() # reference for Entry entry = Entry(root, textvariable=textbox_var) entry.pack() root.mainloop()So everything is still on module level, imports have been changed and better names are given.
Later you want to isolate everything. But I guess you are not so far to use classes with inheritance.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!