I am using streamlit library and qrcode library to make QRgenerator for my project. ** a portion of code as below:**
qr_eyes_img = qr.make_image(image_factory=StyledPilImage,eye_drawer=RoundedModuleDrawer(radius_ratio=1.2), color_mask=SolidFillColorMask(back_color=(255, 255,255),front_color=(255,110,0)))
My issue is back_color and front_color are not accepting the input from the st.color_picker. I have tried lot of options. It always give me none type error etc.
Any suggestion to make above code accept the input from st.color_picker?
Try converting the color values from st.color_picker()
to tuples of integers representing the RGB values that you can then pass into the qr.make_image()
function:
# Color pickers for the background and foreground colors
back_color = st.color_picker("Choose background color", "#FFFFFF")
front_color = st.color_picker("Choose foreground color", "#FF6E00")
# Convert color values to tuples of integers
back_color_tuple = tuple(int(x, 16) for x in (back_color[1:3], back_color[3:5], back_color[5:]))
front_color_tuple = tuple(int(x, 16) for x in (front_color[1:3], front_color[3:5], front_color[5:]))
Finally, replace your values in color_mask
with the variable above:
color_mask=SolidFillColorMask(back_color=back_color_tuple, front_color=front_color_tuple)
Please let me know if this solves the issue.