如何修复从Tkinter示例代码生成的exe?

时间:2019-05-02 11:01:09

标签: python-3.x tkinter exe pyinstaller

我已经使用pyinstaller从此tkinter gui示例生成exe。但是在dist文件夹中生成的exe不显示任何GUI。是因为文件读取操作吗?我已经举了一些例子。但是问题仍然存在。

from tkinter import *
import pandas as pd
import statsmodels.api as sm

class Checkbar(Frame):
   def __init__(self, parent=None, picks=[], side=LEFT, anchor=W):
      Frame.__init__(self, parent)
      self.vars = []
      for pick in picks:
         var = IntVar()
         chk = Checkbutton(self, text=pick, variable=var)
         chk.pack(side=side, anchor=anchor, expand=YES)
         self.vars.append(var)
   def state(self):
      return map((lambda var: var.get()), self.vars)
if __name__ == '__main__':
   dfs = pd.read_excel("data.xlsx")

   root = Tk()
   root.title("Ship Repairing Time")
   root.geometry("800x600+0+0")
   heading = Label(root, text="Choose the variables you want", font=("arial", 25, "bold"), fg="blue").pack()
   lng = Checkbar(root, ['PLATE', 'SB', 'HC', 'GRT', 'D', 'TC', 'V', 'PA'])
   include = Checkbutton(root, )
   lng.pack(side=TOP,  fill=X)
   T = Text(root, height=25, width=90)
   T.pack()
   selected_columns = []
   x = dfs.iloc[:, 1:]
   print(list(x))
   y = dfs["T"]
   #tgl.pack(side=LEFT)
   lng.config(relief=GROOVE, bd=2)

   def allstates():
      T.delete(1.0,END)
      print(list(lng.state()))
      for i in range(len(list(lng.state()))):
          if list(lng.state())[i] == 1:
              selected_columns.append(list(x)[i])
      print(selected_columns)
      selected_frame = x[selected_columns]
      selected_frame = sm.add_constant(selected_frame)
      model = sm.OLS(y, selected_frame).fit()
      predictions = model.predict(selected_frame)
      T.insert(END, model.summary())

      selected_columns.clear()


   Button(root, text='Quit', command=root.quit).pack(side=BOTTOM)
   Button(root, text='Calculate', command=allstates).pack(side=TOP)
   root.mainloop()

0 个答案:

没有答案