-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui7.py
216 lines (184 loc) · 4.71 KB
/
gui7.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
from pathlib import Path
import subprocess, os
from tkinter import *
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage, filedialog, Label, messagebox, Checkbutton, simpledialog
from PIL import Image, ImageTk
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path(r"assets7/frame0")
def center_window(window,height=600,width=500):
window.update_idletasks()
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
x = (screen_width - width) // 2
y = (screen_height - height) // 2
window.geometry(f"{width}x{height}+{x}+{y}")
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
window = Tk()
center_window(window)
window.wm_iconname("Image your disk")
window.title("IYD Mounting Image File")
im = Image.open('assets0/favicon.ico')
photo = ImageTk.PhotoImage(im)
window.wm_iconphoto(True, photo)
window.wm_iconname("IYD")
window.geometry("600x500")
window.configure(bg = "#545252")
canvas = Canvas(
window,
bg = "#545252",
height = 500,
width = 600,
bd = 0,
highlightthickness = 0,
relief = "ridge"
)
canvas.place(x = 0, y = 0)
canvas.create_rectangle(
0.0,
0.0,
271.0,
500.0,
fill="#212121",
outline="")
image_image_1 = PhotoImage(
file=relative_to_assets("image_1.png"))
image_1 = canvas.create_image(
135.0,
226.0,
image=image_image_1
)
button_image_1 = PhotoImage(
file=relative_to_assets("button_1.png"))
button_1 = Button(
image=button_image_1,
borderwidth=0,
highlightthickness=0,
relief="flat"
)
button_1.place(
x=304.0,
y=43.0,
width=259.3500061035156,
height=72.0
)
button_image_2 = PhotoImage(
file=relative_to_assets("button_2.png"))
button_2 = Button(
image=button_image_2,
borderwidth=0,
highlightthickness=0,
relief="flat"
)
button_2.place(
x=291.0,
y=171.0,
width=289.0,
height=212.0
)
entry_image_1 = PhotoImage(
file=relative_to_assets("entry_1.png"))
entry_bg_1 = canvas.create_image(
427.0,
236.0,
image=entry_image_1
)
entry_1 = Entry(
bd=0,
bg="#D9D9D9",
fg="#000716",
highlightthickness=0
)
entry_1.place(
x=327.0,
y=219.0,
width=200.0,
height=32.0
)
entry_image_2 = PhotoImage(
file=relative_to_assets("entry_2.png"))
entry_bg_2 = canvas.create_image(
349.5,
328.0,
image=entry_image_2
)
entry_2 = Entry(
bd=0,
bg="#D9D9D9",
fg="#000716",
highlightthickness=0
)
entry_2.place(
x=314.0,
y=311.0,
width=71.0,
height=32.0
)
image_image_2 = PhotoImage(
file=relative_to_assets("image_2.png"))
image_2 = canvas.create_image(
135.0,
390.0,
image=image_image_2
)
def on_next_click1():
path = entry_1.get()
rd_only = read_only.get()
offset = entry_2.get()
try:
offset = int(offset)
except ValueError:
messagebox.showwarning("Warning", "Offset must be a valid integer.")
return
if rd_only == 1:
command = ["sudo", "mount", "-o", f"loop,ro,offset={offset}", path, "/mnt"]
else:
command = ["sudo", "mount", "-o", f"loop,offset={offset}", path, "/mnt"]
try:
subprocess.run(command, check=True)
print("Mount successful.")
messagebox.showwarning("Mounted successfully, please check /mnt")
window.destroy()
except subprocess.CalledProcessError as e:
print(f"Error mounting: {e}")
messagebox.showwarning("Warning", "Error mounting")
def on_back_click():
window.destroy()
import sys
# subprocess.run(["python3", "gui2.py"])
subprocess.run(["sudo", "myenv/bin/python3", "gui2.py"])
def on_checkbox_click1():
if read_only.get() == 1:
print("read only")
else:
print("not read only")
read_only = IntVar()
checkbutton_encr = Checkbutton(
window,
text="Mount-Read Only",
variable=read_only,
onvalue=1,
offvalue=0,
width=13,
command=on_checkbox_click1,
bg="#545252",
font=("Arial", 12),
relief="raised",
padx=10,
pady=5,
)
checkbutton_encr.place(x=291, y=395)
mount_button = Button(window, text="Mount", command=on_next_click1, width=10, bg="#333333", fg="white")
mount_button.place(x=452, y=445)
back_button = Button(window, text="Back", command=on_back_click, width=10, bg="#333333", fg="white")
back_button.place(x=291, y=445)
def browse_file1():
file_path = filedialog.askopenfilename()
if file_path:
entry_1.insert(0, file_path)
browse_button = Button(window, text="BF",fg="white",width=1,bg="#333333", command=browse_file1)
browse_button.pack(pady=10)
browse_button.place(x=540, y=220)
window.resizable(False, False)
window.mainloop()