To create a dialog in Python using Tkinter module, just inherit from simpledialog.Dialog class from tkinter.simpledialog module (Python 3).
from tkinter import *
from tkinter import simpledialog
import sys, os
class SettingDialog(simpledialog.Dialog):
def body(self, master):
Label(master, text="First").grid(row=0, sticky=W)
root = Tk()
#Without "default" keyword, only root (parent) window icon is changed
#other child dialogs still use Tk icon
root.iconbitmap(default='AC.ico')
#call withdraw() to remove parent window, only show the child dialog.
root.withdraw()
SettingDialog(root, "hello")
No comments:
Post a Comment