mirror of
https://github.com/gryf/coach.git
synced 2025-12-17 19:20:19 +01:00
wxPython removal (#207)
Replacing wxPython with Python's Tkinter. Also removing the option to choose multiple files as it is unused and causes errors, and fixing the load file/directory spinner.
This commit is contained in:
@@ -10,7 +10,6 @@ scikit-image>=0.13.0
|
||||
gym>=0.10.5
|
||||
bokeh>=0.13.0
|
||||
futures>=3.1.1
|
||||
wxPython>=4.0.1
|
||||
kubernetes>=8.0.0b1
|
||||
redis>=2.10.6
|
||||
minio>=4.0.5
|
||||
|
||||
@@ -156,20 +156,17 @@ def create_files_group_signal(files):
|
||||
|
||||
|
||||
# load files from disk as a group
|
||||
def load_files_group():
|
||||
show_spinner("Loading files group...")
|
||||
files = open_file_dialog()
|
||||
# no files selected
|
||||
if not files or not files[0]:
|
||||
def load_file():
|
||||
file = open_file_dialog()
|
||||
show_spinner("Loading file...")
|
||||
# no file selected
|
||||
if not file:
|
||||
hide_spinner()
|
||||
return
|
||||
|
||||
display_boards()
|
||||
|
||||
if len(files) == 1:
|
||||
create_files_signal(files)
|
||||
else:
|
||||
create_files_group_signal(files)
|
||||
create_files_signal([file])
|
||||
|
||||
change_selected_signals_in_data_selector([""])
|
||||
hide_spinner()
|
||||
@@ -230,8 +227,8 @@ def handle_dir(dir_path, run_type):
|
||||
|
||||
# load directory from disk as a group
|
||||
def load_directory_group():
|
||||
show_spinner("Loading directories group...")
|
||||
directory = open_directory_dialog()
|
||||
show_spinner("Loading directories group...")
|
||||
# no files selected
|
||||
if not directory:
|
||||
hide_spinner()
|
||||
@@ -277,19 +274,6 @@ def create_files_signal(files, use_dir_name=False):
|
||||
selected_file = new_signal_files[0]
|
||||
|
||||
|
||||
# load files from disk
|
||||
def load_files():
|
||||
show_spinner("Loading files...")
|
||||
files = open_file_dialog()
|
||||
|
||||
# no files selected
|
||||
if not files or not files[0]:
|
||||
hide_spinner()
|
||||
return
|
||||
|
||||
display_files(files)
|
||||
|
||||
|
||||
def display_files(files):
|
||||
pause_auto_update()
|
||||
|
||||
@@ -497,8 +481,8 @@ plot.y_range = Range1d(0, 100)
|
||||
plot.extra_y_ranges['secondary'] = Range1d(0, 100)
|
||||
|
||||
# select file
|
||||
file_selection_button = Button(label="Select Files", button_type="success", width=120)
|
||||
file_selection_button.on_click(load_files_group)
|
||||
file_selection_button = Button(label="Select File", button_type="success", width=120)
|
||||
file_selection_button.on_click(load_file)
|
||||
|
||||
files_selector_spacer = Spacer(width=10)
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ from os.path import join
|
||||
from enum import Enum
|
||||
from bokeh.models import Div
|
||||
from bokeh.plotting import curdoc
|
||||
import wx
|
||||
import tkinter as tk
|
||||
from tkinter import filedialog
|
||||
import colorsys
|
||||
|
||||
patches = {}
|
||||
@@ -96,7 +97,7 @@ def hide_spinner():
|
||||
spinner.text = ""
|
||||
|
||||
|
||||
# takes path to dir and recursively adds all it's files to paths
|
||||
# takes path to dir and recursively adds all its files to paths
|
||||
def add_directory_csv_files(dir_path, paths=None):
|
||||
if not paths:
|
||||
paths = []
|
||||
@@ -113,24 +114,37 @@ def add_directory_csv_files(dir_path, paths=None):
|
||||
return paths
|
||||
|
||||
|
||||
class DialogApp(wx.App):
|
||||
|
||||
|
||||
class DialogApp():
|
||||
|
||||
def getFileDialog(self):
|
||||
with wx.FileDialog(None, "Open CSV file", wildcard="CSV files (*.csv)|*.csv",
|
||||
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_CHANGE_DIR | wx.FD_MULTIPLE) as fileDialog:
|
||||
if fileDialog.ShowModal() == wx.ID_CANCEL:
|
||||
return None # the user changed their mind
|
||||
else:
|
||||
# Proceed loading the file chosen by the user
|
||||
return fileDialog.GetPaths()
|
||||
application_window = tk.Tk()
|
||||
|
||||
# Build a list of tuples for each file type the file dialog should display
|
||||
my_filetypes = [('csv files', '.csv')]
|
||||
|
||||
# Ask the user to select a one or more file names.
|
||||
answer = filedialog.askopenfilename(parent=application_window,
|
||||
initialdir=os.getcwd(),
|
||||
title="Please select a file",
|
||||
filetypes=my_filetypes)
|
||||
application_window.destroy()
|
||||
return answer
|
||||
|
||||
|
||||
def getDirDialog(self):
|
||||
with wx.DirDialog(None, "Choose input directory", "",
|
||||
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_CHANGE_DIR) as dirDialog:
|
||||
if dirDialog.ShowModal() == wx.ID_CANCEL:
|
||||
return None # the user changed their mind
|
||||
else:
|
||||
# Proceed loading the dir chosen by the user
|
||||
return dirDialog.GetPath()
|
||||
application_window = tk.Tk()
|
||||
|
||||
# Ask the user to select a folder.
|
||||
answer = filedialog.askdirectory(parent=application_window,
|
||||
initialdir=os.getcwd(),
|
||||
title="Please select a folder")
|
||||
application_window.destroy()
|
||||
return answer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class RunType(Enum):
|
||||
@@ -150,4 +164,5 @@ class FolderType(Enum):
|
||||
|
||||
dialog = DialogApp()
|
||||
|
||||
|
||||
doc = curdoc()
|
||||
|
||||
@@ -55,6 +55,9 @@ class SignalsFileBase:
|
||||
signal.toggle_axis()
|
||||
|
||||
def update_source_and_signals(self):
|
||||
# Remove old index
|
||||
self.csv = self.csv.reset_index(drop=True)
|
||||
|
||||
# create bokeh data sources
|
||||
self.bokeh_source_orig = ColumnDataSource(self.csv)
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@@ -50,7 +50,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
|
||||
|
||||
install_requires = list()
|
||||
extras = dict()
|
||||
excluded_packages = ['wxPython', 'kubernetes', 'tensorflow'] if slim_package else []
|
||||
excluded_packages = ['kubernetes', 'tensorflow'] if slim_package else []
|
||||
|
||||
with open(path.join(here, 'requirements.txt'), 'r') as f:
|
||||
for line in f:
|
||||
|
||||
Reference in New Issue
Block a user