1
0
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:
Gal Novik
2019-01-23 20:49:37 +02:00
committed by GitHub
parent 516547e3df
commit 135f02fb46
5 changed files with 45 additions and 44 deletions

View File

@@ -10,7 +10,6 @@ scikit-image>=0.13.0
gym>=0.10.5 gym>=0.10.5
bokeh>=0.13.0 bokeh>=0.13.0
futures>=3.1.1 futures>=3.1.1
wxPython>=4.0.1
kubernetes>=8.0.0b1 kubernetes>=8.0.0b1
redis>=2.10.6 redis>=2.10.6
minio>=4.0.5 minio>=4.0.5

View File

@@ -156,20 +156,17 @@ def create_files_group_signal(files):
# load files from disk as a group # load files from disk as a group
def load_files_group(): def load_file():
show_spinner("Loading files group...") file = open_file_dialog()
files = open_file_dialog() show_spinner("Loading file...")
# no files selected # no file selected
if not files or not files[0]: if not file:
hide_spinner() hide_spinner()
return return
display_boards() display_boards()
if len(files) == 1: create_files_signal([file])
create_files_signal(files)
else:
create_files_group_signal(files)
change_selected_signals_in_data_selector([""]) change_selected_signals_in_data_selector([""])
hide_spinner() hide_spinner()
@@ -230,8 +227,8 @@ def handle_dir(dir_path, run_type):
# load directory from disk as a group # load directory from disk as a group
def load_directory_group(): def load_directory_group():
show_spinner("Loading directories group...")
directory = open_directory_dialog() directory = open_directory_dialog()
show_spinner("Loading directories group...")
# no files selected # no files selected
if not directory: if not directory:
hide_spinner() hide_spinner()
@@ -277,19 +274,6 @@ def create_files_signal(files, use_dir_name=False):
selected_file = new_signal_files[0] 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): def display_files(files):
pause_auto_update() pause_auto_update()
@@ -497,8 +481,8 @@ plot.y_range = Range1d(0, 100)
plot.extra_y_ranges['secondary'] = Range1d(0, 100) plot.extra_y_ranges['secondary'] = Range1d(0, 100)
# select file # select file
file_selection_button = Button(label="Select Files", button_type="success", width=120) file_selection_button = Button(label="Select File", button_type="success", width=120)
file_selection_button.on_click(load_files_group) file_selection_button.on_click(load_file)
files_selector_spacer = Spacer(width=10) files_selector_spacer = Spacer(width=10)

View File

@@ -22,7 +22,8 @@ from os.path import join
from enum import Enum from enum import Enum
from bokeh.models import Div from bokeh.models import Div
from bokeh.plotting import curdoc from bokeh.plotting import curdoc
import wx import tkinter as tk
from tkinter import filedialog
import colorsys import colorsys
patches = {} patches = {}
@@ -96,7 +97,7 @@ def hide_spinner():
spinner.text = "" 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): def add_directory_csv_files(dir_path, paths=None):
if not paths: if not paths:
paths = [] paths = []
@@ -113,24 +114,37 @@ def add_directory_csv_files(dir_path, paths=None):
return paths return paths
class DialogApp(wx.App):
class DialogApp():
def getFileDialog(self): def getFileDialog(self):
with wx.FileDialog(None, "Open CSV file", wildcard="CSV files (*.csv)|*.csv", application_window = tk.Tk()
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_CHANGE_DIR | wx.FD_MULTIPLE) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL: # Build a list of tuples for each file type the file dialog should display
return None # the user changed their mind my_filetypes = [('csv files', '.csv')]
else:
# Proceed loading the file chosen by the user # Ask the user to select a one or more file names.
return fileDialog.GetPaths() 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): def getDirDialog(self):
with wx.DirDialog(None, "Choose input directory", "", application_window = tk.Tk()
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_CHANGE_DIR) as dirDialog:
if dirDialog.ShowModal() == wx.ID_CANCEL: # Ask the user to select a folder.
return None # the user changed their mind answer = filedialog.askdirectory(parent=application_window,
else: initialdir=os.getcwd(),
# Proceed loading the dir chosen by the user title="Please select a folder")
return dirDialog.GetPath() application_window.destroy()
return answer
class RunType(Enum): class RunType(Enum):
@@ -150,4 +164,5 @@ class FolderType(Enum):
dialog = DialogApp() dialog = DialogApp()
doc = curdoc() doc = curdoc()

View File

@@ -55,6 +55,9 @@ class SignalsFileBase:
signal.toggle_axis() signal.toggle_axis()
def update_source_and_signals(self): def update_source_and_signals(self):
# Remove old index
self.csv = self.csv.reset_index(drop=True)
# create bokeh data sources # create bokeh data sources
self.bokeh_source_orig = ColumnDataSource(self.csv) self.bokeh_source_orig = ColumnDataSource(self.csv)

View File

@@ -50,7 +50,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
install_requires = list() install_requires = list()
extras = dict() 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: with open(path.join(here, 'requirements.txt'), 'r') as f:
for line in f: for line in f: