Conversation
usedbytes
left a comment
There was a problem hiding this comment.
Nice, thanks for the patch :)
I'd like to see some tweaks to alignment/padding, but generally looks good.
I haven't tested it yet.
| img = img.resize((int(img.width / ratio), int(img.height / ratio)), Image.Resampling.BOX) | ||
|
|
||
| # Scale image up | ||
| if img.width <= usable_res[0] // 2 and img.height <= usable_res[1] // 2: |
There was a problem hiding this comment.
Should this be an elif? Or at least < instead of <=, otherwise won't it downscale to exactly width,height and then always do this upscale as a no-op
| # Adjust text (description) padding accordingly | ||
| img_text_padding = self.padding.right | ||
| self.text_padding = Label.Padding( | ||
| left=self.inner_img.width + img_text_padding + self.padding.left, |
There was a problem hiding this comment.
I'm not sure what you're intending for the padding(s), but it looks a bit odd to me.
self.padding is supposed to be the border around the edge of the label. You are also re-using the same padding amounts for padding around the image?
I'd expect something like:
,__________________________________________________________________________________________________,
| | | | | |
|<--self.padding.left-->| IMAGE |<--some_new_img_gap-->| TEXT |<--self.padding.right-->|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
|_______________________|_____________|______________________|____________|________________________|
| ] | ||
|
|
||
| lines_copy = [] | ||
| # Make sure all entries are a list of entries |
There was a problem hiding this comment.
Why not leave this in __init__?
| line_top = (line_gap // 2) + self.text_padding.top | ||
| else: | ||
| # Vertically align line top with inner image | ||
| line_top = self.text_padding.top |
There was a problem hiding this comment.
I feel it would be better to vertically align the image, so it has equal spacing top-and-bottom, then align the text to that. Your example image squishes the text and image towards the top of the label
| if self.inner_img is None: | ||
| d.text((x, line_top), elem, font=lp.font, fill=0, anchor='mt') | ||
| else: | ||
| d.text((x, line_top), elem, font=lp.font, fill=0, anchor='lt') |
There was a problem hiding this comment.
Why not still align in the middle of the free space?
| self.template3 = ttk.Button(self, text="WhatsApp", | ||
| command=lambda: self.select_template("https://api.whatsapp.com/send?phone=" + self.contact, self.name)) | ||
| self.template3.grid(column = 2, row = row, sticky = 'nwes') | ||
| self.template4 = ttk.Button(self, text="Equipment", |
There was a problem hiding this comment.
This one seems much less useful than the others
Add support for QR code generation in a new Tk frame.
The
LabelPreviewclass is extended to call the QR code generation lib.The
Labelclass is restructured to support two modes: inner image mode (QR code left aligned, description aligned against it) and traditional text mode (text centered).Some templates are provided as placeholder in the form of buttons. They populate the QR code text and description.