-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathLingL_app.py
71 lines (58 loc) · 1.99 KB
/
LingL_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
'''Create a simple GUI to launch the server Waitress and a button to
open the browser. Done with tkinter '''
from waitress import serve
from LingL.wsgi import application
import webbrowser
import threading
import os
import platform
import wx
page = '127.0.0.1:8000'
'''the Waitress server is run in the background'''
class waitress_thread(object):
def __init__(self, interval=1):
""" Constructor
:type interval: int
:param interval: Check interval, in seconds
"""
# self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.daemon = True # Daemonize thread
thread.start()
def run(self):
serve(application, listen=page)
waitress_thr = waitress_thread()
# serve(application, listen=page)
# window = Tk()
app = wx.App()
#window.title("LingLibre")
frm = wx.Frame(None, title='LingLibre', style=wx.DEFAULT_FRAME_STYLE, size=(250, 100))
# window.title(thispath)
# window.geometry('250x100')
cwd = os.getcwd()
system = platform.system().lower()
if system == 'windows' or system == 'linux':
loc = wx.IconLocation('LingL_app.ico')
loc = wx.IconLocation('LingL_app.ico')
frm.SetIcon(wx.Icon(loc))
else: # MacOS: BUG... not working
loc = wx.IconLocation('LingL_app.icns')
# loc = wx.IconLocation('LingL_app.ico')
# frm.SetIcon(wx.Icon(loc))
# photo = PhotoImage(file = lingl_image_path)
# window.iconphoto(False, photo)
def clicked(event):
webbrowser.open('http://'+page)
main_sizer = wx.BoxSizer(wx.VERTICAL)
# btn = Button(window, text="Launch LingLibre \n(A tab will open in your browser)", command=clicked)
btn = wx.Button(frm, label="Launch LingLibre \n(A tab will open in your browser)")
btn.Bind(wx.EVT_BUTTON, clicked)
main_sizer.AddStretchSpacer()
main_sizer.Add(btn, 0, wx.CENTER)
main_sizer.AddStretchSpacer()
frm.SetSizer(main_sizer)
# btn.place(relx=0.5, rely=0.5, anchor=CENTER)
frm.Show()
# window.mainloop()
app.MainLoop()