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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user