@@ -70,7 +70,7 @@ def __init__(self):
7070 def mouse_down (self , down ):
7171 if hasattr (self , 'gravity' ) or hasattr (self , 'bounciness' ) or hasattr (self , 'friction' ):
7272 widget_under_mouse = self .root .winfo_containing (self .root .winfo_pointerx (), self .root .winfo_pointery ())
73- if widget_under_mouse == self .gravity or widget_under_mouse == self .bounciness or widget_under_mouse == self .friction :
73+ if widget_under_mouse == self .gravity or widget_under_mouse == self .bounciness or widget_under_mouse == self .friction or widget_under_mouse == self . throw :
7474 self .hasBeenUnderMousePreviousFrame = True
7575
7676 if self .mouseDown == False and down == True :
@@ -140,7 +140,7 @@ def on_friction_change(self, value):
140140
141141 def on_throw_factor_change (self , value ):
142142 global THROW_FACTOR
143- THROW_FACTOR = float (value )
143+ THROW_FACTOR = 750 - float (value )
144144
145145 def on_pop_factor_change (self , value ):
146146 global POP_FACTOR
@@ -165,7 +165,13 @@ def show_sliders(self):
165165 self .friction .set (FRICTION )
166166 self .friction .pack (expand = True )
167167 self .friction_label = tk .Label (self .root , text = "Friction" )
168- self .friction_label .pack (pady = (0 , 25 ))
168+ self .friction_label .pack (pady = (0 , 50 ))
169+
170+ self .throw = ttk .Scale (self .root , from_ = 25 , to = 700 , orient = 'horizontal' , length = 300 , command = self .on_throw_factor_change )
171+ self .throw .set (750 - THROW_FACTOR )
172+ self .throw .pack (expand = True )
173+ self .throw_label = tk .Label (self .root , text = "Throw power" )
174+ self .throw_label .pack (pady = (0 , 25 ))
169175
170176 self .slide_in_effect ()
171177
@@ -174,10 +180,12 @@ def slide_in_effect(self, scale=0.0):
174180 self .gravity .configure (length = 300 )
175181 self .friction .configure (length = 300 )
176182 self .bounciness .configure (length = 300 )
183+ self .throw .configure (length = 300 )
177184 return
178185 self .gravity .configure (length = scale )
179186 self .bounciness .configure (length = scale )
180187 self .friction .configure (length = scale )
188+ self .throw .configure (length = scale )
181189 self .root .after (1 , self .slide_in_effect , scale + 2 )
182190
183191 def hide_sliders (self , scale = 300 ):
@@ -188,27 +196,30 @@ def hide_sliders(self, scale=300):
188196 self .bounciness_label .destroy ()
189197 self .friction .destroy ()
190198 self .friction_label .destroy ()
199+ self .throw .destroy ()
200+ self .throw_label .destroy ()
191201 return
192202 self .gravity .configure (length = scale )
193203 self .bounciness .configure (length = scale )
194204 self .friction .configure (length = scale )
205+ self .throw .configure (length = scale )
195206
196207 self .root .after (1 , self .hide_sliders , scale - 2 )
197208
198209 def animate_settings_open (self , center_x , center_y , i = 0 ):
199210 if i < 400 :
200- self .root .geometry ('+{}+{}' .format (int (center_x - (int (100 + i )) / 2 ), int (center_y - (int (100 + i * .5 ) / 2 ))))
201- self .root .geometry (f'{ int (100 + i )} x{ int (100 + i * .5 )} ' )
211+ self .root .geometry ('+{}+{}' .format (int (center_x - (int (100 + i )) / 2 ), int (center_y - (int (100 + i * .75 ) / 2 ))))
212+ self .root .geometry (f'{ int (100 + i )} x{ int (100 + i * .75 )} ' )
202213 self .root .after (10 , self .animate_settings_open , center_x , center_y , i + 10 )
203214 else :
204- self .root .geometry (f'500x300 ' )
215+ self .root .geometry (f'500x400 ' )
205216 self .root .update ()
206217 self .state = "settings"
207218
208219 def animate_settings_close (self , center_x , center_y , i = 0 ):
209220 if i < 400 :
210- self .root .geometry ('+{}+{}' .format (int (center_x - (int (500 - i )) / 2 ), int (center_y - (int (300 - i * .5 ) / 2 ))))
211- self .root .geometry (f'{ int (500 - i )} x{ int (300 - i * .5 )} ' )
221+ self .root .geometry ('+{}+{}' .format (int (center_x - (int (500 - i )) / 2 ), int (center_y - (int (400 - i * .75 ) / 2 ))))
222+ self .root .geometry (f'{ int (500 - i )} x{ int (400 - i * .75 )} ' )
212223 self .root .after (10 , self .animate_settings_close , center_x , center_y , i + 10 )
213224 else :
214225 self .root .geometry (f'100x100' )
0 commit comments