The user wants a Python program to monitor cryptocurrency mining statistics. I'll create a comprehensive GUI application that simulates/monitors mining statistics with:
- A dashboard showing mining statistics
- Hashrate monitoring
- Worker status
- Earnings/rewards tracking
- Pool statistics
- Real-time charts/graphs
- Configuration options
Since we can't connect to real mining hardware or pools without API keys, I'll create a realistic simulation that could be adapted to connect to real mining pool APIs.
I'll use tkinter for the GUI as it's built-in, and matplotlib for charts (which needs to be installed).
Features to include:
- Multiple cryptocurrency support (Bitcoin, Ethereum, etc.)
- Hashrate display with charts
- Worker/miner status
- Temperature monitoring
- Power consumption estimates
- Earnings calculator
- Pool connection status
- Real-time updates
Let me create a comprehensive mining monitor application.
Cryptocurrency Mining Statistics Monitor
I'll create a comprehensive cryptocurrency mining statistics monitor with a professional GUI dashboard, real-time updates, and multiple monitoring features.
Installation
pip install matplotlib psutil
Complete Code
import tkinter as tk
from tkinter import ttk, messagebox
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import random
import time
import threading
import json
import hashlib
from datetime import datetime, timedelta
from collections import deque
import math
class MiningMonitor:
def __init__(self, root):
self.root = root
self.root.title("Cryptocurrency Mining Monitor")
self.root.geometry("1400x900")
self.root.configure(bg='#1a1a2e')
# Theme colors
self.colors = {
'bg_dark': '#1a1a2e',
'bg_medium': '#16213e',
'bg_light': '#0f3460',
'accent': '#e94560',
'text': '#eaeaea',
'text_dim': '#a0a0a0',
'green': '#00d26a',
'red': '#ff4757',
'orange': '#ffa502',
'blue': '#3498db',
'purple': '#9b59b6'
}
# Mining configuration
self.config = {
'wallet_address': '',
'pool_url': 'stratum+tcp://pool.example.com:3333',
'coin': 'Ethereum',
'workers': 3,
'update_interval': 2
}
# Statistics data
self.stats = {
'hashrate': 0,
'shares_accepted': 0,
'shares_rejected': 0,
'blocks_found': 0,
'uptime': 0,
'temperature': [],
'power_usage': 0,
'daily_earnings': 0,
'balance': 0,
'pool_hashrate': 0,
'network_difficulty': 0
}
# History for charts
self.hashrate_history = deque(maxlen=60)
self.temperature_history = deque(maxlen=60)
self.earnings_history = deque(maxlen=30)
self.time_history = deque(maxlen=60)
# Workers data
self.workers = []
for i in range(self.config['workers']):
self.workers.append({
'id': f'worker_{i+1}',
'name': f'GPU-{i+1}',
'hashrate': 0,
'temperature': 0,
'fan_speed': 0,
'status': 'offline',
'shares': 0,
'invalid': 0
})
# Mining state
self.mining_active = False
self.start_time = None
# Cryptocurrency prices (simulated)
self.crypto_prices = {
'Ethereum': 1850.0,
'Bitcoin': 42500.0,
'Litecoin': 72.0,
'Ravencoin': 0.015,
'Ethereum Classic': 18.5,
'Zcash': 28.0
}
self.setup_styles()
self.create_gui()
self.update_loop()
def setup_styles(self):
"""Setup ttk styles for dark theme"""
style = ttk.Style()
style.theme_use('clam')
style.configure('Dark.TFrame', background=self.colors['bg_dark'])
style.configure('Medium.TFrame', background=self.colors['bg_medium'])
style.configure('Card.TFrame', background=self.colors['bg_light'])
style.configure('Dark.TLabel',
background=self.colors['bg_dark'],
foreground=self.colors['text'],
font=('Segoe UI', 10))
style.configure('Title.TLabel',
background=self.colors['bg_dark'],
foreground=self.colors['text'],
font=('Segoe UI', 14, 'bold'))
style.configure('Value.TLabel',
background=self.colors['bg_dark'],
foreground=self.colors['accent'],
font=('Segoe UI', 18, 'bold'))
style.configure('Dark.TButton',
background=self.colors['accent'],
foreground='white',
font=('Segoe UI', 10, 'bold'),
padding=10)
style.configure('Dark.TCombobox',
fieldbackground=self.colors['bg_medium'],
background=self.colors['bg_light'],
foreground=self.colors['text'])
style.map('Dark.TButton',
background=[('active', self.colors['red'])])
def create_gui(self):
"""Create the main GUI layout"""
# Main container
self.main_container = ttk.Frame(self.root, style='Dark.TFrame')
self.main_container.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
# Top bar
self.create_top_bar()
# Main content area
content_frame = ttk.Frame(self.main_container, style='Dark.TFrame')
content_frame.pack(fill=tk.BOTH, expand=True, pady=10)
# Left panel - Statistics
left_panel = ttk.Frame(content_frame, style='Dark.TFrame', width=400)
left_panel.pack(side=tk.LEFT, fill=tk.Y, padx=(0, 10))
left_panel.pack_propagate(False)
self.create_stats_panel(left_panel)
# Center panel - Charts
center_panel = ttk.Frame(content_frame, style='Dark.TFrame')
center_panel.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=10)
self.create_charts_panel(center_panel)
# Right panel - Workers
right_panel = ttk.Frame(content_frame, style='Dark.TFrame', width=350)
right_panel.pack(side=tk.RIGHT, fill=tk.Y, padx=(10, 0))
right_panel.pack_propagate(False)
self.create_workers_panel(right_panel)
def create_top_bar(self):
"""Create top control bar"""
top_frame = ttk.Frame(self.main_container, style='Dark.TFrame')
top_frame.pack(fill=tk.X, pady=(0, 10))
# Logo and title
title_frame = ttk.Frame(top_frame, style='Dark.TFrame')
title_frame.pack(side=tk.LEFT)
title_label = tk.Label(title_frame,
text="⛏️ CryptoMiner Monitor",
bg=self.colors['bg_dark'],
fg=self.colors['accent'],
font=('Segoe UI', 20, 'bold'))
title_label.pack(side=tk.LEFT)
# Coin selector
coin_frame = ttk.Frame(top_frame, style='Dark.TFrame')
coin_frame.pack(side=tk.LEFT, padx=30)
tk.Label(coin_frame, text="Coin:", bg=self.colors['bg_dark'],
fg=self.colors['text'], font=('Segoe UI', 10)).pack(side=tk.LEFT)
self.coin_var = tk.StringVar(value='Ethereum')
coin_combo = ttk.Combobox(coin_frame, textvariable=self.coin_var,
values=list(self.crypto_prices.keys()),
state='readonly', width=12)
coin_combo.pack(side=tk.LEFT, padx=5)
coin_combo.bind('<<ComboboxSelected>>', self.on_coin_change)
# Pool status indicator
self.pool_status_frame = tk.Frame(top_frame, bg=self.colors['bg_dark'])
self.pool_status_frame.pack(side=tk.LEFT, padx=20)
self.pool_indicator = tk.Canvas(self.pool_status_frame, width=12, height=12,
bg=self.colors['bg_dark'], highlightthickness=0)
self.pool_indicator.pack(side=tk.LEFT, padx=5)
self.pool_indicator.create_oval(2, 2, 10, 10, fill='gray', tags='indicator')
self.pool_status_label = tk.Label(self.pool_status_frame, text="Disconnected",
bg=self.colors['bg_dark'],
fg=self.colors['text_dim'],
font=('Segoe UI', 10))
self.pool_status_label.pack(side=tk.LEFT)
# Control buttons
btn_frame = ttk.Frame(top_frame, style='Dark.TFrame')
btn_frame.pack(side=tk.RIGHT)
self.start_btn = tk.Button(btn_frame, text="▶ Start Mining",
bg=self.colors['green'], fg='white',
font=('Segoe UI', 10, 'bold'),
width=12, command=self.toggle_mining)
self.start_btn.pack(side=tk.LEFT, padx=5)
settings_btn = tk.Button(btn_frame, text="⚙ Settings",
bg=self.colors['bg_light'], fg='white',
font=('Segoe UI', 10),
width=10, command=self.open_settings)
settings_btn.pack(side=tk.LEFT, padx=5)
def create_stats_panel(self, parent):
"""Create statistics panel"""
# Hashrate section
self.create_stat_card(parent, "Current Hashrate", "0.00 MH/s", 'hashrate_value')
# Pool stats section
pool_frame = tk.LabelFrame(parent, text=" Pool Statistics ",
bg=self.colors['bg_medium'],
fg=self.colors['accent'],
font=('Segoe UI', 10, 'bold'))
pool_frame.pack(fill=tk.X, pady=10, padx=5)
self.shares_accepted_label = self.create_stat_row(pool_frame, "Shares Accepted:", "0")
self.shares_rejected_label = self.create_stat_row(pool_frame, "Shares Rejected:", "0")
self.share_rate_label = self.create_stat_row(pool_frame, "Share Rate:", "0%")
self.blocks_found_label = self.create_stat_row(pool_frame, "Blocks Found:", "0")
# Earnings section
earnings_frame = tk.LabelFrame(parent, text=" Earnings ",
bg=self.colors['bg_medium'],
fg=self.colors['accent'],
font=('Segoe UI', 10, 'bold'))
earnings_frame.pack(fill=tk.X, pady=10, padx=5)
self.daily_earnings_label = self.create_stat_row(earnings_frame, "Daily:", "0.0000 ETH")
self.weekly_earnings_label = self.create_stat_row(earnings_frame, "Weekly:", "0.0000 ETH")
self.monthly_earnings_label = self.create_stat_row(earnings_frame, "Monthly:", "0.0000 ETH")
self.balance_label = self.create_stat_row(earnings_frame, "Balance:", "0.0000 ETH")
self.usd_value_label = self.create_stat_row(earnings_frame, "USD Value:", "$0.00")
# System stats section
system_frame = tk.LabelFrame(parent, text=" System Statistics ",
bg=self.colors['bg_medium'],
fg=self.colors['accent'],
font=('Segoe UI', 10, 'bold'))
system_frame.pack(fill=tk.X, pady=10, padx=5)
self.uptime_label = self.create_stat_row(system_frame, "Uptime:", "00:00:00")
self.avg_temp_label = self.create_stat_row(system_frame, "Avg Temperature:", "0°C")
self.power_label = self.create_stat_row(system_frame, "Power Usage:", "0W")
self.efficiency_label = self.create_stat_row(system_frame, "Efficiency:", "0 kH/W")
# Network info
network_frame = tk.LabelFrame(parent, text=" Network Info ",
bg=self.colors['bg_medium'],
fg=self.colors['accent'],
font=('Segoe UI', 10, 'bold'))
network_frame.pack(fill=tk.X, pady=10, padx=5)
self.pool_hashrate_label = self.create_stat_row(network_frame, "Pool Hashrate:", "0 GH/s")
self.network_diff_label = self.create_stat_row(network_frame, "Network Diff:", "0 T")
self.block_reward_label = self.create_stat_row(network_frame, "Block Reward:", "0 ETH")
def create_stat_card(self, parent, title, value, attr_name):
"""Create a highlighted stat card"""
card = tk.Frame(parent, bg=self.colors['bg_light'], padx=15, pady=10)
card.pack(fill=tk.X, pady=5, padx=5)
tk.Label(card, text=title, bg=self.colors['bg_light'],
fg=self.colors['text_dim'], font=('Segoe UI', 9)).pack(anchor='w')
value_label = tk.Label(card, text=value, bg=self.colors['bg_light'],
fg=self.colors['green'], font=('Segoe UI', 24, 'bold'))
value_label.pack(anchor='w')
setattr(self, attr_name, value_label)
def create_stat_row(self, parent, label, value):
"""Create a statistic row"""
frame = tk.Frame(parent, bg=self.colors['bg_medium'])
frame.pack(fill=tk.X, padx=10, pady=3)
tk.Label(frame, text=label, bg=self.colors['bg_medium'],
fg=self.colors['text_dim'], font=('Segoe UI', 9),
width=15, anchor='w').pack(side=tk.LEFT)
value_label = tk.Label(frame, text=value, bg=self.colors['bg_medium'],
fg=self.colors['text'], font=('Segoe UI', 9, 'bold'),
anchor='e')
value_label.pack(side=tk.RIGHT)
return value_label
def create_charts_panel(self, parent):
"""Create charts panel with matplotlib"""
# Create figure
self.fig = Figure(figsize=(8, 6), facecolor=self.colors['bg_dark'])
# Hashrate chart
self.ax_hashrate = self.fig.add_subplot(221)
self.setup_chart_style(self.ax_hashrate, 'Hashrate (MH/s)')
# Temperature chart
self.ax_temp = self.fig.add_subplot(222)
self.setup_chart_style(self.ax_temp, 'Temperature (°C)')
# Earnings chart
self.ax_earnings = self.fig.add_subplot(223)
self.setup_chart_style(self.ax_earnings, 'Daily Earnings')
# Worker distribution pie chart
self.ax_workers = self.fig.add_subplot(224)
self.setup_chart_style(self.ax_workers, 'Worker Distribution')
self.fig.tight_layout(pad=3.0)
# Embed in tkinter
self.canvas = FigureCanvasTkAgg(self.fig, parent)
self.canvas.draw()
self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=True)
def setup_chart_style(self, ax, title):
"""Apply consistent styling to charts"""
ax.set_facecolor(self.colors['bg_medium'])
ax.tick_params(colors=self.colors['text_dim'], labelsize=8)
ax.set_title(title, color=self.colors['text'], fontsize=10)
for spine in ax.spines.values():
spine.set_color(self.colors['bg_light'])
def create_workers_panel(self, parent):
"""Create workers panel"""
title = tk.Label(parent, text="Active Workers",
bg=self.colors['bg_dark'],
fg=self.colors['accent'],
font=('Segoe UI', 12, 'bold'))
title.pack(pady=10)
# Workers list
self.worker_widgets = []
workers_frame = tk.Frame(parent, bg=self.colors['bg_dark'])
workers_frame.pack(fill=tk.BOTH, expand=True, padx=5)
for worker in self.workers:
widget = self.create_worker_card(workers_frame, worker)
self.worker_widgets.append(widget)
# Total summary
summary_frame = tk.Frame(parent, bg=self.colors['bg_light'], padx=10, pady=10)
summary_frame.pack(fill=tk.X, pady=10, padx=5)
tk.Label(summary_frame, text="Total Hashrate:", bg=self.colors['bg_light'],
fg=self.colors['text_dim'], font=('Segoe UI', 9)).pack(anchor='w')
self.total_hashrate_label = tk.Label(summary_frame, text="0.00 MH/s",
bg=self.colors['bg_light'],
fg=self.colors['green'],
font=('Segoe UI', 14, 'bold'))
self.total_hashrate_label.pack(anchor='w')
# Quick actions
actions_frame = tk.Frame(parent, bg=self.colors['bg_dark'])
actions_frame.pack(fill=tk.X, pady=10)
tk.Button(actions_frame, text="🔄 Refresh All",
bg=self.colors['bg_light'], fg='white',
font=('Segoe UI', 9),
command=self.refresh_workers).pack(fill=tk.X, pady=2)
tk.Button(actions_frame, text="📊 Export Report",
bg=self.colors['bg_light'], fg='white',
font=('Segoe UI', 9),
command=self.export_report).pack(fill=tk.X, pady=2)
def create_worker_card(self, parent, worker):
"""Create a worker info card"""
card = tk.Frame(parent, bg=self.colors['bg_medium'], padx=10, pady=8)
card.pack(fill=tk.X, pady=5)
# Header with status
header = tk.Frame(card, bg=self.colors['bg_medium'])
header.pack(fill=tk.X)
name_label = tk.Label(header, text=worker['name'],
bg=self.colors['bg_medium'],
fg=self.colors['text'],
font=('Segoe UI', 10, 'bold'))
name_label.pack(side=tk.LEFT)
status_canvas = tk.Canvas(header, width=10, height=10,
bg=self.colors['bg_medium'],
highlightthickness=0)
status_canvas.pack(side=tk.RIGHT)
status_indicator = status_canvas.create_oval(1, 1, 9, 9, fill='gray')
# Stats
stats_frame = tk.Frame(card, bg=self.colors['bg_medium'])
stats_frame.pack(fill=tk.X, pady=5)
hashrate_label = tk.Label(stats_frame, text="0.00 MH/s",
bg=self.colors['bg_medium'],
fg=self.colors['green'],
font=('Segoe UI', 12, 'bold'))
hashrate_label.pack(side=tk.LEFT)
temp_label = tk.Label(stats_frame, text="🌡️ 0°C",
bg=self.colors['bg_medium'],
fg=self.colors['orange'],
font=('Segoe UI', 9))
temp_label.pack(side=tk.RIGHT)
# Progress bar
progress_frame = tk.Frame(card, bg=self.colors['bg_dark'], height=4)
progress_frame.pack(fill=tk.X, pady=3)
progress_bar = tk.Frame(progress_frame, bg=self.colors['accent'], height=4, width=0)
progress_bar.place(x=0, y=0, relheight=1)
return {
'card': card,
'status_canvas': status_canvas,
'status_indicator': status_indicator,
'hashrate_label': hashrate_label,
'temp_label': temp_label,
'progress_bar': progress_bar
}
def toggle_mining(self):
"""Toggle mining on/off"""
if self.mining_active:
self.stop_mining()
else:
self.start_mining()
def start_mining(self):
"""Start mining simulation"""
self.mining_active = True
self.start_time = datetime.now()
self.start_btn.config(text="⏹ Stop Mining", bg=self.colors['red'])
# Update pool status
self.update_pool_status(True)
# Activate workers
for worker in self.workers:
worker['status'] = 'active'
def stop_mining(self):
"""Stop mining"""
self.mining_active = False
self.start_btn.config(text="▶ Start Mining", bg=self.colors['green'])
# Update pool status
self.update_pool_status(False)
# Deactivate workers
for worker in self.workers:
worker['status'] = 'idle'
worker['hashrate'] = 0
def update_pool_status(self, connected):
"""Update pool connection status indicator"""
if connected:
self.pool_indicator.itemconfig('indicator', fill=self.colors['green'])
self.pool_status_label.config(text="Connected", fg=self.colors['green'])
else:
self.pool_indicator.itemconfig('indicator', fill='gray')
self.pool_status_label.config(text="Disconnected", fg=self.colors['text_dim'])
def on_coin_change(self, event):
"""Handle coin selection change"""
self.config['coin'] = self.coin_var.get()
self.reset_statistics()
def reset_statistics(self):
"""Reset mining statistics"""
self.stats['shares_accepted'] = 0
self.stats['shares_rejected'] = 0
self.stats['blocks_found'] = 0
self.stats['daily_earnings'] = 0
def update_loop(self):
"""Main update loop"""
if self.mining_active:
self.update_statistics()
self.update_display()
self.update_charts()
self.update_workers_display()
# Schedule next update
self.root.after(self.config['update_interval'] * 1000, self.update_loop)
def update_statistics(self):
"""Update mining statistics (simulated)"""
coin = self.config['coin']
base_hashrate = {
'Ethereum': 120,
'Bitcoin': 95,
'Litecoin': 850,
'Ravencoin': 45,
'Ethereum Classic': 115,
'Zcash': 75
}
# Simulate hashrate with variation
base = base_hashrate.get(coin, 100)
variation = random.uniform(-5, 5)
self.stats['hashrate'] = base + variation
# Update shares
if random.random() > 0.02: # 98% acceptance rate
self.stats['shares_accepted'] += random.randint(1, 5)
else:
self.stats['shares_rejected'] += 1
# Simulate temperature for each worker
for worker in self.workers:
if worker['status'] == 'active':
worker['hashrate'] = (base / len(self.workers)) + random.uniform(-2, 2)
worker['temperature'] = 60 + random.uniform(-10, 15)
worker['fan_speed'] = min(100, max(30, int(worker['temperature'] - 30)))
worker['shares'] += random.randint(0, 2)
# Calculate averages
temps = [w['temperature'] for w in self.workers if w['status'] == 'active']
self.stats['temperature'] = temps
avg_temp = sum(temps) / len(temps) if temps else 0
# Power usage simulation
self.stats['power_usage'] = len(self.workers) * (180 + random.uniform(-20, 20))
# Earnings calculation (simplified)
hashrate_mh = self.stats['hashrate']
daily_coins = hashrate_mh * 0.0001 * random.uniform(0.9, 1.1) # Simplified
self.stats['daily_earnings'] = daily_coins
self.stats['balance'] += daily_coins / 1000 # Accumulate small amounts
# Network stats
self.stats['pool_hashrate'] = random.uniform(500, 800)
self.stats['network_difficulty'] = random.uniform(8.5, 9.5)
# Update history
current_time = time.time()
self.hashrate_history.append(self.stats['hashrate'])
self.temperature_history.append(avg_temp)
self.time_history.append(current_time)
def update_display(self):
"""Update all display elements"""
coin = self.config['coin']
coin_symbol = coin[:3].upper()
price = self.crypto_prices.get(coin, 100)
# Hashrate
hashrate = self.stats['hashrate']
if hashrate > 1000:
self.hashrate_value.config(text=f"{hashrate/1000:.2f} GH/s")
else:
self.hashrate_value.config(text=f"{hashrate:.2f} MH/s")
# Pool stats
self.shares_accepted_label.config(text=str(self.stats['shares_accepted']))
self.shares_rejected_label.config(text=str(self.stats['shares_rejected']))
total_shares = self.stats['shares_accepted'] + self.stats['shares_rejected']
share_rate = (self.stats['shares_accepted'] / total_shares * 100) if total_shares > 0 else 0
self.share_rate_label.config(text=f"{share_rate:.1f}%")
self.blocks_found_label.config(text=str(self.stats['blocks_found']))
# Earnings
daily = self.stats['daily_earnings']
weekly = daily * 7
monthly = daily * 30
self.daily_earnings_label.config(text=f"{daily:.4f} {coin_symbol}")
self.weekly_earnings_label.config(text=f"{weekly:.4f} {coin_symbol}")
self.monthly_earnings_label.config(text=f"{monthly:.4f} {coin_symbol}")
self.balance_label.config(text=f"{self.stats['balance']:.4f} {coin_symbol}")
usd_value = self.stats['balance'] * price
self.usd_value_label.config(text=f"${usd_value:.2f}")
# System stats
if self.start_time and self.mining_active:
uptime = datetime.now() - self.start_time
hours, remainder = divmod(int(uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
self.uptime_label.config(text=f"{hours:02d}:{minutes:02d}:{seconds:02d}")
temps = self.stats['temperature']
avg_temp = sum(temps) / len(temps) if temps else 0
self.avg_temp_label.config(text=f"{avg_temp:.1f}°C")
# Color temperature based on value
if avg_temp > 75:
self.avg_temp_label.config(fg=self.colors['red'])
elif avg_temp > 65:
self.avg_temp_label.config(fg=self.colors['orange'])
else:
self.avg_temp_label.config(fg=self.colors['green'])
power = self.stats['power_usage']
self.power_label.config(text=f"{power:.0f}W")
efficiency = (self.stats['hashrate'] / power * 1000) if power > 0 else 0
self.efficiency_label.config(text=f"{efficiency:.1f} kH/W")
# Network info
pool_hr = self.stats['pool_hashrate']
self.pool_hashrate_label.config(text=f"{pool_hr:.1f} GH/s")
diff = self.stats['network_difficulty']
self.network_diff_label.config(text=f"{diff:.2f} T")
# Total hashrate
total_worker_hr = sum(w['hashrate'] for w in self.workers)
self.total_hashrate_label.config(text=f"{total_worker_hr:.2f} MH/s")
def update_charts(self):
"""Update all charts"""
# Clear axes
self.ax_hashrate.clear()
self.ax_temp.clear()
self.ax_earnings.clear()
self.ax_workers.clear()
# Setup styles again
self.setup_chart_style(self.ax_hashrate, 'Hashrate (MH/s)')
self.setup_chart_style(self.ax_temp, 'Temperature (°C)')
self.setup_chart_style(self.ax_earnings, 'Daily Earnings')
self.setup_chart_style(self.ax_workers, 'Worker Hashrate Distribution')
# Hashrate chart
if len(self.hashrate_history) > 1:
times = list(range(len(self.hashrate_history)))
self.ax_hashrate.fill_between(times, list(self.hashrate_history),
alpha=0.3, color=self.colors['green'])
self.ax_hashrate.plot(times, list(self.hashrate_history),
color=self.colors['green'], linewidth=2)
self.ax_hashrate.set_ylim(bottom=0)
# Temperature chart
if len(self.temperature_history) > 1:
times = list(range(len(self.temperature_history)))
colors = [self.colors['green'] if t < 70 else
self.colors['orange'] if t < 80 else self.colors['red']
for t in self.temperature_history]
self.ax_temp.plot(times, list(self.temperature_history),
color=self.colors['orange'], linewidth=2)
self.ax_temp.axhline(y=80, color=self.colors['red'], linestyle='--', alpha=0.5)
self.ax_temp.set_ylim(40, 90)
# Earnings simulation (bar chart for last 7 days)
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
earnings = [self.stats['daily_earnings'] * random.uniform(0.8, 1.2) for _ in range(7)]
colors = [self.colors['accent'] if e == max(earnings) else self.colors['blue']
for e in earnings]
self.ax_earnings.bar(days, earnings, color=colors)
# Worker distribution
active_workers = [w for w in self.workers if w['status'] == 'active']
if active_workers:
labels = [w['name'] for w in active_workers]
sizes = [w['hashrate'] for w in active_workers]
colors = [self.colors['accent'], self.colors['blue'],
self.colors['green'], self.colors['purple'],
self.colors['orange']][:len(active_workers)]
self.ax_workers.pie(sizes, labels=labels, colors=colors,
autopct='%1.1f%%', startangle=90,
textprops={'color': self.colors['text'], 'fontsize': 8})
else:
self.ax_workers.text(0.5, 0.5, 'No Active Workers',
ha='center', va='center',
color=self.colors['text_dim'],
transform=self.ax_workers.transAxes)
self.fig.tight_layout(pad=3.0)
self.canvas.draw()
def update_workers_display(self):
"""Update worker cards"""
for i, worker in enumerate(self.workers):
widget = self.worker_widgets[i]
# Update status indicator
if worker['status'] == 'active':
widget['status_canvas'].itemconfig(widget['status_indicator'],
fill=self.colors['green'])
else:
widget['status_canvas'].itemconfig(widget['status_indicator'],
fill='gray')
# Update hashrate
widget['hashrate_label'].config(text=f"{worker['hashrate']:.2f} MH/s")
# Update temperature
temp = worker['temperature']
widget['temp_label'].config(text=f"🌡️ {temp:.0f}°C")
# Temperature color
if temp > 75:
widget['temp_label'].config(fg=self.colors['red'])
elif temp > 65:
widget['temp_label'].config(fg=self.colors['orange'])
else:
widget['temp_label'].config(fg=self.colors['text'])
# Update progress bar
if worker['status'] == 'active':
progress = min(100, worker['hashrate'] / 50 * 100)
widget['progress_bar'].place(x=0, y=0, relwidth=progress/100, relheight=1)
else:
widget['progress_bar'].place(x=0, y=0, relwidth=0, relheight=1)
def refresh_workers(self):
"""Refresh worker data"""
messagebox.showinfo("Refresh", "Workers data refreshed!")
def export_report(self):
"""Export mining report"""
report = {
'timestamp': datetime.now().isoformat(),
'coin': self.config['coin'],
'statistics': {
'hashrate': self.stats['hashrate'],
'shares_accepted': self.stats['shares_accepted'],
'shares_rejected': self.stats['shares_rejected'],
'daily_earnings': self.stats['daily_earnings'],
'balance': self.stats['balance'],
'power_usage': self.stats['power_usage']
},
'workers': self.workers
}
filename = f"mining_report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
try:
with open(filename, 'w') as f:
json.dump(report, f, indent=2)
messagebox.showinfo