0

I am working on a python program using Enthought Canopy (for data acquisition). However I have an issue using tkinter when working in the python 3.5 environment. I can not get the values of my radio buttons using the var.get() function. (both defining it as tk.IntVar() when using integers or as tk.StringVar() like in my example code)

Also the main loop does not stop when pressing the exit button, the tkinter window closes but the program keeps running.

When switching to the python 2.7 environment I don't have these problems. Below is a stripped down version of the code.

Thanks in advance for the help

import tkinter as tk

class GUI:
    def __init__ (self, master):
        self.master = master #Defining the root window

        #Create container
        frame = tk.Frame(master)

        #Defining the labels
        fontName = 'Helvetica 10'
        self.waveform = tk.StringVar()

        self.sawtoothRadio = tk.Radiobutton(frame, text='Sawtooth', 
                                                    variable=self.waveform, value="sawtooth")
        self.triangleRadio = tk.Radiobutton(frame, text='Triangle', 
                                                    variable=self.waveform, value="triangle")
        self.triangleRadio.select()
        self.startButton = tk.Button(frame, text="Start", font = fontName, command=self.calibrate)

        #Structuring the GUI
        self.sawtoothRadio.grid(row=9, column=0)
        self.triangleRadio.grid(row=9, column=1)
        self.startButton.grid(row=10, column=1)

        frame.pack(side=tk.LEFT)

    def draw_graph(self, right_frame):
        #Plotting the graph
        if self.waveform.get() == "sawtooth":
            sawtooth = True
        else:
            sawtooth = False

    def calibrate(self):
        #Plotting the graph
        if self.waveform.get() == "sawtooth":
            sawtooth = True
        else:
            sawtooth = False

root = tk.Tk()
newWindow = GUI(root)
root.mainloop()
  • What are we suppose to do to reproduce the problem? This code all seems to work as expected -- when I add a print statement in `calibrate` it's correctly displaying the radiobutton that I selected. Also, is the `style.use` really necessary to reproduce the problem? – Bryan Oakley Sep 27 '18 at 16:17
  • Thanks for the reply. It might be because I am using Enthought Canopy, so someone using this IDE might provide me with more insight or a solution. – lexhuismans Sep 27 '18 at 16:23

1 Answers1

0

So I finally found out that the problem seems to be with Enthought's Canopy.

The program runs properly in both PyCharm and Anaconda's Spyder, however I still do not know what is causing the problem in Canopy. But using another IDE seems to solve the problem.