(python) I can’t see the graph on .exe

The thing I want is as blow.

  • Click the button ’30d graph’
  • A new window appears and the graph is on the new window

Reality is

  1. In jupyter notebook, all codings are possible

2-1. Push shift + enter

2-2. Input ‘Load VACS spec’ file and ‘Load Distribution’ file.

2-3. Click the ’30d graph’ button.

2-4. A new window is occurs and the graph is shown on the new window well.

  1. Put out the .exe file from anaconda prompt.

  2. Turn on the .exe program

  3. 2-2.~2-4. repeat

  4. A new window is occurs BUT the graph is not shown

Here’s my python code and…anyone who professional to python help me…please
I have suffered from this problem during 2 weeks…

import tkinter as tk
from tkinter import filedialog
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import pandas as pd

window = tk.Tk()
window.geometry("500x300")

def load_spec():
    
    global xx
    global yy
    global xxx
    global yyy
    global xxxx
    global yyyy

    spec_window = tk.Toplevel(window)
    file_path = filedialog.askopenfilename()
    file_name_label=tk.Label(spec_window, text = "Selected File:" + file_path)
    file_name_label.pack()

    df = pd.read_excel(file_path)
    
    xx = df.iloc[:,0].tolist()
    yy = df.iloc[:,1].tolist()
    
    xxx = df.iloc[:,2].tolist()
    yyy = df.iloc[:,3].tolist()
    
    xxxx = df.iloc[:,4].tolist()
    yyyy = df.iloc[:,5].tolist()
    
def load_distribution():
    
    global x1
    global y1
    global x2
    global y2
    global x3
    global y3
    
    distribution_window = tk.Toplevel(window)
    file_path = filedialog.askopenfilename()
    file_name_label=tk.Label(distribution_window, text = "Selected File:" + file_path)
    file_name_label.pack()

    df = pd.read_excel(file_path)
    
    x1 = df.iloc[:,0].tolist()
    y1 = df.iloc[:,1].tolist()
    x2 = df.iloc[:,2].tolist()
    y2 = df.iloc[:,3].tolist()
    x3 = df.iloc[:,4].tolist()
    y3 = df.iloc[:,5].tolist()
    
def draw_30d_graph():
    fig=plt.figure()
    graph_window = tk.Toplevel(window)
    graph_window.geometry("500x300")
    
    plt.savefig('test.png')
    
    plt.plot(x1,y1,'o',label='30d')
    plt.plot(xx,yy,label='30d spec')
    
    plt.title("30d Graph")
    plt.xlabel("du'")
    plt.ylabel("dv'")
    plt.legend()
    
    canvas = FigureCanvasTkAgg(fig, master = graph_window)
    canvas.draw()
    canvas.get_tk_widget().pack()
    
    def save_image():
        file_path = filedialog.asksaveasfilename(defaultextension='.png')
        fig.savefig(file_path)
        
    save_button = tk.Button(graph_window,text="Save",command=save_image)
    save_button.pack()
    
def draw_45d_graph():
    fig=plt.figure()
    graph_window = tk.Toplevel(window)
    graph_window.geometry("500x300")
    
    plt.savefig('test.png')
    
    plt.plot(x2,y2,'o',label='45d')
    plt.plot(xxx,yyy,label='45d spec')
    
    plt.title("45d Graph")
    plt.xlabel("du'")
    plt.ylabel("dv'")
    plt.legend()
    
    canvas = FigureCanvasTkAgg(fig, master = graph_window)
    canvas.draw()
    canvas.get_tk_widget().pack()
    
    def save_image():
        file_path = filedialog.asksaveasfilename(defaultextension='.png')
        fig.savefig(file_path)
        
    save_button = tk.Button(graph_window,text="Save",command=save_image)
    save_button.pack()
    
def draw_60d_graph():
    fig=plt.figure()
    graph_window = tk.Toplevel(window)
    graph_window.geometry("500x300")

    plt.savefig('test.png')
    
    plt.plot(x3,y3,'o',label='60d')
    plt.plot(xxxx,yyyy,label='60d spec')
    
    plt.title("60d Graph")
    plt.xlabel("du'")
    plt.ylabel("dv'")
    plt.legend()
    
    canvas = FigureCanvasTkAgg(fig, master = graph_window)
    canvas.draw()
    canvas.get_tk_widget().pack()

    def save_image():
        file_path = filedialog.asksaveasfilename(defaultextension='.png')
        fig.savefig(file_path)
        
    save_button = tk.Button(graph_window,text="Save",command=save_image)
    save_button.pack()
    
button_30d = tk.Button(window, text="30d graph", command = draw_30d_graph)
button_45d = tk.Button(window, text="45d graph", command = draw_45d_graph)
button_60d = tk.Button(window, text="60d graph", command = draw_60d_graph)
button_load_vacs = tk.Button(window, text = "Load VACS spec", command = load_spec)
button_load_distribution = tk.Button(window, text = "Load Distribution", command = load_distribution)


button_30d.place(x=100, y=100)
button_45d.place(x=100, y=140)
button_60d.place(x=100, y=180)
button_load_vacs.place(x=100, y=20)
button_load_distribution.place(x=100, y=60)

window.mainloop()

New contributor

꼬맹몬 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật