前提・実現したいこと
親ウィンドウ⇒子ウィンドウ⇒孫ウインドウと開き
孫ウィンドウにはカレンダーを表示したい。
よろしくお願い致します。
発生している問題・エラーメッセージ
親ウィンドウ⇒子ウィンドウ⇒孫ウインドウと遷移しているのですが 孫ウインドウを表示すると親ウィンドウの表示が変わってしまい ※長さすぎるためコードを一部削除しております。
初期画面(親)
検索画面(子)
修正画面(孫)
この時の親画面
該当のソースコード
python
1import importlib 2import shutil 3import re, openpyxl 4import tkinter as tkm 5import pandas as pd 6import datetime 7from tkinter import ttk 8from tkinter import * 9from tkinter.ttk import * 10from tkinter import messagebox 11from tkinter import filedialog 12from tkcalendar import DateEntry 13 14class Application(tkm.Frame): 15 def __init__(self,master): 16 super().__init__(master) 17 self.pack() 18 self.master.geometry("550x280+500+350") 19 self.mainwidget() 20 self.mainwindow = [] 21 self.subwindow = [] 22 style = ttk.Style() 23 style.theme_use("default") 24 style.map("Treeview") 25 26 #---------ボタン動作-START---------- 27 #ファイル参照ボタン 28 def select_files(self): 29 30 #検索ボタン(検索画面表示) 31 def search_window(self): 32 self.mainwindow.append(tkm.Toplevel(highlightthickness=5, highlightbackground="white", highlightcolor="red")) 33 self.subwindow.append(SubWindow(self.mainwindow[len(self.mainwindow)-1],len(self.mainwindow))) 34 35 #---------ボタン動作-END---------- 36 37 #-----------パーツ設定-START---------- 38 def mainwidget(self): 39 self.lbl01 = ttk.Label(self.master, text="登録者社員番号", width=17, anchor="e", justify=RIGHT) 40 self.lbl02 = ttk.Label(self.master, text="支店", width=17, anchor="e", justify=RIGHT) 41 self.lbl03 = ttk.Label(self.master, text="種別", width=13, anchor="e", justify=RIGHT) 42 self.lbl04 = ttk.Label(self.master, text="日付", width=17, anchor="e", justify=RIGHT) 43 self.lbl04_1 = ttk.Label(self.master, text="※電子データに記載がある日付を入力", width=30, anchor="e", justify=RIGHT) 44 self.lbl05 = ttk.Label(self.master, text="プロジェクト番号", width=17, anchor= "e", justify=RIGHT) 45 self.lbl06 = ttk.Label(self.master, text="枝番", width=17, anchor="e", justify=RIGHT) 46 self.lbl07 = ttk.Label(self.master, text="顧客名", width=17, anchor="e", justify=RIGHT) 47 self.lbl08 = ttk.Label(self.master, text="金額(税込)", width=17, anchor="e", justify=RIGHT) 48 self.lbl08_1 = ttk.Label(self.master, text="※金額が発生しない場合でも 0 を入力", width=32, anchor="e", justify=RIGHT) 49 self.lbl09 = ttk.Label(self.master, text="対象ファイル", width=17, anchor="e", justify=RIGHT) 50 self.lbl10 = ttk.Label(self.master, text="ファイル保存先", width=17, anchor="e", justify=RIGHT) 51 self.lbl11 = ttk.Label(self.master, text="変更後のファイル名", width=17, anchor="e", justify=RIGHT) 52 53 self.lbl01.place(x=10, y=10) 54 self.lbl02.place(x=10, y=35) 55 self.lbl03.place(x=190, y=35) 56 self.lbl04.place(x=10, y=60) 57 self.lbl04_1.place(x=235, y=60) 58 self.lbl05.place(x=10, y=85) 59 self.lbl06.place(x=166, y=85) 60 self.lbl07.place(x=10, y=110) 61 self.lbl08.place(x=10, y=135) 62 self.lbl08_1.place(x=220, y=135) 63 self.lbl09.place(x=10, y=160) 64 self.lbl10.place(x=10, y=185) 65 self.lbl11.place(x=10, y=210) 66 67 self.entry01 = ttk.Entry(self.master, justify=tkm.LEFT, width=13) 68 self.combo02 = ttk.Combobox(self.master, justify=tkm.CENTER, width=13) 69 self.combo03 = ttk.Combobox(self.master, justify=tkm.CENTER, width=16) 70 self.date04 = DateEntry(date_pattern='yyyy/mm/dd', width=13) 71 self.entry05 = ttk.Entry(self.master, justify = tkm.LEFT, width = 13) 72 self.entry06 = ttk.Entry(self.master, justify=tkm.LEFT, width=5) 73 self.entry07 = ttk.Entry(self.master, justify=tkm.LEFT, width=60) 74 self.entry08 = ttk.Entry(self.master, justify=tkm.RIGHT, width=13) 75 self.entry09 = ttk.Entry(self.master, justify=tkm.LEFT, width=60) 76 self.btn12 = ttk.Button(self.master, text="参照", width=6, command=self.select_files) 77 self.entry10 = ttk.Entry(self.master, justify=tkm.LEFT, width=60, state="readonly") 78 self.entry11 = ttk.Entry(self.master, justify=tkm.LEFT, width=60, state="readonly") 79 self.btn13 = ttk.Button(self.master, text="検索", width=10, state="enable", command=self.search_window) 80 self.btn14 = ttk.Button(self.master, text="確認", width=10, state="enable", command=self.check) 81 self.btn15 = ttk.Button(self.master, text="実行", width=10, state="disable", command=self.renameexe) 82 self.btn16 = ttk.Button(self.master, text="クリア", width=10, command=self.initclear) 83 self.entry01.place(x=130, y=10) 84 self.combo02.place(x=130, y=35) 85 self.combo03.place(x=280, y=35) 86 self.date04.place(x=130, y=60) 87 self.entry05.place(x=130, y=85) 88 self.entry06.place(x=280, y=85) 89 self.entry07.place(x=130, y=110) 90 self.entry08.place(x=130, y=135) 91 self.entry09.place(x=130, y=160) 92 self.entry10.place(x=130, y=185) 93 self.entry11.place(x=130, y=210) 94 self.btn12.place(x=500, y=158) 95 self.btn13.place(x=190, y=240) 96 self.btn14.place(x=270, y=240) 97 self.btn15.place(x=350, y=240) 98 self.btn16.place(x=430, y=240) 99 100 #-----------パーツ設定-END---------- 101#-----------サブウィンドウ画面(検索)START---------- 102class SubWindow(tkm.Frame): 103 def __init__(self,master,num): 104 super().__init__(master) 105 self.pack() 106 self.CorrectWindow = [] 107 master.geometry("1500x400+100+300") 108 master.title("検索画面") 109 master.grab_set() 110 self.set_data() 111 self.sub_widget() 112 self.subwindow = [] 113 self.CorrectWindow = [] 114 115 #各種パーツ読込 116 def sub_widget(self): 117 self.sw_main = ttk.PanedWindow(self.master, orient="vertical") 118 self.sw_main.pack(expand=True, fill=tkm.BOTH, side="left") 119 self.sw_top = ttk.PanedWindow(self.sw_main, orient="horizontal", height=25) 120 self.sw_main.add(self.sw_top) 121 self.sw_bottom = ttk.PanedWindow(self.sw_main, orient="vertical") 122 self.sw_main.add(self.sw_bottom) 123 self.creat_input_frame(self.sw_top) 124 self.create_tree(self.sw_bottom) 125 126 #修正画面表示 127 def onDuble(self, event): 128 self.subwindow.append(tkm.Toplevel(highlightthickness=5, highlightbackground="white", highlightcolor="red")) 129 self.CorrectWindow.append(CorrectWindow(self.subwindow[len(self.subwindow)-1],len(self.subwindow))) 130 131#-----------修正ウィンドウ画面 START---------- 132class CorrectWindow(tkm.Frame): 133 def __init__(self,master,num): 134 super().__init__(master) 135 self.pack() 136 master.geometry("550x250+500+350") 137 master.title("修正画面") 138 master.grab_set() 139 self.correct_widget() 140 self.set_correct_data() 141 #-----------パーツ設定-START---------- 142 def correct_widget(self): 143 self.correct_lbl00 = ttk.Label(self.master, text="ID", width=17, anchor="e", justify=RIGHT) 144 self.correct_lbl01 = ttk.Label(self.master, text="登録者社員番号", width=17, anchor="e", justify=RIGHT) 145 self.correct_lbl02 = ttk.Label(self.master, text="支店", width=17, anchor="e", justify=RIGHT) 146 self.correct_lbl03 = ttk.Label(self.master, text="種別", width=13, anchor="e", justify=RIGHT) 147 self.correct_lbl04 = ttk.Label(self.master, text="日付", width=17, anchor="e", justify=RIGHT) 148 self.correct_lbl04_1 = ttk.Label(self.master, text="※電子データに記載がある日付を入力", width=30, anchor="e", justify=RIGHT) 149 self.correct_lbl05 = ttk.Label(self.master, text="プロジェクト番号", width=17, anchor= "e", justify=RIGHT) 150 self.correct_lbl06 = ttk.Label(self.master, text="枝番", width=17, anchor="e", justify=RIGHT) 151 self.correct_lbl07 = ttk.Label(self.master, text="顧客名", width=17, anchor="e", justify=RIGHT) 152 self.correct_lbl08 = ttk.Label(self.master, text="金額(税込)", width=17, anchor="e", justify=RIGHT) 153 self.correct_lbl08_1 = ttk.Label(self.master, text="※金額が発生しない場合でも 0 を入力", width=32, anchor="e", justify=RIGHT) 154 155 self.correct_lbl00.place(x=10, y=10) 156 self.correct_lbl01.place(x=10, y=35) 157 self.correct_lbl02.place(x=10, y=60) 158 self.correct_lbl03.place(x=190, y=60) 159 self.correct_lbl04.place(x=10, y=85) 160 self.correct_lbl04_1.place(x=235, y=85) 161 self.correct_lbl05.place(x=10, y=110) 162 self.correct_lbl06.place(x=166, y=110) 163 self.correct_lbl07.place(x=10, y=135) 164 self.correct_lbl08.place(x=10, y=160) 165 self.correct_lbl08_1.place(x=220, y=160) 166 167 self.correct_entry00 = ttk.Entry(self.master, justify=tkm.LEFT, width=13) 168 self.correct_entry01 = ttk.Entry(self.master, justify=tkm.LEFT, width=13) 169 self.correct_combo02 = ttk.Combobox(self.master, justify=tkm.CENTER, width=13) 170 self.correct_combo03 = ttk.Combobox(self.master, justify=tkm.CENTER, width=16) 171 self.correct_date04 = DateEntry(date_pattern='yyyy/mm/dd', width=13) 172 self.correct_entry05 = ttk.Entry(self.master, justify = tkm.LEFT, width = 13) 173 self.correct_entry06 = ttk.Entry(self.master, justify=tkm.LEFT, width=5) 174 self.correct_entry07 = ttk.Entry(self.master, justify=tkm.LEFT, width=60) 175 self.correct_entry08 = ttk.Entry(self.master, justify=tkm.RIGHT, width=13) 176 # self.correct_btn13 = ttk.Button(self.master, text="更新", width=10, state="enable", command=self.correct_update) 177 # self.correct_btn14 = ttk.Button(self.master, text="キャンセル", width=10, state="enable", command=self.cancel) 178 self.correct_entry00.place(x=130, y=10) 179 self.correct_entry01.place(x=130, y=35) 180 self.correct_combo02.place(x=130, y=60) 181 self.correct_combo03.place(x=280, y=60) 182 self.correct_date04.place(x=130, y=85) 183 self.correct_entry05.place(x=130, y=110) 184 self.correct_entry06.place(x=280, y=110) 185 self.correct_entry07.place(x=130, y=135) 186 self.correct_entry08.place(x=130, y=160) 187 # self.correct_btn13.place(x=350, y=190) 188 # self.correct_btn14.place(x=430, y=190) 189 190 #-----------パーツ設定-END---------- 191def main(): 192 win = tkm.Tk() 193 app = Application(win) 194 app.mainloop() 195if __name__ == '__main__': 196 main()
回答1件
あなたの回答
tips
プレビュー