Skip to content

Commit

Permalink
release as a conda package
Browse files Browse the repository at this point in the history
  • Loading branch information
Xemin0 committed Oct 9, 2023
1 parent c7fd814 commit 1733cb5
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 150 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@ It simply converts between the copy-pasted XML contents and a visual table. XML
*Could be adapted for other parameter-settings in XML.*

### Required Python Packages
- Python 3.10.12 (Other python should also work)
- `TkInter`
- Python 3.10.12 (Other python should also work; and `TkInter` used is already an integral part of `Python`)
- `Numpy`


### Install
- `conda`
```bash
conda install -c xemin0 xml2table
```
- Directly clone the repo
```bash
git clone https://github.com/Xemin0/XML2Table
```


### How to Use it
- Start the program by running
#### Installed from `conda`
simply run `xml2table` from command line

#### Cloned from Github
Navigate to `xml2table/` folder then start the program by running
```bash
python xml2table_v{current_version_number}.py
python xml2table.py
```

Either:
Expand Down
26 changes: 26 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% set data = load_setup_py_data() %}
package:
name: xml2table
version: {{ data['version'] }}

source:
path: ..

build:
script: python3 setup.py install

requirements:
build:
- python >=3.6,{{PY_VER}}*
- setuptools <60.0
run:
- python {{PY_VER}}*
- numpy >=1.8*

about:
home: https://github.com/Xemin0/XML2Table
license: BSD 3-Clause
license_file: LICENSE
license_family: BSD

summary: data['description']
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from setuptools import setup, find_packages

setup(
name = 'xml2table',
version = '0.2.2',
packages = find_packages(),
url = 'https://github.com/Xemin0/XML2Table',

# BSD 3-Clause License:
# - http://choosealicense.com/licenses/bsd-3-clause
# - http://opensource.org/licenses/BSD-3-Clause
license = 'BSD',
author = 'Xemin0',
author_email = 'loser.qqfang@gmail.com',
description = 'A simple python GUI to facilate parameter settings (Contact Energies) in XML file generated by CompuCell3D, by converting between XML and a colored table. ',
install_requires = [
'numpy>=1.8.0',
],
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
'Development Status :: 4 - Beta',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
entry_points={
'console_scripts': [
'xml2table=xml2table.xml2table:main',
],
}
)
7 changes: 7 additions & 0 deletions xml2table/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# __init__.py

from .xml2table import main

