Copy def display_token_info_by_ca(self, token_data):
if hasattr(self, 'project_info_frame'):
self.project_info_frame.destroy()
self.project_info_frame = customtkinter.CTkFrame(self.main_content_frame)
self.project_info_frame.grid(row=3, column=0, padx=20, pady=20, sticky="nsew")
self.project_info_frame.grid_columnconfigure(0, weight=1)
try:
price_usd = float(token_data['priceUsd'])
except (ValueError, TypeError):
price_usd = 0
name = token_data['baseToken']['name']
symbol = token_data['baseToken']['symbol']
contract_address = token_data['baseToken']['address']
dex_id = token_data['dexId']
liquidity_usd = token_data['liquidity'].get('usd', 0)
volume_24h = token_data['volume'].get('h24', 0)
market_cap = token_data.get('marketCap', 'N/A')
info_frame = customtkinter.CTkFrame(self.project_info_frame, fg_color="transparent")
info_frame.grid(row=0, column=0, padx=20, pady=10, sticky="nsew")
info_frame.grid_columnconfigure(0, weight=1)
info_frame.grid_columnconfigure(1, weight=2)
labels = [
("Token Name:", f"{name} ({symbol})"),
("Contract Address:", contract_address),
("Price:", f"${format_number(price_usd, 2)}"),
("DEX:", dex_id),
("Liquidity (USD):", f"${format_number(liquidity_usd, 2)}"),
("Volume (24h):", f"${format_number(volume_24h, 2)}"),
("Market Cap:", f"${format_number(market_cap, 2)}" if isinstance(market_cap, (int, float)) else "N/A")
]
for idx, (label_text, value_text) in enumerate(labels):
label = customtkinter.CTkLabel(info_frame, text=label_text, anchor="w", font=customtkinter.CTkFont(weight="bold"))
label.grid(row=idx, column=0, padx=5, pady=2, sticky="w")
value = customtkinter.CTkLabel(info_frame, text=value_text, anchor="w")
value.grid(row=idx, column=1, padx=5, pady=2, sticky="w")
if label_text == "Contract Address:":
copy_button = customtkinter.CTkButton(info_frame, text="Copy", width=60, command=lambda ca=contract_address: self.copy_to_clipboard(ca))
copy_button.grid(row=idx, column=2, padx=5, pady=2, sticky="w")
buttons_frame = customtkinter.CTkFrame(self.project_info_frame)
buttons_frame.grid(row=1, column=0, padx=20, pady=10, sticky="w")
dexscreener_button = customtkinter.CTkButton(buttons_frame, text="Show on Dexscreener", command=lambda: self.open_dexscreener(token_data['baseToken']['address']))
dexscreener_button.grid(row=0, column=0, padx=10, pady=10)
swap_button = customtkinter.CTkButton(buttons_frame, text="Swap via Jupiter", command=lambda: self.open_jupiter(token_data['baseToken']['address']))
swap_button.grid(row=0, column=1, padx=10, pady=10)
audit_button = customtkinter.CTkButton(buttons_frame, text="Audit via GoPlus", command=lambda: self.open_goplus_audit(token_data['baseToken']['address']))
audit_button.grid(row=0, column=2, padx=10, pady=10)