Skip to content

Commit

Permalink
fix file load crash - closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
maqifrnswa committed Sep 14, 2020
1 parent 650e20d commit 2a02f49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.2] - 2020-09-01

### Changed

- Issue #16: Fixed a bug where PCSI would crash if you cancelled loading a file.

## [0.0.1] - 2020-07-26

### Added
Expand All @@ -32,6 +38,7 @@ and this project adheres to

- First release

[Unreleased]: https://github.com/maqifrnswa/PCSI/compare/v0.0.1...HEAD
[Unreleased]: https://github.com/maqifrnswa/PCSI/compare/v0.0.2...HEAD
[0.0.2]: https://github.com/maqifrnswa/PCSI/compare/v0.0.1...v0.0.2
[0.0.1]: https://github.com/maqifrnswa/PCSI/compare/v0.0.0...v0.0.1
[0.0.0]: https://github.com/maqifrnswa/PCSI/releases/tag/v0.0.0
26 changes: 14 additions & 12 deletions pcsiGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,21 @@ def connectTCP(*args):


def loadfile(*args):
filename = False
filename = filedialog.askopenfilename()
imagefilename.set(filename)
imagedata=Image.open(filename)
croppedString = ""
# image must be multiples of 16px
if imagedata.width %16 or imagedata.height%16:
imagedata = imagedata.crop((0,0,imagedata.width//16*16,imagedata.height//16*16))
croppedString = "\nImage is CROPPED!"
dimVar.set(str(imagedata.width)+"x"+str(imagedata.height)+" px" + croppedString)
imagedata.thumbnail([320,240])
imagedata=ImageTk.PhotoImage(imagedata)
imageCanvas.create_image(0,0,image=imagedata, anchor=NW)
imageCanvas.image=imagedata # see: http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm
if filename:
imagefilename.set(filename)
imagedata=Image.open(filename)
croppedString = ""
# image must be multiples of 16px
if imagedata.width %16 or imagedata.height%16:
imagedata = imagedata.crop((0,0,imagedata.width//16*16,imagedata.height//16*16))
croppedString = "\nImage is CROPPED!"
dimVar.set(str(imagedata.width)+"x"+str(imagedata.height)+" px" + croppedString)
imagedata.thumbnail([320,240])
imagedata=ImageTk.PhotoImage(imagedata)
imageCanvas.create_image(0,0,image=imagedata, anchor=NW)
imageCanvas.image=imagedata # see: http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm


ttk.Button(mainframe,text="Load Image",command=loadfile).grid(column=1, row=3, sticky=(N))#, W, E, S))
Expand Down

0 comments on commit 2a02f49

Please sign in to comment.