-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
135 additions
and
84 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
# tk-tutorial | ||
Create OOP applications using the Tk interface. | ||
Introduction to Tk | ||
================== | ||
|
||
You can find the online tutorial here: | ||
https://tk-tutorial.readthedocs.io/ | ||
Tk is a **graphical user interface** (GUI) library. It allows to create windows, buttons and all the other graphical elements. | ||
|
||
This tutorial shows how to use **object-oriented programming** (OOP) | ||
for making applications with the **Tk** framework. | ||
|
||
You can find the online tutorial here: https://tk-tutorial.readthedocs.io | ||
|
||
More tutorials | ||
-------------- | ||
|
||
* https://opencv-tutorial.readthedocs.io | ||
* https://pygame.readthedocs.io | ||
* https://pymunk-tutorial.readthedocs.io | ||
* https://tk-tutorial.readthedocs.io | ||
* https://cocos2d-tutorial.readthedocs.io |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Basic widgets | |
* Button | ||
* Label | ||
* Entry | ||
* Frame | ||
* Frame | ||
|
This file contains 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
File renamed without changes
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import tkinter as tk | ||
import tkinter.ttk as ttk | ||
|
||
class Label(ttk.Label): | ||
"""Create a Label object.""" | ||
def __init__(self, text='Label', **kwargs): | ||
super().__init__(App.stack[-1], text=text, **kwargs) | ||
self.grid() | ||
|
||
class Button(ttk.Button): | ||
"""Create a Button object.""" | ||
def __init__(self, text='Button', **kwargs): | ||
super().__init__(App.stack[-1], text=text, **kwargs) | ||
self.grid() | ||
|
||
class App: | ||
"""Define the application class.""" | ||
stack = [] | ||
|
||
def __init__(self): | ||
self.root = tk.Tk() | ||
self.root.title('App') | ||
App.stack.append(self.root) | ||
|
||
Label('New Label') | ||
Label() | ||
|
||
Button('New Button') | ||
Button() | ||
|
||
def run(self): | ||
"""Run the main loop.""" | ||
self.root.mainloop() | ||
|
||
if __name__ == '__main__': | ||
App().run() |
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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