Compare commits
3 Commits
9a714022a0
...
02a6f555e0
Author | SHA1 | Date |
---|---|---|
BodgeMaster | 02a6f555e0 | |
BodgeMaster | 3a66d4e2d7 | |
BodgeMaster | ebbba309ff |
|
@ -1,155 +0,0 @@
|
|||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# ---> Linux
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
|
@ -8,6 +8,6 @@ Redistribution and use in source and binary forms, with or without modification,
|
|||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
4. Derivative works that redistribute parts or the entirety of this software must have their source code publicly available and must be published under this license. Interfacing with APIs or ABIs does not constitute redistribution.
|
||||
4. Derivative works that redistribute parts or the entirety of this software must have their source code available to their users and must be published under this license. Interfacing with APIs or ABIs does not constitute redistribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/python3
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import sys, os, json, traceback
|
||||
|
||||
def warn(text):
|
||||
print("WARNING: "+str(text), file=sys.stderr)
|
||||
traceback.print_stack()
|
||||
|
||||
# easy way to get data out of window events
|
||||
class Window_Interaction_Handler:
|
||||
# constructor
|
||||
def __init__(self):
|
||||
self.__window_interactions = {}
|
||||
|
||||
# add a result for an interaction event, saves results in reverse order by default, can optionally call another function
|
||||
def interact(self, name, result, reverse_order=True, additional_action=None, additional_action_parameters=()):
|
||||
if name in self.__window_interactions:
|
||||
if reverse_order:
|
||||
self.__window_interactions[name] = [result] + self.__window_interactions[name]
|
||||
else:
|
||||
self.__window_interactions[name] = self.__window_interactions[name] + [result]
|
||||
else:
|
||||
self.__window_interactions[name] = [result]
|
||||
|
||||
if not additional_action==None:
|
||||
additional_action(*additional_action_parameters)
|
||||
|
||||
# get first result for a given event from the list of results (newest (default) or oldest), removes the returned result from the list by default
|
||||
def get_result(self, name, remove=True):
|
||||
if name in self.__window_interactions and len(self.__window_interactions[name])>0:
|
||||
if remove:
|
||||
result = self.__window_interactions[name].pop(0)
|
||||
if len(self.__window_interactions[name])==0:
|
||||
del self.__window_interactions[name]
|
||||
return result
|
||||
else:
|
||||
return self.__window_interactions[name][0]
|
||||
else:
|
||||
return None
|
||||
|
||||
# get all results for a given event
|
||||
def get_results(self, name, clear=False):
|
||||
if name in self.__window_interactions and len(self.__window_interactions[name])>0:
|
||||
results = self.__window_interactions[name]
|
||||
if clear:
|
||||
del self.__window_interactions[name]
|
||||
return results
|
||||
|
||||
# clear results for a given event
|
||||
def clear(self, name):
|
||||
if name in self.__window_interactions:
|
||||
del self.__window_interactions[name]
|
||||
|
||||
# destructor
|
||||
def __del__(self):
|
||||
if len(self.__window_interactions)>0:
|
||||
warn("__window_interactions not empty upon destruction of Window_Interaction_Handler:\n"+str(self.__window_interactions))
|
||||
|
||||
|
||||
# read configuration
|
||||
home_directory = os.path.expanduser("~")
|
||||
config_file_path = os.path.join(home_directory, "some_ide_config.json")
|
||||
configuration = {}
|
||||
if os.path.isfile(config_file_path):
|
||||
try:
|
||||
config_file = open(config_file_path, "r")
|
||||
configuration = json.loads(config_file.read())
|
||||
config_file.close()
|
||||
except:
|
||||
#TODO: show an error message
|
||||
warn("Not implemented!")
|
||||
else:
|
||||
# config not found
|
||||
dialog_interaction_handler = Window_Interaction_Handler()
|
||||
|
||||
dialog = tk.Tk()
|
||||
ttk.Label(dialog, text="No configuration found!").pack()
|
||||
buttons_frame = tk.Frame(dialog)
|
||||
buttons_frame.pack()
|
||||
ttk.Button(buttons_frame, text="Create", command=lambda: dialog_interaction_handler.interact("create", True, additional_action=dialog.destroy)).grid(column=0, row=0) #TODO: add functionality
|
||||
ttk.Button(buttons_frame, text="Quit", command=lambda: dialog_interaction_handler.interact("create", False, additional_action=dialog.destroy)).grid(column=1, row=0) #TODO: add functionality
|
||||
dialog.resizable(0,0)
|
||||
dialog.mainloop()
|
||||
|
||||
if dialog_interaction_handler.get_result("create"):
|
||||
#TODO: store default configuration
|
||||
warn("Not implemented!")
|
||||
else:
|
||||
print("No config present and user chose not to create one. Exiting.")
|
||||
sys.exit()
|
||||
|
||||
#window = tk.Tk()
|
||||
#frame = ttk.Frame(window, padding=10)
|
||||
#frame.grid()
|
||||
#ttk.Label(frame, text="Hello, World!").grid(column=0, row=0)
|
||||
#ttk.Button(frame, text="Quit", command=window.destroy).grid(column=0, row=1)
|
||||
|
||||
#window.mainloop()
|
Reference in New Issue