-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgui.py
More file actions
115 lines (94 loc) · 3.03 KB
/
Copy pathgui.py
File metadata and controls
115 lines (94 loc) · 3.03 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
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
# import tkinter as tk
# from tkinter import filedialog
# import subprocess
# def select_image():
# # Open a file dialog to select an image file
# file_path = filedialog.askopenfilename(
# title='Select Image',
# filetypes=[('Image Files', '*.jpg *.jpeg *.png *.gif *.bmp')]
# )
# if file_path:
# # Run 'python3 main.py <image_file>'
# subprocess.run(['python3', 'main.py', file_path])
# # Create the main application window
# root = tk.Tk()
# root.title('Image Submitter')
# # Create and place the 'Select Image' button
# select_button = tk.Button(root, text='Select Image', command=select_image)
# select_button.pack(pady=20)
# # Start the GUI event loop
# root.mainloop()
import tkinter as tk
from tkinter import filedialog
import subprocess
from PIL import Image, ImageTk
def select_image():
# Open a file dialog to select an image file
file_path = filedialog.askopenfilename(
title='Select Image',
filetypes=[('Image Files', '*.jpg *.jpeg *.png *.gif *.bmp')]
)
if file_path:
# Run 'python3 main.py <image_file>'
subprocess.run(['python3', 'main.py', file_path])
# Create the main application window
root = tk.Tk()
root.title('Ludwig')
# Set window size
root.geometry('900x600')
root.resizable(False, False)
# Set window icon (replace 'icon.ico' with your icon file)
try:
root.iconbitmap('icon.ico')
except:
pass # If the icon file is not found, continue without setting an icon
# Load and set the background image (replace 'background.jpg' with your image file)
try:
bg_image = Image.open('background.jpg')
bg_image = bg_image.resize((300, 300), Image.ANTIALIAS)
bg_photo = ImageTk.PhotoImage(bg_image)
bg_label = tk.Label(root, image=bg_photo)
bg_label.place(relwidth=1, relheight=1)
except:
root.configure(bg='#ffffff') # Set a default background color if image not found
# Create a frame to hold the content with transparent background
content_frame = tk.Frame(root, bg='#ffffff')
content_frame.pack(pady=150)
# Create and place a title label
title_label = tk.Label(
content_frame,
text='Ludwig',
font=('Arial', 60, 'bold'),
bg='#ffffff', # Match the background color
fg='#333333'
)
title_label.pack(pady=10)
# Add the description label
description_label = tk.Label(
content_frame,
text='Ludwig is a tool that takes in a picture of sheet music as input and then plays the notes on a physical piano. Upload a picture of sheet music to get started!',
font=('Arial', 20),
bg='#ffffff',
fg='#555555',
wraplength=600,
justify='center',
)
description_label.pack(pady=10)
# Create and place the 'Select Image' button with styling
select_button = tk.Button(
content_frame,
text='Select Image',
command=select_image,
font=('Arial', 20),
bg='#4CAF50',
fg='#000000', # Changed from white to black
activebackground='#45a049',
padx=20,
pady=10,
bd=0,
relief='flat',
cursor='hand2'
)
select_button.pack(pady=20)
# Start the GUI event loop
root.mainloop()