def OnOpen(self, event): dlg = OpenFileDialog() dlg.lpstrInitialDir = self.current_path dlg.SetFilter('Icon file(*.xpm)|*.xpm|All files(*.*)|*.*') if dlg.DoModal(parent=self): self.current_path = dlg.lpstrFile self.xpm_to_icon_data(self.current_path)
def OnOpenImage(self, event): dlg = OpenFileDialog() dlg.lpstrInitialDir = getcwd() dlg.lpstrInitialDir = self.current_open_dir dlg.nFilterIndex = self.current_open_filter_index dlg.SetFilter( 'BMP Image(*.bmp)|*.bmp|PNG Image(*.png)|*.png|JPG Image(*.jpg)|*.jpg|GIF Image(*.gif)|*.gif|Icon Image(*.ico)|*.ico|Cursor Image(*.cur)|*.cur|EMF Image(*.emf)|*.emf|WMF Image(*.wmf)|*.wmf|All files(*.*)|*.*' ) if dlg.DoModal(self): self.current_open_dir = dlg.lpstrFile self.current_open_filter_index = dlg.nFilterIndex status = -1 if dlg.nFilterIndex == 1: #BMP status, image = gdiplus.GdipCreateBitmapFromFile(dlg.lpstrFile) elif dlg.nFilterIndex in (5, 6): #ICO#CUR hicon = ExtractIcon(None, dlg.lpstrFile, 0) if hicon: status, image = gdiplus.GdipCreateBitmapFromHICON(hicon) else: status, image = gdiplus.GdipLoadImageFromFile(dlg.lpstrFile) if status == gdiplus.Ok: self.grid.current_image = (image, dlg.lpstrFile) self.set_paste_property()