@@ -9,7 +9,7 @@ def __init__(self, parent, image_size):
99 self .max_size = 240
1010
1111 img = wx .Image (* image_size )
12- self .image_ctrl = wx .StaticBitmap (self ,
12+ self .image_ctrl = wx .StaticBitmap (self ,
1313 bitmap = wx .Bitmap (img ))
1414
1515 browse_btn = wx .Button (self , label = 'Browse' )
@@ -37,29 +37,29 @@ def on_browse(self, event):
3737 wildcard = "JPEG files (*.jpg)|*.jpg"
3838 with wx .FileDialog (None , "Choose a file" ,
3939 wildcard = wildcard ,
40- style = wx .ID_OPEN ) as dialog :
40+ style = wx .FD_OPEN ) as dialog :
4141 if dialog .ShowModal () == wx .ID_OK :
4242 self .photo_txt .SetValue (dialog .GetPath ())
4343 self .load_image ()
44-
44+
4545 def load_image (self ):
4646 """
4747 Load the image and display it to the user
4848 """
4949 filepath = self .photo_txt .GetValue ()
5050 img = wx .Image (filepath , wx .BITMAP_TYPE_ANY )
51-
51+
5252 # scale the image, preserving the aspect ratio
5353 W = img .GetWidth ()
5454 H = img .GetHeight ()
5555 if W > H :
5656 NewW = self .max_size
57- NewH = self .max_size * H / W
57+ NewH = int ( self .max_size * H / W )
5858 else :
5959 NewH = self .max_size
60- NewW = self .max_size * W / H
60+ NewW = int ( self .max_size * W / H )
6161 img = img .Scale (NewW ,NewH )
62-
62+
6363 self .image_ctrl .SetBitmap (wx .Bitmap (img ))
6464 self .Refresh ()
6565
@@ -75,4 +75,4 @@ def __init__(self):
7575if __name__ == '__main__' :
7676 app = wx .App (redirect = False )
7777 frame = MainFrame ()
78- app .MainLoop ()
78+ app .MainLoop ()
0 commit comments