# Optional
#from .utils.EventHandler import EventHandler
#from .visual_components.ColorBar import ColorBar
8 changes: 4 additions & 4 deletions utils/EventHandler.py → xml2table/utils/EventHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def renderTable2(self):
- Symmetric Entries are now dynamically synced
"""
if 1 == len(self.names):
tk.Label(master = self.frame4table, text = self.names[0], foreground = 'purple').grid(row = 0, column = 1) # top row
tk.Label(master = self.frame4table, text = self.names[0], foreground = 'purple').grid(row = 1, column = 0) # Leftmost column
tk.Label(master = self.frame4table, text = self.names[0]).grid(row = 0, column = 1) # top row
tk.Label(master = self.frame4table, text = self.names[0]).grid(row = 1, column = 0) # Leftmost column

self.entries = []
entry = tk.Entry(master = self.frame4table, width = 5)
Expand All @@ -110,8 +110,8 @@ def renderTable2(self):
#N = len(self.names)
# Create and place the Label widgets for the names
for i, name in enumerate(self.names):
tk.Label(master = self.frame4table, text = name, foreground = 'purple').grid(row = 0, column = i+1) # top row
tk.Label(master = self.frame4table, text = name, foreground = 'purple').grid(row = i+1, column = 0) # Leftmost column
tk.Label(master = self.frame4table, text = name).grid(row = 0, column = i+1) # top row
tk.Label(master = self.frame4table, text = name).grid(row = i+1, column = 0) # Leftmost column

# Create and place the Entry widgets for the matrix values (contact energies)
self.entries = [] # clear the old widgets
Expand Down
1 change: 1 addition & 0 deletions xml2table/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .EventHandler import EventHandler
1 change: 1 addition & 0 deletions xml2table/utils/xml_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .xml_parser import names_and_values
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions xml2table/visual_components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ColorBar import ColorBar
151 changes: 151 additions & 0 deletions xml2table/xml2table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
"""
Front-end GUI for the python app XML2Table
to facilitate the Contact Energy Plugin settings in XML generated in CompuCell3D
Visual Compenents and their usages (Left to Right)
- Text Field for XML(Contact Energy Plugin):
- XML section copy-pasted from CC3D.twedit to be converted to table
or
- XML section generated based on the adjusted table
- Four Buttons:
- Convert XML to Table
- Generate XML from Table
- Add a New Cell
- Clear the Table
- Color Bar Field:
- Table Field:
"""
import tkinter as tk

if __name__ == "__main__":
# running as a script
from utils.EventHandler import EventHandler
from visual_components.ColorBar import ColorBar
else:
from .utils.EventHandler import EventHandler
from .visual_components.ColorBar import ColorBar

def main():
"""
# Base window
"""

window = tk.Tk()
window.title("Simple XML2Table Editor")

# Set minimal Size to ensure the texts in the buttons will be shown properly
window.rowconfigure(0, minsize = 200, weight = 1)
window.columnconfigure(0, minsize = 100, weight = 1)
window.columnconfigure(1, minsize = 150, weight = 1)
window.columnconfigure(2, minsize = 25, weight = 1)
window.columnconfigure(3, minsize = 100, weight = 1)

# ====================================== #



"""
# Create Frames for each region and attach them to the main window horizontally
# with default sizes
"""

frame_txtField = tk.Frame(master = window, width = 60, height = 200)

frame_buttons = tk.Frame(master = window, relief = tk.RAISED, bd = 2, width = 20, height = 200)

frame_CB = tk.Frame(master = window, width = 30, height = 200)

frame_table = tk.Frame(master = window, width = 100, height = 200)

# ====================================== #


"""
# Arrange the Fields/Widgets accordingly inside the main window
"""
#frame_txtField.pack(fill = tk.BOTH, side = tk.LEFT, expand = True)
#frame_buttons.pack(fill = tk.Y, side = tk.LEFT, expand = True)
#frame_table.pack(fill = tk.BOTH, side = tk.LEFT, expand = True)

frame_txtField.grid(row = 0, column = 0, sticky = 'nsew')
frame_buttons.grid(row = 0, column = 1, sticky = 'ns')
frame_CB.grid(row = 0, column = 2, sticky = 'ns')
frame_table.grid(row = 0, column = 3, sticky = 'nsew')

# ====================================== #



"""
# Text Field for XML
"""

text_box = tk.Text(master = frame_txtField) # height = 10, width = 20)

# Place text field inside the frame
text_box.pack(fill = tk.BOTH, expand = True)

# ====================================== #
"""
# Event Handler Class Object
"""
e_handler = EventHandler(text_box, frame_table)

# ====================================== #




"""
# Buttons
- convert to table
- convert to XML
- add new cell
- clear table
# Event Handlers for each Button
"""


btn_xml2table = tk.Button(master = frame_buttons, text = 'Convert to Table', command = e_handler.toTable)
btn_table2xml = tk.Button(master = frame_buttons, text = 'Convert to XML', command = e_handler.toXML)
btn_newCell = tk.Button(master = frame_buttons, text = 'Add New Cell', command = e_handler.newCell)
btn_clear = tk.Button(master = frame_buttons, text = 'Clear Table', command = e_handler.clearTable)

# Place the three buttons inside the frame
#btn_xml2table.pack(fill = tk.Y, padx = 5)
#btn_table2xml.pack(fill = tk.Y, padx = 5)
#btn_newCell.pack(fill = tk.Y, padx = 5)

# Sticky = 'ew' to guarantee the buttons are all of the same width
btn_xml2table.grid(row = 0, column = 0, sticky = 'ew', padx = 5, pady = 5)
btn_table2xml.grid(row = 1, column = 0, sticky = 'ew', padx = 5, pady = 5)
btn_newCell.grid(row = 2, column = 0, sticky = 'ew', padx = 5, pady = 5)
btn_clear.grid(row = 3, column = 0, sticky = 'ew', padx = 5, pady = 5)


# ====================================== #


"""
Color Bar
200 x 25
"""
color_bar = ColorBar(root = frame_CB, compute_color_func = e_handler.compute_color,
W = 25, H = 200)


# ====================================== #

"""
# Table Field
** This part is not initialized by default, but will be updated once a related button event occurs
"""


window.mainloop()


if __name__ == '__main__':
main()
Loading

0 comments on commit 1733cb5

Please sign in to comment.