Exemplo n.º 1
0
def main():
    data_dir = os.path.abspath(os.path.join(".", "data"))
    log_dir = os.path.join(data_dir, "log")
    report_dir = os.path.join(data_dir, "report")
    os.makedirs(data_dir, exist_ok=True)
    os.makedirs(log_dir, exist_ok=True)
    os.makedirs(report_dir, exist_ok=True)

    global app
    icon_file = os.path.abspath(
        os.path.join(ROOT_DIR, "ui", "res", "img", "icon.png")),
    splash_file = os.path.abspath(
        os.path.join(ROOT_DIR, "ui", "res", "img", "splash.png")),
    splash_text = "%s v%s\n\nLoading..." % (app_name, get_version()),
    icon_file = icon_file,
    app = App(
        headless=False,
        configs_file=os.path.abspath(os.path.join(".", "configs.ini")),
        log_file=os.path.abspath(
            os.path.join(
                log_dir, '%s_%s.log' %
                (app_name, datetime.datetime.fromtimestamp(int(
                    time.time())).strftime('%Y_%m_%d_%H%M%S')))),
    )
    # add ext dir to path
    ext = app.get_config("Ext/Ext_PATH", "./ext")
    sys.path.append(os.path.abspath(ext))

    sys.path.append(os.path.join(ROOT_DIR, 'ext'))

    app.on("create", on_create)
    app.on("destroy", on_destroy)
    exit_code = app.run()
    logging.debug("sys.exit code=%d" % exit_code)
    sys.exit(exit_code)
Exemplo n.º 2
0
Arquivo: app.py Projeto: sandin/mmgui
def main():
    app = App(headless=False)
    win = None
    def on_create(ctx):
        global win
        win = BrowserWindow({
            "title": "Demo - mmgui",
            "width": 1200,
            "height": 800,
            "dev_mode": True,
        })
        win.webview.bind_function("py_func", py_func)
        win.webview.load_file(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ui", "index.html"))
        win.show()
    app.on("create", on_create)
    app.run()
Exemplo n.º 3
0
import sys, os
from mmgui import App, BrowserWindow

app = App(headless=False)
win = None


def open_file():
    files = win.show_file_dialog_for_file("打开文件", "Text File(*.txt)")
    if files and len(files) > 0:
        return files[0]
    return None


def on_create(ctx):
    global win
    win = BrowserWindow({
        "title": "Demo - mmgui",
        "width": 1200,
        "height": 800,
        "dev_mode": True,
    })
    win.webview.bind_function("open_file", open_file)
    win.webview.load_file(
        os.path.join(os.path.dirname(os.path.abspath(__file__)), "index.html"))
    win.show()


app.on("create", on_create)
app.run()
Exemplo n.º 4
0
import logging
import os
import sys

from mmgui import App, BrowserWindow, Menu, MenuSeparator

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

app = App(headless=False)
win = None


def move_window(dx, dy):
    win.move_by(dx, dy)


def close_window():
    win.close()


def toggle_maximized_window():
    if win.is_maximized():
        win.show_normal()
    else:
        win.show_maximized()


def show_minimized_window():
    win.show_minimized()