#!/usr/bin/env python
# -*- coding: ascii -*-
from __future__ import print_function

# NOTICE... this file is generated by TkGridGUI.
# Any code or comments added by the user must be in designated areas ONLY.
# User additions will be lost if they are placed in code-generated areas.
# (i.e. Saving from TkGridGUI will over-write code-generated areas.)

# TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "imports"


from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import object

from tkinter.ttk import Combobox, Progressbar, Separator, Treeview, Notebook

from tkinter import *
from tkinter import Button, Canvas, Checkbutton, Entry, Frame, Label, LabelFrame
from tkinter import Listbox, Message, Radiobutton, Spinbox, Text
from tkinter import OptionMenu
import tkinter.filedialog
from tkinter import _setit as set_command


# >>>>>>insert any user code below this comment for section "imports"
# Place any user import statements here
import sys
# TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "top_of_init"

if sys.version_info < (3,):
    from tkSimpleDialog import Dialog
else:
    from tkinter.simpledialog import Dialog

class _Dialog(Dialog):
    # use dialogOptions dictionary to set any values in the dialog
    def __init__(self, parent, title = None, dialogOptions=None):
    
        self.dialogOptions = dialogOptions
        Dialog.__init__(self, parent, title)

class _new_options(_Dialog):

    def body(self, master):
        dialogframe = Frame(master, width=300, height=200)
        self.dialogframe = dialogframe
        dialogframe.pack()

        self.geometry("300x200")

        self.RadioGroup_1_StringVar = StringVar()

        self.make_Checkbutton_1( self.dialogframe )    # Checkbutton: log X Axis : at Main(2,2)
        self.make_Checkbutton_2( self.dialogframe )    # Checkbutton: log Y Axis : at Main(3,2)
        self.make_Label_1( self.dialogframe )          #       Label: Select Options for New Plot : at Main(1,2)
        self.make_RadioGroup_1( self.dialogframe )     #  RadioGroup:  at Main(4,2)
        self.make_Radiobutton_1( self.RadioGroup_1 )   # Radiobutton: Already Square : at RadioGroup_1(2,2)
        self.make_Radiobutton_2( self.RadioGroup_1 )   # Radiobutton: 4 Corner Alignment : at RadioGroup_1(3,2)
        self.make_Radiobutton_3( self.RadioGroup_1 )   # Radiobutton: 3 Corner Alignment : at RadioGroup_1(4,2)


        self.RadioGroup_1_StringVar.set("0")
        self.RadioGroup_1_StringVar_traceName = self.RadioGroup_1_StringVar.trace_variable("w", self.RadioGroup_1_StringVar_Callback)
        # >>>>>>insert any user code below this comment for section "top_of_init"

        self.RadioGroup_1_StringVar.set("0")


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_1"
    def make_Checkbutton_1(self, frame):
        """ Checkbutton: log X Axis : at Main(2,2)"""
        self.Checkbutton_1 = Checkbutton( frame , text="log X Axis", width="15")
        self.Checkbutton_1.grid(row=2, column=2)
        self.Checkbutton_1_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_1"

        self.Checkbutton_1.configure(variable=self.Checkbutton_1_StringVar, onvalue="yes", offvalue="no")
        self.Checkbutton_1_StringVar.set("no")
        self.Checkbutton_1_StringVar_traceName = self.Checkbutton_1_StringVar.trace_variable("w", self.Checkbutton_1_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Checkbutton_2"
    def make_Checkbutton_2(self, frame):
        """ Checkbutton: log Y Axis : at Main(3,2)"""
        self.Checkbutton_2 = Checkbutton( frame , text="log Y Axis", width="15")
        self.Checkbutton_2.grid(row=3, column=2)
        self.Checkbutton_2_StringVar = StringVar()

        # >>>>>>insert any user code below this comment for section "make_Checkbutton_2"

        self.Checkbutton_2.configure(variable=self.Checkbutton_2_StringVar, onvalue="yes", offvalue="no")
        self.Checkbutton_2_StringVar.set("no")
        self.Checkbutton_2_StringVar_traceName = self.Checkbutton_2_StringVar.trace_variable("w", self.Checkbutton_2_StringVar_Callback)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_1"
    def make_Label_1(self, frame):
        """       Label: Select Options for New Plot : at Main(1,2)"""
        self.Label_1 = Label( frame , text="Select Options for New Plot", width="30")
        self.Label_1.grid(row=1, column=2)

        # >>>>>>insert any user code below this comment for section "make_Label_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_RadioGroup_1"
    def make_RadioGroup_1(self, frame):
        """  RadioGroup:  at Main(4,2)"""
        self.RadioGroup_1 = LabelFrame( frame , width="60", height="50")
        self.RadioGroup_1.grid(row=4, column=2)

        # >>>>>>insert any user code below this comment for section "make_RadioGroup_1"


    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_1"
    def make_Radiobutton_1(self, frame):
        """ Radiobutton: Already Square : at RadioGroup_1(2,2)"""
        self.Radiobutton_1 = Radiobutton( frame , value="1", text="Already Square", width="15", anchor="w")
        self.Radiobutton_1.grid(row=2, column=2)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_1"

        self.Radiobutton_1.configure(value="0")
        self.Radiobutton_1.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_2"
    def make_Radiobutton_2(self, frame):
        """ Radiobutton: 4 Corner Alignment : at RadioGroup_1(3,2)"""
        self.Radiobutton_2 = Radiobutton( frame , value="1", text="4 Corner Alignment", width="15", anchor="w")
        self.Radiobutton_2.grid(row=3, column=2)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_2"

        self.Radiobutton_2.configure(value="4")
        self.Radiobutton_2.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Radiobutton_3"
    def make_Radiobutton_3(self, frame):
        """ Radiobutton: 3 Corner Alignment : at RadioGroup_1(4,2)"""
        self.Radiobutton_3 = Radiobutton( frame , value="1", text="3 Corner Alignment", width="15", anchor="w")
        self.Radiobutton_3.grid(row=4, column=2)

        # >>>>>>insert any user code below this comment for section "make_Radiobutton_3"

        self.Radiobutton_3.configure(value="3")
        self.Radiobutton_3.configure(variable=self.RadioGroup_1_StringVar)

    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_1_StringVar_traceName"
    def Checkbutton_1_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: log X Axis : at Main(2,2)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Checkbutton_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Checkbutton_1_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Checkbutton_2_StringVar_traceName"
    def Checkbutton_2_StringVar_Callback(self, varName, index, mode):
        """ Checkbutton: log Y Axis : at Main(3,2)"""
        pass

        # >>>>>>insert any user code below this comment for section "Checkbutton_2_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "Checkbutton_2_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.Checkbutton_2_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "RadioGroup_1_StringVar_traceName"
    def RadioGroup_1_StringVar_Callback(self, varName, index, mode):
        """  RadioGroup:  at Main(4,2)"""
        pass

        # >>>>>>insert any user code below this comment for section "RadioGroup_1_StringVar_traceName"
        # replace, delete, or comment-out the following
        print( "RadioGroup_1_StringVar_Callback varName, index, mode",varName, index, mode )
        print( "    new StringVar value =",self.RadioGroup_1_StringVar.get() )



    # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "dialog_validate"
    def validate(self):
        self.result = {} # return a dictionary of results
    

        self.result["Checkbutton_1"] = self.Checkbutton_1_StringVar.get()
        self.result["Checkbutton_2"] = self.Checkbutton_2_StringVar.get()
        self.result["RadioGroup_1"] = self.RadioGroup_1_StringVar.get()

        # >>>>>>insert any user code below this comment for section "dialog_validate"
        # set values in "self.result" dictionary for return
        # for example...
        # self.result["age"] = self.Entry_2_StringVar.get() 


        self.result["test"] = "test message" 
        return 1
# TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "end"


    def apply(self):
        pass
        #print( 'apply called' )

class _Testdialog:
    def __init__(self, master):
        frame = Frame(master, width=300, height=300)
        frame.pack()
        self.master = master
        self.x, self.y, self.w, self.h = -1,-1,-1,-1
        
        self.Button_1 = Button(text="Test Dialog", relief="raised", width="15")
        self.Button_1.place(x=84, y=36)
        self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click)

    def Button_1_Click(self, event): #click method for component ID=1
        dialog = _new_options(self.master, "Test Dialog")
        print( '===============Result from Dialog====================' )
        print( dialog.result )
        print( '=====================================================' )

def main():
    root = Tk()
    app = _Testdialog(root)
    root.mainloop()

if __name__ == '__main__':
    main()
