-
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
61 changed files
with
477 additions
and
229 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import tkinter as tk | ||
|
||
root = tk.Tk() | ||
|
||
var0 = tk.StringVar() | ||
var1 = tk.StringVar() | ||
var2 = tk.StringVar() | ||
|
||
var0.set('1') | ||
var1.set('0') | ||
var2.set('0') | ||
|
||
def cb(): | ||
print('--- languages ---') | ||
print('English', var0.get()) | ||
print('German', var1.get()) | ||
print('French', var2.get()) | ||
|
||
tk.Checkbutton(root, text='English', variable=var0, command=cb).pack() | ||
tk.Checkbutton(root, text='German', variable=var1, offvalue='barely', command=cb).pack() | ||
tk.Checkbutton(root, text='French', variable=var2, onvalue='fluent' command=cb).pack() | ||
|
||
root.mainloop() |
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,20 @@ | ||
import tkinter as tk | ||
|
||
root = tk.Tk() | ||
|
||
texts = ['English', 'German', 'French'] | ||
vars = [tk.StringVar(), tk.StringVar(), tk.StringVar()] | ||
|
||
for var in vars: | ||
var.set('0') | ||
|
||
def cb(): | ||
print('--- languages ---') | ||
for i, s in enumerate(texts): | ||
print(s, vars[i].get()) | ||
|
||
tk.Checkbutton(root, text=texts[0], variable=vars[0], command=cb).pack() | ||
tk.Checkbutton(root, text=texts[1], variable=vars[1], command=cb).pack() | ||
tk.Checkbutton(root, text=texts[2], variable=vars[2], command=cb).pack() | ||
|
||
root.mainloop() |
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,6 @@ | ||
"""Create checkbuttons.""" | ||
from tklib import * | ||
|
||
app = App() | ||
Checkbutton('English;German;French', 'print(self.selection)') | ||
app.run() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import tkinter as tk | ||
root = tk.Tk() | ||
|
||
name = tk.StringVar() | ||
tk.Label(text='Name').pack() | ||
tk.Entry(root, textvariable=name, width=10).pack() | ||
|
||
password = tk.StringVar() | ||
tk.Label(text='Password').pack() | ||
tk.Entry(root, textvariable=password, show='*').pack() | ||
|
||
root.mainloop() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Create entry fields.""" | ||
from tklib import * | ||
app = App('Entry') | ||
|
||
Label('Entry fields', font='Arial 24') | ||
Entry('First name:', 'print(self.var.get())', 'James') | ||
Entry('Last name:', 'print(self.var.get())') | ||
Entry('Password:', 'print(self.var.get())', show='*') | ||
|
||
Entry('Enter expression', 'App.res["text"] = eval(self.var.get())') | ||
App.res = Label('Result') | ||
|
||
app.run() |
This file was deleted.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
"""Create a canvas and add lines and rectangles.""" | ||
from tklib import * | ||
app = App('Canvas with lines and rectangles') | ||
|
||
class Demo(App): | ||
def __init__(self): | ||
super().__init__() | ||
Label("Canvas", font="Arial 24") | ||
c = Canvas(width=600, height=300, background='lightblue') | ||
c.create_line(10, 10, 200, 200, fill='red') | ||
c.create_line(20, 10, 210, 200, fill='blue', width=3) | ||
c.create_rectangle(100, 200, 150, 250, fill='green', width=2) | ||
c.create_rectangle(300, 100, 580, 250, fill='yellow', width=5) | ||
|
||
c = Canvas(width=600, height=300, background='lightblue') | ||
|
||
c.create_line(10, 10, 200, 200, fill='red') | ||
c.create_line(20, 10, 210, 200, fill='blue', width=3) | ||
c.create_rectangle(100, 200, 150, 250, fill='green', width=2) | ||
c.create_rectangle(300, 100, 580, 250, fill='yellow', width=5) | ||
|
||
Demo().run() | ||
app.run() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
"""Draw lines, ovals and text on a canvas.""" | ||
from tklib import * | ||
app = App('Canvas with ovals and text') | ||
|
||
class Demo(App): | ||
def __init__(self): | ||
super().__init__() | ||
Label("Canvas", font="Arial 24") | ||
c = Canvas(width=600, height=300, background='lightblue') | ||
c.create_line(10, 10, 200, 200, fill='red') | ||
c.create_line(20, 10, 210, 200, fill='blue', width=3) | ||
c.create_oval(100, 200, 150, 250, fill='green', width=2) | ||
c.create_oval(300, 100, 580, 250, fill='yellow', width=5) | ||
c.create_text(300, 150, text="Python", font='Arial 48') | ||
c.create_text(300, 250, text="Canvas", font='Zapfino 72') | ||
|
||
c = Canvas(width=600, height=300, background='lightblue') | ||
|
||
c.create_line(10, 10, 200, 200, fill='red') | ||
c.create_line(20, 10, 210, 200, fill='blue', width=3) | ||
c.create_oval(100, 200, 150, 250, fill='green', width=2) | ||
c.create_oval(300, 100, 580, 250, fill='yellow', width=5) | ||
c.create_text(300, 150, text="Python", font='Arial 48') | ||
c.create_text(300, 250, text="Canvas", font='Zapfino 72') | ||
|
||
Demo().run() | ||
app.run() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
"""Place polygons on the canvas.""" | ||
from tklib import * | ||
app = App('Draw a polygon') | ||
|
||
class Demo(App): | ||
def __init__(self): | ||
super().__init__() | ||
Label("Polygons", font="Arial 24") | ||
self.c = Canvas(width=600, height=300, background='lightblue') | ||
self.c.polygon(150, 150, 100, 6, fill='blue') | ||
self.c.polygon(450, 150, 80, 8, fill='red', width=5) | ||
c = Canvas(width=600, height=300, background='lightblue') | ||
c.polygon(150, 150, 100, 6, fill='blue') | ||
c.polygon(450, 150, 80, 8, fill='red', width=5) | ||
|
||
Demo().run() | ||
app.run() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
"""Place random circles on the canvas.""" | ||
from tklib import * | ||
app = App('Random circles') | ||
|
||
class Demo(App): | ||
def __init__(self): | ||
super().__init__() | ||
Label("Random Circles", font="Arial 24") | ||
w, h = 600, 300 | ||
c = Canvas(width=w, height=h, background='lightblue') | ||
|
||
w, h = 600, 300 | ||
c = Canvas(width=w, height=h, background='lightblue') | ||
|
||
for i in range(50): | ||
x = random.randint(0, w) | ||
y = random.randint(0, h) | ||
r = random.randint(10, 100) | ||
c.create_oval(x, y, x+r, y+r) | ||
for i in range(50): | ||
x = random.randint(0, w) | ||
y = random.randint(0, h) | ||
r = random.randint(10, 100) | ||
c.create_oval(x, y, x+r, y+r) | ||
|
||
Demo().run() | ||
app.run() |
Oops, something went wrong.