11from json import loads as json_loads
2- from re import L
3- from pyperclip import copy
2+ from pyperclip import copy , paste
43import PySimpleGUI as sg
54from decimal import Decimal as d
65
98
109class retime : #Class for all timer related functions
1110 def frame_round (time , fps ): # Rounds to the nearest frame
12- time = d (time )
13- time = round (time , 3 )
11+ time = d (round (time , 3 ))
1412 output = d (time - time % (d (1 )/ fps )) #Credit to Slush0Puppy for this 1 Line of Code
1513 return round (output , 3 )
1614
1715 # Formats the time to the SRC format
1816 def format (time ):
1917 time = str (time )
2018 time = time .split ('.' , 1 )
21- seconds = time [0 ]
22- milliseconds = time [1 ]
23- milliseconds = str (milliseconds )
24- seconds = int (seconds )
19+ seconds = int (time [0 ])
20+ milliseconds = str (time [1 ])
2521 minutes = seconds // 60
2622 hours = minutes // 60
2723 if seconds > 60 : #makes sure that the seconds are less than 60
2824 seconds = seconds - (minutes * 60 )
2925 if minutes > 60 : #makes sure that the minutes are less than 60
3026 minutes = minutes - (hours * 60 )
3127 #Converts Integers to Strings
32- seconds = str (seconds )
33- minutes = str (minutes )
34- hours = str (hours )
3528 #Combines the time into a single string
3629 if seconds == '0' :
3730 return (f'0s { milliseconds } ms' )
3831 elif minutes == '0' :
3932 if len (seconds ) == 1 :
40- return (f'0{ seconds } s { milliseconds } ms' )
33+ return (f'0{ str ( seconds ) } s { milliseconds } ms' )
4134 else :
42- return (f'{ seconds } s { milliseconds } ms' )
35+ return (f'{ str ( seconds ) } s { milliseconds } ms' )
4336 elif hours == '0' :
44- return (f'{ minutes } m { seconds } s { milliseconds } ms' )
37+ return (f'{ str ( minutes ) } m { str ( seconds ) } s { milliseconds } ms' )
4538 else :
46- return (f'{ hours } h { minutes } m { seconds } s { milliseconds } ms' )
39+ return (f'{ str ( hours ) } h { str ( minutes ) } m { str ( seconds ) } s { milliseconds } ms' )
4740
4841 #Calculates the loads
4942 def loads (dbi_start , dbi_end , fps ):
@@ -110,26 +103,26 @@ def final(dbi_start, dbi_end, loads, fps):
110103 if loads == 0 :
111104 final_confirm = sg .popup_yes_no (f'Without Loads: { no_loads } ' , 'Would you like the Mod Note to be Copied to the Clipboard?' , title = 'Results' )
112105 if final_confirm == 'Yes' :
113- copy (f'Mod Note: Retimed to { no_loads } at { fps } using https://github.com/ConnerConnerConner/PyTime' )
106+ copy (f'Mod Note: Retimed to { no_loads } at { fps } FPS using [PyTime]( https://github.com/ConnerConnerConner/PyTime) ' )
114107 elif final_confirm == 'No' :
115108 return
116109 else :
117110 final_confirm = sg .popup_yes_no (f'Without Loads: { no_loads } , With Loads: { with_loads } ' , 'Mod Note Copied to Clipboard' , title = 'Results' )
118111 if final_confirm == 'Yes' :
119- copy (f'Mod Note: Retimed to { no_loads } at { fps } using https://github.com/ConnerConnerConner/PyTime' )
112+ copy (f'Mod Note: Retimed to { no_loads } at { fps } FPS using [PyTime]( https://github.com/ConnerConnerConner/PyTime) ' )
120113 elif final_confirm == 'No' :
121114 return
122115
123116#GUI Layout
124117main_layout = [
125- [sg .Text ('PyTime' , font = ('Helvetica' , 36 )), sg .Text (' FPS' , font = (' Helvetica' , 30 )), sg .InputText ('60' , size = (5 , 1 ), key = 'fps' , font = ('Helvetica' , 30 ))],
126- [sg .InputText (key = 'dbis' , font = ('Helvetica' , 16 ), pad = ((5 , 0 ), (0 , 0 )), size = (20 , 1 )), sg .Text (' Debug Info Start' , font = ('Helvetica' , 16 ), justification = 'right' )],
127- [sg .InputText (key = 'dbie' , font = ('Helvetica' , 16 ), pad = ((5 , 0 ), (0 , 0 )), size = (20 , 1 )), sg .Text (' Debug Info End' , font = ('Helvetica' , 16 ), justification = 'right' )],
128- [sg .InputText (key = 'dbis_loads' , font = ('Helvetica' , 14 ), pad = ((5 , 0 ), (0 , 0 )), size = (15 , 1 )), sg .Text (' Debug Info Start (Loads)' , font = ('Helvetica' , 14 ), justification = 'right' )],
129- [sg .InputText (key = 'dbie_loads' , font = ('Helvetica' , 14 ), pad = ((5 , 0 ), (0 , 0 )), size = (15 , 1 )), sg .Text (' Debug Info End (Loads)' , font = ('Helvetica' , 14 ), justification = 'right' )],
130- [sg .Button ('Calculate' , font = ('Helvetica' , 16 )), sg .Button ('Add Loads' , font = ('Helvetica' , 16 )), sg .Button ('Remove All Loads' , font = ('Helvetica' , 16 ))]
118+ [sg .Text ('PyTime' , font = ('Helvetica' , 48 )), sg .Text (' FPS' , font = ('Helvetica' , 40 )), sg .InputText ('60' , size = (4 , 1 ), key = 'fps' , font = ('Helvetica' , 36 ))],
119+ [sg .Button ( 'Paste' , font = ( 'Helvetica' , 10 ), key = 'paste_dbis' ), sg . InputText (key = 'dbis' , font = ('Helvetica' , 16 ), pad = ((5 , 0 ), (0 , 0 )), size = (20 , 1 )), sg .Text (' Debug Info Start' , font = ('Helvetica' , 16 ), justification = 'right' )],
120+ [sg .Button ( 'Paste' , font = ( 'Helvetica' , 10 ), key = 'paste_dbie' ), sg . InputText (key = 'dbie' , font = ('Helvetica' , 16 ), pad = ((5 , 0 ), (0 , 0 )), size = (20 , 1 )), sg .Text (' Debug Info End' , font = ('Helvetica' , 16 ), justification = 'right' )],
121+ [sg .Button ( 'Paste' , font = ( 'Helvetica' , 10 ), key = 'paste_dbis_loads' ), sg . InputText (key = 'dbis_loads' , font = ('Helvetica' , 14 ), pad = ((5 , 0 ), (0 , 0 )), size = (15 , 1 )), sg .Text (' Debug Info Start (Loads)' , font = ('Helvetica' , 14 ), justification = 'right' )],
122+ [sg .Button ( 'Paste' , font = ( 'Helvetica' , 10 ), key = 'paste_dbie_loads' ), sg . InputText (key = 'dbie_loads' , font = ('Helvetica' , 14 ), pad = ((5 , 0 ), (0 , 0 )), size = (15 , 1 )), sg .Text (' Debug Info End (Loads)' , font = ('Helvetica' , 14 ), justification = 'right' )],
123+ [sg .Button ('Calculate' , font = ('Helvetica' , 18 )), sg .Button ('Add Loads' , font = ('Helvetica' , 18 )), sg .Button ('Remove All Loads' , font = ('Helvetica' , 18 ))]
131124 ]
132- main_window = sg .Window ('PyTime' , main_layout , resizable = False , element_justification = 'left' , size = ( 447 , 253 ) )
125+ main_window = sg .Window ('PyTime' , main_layout , resizable = False , element_justification = 'left' , size = ( 516 , 275 ), finalize = True )
133126
134127#Main Loop
135128while True :
@@ -157,16 +150,16 @@ def final(dbi_start, dbi_end, loads, fps):
157150 continue
158151 if not 'loads' in globals () or loads == 0 : #Checks if Loads exists
159152 try :
160- loads = retime .loads (dbis_loads , dbiel_loads , fps ) #Calculates Loade
153+ loads = retime .loads (dbis_loads , dbiel_loads , fps ) #Calculates Loads
161154 main_window ['dbis_loads' ].update ('' )
162155 main_window ['dbie_loads' ].update ('' )
163156 except :
164157 continue
165158 else :
166159 try :
167160 loads = retime .loads (dbis_loads , dbiel_loads , fps ) + loads
168- main_window ['dbis_loads' ].update ('' )
169- main_window ['dbie_loads' ].update ('' ) #Calculates Loads
161+ main_window ['dbis_loads' ].update ('' ) #Calculates Loads
162+ main_window ['dbie_loads' ].update ('' )
170163 except :
171164 continue
172165 if event == 'Calculate' :
@@ -189,6 +182,17 @@ def final(dbi_start, dbi_end, loads, fps):
189182 #Clears Input Boxes
190183 main_window ['dbis' ].update ('' )
191184 main_window ['dbie' ].update ('' )
185+ #Checks if the Paste Button is Pressed
186+ #Pastes the Clipboard to the Input Box
187+ if event == 'paste_dbis' :
188+ main_window ['dbis' ].update (paste ())
189+ if event == 'paste_dbie' :
190+ main_window ['dbie' ].update (paste ())
191+ if event == 'paste_dbis_loads' :
192+ main_window ['dbis_loads' ].update (paste ())
193+ if event == 'paste_dbie_loads' :
194+ main_window ['dbie_loads' ].update (paste ())
195+
192196
193197main_window .close () #Closes the Window once
194198
0 commit comments