0

I am doing a very small GUI with easygui and its buttonbox. My problem is: My image is also displayed as button, but it shouldn't. Is there a way to display a image in the button box, but this image should not be "clickable" ? To test you have to do pip Install easygui

Here is my buttonbox call:

import easygui
version = "Version 1.0 -- 10.2018"

main_options=["Doors EXPORT","ANALYSE","VISUALIZE","Auto-Mode","Configuration"]

choosed_option = gui.buttonbox(msg="",title = version, choices = main_options,image ="logo.gif" )
Mike - SMT
  • 14,784
  • 4
  • 35
  • 79
Loois95
  • 85
  • 12
  • 1
    Please provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Mike - SMT Oct 15 '18 at 14:37
  • What do you think is Missing ? – Loois95 Oct 15 '18 at 14:38
  • Your code is not testable. You need to read on how to provide a MCVE. You should have enough code for us to copy paste into a IDE and test. As it stands now your code is missing imports, the root window code and mainloop at least before it can be tested. – Mike - SMT Oct 15 '18 at 14:39
  • IT is able to run with Import easygui – Loois95 Oct 15 '18 at 14:43
  • 1
    Nothing in the documentation for easygui stats your image will be just an image. According to the documentation it does appear that all your variables are buttons including images. There is no documentation that I can find that says you can disable the image. You are probably better off building this in tkinter. – Mike - SMT Oct 15 '18 at 14:57
  • In the easygui Tutorial (Project Side) it is no button – Loois95 Oct 15 '18 at 15:06
  • 1
    Testing from the easygui documentation shows that `image` and `images` argument for `buttonbox` produce a clickable image button. I cannot find any documented settings that will change that. However I did finish an example that will work written in tkinter. – Mike - SMT Oct 15 '18 at 15:11

1 Answers1

1

From the documentation I fond on buttonbox for easygui there is nothing stating the image should not be a button or a way of changing it state. However here is a pure tkinter example that should be close to what you need.

import tkinter as tk


root = tk.Tk()
version = "Version 1.0 -- 10.2018"
root.title(version)
root.geometry("675x200")
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

main_options=["Doors EXPORT","ANALYSE","VISUALIZE","Auto-Mode","Configuration"]

tk.Label(root, text="Here is where you message will go from the msg section of your buttonbox").grid(row=0, column=0, columnspan = len(main_options), stick="n", pady=(15,0))

img = tk.PhotoImage(file="logo.gif")
tk.Label(root,image=img).grid(row=1, column=0, pady=5)

frame2 = tk.Frame(root)
frame2.grid(row=2, column=0)

for ndex, item in enumerate(main_options):
    tk.Button(frame2, text=item).grid(row=0, column=ndex, ipadx=5, ipady=5, padx=5, pady=(30, 5), stick="ew")

root.mainloop()

You can also create a class that does essentially the same thing and takes all the arguments as the buttonbox does like this:

import tkinter as tk


options = ["Doors EXPORT","ANALYSE","VISUALIZE","Auto-Mode","Configuration"]
version = "Version 1.0 -- 10.2018"
msg = "Here is where you message will go from the msg section of your buttonbox"
ipath = "logo.gif"


class mock_buttonbox(tk.Tk):
    def __init__(self, var_msg = "", version = "", main_options = [], img_path=""):
        tk.Tk.__init__(self)
        self.title(version)
        self.geometry("675x200")
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        try:
            tk.Label(self, text=var_msg).grid(row=0, column=0, columnspan = len(main_options), stick="n", pady=(15,0))
            img = tk.PhotoImage(file=img_path)
            tk.Label(self,image=img).grid(row=1, column=0, pady=5)
        except:
            print("Bad image path, wrong image format or no options provided.")

        frame2 = tk.Frame(self)
        frame2.grid(row=2, column=0)

        try:
            for ndex, item in enumerate(main_options):
                tk.Button(frame2, text=item).grid(row=0, column=ndex, ipadx=5, ipady=5, padx=5, pady=(30, 5), stick="ew")
        except:
            print("No options provided or options are not a value argument for text field.")
        self.mainloop()

mock_buttonbox(var_msg = msg, version = version, main_options = options, img_path = ipath)
Mike - SMT
  • 14,784
  • 4
  • 35
  • 79
  • @Loois95 See my updated answer. It should basically provide the same format as your buttonbox with an image that is not a button. – Mike - SMT Oct 15 '18 at 15:22