|
1威望
- import wx
- from pyecharts import HeatMap
- import pandas as pd
- import numpy as np
- class Draw_Interface(wx.Frame):
- def __init__(self):
- wx.Frame.__init__(self, None, -1, '信噪比寻北补偿插件', size=(600, 100))
- panel = wx.Panel(self, -1)
- self.url_lable = wx.StaticText(panel, -1, '文件路径')
- self.url_text = wx.TextCtrl(panel, -1, '', size=(300, -1))
- self.url_button = wx.Button(panel, -1, '选择')
- self.Bind(wx.EVT_BUTTON, self.url_button_click, self.url_button)
- self.url_button.SetDefault()
- self.draw_button = wx.Button(panel, -1, '绘图')
- self.Bind(wx.EVT_BUTTON, self.draw_button_click, self.draw_button)
- self.draw_button.SetDefault()
- sizer = wx.FlexGridSizer(cols=4)
- sizer.AddMany([self.url_lable, self.url_text, self.url_button, self.draw_button])
- panel.SetSizer(sizer)
- def draw_button_click(self, *all):
- url = self.url_text.GetValue()
- flag = self.SNR_draw(url)
- if flag:
- wx.MessageBox('绘图成功')
- def url_button_click(self, *all):
- dlg = wx.FileDialog(self, wildcard="csv(*.csv)|*.csv", style=wx.DD_DEFAULT_STYLE)
- if dlg.ShowModal() == wx.ID_OK:
- global savefile
- savefile = dlg.GetPath()
- self.url_text.SetValue(savefile)
- dlg.Destroy()
- def SNR_draw(self, url):
- lis = np.arange(8, 535, 4)
- lis = np.insert(lis, 0, [5])
- datas = pd.read_csv(url, skiprows=1, usecols=lis)
- x_axis = datas['Azimuth']
- y_axis = datas.columns.values[1:]
- x = [str(i) for i in x_axis]
- y = [str(i) for i in y_axis]
- data = [[i, j, datas.loc[i, j]] for i in range(len(x)) for j in y]
- hp = HeatMap('信噪比', width=1200, height=600)
- hp.add(None, x, y, data, is_datazoom_show=True, datazoom_orient='vertical', datazoom_type='both',
- datazoom_xaxis_index=0, datazoom_yaxis_index=0, is_visualmap=True,
- visual_range=[0, np.max(datas.values)],
- visual_orient='horizontal', tooltip_tragger_on='click', tooltip_formatter='方位角:{b}---其他:{c}',
- datazoom_range=[0, 100])
- hp.render()
- return 1
- if __name__ == '__main__':
- app = wx.App()
- frame = Draw_Interface()
- frame.Show()
- app.MainLoop()
复制代码 利用pyinstaller打包exe,闪退,求大神帮忙 |
|