1+ import tkinter as tk
2+ from PIL import Image , ImageTk
3+ from twilio .rest import Client
4+
5+ window = tk .Tk ()
6+ window .title ("Anonymous_Text_App" )
7+ window .geometry ("800x750" )
8+
9+ # Define global variables
10+ body = ""
11+ to = ""
12+
13+ def message ():
14+ global body , to
15+ account_sid = 'Your_account_sid' # Your account sid
16+ auth_token = 'Your_auth_token' # Your auth token
17+ client = Client (account_sid , auth_token )
18+ msg = client .messages .create (
19+ from_ = 'Twilio_number' , # Twilio number
20+ body = body ,
21+ to = to
22+ )
23+ print (msg .sid )
24+ confirmation_label .config (text = "Message Sent!" )
25+
26+
27+
28+ try :
29+ # Load the background image
30+ bg_img = Image .open (r"D:\Downloads\img2.png" )
31+
32+ #Canvas widget
33+ canvas = tk .Canvas (window , width = 800 , height = 750 )
34+ canvas .pack (fill = "both" , expand = True )
35+
36+ # background image to the Canvas
37+ bg_photo = ImageTk .PhotoImage (bg_img )
38+ bg_image_id = canvas .create_image (0 , 0 , image = bg_photo , anchor = "nw" )
39+ bg_image_id = canvas .create_image (550 , 250 , image = bg_photo , anchor = "center" )
40+ bg_image_id = canvas .create_image (1100 , 250 , image = bg_photo , anchor = "center" )
41+ bg_image_id = canvas .create_image (1250 , 250 , image = bg_photo , anchor = "center" )
42+ bg_image_id = canvas .create_image (250 , 750 , image = bg_photo , anchor = "center" )
43+ bg_image_id = canvas .create_image (850 , 750 , image = bg_photo , anchor = "center" )
44+ bg_image_id = canvas .create_image (1300 , 750 , image = bg_photo , anchor = "center" )
45+
46+
47+
48+ # Foreground Image
49+ img = Image .open (r"D:\Downloads\output-onlinepngtools.png" )
50+ photo = ImageTk .PhotoImage (img )
51+ img_label = tk .Label (window , image = photo , anchor = "w" )
52+ img_label .image = photo
53+ img_label .place (x = 10 , y = 20 )
54+
55+ # Text for number input
56+ canvas .create_text (1050 , 300 , text = "Enter the number starting with +[country code]" , font = ("Poppins" , 18 , "bold" ), fill = "black" , anchor = "n" )
57+ text_field_number = tk .Entry (canvas , width = 17 , font = ("Poppins" , 25 , "bold" ), bg = "#404040" , fg = "white" , show = "*" )
58+ canvas .create_window (1100 , 350 , window = text_field_number , anchor = "n" )
59+
60+ # Text for message input
61+ canvas .create_text (1050 , 450 , text = "Enter the Message" , font = ("Poppins" , 18 , "bold" ), fill = "black" , anchor = "n" )
62+ text_field_text = tk .Entry (canvas , width = 17 , font = ("Poppins" , 25 , "bold" ), bg = "#404040" , fg = "white" )
63+ canvas .create_window (1100 , 500 , window = text_field_text , anchor = "n" )
64+
65+ # label for confirmation message
66+ confirmation_label = tk .Label (window , text = "" , font = ("Poppins" , 16 ), fg = "green" )
67+ canvas .create_window (1100 , 600 , window = confirmation_label , anchor = "n" )
68+
69+ except Exception as e :
70+ print (f"Error loading image: { e } " )
71+
72+ # Function to save input and send message
73+ def save_and_send ():
74+ global body , to
75+ to = str (text_field_number .get ())
76+ body = str (text_field_text .get ())
77+ message ()
78+
79+ # Button to save input and send message
80+ save_button = tk .Button (window , text = "Save and Send" , command = save_and_send )
81+ canvas .create_window (1200 , 550 , window = save_button , anchor = 'n' )
82+
83+ window .mainloop ()
0 commit comments