Skip to content

Commit

Permalink
Do small ImageBox refactor
Browse files Browse the repository at this point in the history
Correct ImageBox.commit type hinting; reformat ImageBox.__init__
  • Loading branch information
cydanil committed Jul 4, 2021
1 parent 38307bd commit bc5b546
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/gourmet/reccard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import webbrowser
import xml.sax.saxutils
from pkgutil import get_data
from typing import Any, Callable, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from gi.repository import Gdk, GdkPixbuf, GLib, GObject, Gtk, Pango
from PIL import Image
Expand Down Expand Up @@ -1459,13 +1459,15 @@ def save(self, recdic):
self.emit('saved')
return recdic

class ImageBox: # used in DescriptionEditor for recipe image.
def __init__ (self, RecCard):

class ImageBox:
"""A widget for handling images in the DescriptionEditor."""
def __init__(self, rec_card):
debug("__init__ (self, RecCard):",5)
self.edited = False
self.rg = RecCard.rg
self.rc = RecCard
self.ui = self.rc.ui
self.rc = rec_card
self.rg = rec_card.rg
self.ui = rec_card.ui
self.imageW = self.ui.get_object('recImage')
self.addW = self.ui.get_object('addImage')
self.delW = self.ui.get_object('delImageButton')
Expand Down Expand Up @@ -1506,7 +1508,7 @@ def hide (self):
self.addW.show()
return True

def commit(self) -> Optional[Tuple[bytes, bytes]]:
def commit(self) -> Union[Tuple[bytes, bytes], Tuple[None, None]]:
"""Return image and thumbnail data for storage in the database."""
debug("commit (self):", 5)
if self.image:
Expand Down

0 comments on commit bc5b546

Please sign in to comment.