-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubwindow.py
More file actions
41 lines (36 loc) · 1.41 KB
/
Copy pathsubwindow.py
File metadata and controls
41 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
# tkinter
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.font as font
# アプリ定数
SUB_WIDTH = 300
SUB_HEIGHT = 160
# ---------------------------------------------------------------------------
# SubWindow
#
# 確認ウィンドウ用クラス
# ボタンを押した場合,呼び出し元に従うまたはdestroy()を実行.
# ボタンは複数配置可能.(例:はい/いいえボタン)
# ---------------------------------------------------------------------------
class SubWindow(tk.Toplevel):
def __init__(self, title, mess, font, master=None):
super().__init__(master)
# ウィンドウタイトル
self.title(title)
sx = int(self.winfo_screenwidth()/2)
sy = int(self.winfo_screenheight()/2)
self.resizable(0, 0)
self.geometry("%sx%s+%s+%s" % (SUB_WIDTH, SUB_HEIGHT, int(sx - SUB_WIDTH/2), int(sy - SUB_HEIGHT/2)))
self.transient(master)
self.grab_set()
# メッセージ&フレーム生成
self.label_message = tk.Label(self, text=mess, font=(font, 10))
self.label_message.pack(padx=5, pady=15)
self.frame = tk.Frame(self)
self.frame.pack(side=tk.BOTTOM, padx=5, pady=15)
if __name__ == '__main__':
root = tk.Tk()
root.title('SubWindow')
app = SubWindow(title='title', mess='mess', font='メイリオ', master=root)
app.mainloop()