maybe_save_Dialog.py


directory : D:\2018_py_proj\TkGridGUI\tkgridgui
Line Count : 192
Line Clip Size : No Clipping

tab_of_notebook_changed  Word MatchCase (0) 
1 #!/usr/bin/env python 2 # -*- coding: ascii -*- 3 from __future__ import print_function 4 from __future__ import unicode_literals 5 6 # NOTICE... this file is generated by TkGridGUI. 7 # Any code or comments added by the user must be in designated areas ONLY. 8 # User additions will be lost if they are placed in code-generated areas. 9 # (i.e. Saving from TkGridGUI will over-write code-generated areas.) 10 11 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "imports" 12 13 from future import standard_library 14 standard_library.install_aliases() 15 from builtins import object 16 import sys 17 18 if sys.version_info < (3,): 19 from tkSimpleDialog import Dialog 20 else: 21 from tkinter.simpledialog import Dialog 22 23 from tkinter import * 24 from tkinter import Button, Canvas, Checkbutton, Entry, Frame, Label, LabelFrame 25 from tkinter import Listbox, Message, Radiobutton, Spinbox, Text 26 from tkinter import OptionMenu 27 from tkinter.ttk import Combobox, Progressbar, Separator, Treeview, Style, Notebook 28 29 from tkinter import _setit as set_command 30 31 32 # >>>>>>insert any user code below this comment for section "imports" 33 # Place any user import statements here 34 35 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "top_of_init" 36 37 class _Dialog(Dialog): 38 # use dialogOptions dictionary to set any values in the dialog 39 def __init__(self, parent, title = None, dialogOptions=None): 40 41 self.dialogOptions = dialogOptions 42 Dialog.__init__(self, parent, title) 43 44 class maybe_save_dialog(_Dialog): 45 46 def buttonbox(self): 47 pass 48 # this dummy routine overrides the standard "OK" and "Cancel" buttons 49 # REMEMBER!!! to call self.ok() and self.cancel() in User Code 50 51 def body(self, master): 52 dialogframe = Frame(master, width=321, height=110) 53 self.dialogframe = dialogframe 54 dialogframe.pack() 55 56 57 self.make_Button_1( self.dialogframe ) # Button: Save File : at Main(4,1) 58 self.make_Button_2( self.dialogframe ) # Button: Do NOT Save : at Main(4,3) 59 self.make_Label_1( self.dialogframe ) # Label: Current File has Changed : at Main(1,1) 60 self.make_Label_2( self.dialogframe ) # Label: Do you want to Save before Continuing? : at Main(2,1) 61 self.make_Label_3( self.dialogframe ) # Label: at Main(3,1) 62 self.make_Label_4( self.dialogframe ) # Label: at Main(5,1) 63 64 65 # >>>>>>insert any user code below this comment for section "top_of_init" 66 67 self.save_file = False 68 69 70 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Button_1" 71 def make_Button_1(self, frame): 72 """ Button: Save File : at Main(4,1)""" 73 self.Button_1 = Button( frame , text="Save File", width="15") 74 self.Button_1.grid(row=4, column=1) 75 76 # >>>>>>insert any user code below this comment for section "make_Button_1" 77 78 self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click) 79 80 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Button_2" 81 def make_Button_2(self, frame): 82 """ Button: Do NOT Save : at Main(4,3)""" 83 self.Button_2 = Button( frame , text="Do NOT Save", width="15") 84 self.Button_2.grid(row=4, column=3) 85 86 # >>>>>>insert any user code below this comment for section "make_Button_2" 87 88 self.Button_2.bind("<ButtonRelease-1>", self.Button_2_Click) 89 90 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_1" 91 def make_Label_1(self, frame): 92 """ Label: Current File has Changed : at Main(1,1)""" 93 self.Label_1 = Label( frame , text="Current File has Changed", width="45") 94 self.Label_1.grid(row=1, column=1, columnspan="3") 95 96 # >>>>>>insert any user code below this comment for section "make_Label_1" 97 98 99 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_2" 100 def make_Label_2(self, frame): 101 """ Label: Do you want to Save before Continuing? : at Main(2,1)""" 102 self.Label_2 = Label( frame , text="Do you want to Save before Continuing?", width="45") 103 self.Label_2.grid(row=2, column=1, columnspan="3") 104 105 # >>>>>>insert any user code below this comment for section "make_Label_2" 106 107 108 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_3" 109 def make_Label_3(self, frame): 110 """ Label: at Main(3,1)""" 111 self.Label_3 = Label( frame , text="", width="15") 112 self.Label_3.grid(row=3, column=1) 113 114 # >>>>>>insert any user code below this comment for section "make_Label_3" 115 116 117 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "make_Label_4" 118 def make_Label_4(self, frame): 119 """ Label: at Main(5,1)""" 120 self.Label_4 = Label( frame , text="", width="15") 121 self.Label_4.grid(row=5, column=1) 122 123 # >>>>>>insert any user code below this comment for section "make_Label_4" 124 125 126 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Button_1_Click" 127 def Button_1_Click(self, event): #bind method for component ID=Button_1 128 """ Button: Save File : at Main(4,1)""" 129 pass 130 # >>>>>>insert any user code below this comment for section "Button_1_Click" 131 # replace, delete, or comment-out the following 132 #print( "executed method Button_1_Click" ) 133 self.save_file = True 134 self.ok() 135 136 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "Button_2_Click" 137 def Button_2_Click(self, event): #bind method for component ID=Button_2 138 """ Button: Do NOT Save : at Main(4,3)""" 139 pass 140 # >>>>>>insert any user code below this comment for section "Button_2_Click" 141 # replace, delete, or comment-out the following 142 #print( "executed method Button_2_Click" ) 143 self.save_file = False 144 self.ok() 145 146 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "dialog_validate" 147 def validate(self): 148 self.result = {} # return a dictionary of results 149 150 151 152 # >>>>>>insert any user code below this comment for section "dialog_validate" 153 # set values in "self.result" dictionary for return 154 # for example... 155 # self.result["age"] = self.Entry_2_StringVar.get() 156 157 if self.save_file: 158 self.result["save_file"] = "yes" 159 else: 160 self.result["save_file"] = "no" 161 return 1 162 # TkGridGUI generated code. DO NOT EDIT THE FOLLOWING. section "end" 163 164 165 def apply(self): 166 #print( 'apply called' ) 167 pass 168 169 class _Testdialog(object): 170 def __init__(self, master): 171 frame = Frame(master, width=300, height=300) 172 frame.pack() 173 self.master = master 174 self.x, self.y, self.w, self.h = -1,-1,-1,-1 175 176 self.Button_1 = Button(text="Test Dialog", relief="raised", width="15") 177 self.Button_1.place(x=84, y=36) 178 self.Button_1.bind("<ButtonRelease-1>", self.Button_1_Click) 179 180 def Button_1_Click(self, event): #click method for component ID=1 181 dialog = maybe_save_dialog(self.master, "Test Dialog") 182 print( '===============Result from Dialog====================' ) 183 print( dialog.result ) 184 print( '=====================================================' ) 185 186 def main(): 187 root = Tk() 188 app = _Testdialog(root) 189 root.mainloop() 190 191 if __name__ == '__main__': 192 main() 193