-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui_for_message.py
113 lines (106 loc) · 3.21 KB
/
gui_for_message.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from pathlib import Path
from tkinter import Tk, Canvas, Button, PhotoImage, scrolledtext
# asset directory
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path('./assets')
# func for get asset-media with name
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
# UserInterface Communicate window
class tk_gui:
# window details
def __init__(self):
self.window = Tk()
self.window.title('PCPos 2.2.0 - Log')
self.window.iconbitmap('assets/pos.ico')
self.window.eval('tk::PlaceWindow . center')
self.window.geometry("300x150")
self.window.configure(bg="#FFFFFF")
self.window.resizable(False, False)
self.window.attributes('-topmost', True)
# canvas obj for window in tk
def canvas(self):
self.canvas = Canvas(
self.window,
bg="#FFFFFF",
height=150,
width=300,
bd=0,
highlightthickness=0,
relief="ridge"
)
# Dialog for get response from user
def dialog(self, option_1, func_1, flag, option_2, func_2, log):
self.canvas()
# btn 1 - OK
self.canvas.place(x=0, y=0)
button_image_1 = PhotoImage(
file=relative_to_assets(option_1))
button_1 = Button(
image=button_image_1,
borderwidth=0,
highlightthickness=0,
command=lambda: [self.window.destroy(), func_1()],
relief="flat"
)
button_1.place(
x=7.0,
y=89.0,
width=90.0,
height=46.0
)
if flag:
pass
else:
# btn 2 - Cancell
button_image_2 = PhotoImage(
file=relative_to_assets(option_2))
button_2 = Button(
image=button_image_2,
borderwidth=0,
highlightthickness=0,
command=lambda: [self.window.destroy(), func_2()],
relief="flat"
)
button_2.place(
x=203.0,
y=89.0,
width=90.0,
height=46.0
)
# TextAria for show log
entry_image_1 = PhotoImage(
file=relative_to_assets("entry_1.png"))
entry_bg_1 = self.canvas.create_image(
150.0,
37.5,
image=entry_image_1
)
entry_1 = scrolledtext.ScrolledText(
bd=0,
bg="#C4C4C4",
highlightthickness=0,
font=("Aria", 15),
wrap='word'
)
entry_1.place(
x=0.0,
y=0.0,
width=300.0,
height=73.0
)
# Show log
entry_1.insert("end", log)
entry_1.configure(state='disabled')
self.window.mainloop()
# Fail TransAction - window
def show_message(self, send_prc, abort_pay, json, pay_name):
# Do TransAction again btn or Cancell TransAction btn
self.dialog(
'button_1.png',
send_prc,
False,
'button_2.png',
abort_pay,
json['PcPosStatus']+'\n'+json['ResponseCodeMessage']+'\n'+pay_name
)