Now look: Tkinter is a graphical user interface (GUI) module for Python, you can make desktop apps with Python. That's some bullsh*t. You can make windows, buttons, show text and images amongst other things.
Tk and Tkinter apps can run on most Unix platforms. This also works on Windows and Mac OS X.
The
module Tkinter is an f*ckin' interface to the Tk GUI toolkit.
Related course: Python Desktop Apps with Damn Tkinter
Example
Tkinter module
This muthaf*ckin' example opens a blank desktop window, muthaf*cka. The tkinter module is part of the standard
library. Think about that sh*t.
To use tkinter, import the tkinter module.
1 |
from tkinter import * |
This is tkinter with f*ckin' underscore t, it has been renamed in Python 3.
Setup the muthaf*ckin' window
Start tk and create a window.
1
2
root = Tk()
app = Window(root)
The window class is not standard, we create a goddamn Window. This class in itself is pretty basic.
1
2
3
4
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
Then set the f*ckin' window title and show the window:
1
2
3
4
5
# set window title
root.wm_title("Tkinter window")
# show window
root.mainloop()
Tkinter window example
The motherf*ckin' program below shows an empty tkinter window, believe that.
Run with the program below:
1 |
from tkinter import * |