最後の画像の余白を除去したいです。
ある程度 元のデザインから簡素化しましたが 行列構成に 大きな違いはございません。
ご見解頂けますと幸いです
python
import tkinter as tk import tkinter.ttk as ttk import math import os def resource_path(relative_path): try: base_path = sys._MEIPASS except Exception: base_path = os.path.abspath(".") return os.path.join(base_path, relative_path) def adjust_windowsize1(root): ww = root.winfo_screenwidth() wh = root.winfo_screenheight() lw = math.ceil(ww * 0.3208) lh = math.ceil(wh * 0.477) root.geometry(str(lw)+"x"+str(lh)+"+"+str(int(ww/2-lw/2))+"+"+str(int(wh/2-lh/2))) def adjust_windowsize2(root): ww = root.winfo_screenwidth() wh = root.winfo_screenheight() lw = math.ceil(ww * 0.3208) lh = math.ceil(wh * 0.097) root.geometry(str(lw)+"x"+str(lh)+"+"+str(int(ww/2-lw/2))+"+"+str(int(wh/2-lh/2))) def generate_frame(root): def generate_subwindow1(): dlg_modal = tk.Toplevel() dlg_modal.grab_set() dlg_modal.focus_set() dlg_modal.transient(root) adjust_windowsize1(dlg_modal) dlg_modal.grid_columnconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], weight=1) dlg_modal.grid_rowconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], weight=1) frmTable = ttk.Frame(dlg_modal, name="frmTable") frmTable.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S) frmTable.grid_columnconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], weight=1, minsize=40) frmTable.grid_rowconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], weight=1) tree4 = ttk.Treeview(frmTable, show="headings", height=15) tree4.grid(row=0, column=0, columnspan=10, rowspan=10, sticky=tk.E + tk.W, pady=(10,0), padx=(10,10)) ybar4 = ttk.Scrollbar(frmTable, orient=tk.VERTICAL, command=tree4.yview) ybar4.grid(row=0, column=9, rowspan=10, sticky=tk.N + tk.S + tk.E, pady=(10,0), padx=(0,10)) tree4.config(yscrollcommand=lambda f, l: ybar4.set(f, l)) xbar4 = ttk.Scrollbar(frmTable, orient=tk.HORIZONTAL, command=tree4.xview) xbar4.grid(row=10, column=0, columnspan=10, sticky=tk.N + tk.S + tk.E + tk.W, padx=(10,10)) tree4.config(xscrollcommand=lambda f, l: xbar4.set(f, l)) btn_ReturnConvMenu = ttk.Button(frmTable, text = "閉じる", command=dlg_modal.destroy) btn_ReturnConvMenu.grid(row=11, column=9, sticky=tk.N + tk.S + tk.E + tk.W, padx=(0,10)) def change_frame(frame): frame.tkraise() style = ttk.Style() style.theme_use('winnative') style.configure("TFrame", background="#FFFFCC") style.configure("TLabel", font=("Arial", 16), anchor='', background="#FFFFCC") style.configure("TLabelframe", background="#FFFFCC", relief="sunken") style.configure("TLabelframe.Label", foreground="red", font=("Arial", 16), background="#FFFFCC") frm1 = ttk.Frame(root, name="frm1") frm1.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S) btn_SettingMenu = ttk.Button(frm1, text = "入出力", command=lambda: change_frame(frm2)) btn_SettingMenu.pack(fill = tk.BOTH, expand=True) btn_SettingMenu.bind('<Return>', lambda a: change_frame(frm2)) btn_SettingMenu = ttk.Button(frm1, text = "変換", command=lambda: change_frame(frm3)) btn_SettingMenu.pack(fill = tk.BOTH, expand=True) btn_SettingMenu.bind('<Return>', lambda a: change_frame(frm3)) btn_RunMenu = ttk.Button(frm1, text = "") btn_RunMenu.pack(fill = tk.BOTH, expand=True) btn_RunMenu.focus_set() btn_Close = ttk.Button(frm1, text = "終了", command=root.destroy) btn_Close.pack(fill = tk.BOTH, expand=True) # frm2 = ttk.Frame(root, name="frm2") frm2.grid_rowconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], weight=1) frm2.grid_columnconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], weight=1, minsize=40) frm2.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S) ent_RecName = ttk.Entry(frm2, font=("Arial", 16)) ent_RecName.grid(row=0, column=2, columnspan=8, sticky=tk.E + tk.W + tk.N + tk.S, pady=(10,0), padx=(0,10)) btn_AssignInputFile = ttk.Button(frm2, text = "入力") btn_AssignInputFile.grid(row=1, column=0, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S, padx=(10,0)) ent_InputPath = ttk.Entry(frm2, state="disabled", font=("Arial", 16)) ent_InputPath.grid(row=1, column=2, columnspan=8, sticky=tk.E + tk.W + tk.N + tk.S, padx=(0,10)) ent_OutputPath = ttk.Entry(frm2, state="disabled", font=("Arial", 16)) ent_OutputPath.grid(row=2, column=2, columnspan=8, sticky=tk.E + tk.W + tk.N + tk.S, padx=(0,10)) tree1 = ttk.Treeview(frm2, show="tree") tree1.grid(row=3, column=0, rowspan=4, columnspan=4, sticky=tk.E + tk.W + tk.N + tk.S, pady=(10,0), padx=(10,0)) ybar1 = ttk.Scrollbar(frm2, orient=tk.VERTICAL, command=tree1.yview) ybar1.grid(row=3, column=3, rowspan=4, sticky=tk.N + tk.S + tk.E, pady=(10,0), padx=(10,0)) tree1.config(yscrollcommand=lambda f, l: ybar1.set(f, l)) btn_AddColumn = ttk.Button(frm2, text = "→") btn_AddColumn.grid(row=3, column=4, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S, pady=(10,0)) lstbox = tk.Listbox(frm2, bg="black", exportselection=False, foreground="white", font=("Arial", 16)) lstbox.grid(row=3, column=6, rowspan=4, columnspan=4, sticky=tk.E + tk.W + tk.N + tk.S, pady=(10,0), padx=(0,10)) ybar2 = ttk.Scrollbar(frm2, orient=tk.VERTICAL, command=lstbox.yview) ybar2.grid(row=3, column=9, rowspan=4, sticky=tk.N + tk.S + tk.E, pady=(10,0), padx=(0,10)) lstbox.config(yscrollcommand=lambda f, l: ybar2.set(f, l)) xbar2 = ttk.Scrollbar(frm2, orient=tk.HORIZONTAL, command=lstbox.xview) xbar2.grid(row=6, column=6, columnspan=4, sticky=tk.S + tk.E + tk.W, padx=(0,10)) lstbox.config(xscrollcommand=lambda f, l: xbar2.set(f, l)) btn_Up = ttk.Button(frm2, text = "↑") btn_Up.grid(row=4, column=4, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S) btn_Down = ttk.Button(frm2, text = "↓") btn_Down.grid(row=5, column=4, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S) btn_Cancel = ttk.Button(frm2, text = "←") btn_Cancel.grid(row=6, column=4, columnspan=2, sticky=tk.E + tk.W + tk.N+ tk.S) lab_Type = ttk.Label(frm2, text="有無") lab_Type.grid(row=7, column=0, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S, padx=(0,10)) cmbox_Type = ttk.Combobox(frm2, state="disabled", height=3, font=("Arial", 16)) cmbox_Type.grid(row=8, column=0, columnspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=(10, 0)) tree3 = ttk.Treeview(frm2, show="headings", height=1) tree3.grid(row=9, column=0, columnspan=9, sticky=tk.E + tk.W, padx=(10,0)) xbar3 = ttk.Scrollbar(frm2, orient=tk.HORIZONTAL, command=tree3.xview) xbar3.grid(row=10, column=0, columnspan=9, sticky=tk.N + tk.S + tk.E + tk.W, padx=(10,0)) tree3.config(xscrollcommand=lambda f, l: xbar3.set(f, l)) btn_ReturnMenu = ttk.Button(frm2, text = "閉じる", command=lambda: change_frame(frm1)) btn_ReturnMenu.grid(row=11, column=8, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S, pady=(0,10), padx=(0,10)) # frm3 = ttk.Frame(root, name="frm3") frm3.grid_rowconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], weight=1) frm3.grid_columnconfigure([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], weight=1, minsize=40) frm3.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S) lbfrm1 = ttk.LabelFrame(frm3, text="対応表", labelanchor="n") lbfrm1.grid(row=1, column=0, rowspan=5, columnspan=10, sticky=tk.W + tk.E + tk.N + tk.S, padx=(10,10)) list_tmp1 = [1,2,3,4,5] cmbox_Tbl1 = ttk.Combobox(frm3, height=3, font=("Arial", 16), state="readonly", values=list_tmp1) cmbox_Tbl1.grid(row=2, column=1, columnspan=8, sticky=tk.E + tk.W, pady=(10,0), padx=(10,10)) frmTmp = ttk.Frame(frm3, name="frmTmp") frmTmp.grid(row=3, column=1, columnspan=8, sticky=tk.E + tk.W + tk.N + tk.S, padx=(10,10), pady=(10,0)) lab_Select = ttk.Label(frmTmp, text="種類", font=("Arial", 11)) lab_Select.grid(row=0, column=1, sticky=tk.E + tk.W) btn_Select = ttk.Button(frm3, text = "選択") btn_Select.grid(row=4, column=1, columnspan=1, sticky=tk.E + tk.W, padx=(10,0), pady=(0,10)) btn_TblM = ttk.Button(frm3, text = "編集", command=generate_subwindow1) btn_TblM.grid(row=5, column=1, columnspan=8, sticky=tk.E + tk.W, padx=(10,10)) lbfrm2 = ttk.LabelFrame(frm3, text="定義", labelanchor="n") lbfrm2.grid(row=6, column=0, rowspan=5, columnspan=10, sticky=tk.W + tk.E + tk.N + tk.S, padx=(10,10), pady=(20,0)) list_tmp2 = [1,2,3,4,5] cmbox_Tbl2 = ttk.Combobox(frm3, height=3, font=("Arial", 16), state="readonly", values=list_tmp2) cmbox_Tbl2.grid(row=7, column=1, columnspan=8, sticky=tk.E + tk.W, pady=(30,0), padx=(10,10)) btn_ConvM = ttk.Button(frm3, text = "追加変更") btn_ConvM.grid(row=8, column=1, columnspan=8, sticky=tk.E + tk.W, padx=(10,10)) btn_Inq = ttk.Button(frm3, text = "一覧参照") btn_Inq.grid(row=9, column=1, columnspan=8, sticky=tk.E + tk.W, padx=(10,10)) btn_ReturnMenu = ttk.Button(frm3, text = "閉じる", command=lambda: change_frame(frm1)) btn_ReturnMenu.grid(row=11, column=8, sticky=tk.E + tk.W, padx=(0,10)) frm1.tkraise() if __name__ == "__main__": root = tk.Tk() adjust_windowsize1(root) root.title("勉強") root.grid_columnconfigure([0,1, 2, 3, 4, 5, 6, 7, 8, 9], weight=1) root.grid_rowconfigure([0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], weight=1) root.resizable(0,0) root.protocol('WM_DELETE_WINDOW', (lambda: 'pass')()) root["cursor"] = "hand2" generate_frame(root) root.mainloop()
調べたこと、試したことを質問に追記していただけませんか。
自分でプログラミングしないタイプですか。
本文が文字制限数の10000文字ギリギリの状態なので、こちらに自分が試したことを記載します。(問い合わせ掲載時、試行錯誤して10000文字以内にどうにか収めました)
問題になっているフォーム画面とは 関係のないフレームのコードをはしょると デザインが極端に変わってしまい 陥っている事象を再現出来ませんでした。rootのWindowの上で、二つのフレームを使い分ける仕様で進めてきたので、互いの構造が相互に作用して デザインが保たれているのかな、と推察しています。
問題のフォーム画面は 上記と異なる新たなダイアログの上でのフレーム配置なので、影響を受けないと思っていたんですが やはり何かが作用してしまっているようで。
ツリービューの1行あたりの高さを統一にすような記述が必要なのかな?
まだ回答がついていません
会員登録して回答してみよう