This repository was archived by the owner on Oct 20, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathDeleteMe.py
More file actions
198 lines (169 loc) · 7.95 KB
/
Copy pathDeleteMe.py
File metadata and controls
198 lines (169 loc) · 7.95 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# def get_maximum():
# celsius = [14, 15.1, 12.3]
# maximum = max(celsius)
# print(maximum)
#
#
# celsius = get_maximum()
#
# fahrenheit = celsius * 1.8 + 32
# print(fahrenheit)
# def get_maximum():
# celsius = [14, 15.1, 12.3]
# maximum = max(celsius)
# return(maximum)
#
#
# celsius = get_maximum()
#
# fahrenheit = celsius * 1.8 + 32
# print(fahrenheit)
import textwrap
import time
# list = ("Apple","Banana","Orange")
#
# print(list)
# print(len(list))
#
# TIME STARTS HERE========================
# import datetime
# def ord(n):
# return str(n)+("th" if 4<=n%100<=20 else {1:"st",2:"nd",3:"rd"}.get(n%10, "th"))
#
# def dtStylish(dt,f):
# return dt.strftime(f).replace("{th}", ord(dt.day))
#
# dtStylish(datetime.datetime(2019, 5, 2, 16, 30), '%a the {th} at %I:%M')
#
#
# def ord(n):
# return str(n)+("th" if 4<=n%100<=20 else {1:"st",2:"nd",3:"rd"}.get(n%10, "th"))
#
# import time
# # Monday, June 12th, 2023, 10:24 am)
# daymonth = time.strftime("%A, %B ")
# date = ord(int(time.strftime("%d")))
# dayofyear = ord(int(time.strftime("%j")))
# time = time.strftime("%I:%M:%S %p")
#
# print(f"Hello! The current date is {daymonth}{date}.\nThe current time is {time}.\n"
# f"It is the {dayofyear} day of the year.")
# TIME ENDS HERE========================
# XXXXXXXXX
# import PySimpleGUI as sg
#
# selectlabel = sg.Text("Enter feet:")
# selectinput = sg.Input()
# selects = [selectlabel, selectinput]
#
# destlabel = sg.Text("Enter inches:")
# destinput = sg.Input()
# dests = [destlabel,destinput]
#
# compress_button = sg.Button("Convert!")
#
# window = sg.Window("Converter",layout=[[selects], [dests], [compress_button]])
# # aha that did work!
#
# window.read()
#
# window.close()
#
# import PySimpleGUI as sg
#
# label = sg.Text("What are dolphins?")
# option1 = sg.Radio("Amphibians", group_id="question1")
# option2 = sg.Radio("Fish", group_id="question1")
# option3 = sg.Radio("Mammals", group_id="question1")
# option4 = sg.Radio("Birds", group_id="question1")
#
# window = sg.Window("File Compressor",
# layout=[[label],
# [option1],
# [option2],
# [option3],
# [option4],
# ])
#
# window.read()
# window.close()
# XXXXXXXXX
import PySimpleGUI as sg
# from multiprocessing import Process
'''
Notification Window Demo Program
Shamelessly stolen from PySimpleGUI user ncotrb
Displays a small informational window with an Icon and a message in the lower right corner of the display
Option to fade in/out or immediatealy display.
'''
# -------------------------------------------------------------------
# fade in/out info and default window alpha
USE_FADE_IN = True
WINDOW_ALPHA = 0.9
WIN_MARGIN = 60
# colors
WIN_COLOR = "#282828"
TEXT_COLOR = "#ffffff"
DEFAULT_DISPLAY_DURATION_IN_MILLISECONDS = 10000
# -------------------------------------------------------------------
def display_notification(title, message, icon, display_duration_in_ms=DEFAULT_DISPLAY_DURATION_IN_MILLISECONDS,
use_fade_in=True, location=None):
# Compute location and size of the window
message = textwrap.fill(message, 50)
win_msg_lines = message.count("\n") + 1
screen_res_x, screen_res_y = sg.Window.get_screen_size()
win_margin = WIN_MARGIN # distance from screen edges
win_width, win_height = 364, 66 + (14.8 * win_msg_lines)
layout = [[sg.Graph(canvas_size=(win_width, win_height), graph_bottom_left=(0, win_height),
graph_top_right=(win_width, 0), key="-GRAPH-", background_color=WIN_COLOR,
enable_events=True)]]
win_location = location if location is not None else (
screen_res_x - win_width - win_margin, screen_res_y - win_height - win_margin)
window = sg.Window(title, layout, background_color=WIN_COLOR, no_titlebar=True,
location=win_location, keep_on_top=True, alpha_channel=0, margins=(0, 0),
element_padding=(0, 0),
finalize=True)
window["-GRAPH-"].draw_rectangle((win_width, win_height), (-win_width, -win_height), fill_color=WIN_COLOR,
line_color=WIN_COLOR)
window["-GRAPH-"].draw_image(data=icon, location=(20, 20))
window["-GRAPH-"].draw_text(title, location=(64, 20), color=TEXT_COLOR, font=("Arial", 12, "bold"),
text_location=sg.TEXT_LOCATION_TOP_LEFT)
window["-GRAPH-"].draw_text(message, location=(64, 44), color=TEXT_COLOR, font=("Arial", 9),
text_location=sg.TEXT_LOCATION_TOP_LEFT)
window["-GRAPH-"].Widget.config(cursor="hand2")
if use_fade_in == True:
for i in range(1, int(WINDOW_ALPHA * 100)): # fade in
window.set_alpha(i / 100)
window.refresh()
time.sleep(.02)
event, values = window(timeout=display_duration_in_ms)
for i in range(int(WINDOW_ALPHA * 100), 1, -1): # fade out
window.set_alpha(i / 100)
window.refresh()
time.sleep(.02)
else:
window.set_alpha(WINDOW_ALPHA)
event, values = window(timeout=display_duration_in_ms)
print(f'The event was {event}')
# Base64 Images to use as icons in the window
img_error = b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAADlAAAA5QGP5Zs8AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAIpQTFRF////20lt30Bg30pg4FJc409g4FBe4E9f4U9f4U9g4U9f4E9g31Bf4E9f4E9f4E9f4E9f4E9f4FFh4Vdm4lhn42Bv5GNx5W575nJ/6HqH6HyI6YCM6YG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c2y2nOqc6OwruxUWx0rDjNJtyp6HkUW4bJn0VWdf/a7nDpj1u++PBOR694+Ftj/8PKNdnDLn/V8YAAAAASUVORK5CYII='
def process(location=None):
title = "Action completed successfully"
message = "This message is intended to inform you that the action you have performed has been successful. There is no need for further action."
display_notification(title, message, img_success, 4000, True, location=location)
todo1 = "Walk the dog"
todo2 = 'Have the dog put down for rabies'
def todosuccessfuledit(location=None):
title = "To-Do Item Edited Successfully"
message = f"''{todo1}'' was successfully changed to ''{todo2}''. There is no need for further action."
display_notification(title, "", img_success, 0, True, location=location)
if __name__ == '__main__':
todosuccessfuledit(location=(WIN_MARGIN, WIN_MARGIN))
# was experimenting with using multiprocessing with these windows. Couldn't get it to work
# p = Process(target=process)
# p1 = Process(target=process, args=((WIN_MARGIN, WIN_MARGIN),))
# p1.start()
# p.start()
# p.join()
# p1.join()