'Opencv GUI python: arrange the created buttons

I use python 3.8 and Opencv in Linux.

  1. I have several buttons that have stacked horizontally. How can I arrange them as I like (e.g., in a grid way?)

  2. Is it possible to show some icons for each of the buttons?

  3. Is it possible to make the fonts of the buttons bar larger?

Part of my script: (any suggestion to make my script better is appreciated)

if __name__== "__main__":


    Folder_name = "male"
    data_path = "path/to/images"
    data_path = os.path.join(data_path, Folder_name)

    all_imgs_path = glob.glob("{}/*.jpg".format(data_path))
    all_imgs_path = sorted(all_imgs_path)
    annot = annotation_tool(nof_imgs=len(all_imgs_path))

    for index, im_dir in enumerate(all_imgs_path):
        annot[index] = im_dir

    item_path = "guid.jpg"
    img = cv2.imread(item_path)
    img_name = item_path.split("/")[-1]
    cv2.imshow("{}".format(img_name), img)

    cv2.createButton('Next', annot.Next, ["Next Image"])
    cv2.createButton('Back', annot.Back, ["Previous Image"])
    cv2.createButton('Submit', annot.Submit, ["Submit"])

     # there are many of these buttons
    UB_Tshirt = cv2.createButton("UB_Tshirt", annot.checkbox, "UB_Tshirt", 1, 0)
    UB_Shirt = cv2.createButton("UB_Shirt", annot.checkbox, "UB_Shirt", 1, 0)
    UB_Coat = cv2.createButton("UB_Coat", annot.checkbox, "UB_Coat", 1, 0)

    cv2.waitKey(0)
    print("end")

Edit:

As you see in the image, the buttons bar is very long and goes out of the screen. I would like to create a button pad that is squared. enter image description here



Solution 1:[1]

This isn't a complete answer, but in regards to button arrangement, you have a little control using 'cv2.QT_NEW_BUTTONBAR'.

There's further detail here: https://docs.opencv.org/4.x/dc/d46/group__highgui__qt.html#gad15c7adb377e778dc907c0e318be193e

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ouflak