#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2022/04/24 08:25:51 +0900> u""" Button only * Windows10 x64 21H2 + Python 3.9.11 64bit + tkinter """ try: # Python 2.7 import Tkinter as tk except Exception: # Python 3.x import tkinter as tk class App(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.pack() self.btn = tk.Button(self) self.btn["text"] = "Translation" self.btn["command"] = self.trans self.btn.pack({"side": "left"}) self.btnquit = tk.Button(self) self.btnquit["text"] = "Exit" self.btnquit["command"] = self.quit self.btnquit.pack({"side": "left"}) def trans(self): print("Hello world ! Tkinter.") def main(): root = tk.Tk() app = App(master=root) app.mainloop() # root.destroy() if __name__ == "__main__": main()