|
19 | 19 | from tkinter import * |
20 | 20 | import webbrowser |
21 | 21 |
|
22 | | -# Build Window |
23 | | -window = Tk() |
24 | | -window.title("Online Account Avatars and Banners") |
| 22 | +# Account Avatar Function |
| 23 | +row_count = 2 |
| 24 | +column_count = 1 |
25 | 25 |
|
26 | | -# Window Title |
27 | | -title = Label(window, text = "Online Account Avatars and Banners", fg = "blue", font = "Consolas 20") |
28 | | -title.grid(row = 1, column = 1, columnspan = 5) |
| 26 | +# PyAvatar Window |
| 27 | +def avatars(): |
| 28 | + # Build Window |
| 29 | + window = Tk() |
| 30 | + window.title("Online Account Avatars and Banners") |
29 | 31 |
|
30 | | -# Placeholder Image Constant |
31 | | -PLACEHOLDER = PhotoImage(file = "PyAvatar/images/placeholder.gif") |
| 32 | + # Window Title |
| 33 | + title = Label(window, text = "Online Account Avatars and Banners", fg = "blue", font = "Consolas 20") |
| 34 | + title.grid(row = 1, column = 1, columnspan = 5) |
32 | 35 |
|
33 | | -# Account Link Function |
34 | | -def link(url): |
35 | | - webbrowser.open_new(url) |
| 36 | + # Placeholder Image Constant |
| 37 | + PLACEHOLDER = PhotoImage(file = "PyAvatar/images/placeholder.gif") |
36 | 38 |
|
37 | | -# Account Avatar Function |
38 | | -row_count = 2 |
39 | | -column_count = 1 |
40 | | -def accounts(image, name, hyperlink): |
41 | | - global row_count |
42 | | - global column_count |
| 39 | + # Account Link Function |
| 40 | + def link(url): |
| 41 | + webbrowser.open_new(url) |
| 42 | + |
| 43 | + def accounts(image, name, hyperlink): |
| 44 | + # Build each account frame |
| 45 | + account = Frame(window) |
| 46 | + img_account = image # needs to be a GIF |
| 47 | + title_account = Label(account, image = img_account) |
| 48 | + text_account = Label(account, text = name) |
| 49 | + hyperlink_account = Label(account, text = hyperlink, fg = "blue", cursor = "hand2") |
43 | 50 |
|
44 | | - # Build each account frame |
45 | | - account = Frame(window) |
46 | | - img_account = image # needs to be a GIF |
47 | | - title_account = Label(account, image = img_account) |
48 | | - text_account = Label(account, text = name) |
49 | | - hyperlink_account = Label(account, text = hyperlink, fg = "blue", cursor = "hand2") |
| 51 | + # Layout elements in frame |
| 52 | + title_account.pack(side = TOP) |
| 53 | + text_account.pack(side = BOTTOM) |
| 54 | + hyperlink_account.pack(side = BOTTOM) |
| 55 | + hyperlink_account.bind("<Button-1>", lambda e: link(hyperlink)) |
50 | 56 |
|
51 | | - # Layout elements in frame |
52 | | - title_account.pack(side = TOP) |
53 | | - text_account.pack(side = BOTTOM) |
54 | | - hyperlink_account.pack(side = BOTTOM) |
55 | | - hyperlink_account.bind("<Button-1>", lambda e: link(hyperlink)) |
| 57 | + # Layout elements in window |
| 58 | + global row_count |
| 59 | + global column_count |
| 60 | + if column_count <= 5: |
| 61 | + account.grid(row = row_count, column = column_count, padx= 5, pady= 5) |
| 62 | + column_count += 1 |
| 63 | + else: |
| 64 | + row_count += 1 |
| 65 | + column_count = 1 |
| 66 | + account.grid(row = row_count, column = column_count, padx = 5, pady = 5) |
56 | 67 |
|
57 | | - # Layout elements in window |
58 | | - if column_count <= 5: |
59 | | - account.grid(row = row_count, column = column_count, padx= 5, pady= 5) |
60 | | - column_count += 1 |
61 | | - else: |
62 | | - row_count += 1 |
63 | | - column_count = 1 |
64 | | - account.grid(row = row_count, column = column_count, padx = 5, pady = 5) |
| 68 | + # Account Profiles |
| 69 | + accounts(PLACEHOLDER, "GitHub", "https://github.com") |
| 70 | + accounts(PLACEHOLDER, "GitLab", "https://gitlab.com") |
65 | 71 |
|
66 | | -# Account Profiles |
67 | | -accounts(PLACEHOLDER, "Github", "https://github.com") |
68 | | -accounts(PLACEHOLDER, "GitLab", "https://gitlab.com") |
| 72 | + # Sustain Window |
| 73 | + window.mainloop() |
69 | 74 |
|
70 | | -# Sustain Window |
71 | | -window.mainloop() |
| 75 | +if __name__ == '__main__': |
| 76 | + avatars() |
0 commit comments