-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguitest.py
123 lines (82 loc) · 2.93 KB
/
guitest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from Tkinter import *
import time
import tkMessageBox # if you want pop ups
class Gui:
def __init__(self, master):
topframe = Frame(master)
bottomframe = Frame(master)
topframe.pack()
bottomframe.pack(side=BOTTOM)
self.button1 = Button(topframe, text="Button 1", command=lambda: self.recog(1))
self.button2 = Button(topframe, text="Button 2", command=lambda: self.recog(2))
self.button3 = Button(bottomframe, text="Button 3", command=lambda: self.recog(3))
self.button1.pack(side=LEFT)
self.button2.pack(side=LEFT)
self.button3.pack()
@staticmethod
def recog(n):
print "This is button", n
def click():
print "Not doing anything just yet"
blank = Tk()
blank.geometry("500x300")
# Top Menu
menu = Menu(blank)
blank.config(menu=menu)
subMenu = Menu(menu)
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New file", command=click)
subMenu.add_command(label="Save file", command=click)
subMenu.add_command(label="Load file", command=click)
subMenu.add_separator()
subMenu.add_command(label="Settings", command=click)
subMenu.add_separator()
subMenu.add_command(label="Exit", command=blank.destroy)
editMenu = Menu(menu)
menu.add_cascade(label="Edit", menu=editMenu)
editMenu.add_command(label="Edit", command=click)
# Toolbar
toolbar = Frame(blank)
insertButt = Button(toolbar, text="Insert", command=click)
insertButt.pack(side=LEFT, padx=2, pady=2)
printButt = Button(toolbar, text="Print", command=click)
printButt.pack(side=LEFT, padx=2, pady=2)
toolbar.pack(side=TOP, fill=X)
# Status bar
statusBar = Label(blank, text="Preparing to do nothing...", bd=1, relief=SUNKEN, anchor=W)
statusBar.pack(side=BOTTOM, fill=X)
b = Gui(blank)
# Message boxes - this currently kinda breaks the program.
tkMessageBox.showinfo('Window Title', "This is a bunch of text")
# answer = tkMessageBox.askquestion('Question 1', 'Do you like silly faces?')
# if answer == 'yes':
# print "Zdenda"
# Shapes and graphics
canvas = Canvas(blank, width=200, height=100)
canvas.pack()
blackline = canvas.create_line(0, 0, 200, 50)
redline = canvas.create_line(0, 100, 200, 50, fill="red")
middle = canvas.create_text(0 + (200 - 0)/3, 100 + (50 - 100)/3,text="Middle?")
greenBox = canvas.create_rectangle(25, 25, 130, 60, fill="green")
# canvas.delete(redline)
# canvas.delete(ALL)
# Images - works on gifs, not pngs.
# Photo = PhotoImage(file="print.png")
# label = Label(blank, image=Photo)
# label.pack()
canvas = Canvas(blank)
canvas.pack()
circleX = (25, 25)
circleY = (35, 35)
circle = canvas.create_oval(circleX, circleY, fill="red")
label = canvas.create_text(35, 45, text="Bitch")
def move():
for step in range(50):
x = 5
time.sleep(0.0025)
canvas.move(circle, x, 0)
canvas.move(label, x, 0)
canvas.update()
button = Button(blank, text="MOVE BITCH", command=move)
button.pack(side=BOTTOM)
blank.mainloop()