-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub.py
70 lines (51 loc) · 2.01 KB
/
sub.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
import tkinter
from frames import *
from tkinter import *
from tkinter import font
from tkinter import filedialog
from PIL import Image, ImageTk
import userInformation
class sub(Frame):
def __init__(self, cvs, username, master = None):
Frame.__init__(self, master, bg = "AntiqueWhite")
self.cvs = cvs
self.username = username
self.root = master
self.createPage()
def createPage(self):
f = font.Font(size = 20, family = "Times")
Label_fillup = []
for i in range(0,3):
Label_fillup.append(Label(self, bg = "AntiqueWhite"))
Label_fillup[i].pack()
L1 = Label(self, text = "hello " + self.username + "! you are almost done", font = f, bg = "AntiqueWhite")
L1.pack()
self.photoName = StringVar()
Button_select_file = Button(self, text = "select your profile photo", command = self.selectFileName, bg = "WhiteSmoke")
Button_select_file.pack()
def selectFileName(self):
selectFile = filedialog.askopenfilename(title = "select your profile photo")
self.photoName.set(selectFile)
load = Image.open(selectFile)
w_box = 200
h_box = 200
load = self.resize(w_box, h_box, load)
render = ImageTk.PhotoImage(load)
img = Label(self, image = render)
img.image = render
img.pack()
b2 = Button(self, text = "finish signup!", command = self.nextCallBack)
b2.pack()
def resize(self, w_box, h_box, image):
w, h = image.size
f1 = 1.0*w_box/w
f2 = 1.0*h_box/h
factor = min([f1,f2])
width = int(w*factor)
height = int(h*factor)
return image.resize((width,height), Image.ANTIALIAS)
def nextCallBack(self):
self.destroy()
userInformation.writePhotoInfo(self.username, self.photoName.get())
self.Frame_main = mainFrame(self.cvs, self.username, self.master)
self.cvs.create_window(500, 215, width=500, height=430, window=self.Frame_main)