| OLD | NEW |
| 1 #!/usr/bin/python -tt | 1 #!/usr/bin/python -tt |
| 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Edit buttons for bmpblock object""" | 6 """Edit buttons for bmpblock object""" |
| 7 | 7 |
| 8 import wx | 8 import wx |
| 9 | 9 |
| 10 class Frame(wx.Frame): | 10 class Frame(wx.Frame): |
| 11 | 11 |
| 12 def __init__(self, bmpblock=None, title=None): | 12 def __init__(self, bmpblock=None, title=None): |
| 13 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(200,400)) | 13 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(200,400)) |
| 14 menuFile = wx.Menu() | 14 menuFile = wx.Menu() |
| 15 m_about = menuFile.Append(wx.ID_ANY, "About...\tCtrl+A") | 15 m_about = menuFile.Append(wx.ID_ANY, "About...\tCtrl+A") |
| 16 menuFile.AppendSeparator() | 16 menuFile.AppendSeparator() |
| 17 m_reload = menuFile.Append(wx.ID_ANY, "Reload\tCtrl+R") | 17 m_reload = menuFile.Append(wx.ID_ANY, "Reload\tCtrl+R") |
| 18 m_snapshot = menuFile.Append(wx.ID_ANY, "Save snapshot") | 18 m_snapshot = menuFile.Append(wx.ID_ANY, "Save snapshot") |
| 19 m_snapshotall = menuFile.Append(wx.ID_ANY, "Save snapshot of all screens") |
| 19 m_quit = menuFile.Append(wx.ID_ANY, "Quit\tCtrl+Q") | 20 m_quit = menuFile.Append(wx.ID_ANY, "Quit\tCtrl+Q") |
| 20 menuBar = wx.MenuBar() | 21 menuBar = wx.MenuBar() |
| 21 menuBar.Append(menuFile, "&File") | 22 menuBar.Append(menuFile, "&File") |
| 22 self.SetMenuBar(menuBar) | 23 self.SetMenuBar(menuBar) |
| 23 self.CreateStatusBar() | 24 self.CreateStatusBar() |
| 24 self.Bind(wx.EVT_MENU, self.OnAbout, m_about) | 25 self.Bind(wx.EVT_MENU, self.OnAbout, m_about) |
| 25 self.Bind(wx.EVT_MENU, self.OnReload, m_reload) | 26 self.Bind(wx.EVT_MENU, self.OnReload, m_reload) |
| 26 self.Bind(wx.EVT_MENU, self.OnSaveit, m_snapshot) | 27 self.Bind(wx.EVT_MENU, self.OnSaveit, m_snapshot) |
| 28 self.Bind(wx.EVT_MENU, self.OnSaveAll, m_snapshotall) |
| 27 self.Bind(wx.EVT_MENU, self.OnQuit, m_quit) | 29 self.Bind(wx.EVT_MENU, self.OnQuit, m_quit) |
| 28 self.Bind(wx.EVT_CLOSE, self.OnQuit) | 30 self.Bind(wx.EVT_CLOSE, self.OnQuit) |
| 29 | 31 |
| 30 acctbl = wx.AcceleratorTable([ | 32 acctbl = wx.AcceleratorTable([ |
| 31 (wx.ACCEL_CTRL, ord('A'), m_about.GetId()), | 33 (wx.ACCEL_CTRL, ord('A'), m_about.GetId()), |
| 32 (wx.ACCEL_CTRL, ord('R'), m_reload.GetId()), | 34 (wx.ACCEL_CTRL, ord('R'), m_reload.GetId()), |
| 33 (wx.ACCEL_CTRL, ord('Q'), m_quit.GetId()) | 35 (wx.ACCEL_CTRL, ord('Q'), m_quit.GetId()) |
| 34 ]) | 36 ]) |
| 35 | 37 |
| 36 self.SetAcceleratorTable(acctbl) | 38 self.SetAcceleratorTable(acctbl) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 current = self.bmpblock.current_screen | 101 current = self.bmpblock.current_screen |
| 100 self.screenlist.SetStringSelection(current) | 102 self.screenlist.SetStringSelection(current) |
| 101 self.SetStatusText(self.bmpblock.filename) | 103 self.SetStatusText(self.bmpblock.filename) |
| 102 | 104 |
| 103 def OnIdle(self, event=None): | 105 def OnIdle(self, event=None): |
| 104 """What to do, what to do...""" | 106 """What to do, what to do...""" |
| 105 if self.do_update: | 107 if self.do_update: |
| 106 # FIXME: The model should know when to do this itself, right? | 108 # FIXME: The model should know when to do this itself, right? |
| 107 self.bmpblock.Redisplay() | 109 self.bmpblock.Redisplay() |
| 108 self.do_update = False | 110 self.do_update = False |
| 111 |
| 112 def OnSaveAll(self, event=None): |
| 113 """Save snapshots of all screens""" |
| 114 start = self.bmpblock.current_screen |
| 115 thinglist = self.screenlist.GetItems() |
| 116 for thing in thinglist: |
| 117 self.bmpblock.current_screen = thing |
| 118 self.bmpblock.Redisplay() |
| 119 self.bmpblock.Saveit() |
| 120 self.bmpblock.current_screen = start |
| 121 self.do_update = True |
| OLD | NEW |