Example #1
0
def get_view_html():
    output = None
    output_path = access.get_abs_base_dir_path() + 'view/output.html'
    with open(output_path, 'r') as file:
        output = file.read()

    style_path = get_css_location()

    from string import Template
    template = Template(get_template())
    html = template.substitute(content=output, style=style_path)

    return str(html)
Example #2
0
def create_window():

    # Create a GTK+ window
    global window
    window = gtk.Window()
    window.set_position(gtk.WIN_POS_CENTER)

    #window.set_icon_from_file(icon.get_icon_path('folder'))
    base_path = access.get_abs_base_dir_path()
    icon_path = base_path + 'resources/icons/main.png'
    window.set_icon_from_file(icon_path)

    # Terminate the program when the window is closed
    window.connect("destroy", gtk.main_quit)
    # Instantiate the WebKit renderer
    global web_view
    web_view = webkit.WebView()
    # web_view.set_editable(True) <- hmm, look into this!

    # disable right-click
    web_view.props.settings.props.enable_default_context_menu = False

    web_view.connect('size-allocate', autoscroll_view) # auto scroll to bottom

    global input_area
    input_area = gtk.Entry(max=0)
    input_area.set_has_frame(False)

    scrolled_window = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
    scrolled_window.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, 
                               vscrollbar_policy=gtk.POLICY_ALWAYS)
    scrolled_window.add_with_viewport(web_view)

    box = gtk.VBox(homogeneous=False, spacing=0)
    box.pack_start(scrolled_window, expand=True, fill=True, padding=0)
    box.pack_end(input_area, expand=False, fill=False, padding=0)
    window.add(box)

    # Load an HTML string into the renderer
    refresh()


    # Add the renderer to the window
    #window.add(web_view)
    window.resize(width=800, height=600)
    window.show_all()
Example #3
0
def get_css_location():
    return access.get_abs_base_dir_path() + 'view/stylesheet.css'
Example #4
0
def load_template():
    template_path = access.get_abs_base_dir_path() + 'view/template.html'
    template = None
    with open(template_path, "r") as file:
        template = file.read()
    return template
Example #5
0
import apps
from util import html
from control import access

##### stuff to write to html; to be done properly

output_file = access.get_abs_base_dir_path() + 'view/output.html'

def print_input(input):
    add_output(input, "command")

def print_outputs(outputs):
    print_output('\n\n'.join(outputs))

def print_output(output):
    add_output(output, "output")

def print_misc(text, clazz):
    add_output(text, clazz)

    
def add_output(text, elementName):
    element = '\n\n' + html.div(text, clazz=elementName)

    with open(output_file, "a") as file:
        file.write(element)


def add_output_nicer(text, elementName):

    dom = parse("output.html")