example
This commit is contained in:
55
start.py
Executable file
55
start.py
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import wx
|
||||
|
||||
from slic.gui.persist import Persistence
|
||||
|
||||
from panel import MainPanel
|
||||
|
||||
|
||||
def run(*args, **kwargs):
|
||||
app = wx.App()
|
||||
frame = MainFrame(*args, **kwargs)
|
||||
frame.Show()
|
||||
app.MainLoop()
|
||||
app.Yield() #TODO: without this, wxPython segfaults locking a mutex
|
||||
|
||||
|
||||
def get_wx_icon(fname="icon.png"):
|
||||
iname = os.path.dirname(__file__)
|
||||
iname = os.path.join(iname, fname)
|
||||
return wx.Icon(iname)
|
||||
|
||||
|
||||
|
||||
class MainFrame(wx.Frame):
|
||||
|
||||
def __init__(self, title="Coffee 365"):
|
||||
super().__init__(None, title=title)
|
||||
self.SetIcon(get_wx_icon())
|
||||
|
||||
main = MainPanel(self)
|
||||
|
||||
# make sure the window is large enough
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add(main, proportion=1, flag=wx.EXPAND)
|
||||
self.SetSizerAndFit(sizer)
|
||||
|
||||
self.persist = persist = Persistence(".coffee365", self)
|
||||
persist.load()
|
||||
|
||||
self.Bind(wx.EVT_CLOSE, self.on_close)
|
||||
|
||||
|
||||
def on_close(self, event):
|
||||
self.persist.save()
|
||||
event.Skip() # forward the close event
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user