Created
February 11, 2019 04:53
-
-
Save nuta/9b76a20fe8fefe0480e51d7c7058ef77 to your computer and use it in GitHub Desktop.
tk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 0 LOAD_CONST 0 (0) | |
| 2 LOAD_CONST 1 (None) | |
| 4 IMPORT_NAME 0 (tkinter) | |
| 6 STORE_NAME 1 (tk) | |
| 3 8 LOAD_BUILD_CLASS | |
| 10 LOAD_CONST 2 (<code object Application at 0x10dc9af60, file "<dis>", line 3>) | |
| 12 LOAD_CONST 3 ('Application') | |
| 14 MAKE_FUNCTION 0 | |
| 16 LOAD_CONST 3 ('Application') | |
| 18 LOAD_NAME 1 (tk) | |
| 20 LOAD_ATTR 2 (Frame) | |
| 22 CALL_FUNCTION 3 | |
| 24 STORE_NAME 3 (Application) | |
| 23 26 LOAD_NAME 1 (tk) | |
| 28 LOAD_METHOD 4 (Tk) | |
| 30 CALL_METHOD 0 | |
| 32 STORE_NAME 5 (root) | |
| 24 34 LOAD_NAME 3 (Application) | |
| 36 LOAD_NAME 5 (root) | |
| 38 LOAD_CONST 4 (('master',)) | |
| 40 CALL_FUNCTION_KW 1 | |
| 42 STORE_NAME 6 (app) | |
| 25 44 LOAD_NAME 6 (app) | |
| 46 LOAD_METHOD 7 (mainloop) | |
| 48 CALL_METHOD 0 | |
| 50 POP_TOP | |
| 52 LOAD_CONST 1 (None) | |
| 54 RETURN_VALUE | |
| Disassembly of <code object Application at 0x10dc9af60, file "<dis>", line 3>: | |
| 3 0 LOAD_NAME 0 (__name__) | |
| 2 STORE_NAME 1 (__module__) | |
| 4 LOAD_CONST 0 ('Application') | |
| 6 STORE_NAME 2 (__qualname__) | |
| 4 8 LOAD_CONST 8 ((None,)) | |
| 10 LOAD_CLOSURE 0 (__class__) | |
| 12 BUILD_TUPLE 1 | |
| 14 LOAD_CONST 2 (<code object __init__ at 0x10dc9adb0, file "<dis>", line 4>) | |
| 16 LOAD_CONST 3 ('Application.__init__') | |
| 18 MAKE_FUNCTION 9 | |
| 20 STORE_NAME 3 (__init__) | |
| 10 22 LOAD_CONST 4 (<code object create_widgets at 0x10dc9ad20, file "<dis>", line 10>) | |
| 24 LOAD_CONST 5 ('Application.create_widgets') | |
| 26 MAKE_FUNCTION 0 | |
| 28 STORE_NAME 4 (create_widgets) | |
| 20 30 LOAD_CONST 6 (<code object say_hi at 0x10dc9aed0, file "<dis>", line 20>) | |
| 32 LOAD_CONST 7 ('Application.say_hi') | |
| 34 MAKE_FUNCTION 0 | |
| 36 STORE_NAME 5 (say_hi) | |
| 38 LOAD_CLOSURE 0 (__class__) | |
| 40 DUP_TOP | |
| 42 STORE_NAME 6 (__classcell__) | |
| 44 RETURN_VALUE | |
| Disassembly of <code object __init__ at 0x10dc9adb0, file "<dis>", line 4>: | |
| 5 0 LOAD_GLOBAL 0 (super) | |
| 2 CALL_FUNCTION 0 | |
| 4 LOAD_METHOD 1 (__init__) | |
| 6 LOAD_FAST 1 (master) | |
| 8 CALL_METHOD 1 | |
| 10 POP_TOP | |
| 6 12 LOAD_FAST 1 (master) | |
| 14 LOAD_FAST 0 (self) | |
| 16 STORE_ATTR 2 (master) | |
| 7 18 LOAD_FAST 0 (self) | |
| 20 LOAD_METHOD 3 (pack) | |
| 22 CALL_METHOD 0 | |
| 24 POP_TOP | |
| 8 26 LOAD_FAST 0 (self) | |
| 28 LOAD_METHOD 4 (create_widgets) | |
| 30 CALL_METHOD 0 | |
| 32 POP_TOP | |
| 34 LOAD_CONST 0 (None) | |
| 36 RETURN_VALUE | |
| Disassembly of <code object create_widgets at 0x10dc9ad20, file "<dis>", line 10>: | |
| 11 0 LOAD_GLOBAL 0 (tk) | |
| 2 LOAD_METHOD 1 (Button) | |
| 4 LOAD_FAST 0 (self) | |
| 6 CALL_METHOD 1 | |
| 8 LOAD_FAST 0 (self) | |
| 10 STORE_ATTR 2 (hi_there) | |
| 12 12 LOAD_CONST 1 ('Hello World\n(click me)') | |
| 14 LOAD_FAST 0 (self) | |
| 16 LOAD_ATTR 2 (hi_there) | |
| 18 LOAD_CONST 2 ('text') | |
| 20 STORE_SUBSCR | |
| 13 22 LOAD_FAST 0 (self) | |
| 24 LOAD_ATTR 3 (say_hi) | |
| 26 LOAD_FAST 0 (self) | |
| 28 LOAD_ATTR 2 (hi_there) | |
| 30 LOAD_CONST 3 ('command') | |
| 32 STORE_SUBSCR | |
| 14 34 LOAD_FAST 0 (self) | |
| 36 LOAD_ATTR 2 (hi_there) | |
| 38 LOAD_ATTR 4 (pack) | |
| 40 LOAD_CONST 4 ('top') | |
| 42 LOAD_CONST 5 (('side',)) | |
| 44 CALL_FUNCTION_KW 1 | |
| 46 POP_TOP | |
| 16 48 LOAD_GLOBAL 0 (tk) | |
| 50 LOAD_ATTR 1 (Button) | |
| 52 LOAD_FAST 0 (self) | |
| 54 LOAD_CONST 6 ('QUIT') | |
| 56 LOAD_CONST 7 ('red') | |
| 17 58 LOAD_FAST 0 (self) | |
| 60 LOAD_ATTR 5 (master) | |
| 62 LOAD_ATTR 6 (destroy) | |
| 64 LOAD_CONST 8 (('text', 'fg', 'command')) | |
| 66 CALL_FUNCTION_KW 4 | |
| 68 LOAD_FAST 0 (self) | |
| 70 STORE_ATTR 7 (quit) | |
| 18 72 LOAD_FAST 0 (self) | |
| 74 LOAD_ATTR 7 (quit) | |
| 76 LOAD_ATTR 4 (pack) | |
| 78 LOAD_CONST 9 ('bottom') | |
| 80 LOAD_CONST 5 (('side',)) | |
| 82 CALL_FUNCTION_KW 1 | |
| 84 POP_TOP | |
| 86 LOAD_CONST 0 (None) | |
| 88 RETURN_VALUE | |
| Disassembly of <code object say_hi at 0x10dc9aed0, file "<dis>", line 20>: | |
| 21 0 LOAD_GLOBAL 0 (print) | |
| 2 LOAD_CONST 1 ('hi there, everyone!') | |
| 4 CALL_FUNCTION 1 | |
| 6 POP_TOP | |
| 8 LOAD_CONST 0 (None) | |
| 10 RETURN_VALUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| class Application(tk.Frame): | |
| def __init__(self, master=None): | |
| super().__init__(master) | |
| self.master = master | |
| self.pack() | |
| self.create_widgets() | |
| def create_widgets(self): | |
| self.hi_there = tk.Button(self) | |
| self.hi_there["text"] = "Hello World\n(click me)" | |
| self.hi_there["command"] = self.say_hi | |
| self.hi_there.pack(side="top") | |
| self.quit = tk.Button(self, text="QUIT", fg="red", | |
| command=self.master.destroy) | |
| self.quit.pack(side="bottom") | |
| def say_hi(self): | |
| print("hi there, everyone!") | |
| root = tk.Tk() | |
| app = Application(master=root) | |
| app.mainloop() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment