Skip to content

Conversation

@Tumlinh
Copy link

@Tumlinh Tumlinh commented Oct 29, 2025

Add support for QR code generation in a new Tk frame.
The LabelPreview class is extended to call the QR code generation lib.
The Label class 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.

Copy link
Collaborator

@usedbytes usedbytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems much less useful than the others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants