-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GUI and Improved Documentation #32
base: master
Are you sure you want to change the base?
Changes from all commits
e4fa903
9a08f11
de74984
fd512a2
4e064ec
2c18d2f
abd689a
90e049f
dcaa630
4145dda
bcffa1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,6 +13,37 @@ | |||||
* (optional) Change server ip/port number in config. | ||||||
* All other packages that generate error "No module named" does exist, must be installed. | ||||||
|
||||||
## Installation and Setup | ||||||
|
||||||
Clone the repository and move into the directory | ||||||
|
||||||
``` | ||||||
git clone https://github.com/oduwsdl/CarbonDate | ||||||
cd CarbonDate | ||||||
``` | ||||||
|
||||||
Install python requirements | ||||||
|
||||||
``` | ||||||
pip install -r requirements.txt | ||||||
``` | ||||||
|
||||||
### Missing Aysnchronous attribute | ||||||
|
||||||
![Example Error](https://github.com/njenn001/CarbonDate/blob/master/images/Error.jpg) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm kind of curious where this error stems from. I don't have issues with the docker hub image. Maybe there is a Python version and library version mismatch going on? The docker image is python 3.7 with the following library versions:
|
||||||
|
||||||
For quick installation and running purposes simply comment out the use of the server import in main.py. Otherwise, check Tornado import. | ||||||
|
||||||
![Example Solution](https://github.com/njenn001/CarbonDate/blob/master/images/solution.JPG) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the image source relative, so it does not point to a specific fork.
Suggested change
|
||||||
|
||||||
### Missing/Broken Modules | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these modules broken? Open separate issues with details to either fix or remove them. |
||||||
|
||||||
* Bitly | ||||||
* Bing | ||||||
|
||||||
|
||||||
|
||||||
## Running as a Docker Container | ||||||
|
||||||
It is recommended to use [Docker](https://www.docker.com/) to install and run this application. | ||||||
|
@@ -55,6 +86,19 @@ To run it in one-off mode: | |||||
$ ./main.py -l {URI-R} | ||||||
``` | ||||||
|
||||||
### Running the GUI | ||||||
|
||||||
|
||||||
* Initialized in terminal | ||||||
``` | ||||||
$ ./main.py --gui | ||||||
``` | ||||||
* Use the small tkinter window to carbon date URLs | ||||||
|
||||||
* ![GUI Figure](https://github.com/njenn001/CarbonDate/blob/master/images/GuiFig.png) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the image source relative, so it does not point to a specific fork.
Suggested change
|
||||||
|
||||||
* Output will lie in the terminal | ||||||
|
||||||
### Environment variables | ||||||
|
||||||
Carbon Date provides the option of passing in environment variables for both the Bing and Bitly services. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"AccessToken":["YourBitlyAccessTokenHere"], | ||
"AccessToken":["Yf7d318a38ee40a5049861a32814bb1b0fb78cb8b"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to provide an access token in the source? This token will perhaps be revoked by GitHub. It is better to tell user how to create a token and then they can use that instead. |
||
"BingAPIKey":"YourBingSearchAPIKey", | ||
"ServerIP": "0.0.0.0", | ||
"ServerPort": 8888, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ def run(self, args, **kwargs): | |
if args.local_uri: | ||
url = args.local_uri | ||
else: | ||
url = kwargs['url'] | ||
url = 'https://www.cs.odu.edu/' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason of this change? |
||
# handle character accents | ||
url = requote_uri(url) | ||
|
||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import tkinter as tk | ||
|
||
LARGE_FONT= ("Verdana", 12) | ||
|
||
|
||
class Gui(tk.Tk): | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
||
tk.Tk.__init__(self, *args, **kwargs) | ||
container = tk.Frame(self) | ||
|
||
container.pack(side="top",expand = True) | ||
|
||
container.grid_rowconfigure(0, weight=1) | ||
container.grid_columnconfigure(0, weight=1) | ||
|
||
self.frames = {} | ||
|
||
for F in ([StartPage]): | ||
|
||
frame = F(container, self) | ||
|
||
self.frames[F] = frame | ||
|
||
frame.grid(row=0, column=0, sticky="nsew") | ||
|
||
self.show_frame(StartPage) | ||
|
||
def show_frame(self, cont): | ||
|
||
frame = self.frames[cont] | ||
frame.tkraise() | ||
|
||
|
||
#FORMATTING FUNCTION FOR THE TKINTER ENTRY BOX | ||
|
||
|
||
class StartPage(tk.Frame): | ||
|
||
def __init__(self, parent, controller): | ||
def on_entry_click(event): | ||
"""function that gets called whenever entry is clicked""" | ||
if URIentry.get() == 'https://cs.odu.edu/': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding hardcoded values like this is not a good practice. If this were to be used as the sample URI, a constant should be defined at the top of the file or better yet, add this in the config file to reuse everywhere. |
||
URIentry.delete(0, "end") # delete all the text in the entry | ||
URIentry.insert(0, '') #Insert blank for user input | ||
URIentry.config(fg = 'black') | ||
def on_focusout(event): | ||
if URIentry.get() == '': | ||
URIentry.insert(0, 'https://cs.odu.edu/') | ||
URIentry.config(fg = 'grey') | ||
def startlocal(uri): | ||
print (uri) | ||
|
||
tk.Frame.__init__(self,parent) | ||
|
||
label = tk.Label(self, text="CarbonDate", font=LARGE_FONT) | ||
label.pack(pady=20,padx=50) | ||
|
||
label = tk.Label(self, text="Enter Uri:") | ||
label.pack() | ||
URIentry = tk.Entry(self) | ||
URIentry.insert(0, 'https://cs.odu.edu/') | ||
URIentry.config(fg = 'grey') | ||
URIentry.bind('<FocusIn>', on_entry_click) | ||
URIentry.bind('<FocusOut>', on_focusout) | ||
URIentry.pack() | ||
|
||
button = tk.Button(self, text="Estimate birthdate", | ||
command=lambda: controller.show_frame(startlocal(URIentry.get()))) | ||
button.pack() | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,10 @@ | |
import server | ||
import local | ||
import core | ||
import gui | ||
import json | ||
import time | ||
import tkinter as tk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update |
||
|
||
logo = (''' | ||
_____ ___ _____ _____ _____ __ _ _____ ___ _____ _____ | ||
|
@@ -23,7 +25,10 @@ def parserinit(): | |
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description=logo + 'Integrated interface for Carbon Date Tool', | ||
epilog='For more help, type main.py -h') | ||
|
||
mode_group = parser.add_mutually_exclusive_group(required=True) | ||
mode_group.add_argument('--gui', help='Activate the tkinter implementation.', | ||
action='store_true') | ||
mode_group.add_argument('--list-mods', action='store_true', | ||
help='List all avaiable modules') | ||
mode_group.add_argument('-s', '--server', action='store_true', | ||
|
@@ -32,11 +37,13 @@ def parserinit(): | |
help='Run Carbon Date Tool as a local application.' | ||
' Takes a URI as a parameter', | ||
dest="local_uri") | ||
|
||
parser.add_argument('-t', '--timeout', type=int, | ||
help='Set timeout for all modules in seconds', | ||
default=300) | ||
parser.add_argument( | ||
'-v', '--verbose', action='store_true', help='Enable verbose output') | ||
|
||
modOpGroup = parser.add_mutually_exclusive_group() | ||
modOpGroup.add_argument('-a', '--all', action="store_true", | ||
help='Load all modules (default)', dest='all') | ||
|
@@ -47,6 +54,23 @@ def parserinit(): | |
'-e', metavar='MODULE', help="Exclusive mode, load all modules except \ | ||
the given modules", nargs='+') | ||
return parser | ||
|
||
#FORMATTING FUNCTION FOR THE TKINTER ENTRY BOX | ||
def on_entry_click(event): | ||
"""function that gets called whenever entry is clicked""" | ||
if nameE.get() == 'https://www.cs.odu.edu': | ||
nameE.delete(0, "end") # delete all the text in the entry | ||
nameE.insert(0, '') #Insert blank for user input | ||
nameE.config(fg = 'black') | ||
def on_focusout(event): | ||
if nameE.get() == '': | ||
nameE.insert(0, 'https://www.cs.odu.edu') | ||
nameE.config(fg = 'grey') | ||
|
||
def passArgs(args, mod, name): | ||
args.local_uri = name | ||
|
||
local.start(args, mod) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
@@ -68,6 +92,7 @@ def parserinit(): | |
mod = core.ModuleManager() | ||
mod.loadModule(cfg, args) | ||
|
||
|
||
if args.list_mods: | ||
print('Available Modules (include system utilities)') | ||
print('====================================') | ||
|
@@ -78,3 +103,22 @@ def parserinit(): | |
server.start(args, cfg, mod) | ||
elif args.local_uri: | ||
local.start(args, mod) | ||
elif args.gui: | ||
root = tk.Tk() | ||
root.title('CarbonDate') | ||
nameL = tk.Label (root, text="URL") | ||
nameL.grid(column = 0, row = 0, sticky = "W") | ||
|
||
nameE = tk.Entry(root, bd = 5, width = 25) | ||
nameE.insert(0, 'https://www.cs.odu.edu/') | ||
nameE.config(fg = 'grey') | ||
nameE.bind('<FocusIn>', on_entry_click) | ||
nameE.bind('<FocusOut>', on_focusout) | ||
nameE.grid(column = 1, row = 0, sticky = "W") | ||
s = tk.Button(root, text="Start", command = lambda : passArgs(args, mod, str(nameE.get()))) | ||
s.grid(column = 2, row = 0, pady = 5) | ||
root.mainloop() | ||
|
||
|
||
# gui = gui.Gui() | ||
# gui.mainloop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the image source relative, so it does not point to a specific fork.