示例#1
0
    def __init__(self, parent):
        wxgui_api.install_icon_bundle("wxalarms", '&alarmswin',
                                (("alarmswin16.png", ), ("alarmswin24.png", ),
                                ("alarmswin32.png", ), ("alarmswin48.png", ),
                                ("alarmswin64.png", ), ("alarmswin128.png", )))

        self.ALARMS_MIN_HEIGHT = 140
        self.ALARMS_ICON_BUNDLE = wxgui_api.get_frame_icon_bundle('&alarmswin')

        self.config = coreaux_api.get_plugin_configuration('wxalarms')

        self.window = wx.Frame(parent, size=[int(s)
                          for s in self.config['initial_geometry'].split('x')])

        self.window.SetIcons(self.ALARMS_ICON_BUNDLE)

        self.alarms = {}
        self._update_title()

        self.box = wx.BoxSizer(wx.VERTICAL)
        self.window.SetSizer(self.box)

        self.panel = wx.ScrolledWindow(self.window, style=wx.BORDER_THEME)
        self.panel.SetScrollRate(20, 20)
        self.pbox = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(self.pbox)
        self.box.Add(self.panel, proportion=1, flag=wx.EXPAND | wx.ALL,
                                                                    border=4)

        self.hidden_panel = wx.BoxSizer(wx.HORIZONTAL)
        self._init_hidden_panel()
        self.box.Add(self.hidden_panel, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM |
                                                        wx.EXPAND, border=4)
        self._hide_hidden_panel()

        self.bottom = wx.BoxSizer(wx.HORIZONTAL)
        self._init_bottom()
        self.box.Add(self.bottom, flag=wx.LEFT | wx.RIGHT | wx.EXPAND,
                                                                    border=4)

        # Set the minimum width so that the bottom controls can fit, and also
        # add 20 px for the stretch spacer
        minwidth = self.bottom.ComputeFittingWindowSize(self.window).GetWidth()
        self.window.SetMinSize((minwidth + 20, self.ALARMS_MIN_HEIGHT))

        self.DELAY = 50
        # Set CDELAY shorter than DELAY, so that if an alarm is activated at
        # the same time an alarm is dismissed, there's a better chance that
        # the alarm window requests the user attention
        self.CDELAY = 30

        # Initialize self.timer and self.stimer with a dummy function (int)
        self.timer = wx.CallLater(1, int)
        self.stimer = wx.CallLater(1, int)

        self.LIMIT = self.config.get_int('limit')
        self.hiddenalarms = set()

        self.ID_SHOW_MENU = wx.NewId()
        self.menushow = wx.MenuItem(wxgui_api.get_menu_view(),
                                self.ID_SHOW_MENU,
                                "Show &alarms window\t{}".format(
                                    self.config('GlobalShortcuts')['show']),
                                "Show the alarms window", kind=wx.ITEM_CHECK)
        wxgui_api.add_menu_view_item(self.menushow)

        TrayMenu(self)

        self.window.Bind(wx.EVT_CLOSE, self._handle_close)

        wxgui_api.bind_to_menu(self.toggle_shown, self.menushow)
        wxgui_api.bind_to_menu_view_update(self._handle_menu_view_update)

        organism_alarms_api.bind_to_alarm(self._handle_alarm)
        organism_alarms_api.bind_to_alarm_off(self._handle_alarm_off)
        wxgui_api.bind_to_close_database(self._handle_close_db)
示例#2
0
文件: menus.py 项目: xguse/outspline
    def __init__(self, tasklist):
        self.tasklist = tasklist
        self.occview = tasklist.list_

        self.ID_EVENTS = wx.NewId()
        self.ID_SHOW = wx.NewId()
        self.ID_FOCUS = wx.NewId()
        self.ID_ALARMS = wx.NewId()
        self.ID_TOGGLE_NAVIGATOR = wx.NewId()
        self.ID_GAPS = wx.NewId()
        self.ID_OVERLAPS = wx.NewId()
        self.ID_AUTOSCROLL = wx.NewId()

        submenu = wx.Menu()
        self.alarms_submenu = AlarmsMenu(tasklist)

        config = coreaux_api.get_plugin_configuration('wxtasklist')(
            'GlobalShortcuts')('View')

        self.events = wx.MenuItem(wxgui_api.get_menu_view(),
                                  self.ID_EVENTS,
                                  '&Schedule',
                                  'Schedule navigation actions',
                                  subMenu=submenu)
        self.show = wx.MenuItem(submenu,
                                self.ID_SHOW,
                                "Show &panel\t{}".format(config['show']),
                                "Show the schedule panel",
                                kind=wx.ITEM_CHECK)
        self.focus = wx.MenuItem(submenu, self.ID_FOCUS,
                                 "&Focus\t{}".format(config['focus']),
                                 "Set focus on the schedule tab")
        self.alarms = wx.MenuItem(submenu,
                                  self.ID_ALARMS,
                                  '&Active alarms',
                                  'Set the visibility of active alarms',
                                  subMenu=self.alarms_submenu)
        self.navigator = wx.MenuItem(submenu,
                                     self.ID_TOGGLE_NAVIGATOR,
                                     "Show &navigator\t{}".format(
                                         config['show_navigator']),
                                     "Show or hide the navigator bar",
                                     kind=wx.ITEM_CHECK)
        self.gaps = wx.MenuItem(
            submenu,
            self.ID_GAPS,
            "Show &gaps\t{}".format(config['toggle_gaps']),
            "Show any unallocated time in the shown interval",
            kind=wx.ITEM_CHECK)
        self.overlaps = wx.MenuItem(
            submenu,
            self.ID_OVERLAPS,
            "Show &overlappings\t{}".format(config['toggle_overlappings']),
            "Show time intervals used by more than one event",
            kind=wx.ITEM_CHECK)
        self.autoscroll = wx.MenuItem(submenu,
                                      self.ID_AUTOSCROLL,
                                      "Enable a&uto-scroll",
                                      "Auto-scroll to the first ongoing "
                                      "event when refreshing",
                                      kind=wx.ITEM_CHECK)

        self.events.SetBitmap(wxgui_api.get_menu_icon('@tasklist'))
        self.focus.SetBitmap(wxgui_api.get_menu_icon('@jump'))
        self.alarms.SetBitmap(wxgui_api.get_menu_icon('@activealarms'))

        wxgui_api.insert_menu_right_tab_group(self.events)
        submenu.AppendItem(self.show)
        submenu.AppendItem(self.focus)
        submenu.AppendSeparator()
        submenu.AppendItem(self.alarms)
        submenu.AppendItem(self.navigator)
        submenu.AppendItem(self.gaps)
        submenu.AppendItem(self.overlaps)
        submenu.AppendItem(self.autoscroll)

        wxgui_api.bind_to_menu(self.tasklist.toggle_shown, self.show)
        wxgui_api.bind_to_menu(self._focus, self.focus)
        wxgui_api.bind_to_menu(self._toggle_navigator, self.navigator)
        wxgui_api.bind_to_menu(self._show_gaps, self.gaps)
        wxgui_api.bind_to_menu(self._show_overlappings, self.overlaps)
        wxgui_api.bind_to_menu(self._enable_autoscroll, self.autoscroll)

        wxgui_api.bind_to_reset_menu_items(self._reset_items)
        wxgui_api.bind_to_menu_view_update(self._update_items)
示例#3
0
    def __init__(self, parent):
        wxgui_api.install_icon_bundle(
            "wxalarms",
            "&alarmswin",
            (
                ("alarmswin16.png",),
                ("alarmswin24.png",),
                ("alarmswin32.png",),
                ("alarmswin48.png",),
                ("alarmswin64.png",),
                ("alarmswin128.png",),
            ),
        )

        self.ALARMS_MIN_HEIGHT = 140
        self.ALARMS_ICON_BUNDLE = wxgui_api.get_frame_icon_bundle("&alarmswin")

        self.config = coreaux_api.get_plugin_configuration("wxalarms")

        self.window = wx.Frame(parent, size=[int(s) for s in self.config["initial_geometry"].split("x")])

        self.window.SetIcons(self.ALARMS_ICON_BUNDLE)

        self.alarms = {}
        self._update_title()

        self.box = wx.BoxSizer(wx.VERTICAL)
        self.window.SetSizer(self.box)

        self.panel = wx.ScrolledWindow(self.window, style=wx.BORDER_THEME)
        self.panel.SetScrollRate(20, 20)
        self.pbox = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(self.pbox)
        self.box.Add(self.panel, proportion=1, flag=wx.EXPAND | wx.ALL, border=4)

        self.hidden_panel = wx.BoxSizer(wx.HORIZONTAL)
        self._init_hidden_panel()
        self.box.Add(self.hidden_panel, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=4)
        self._hide_hidden_panel()

        self.bottom = wx.BoxSizer(wx.HORIZONTAL)
        self._init_bottom()
        self.box.Add(self.bottom, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=4)

        # Set the minimum width so that the bottom controls can fit, and also
        # add 20 px for the stretch spacer
        minwidth = self.bottom.ComputeFittingWindowSize(self.window).GetWidth()
        self.window.SetMinSize((minwidth + 20, self.ALARMS_MIN_HEIGHT))

        self.DELAY = 50
        # Set CDELAY shorter than DELAY, so that if an alarm is activated at
        # the same time an alarm is dismissed, there's a better chance that
        # the alarm window requests the user attention
        self.CDELAY = 30

        # Initialize self.timer and self.stimer with a dummy function (int)
        self.timer = wx.CallLater(1, int)
        self.stimer = wx.CallLater(1, int)

        self.LIMIT = self.config.get_int("limit")
        self.hiddenalarms = set()

        self.ID_SHOW_MENU = wx.NewId()
        self.menushow = wx.MenuItem(
            wxgui_api.get_menu_view(),
            self.ID_SHOW_MENU,
            "Show &alarms window\t{}".format(self.config("GlobalShortcuts")["show"]),
            "Show the alarms window",
            kind=wx.ITEM_CHECK,
        )
        wxgui_api.add_menu_view_item(self.menushow)

        TrayMenu(self)

        self.window.Bind(wx.EVT_CLOSE, self._handle_close)

        wxgui_api.bind_to_menu(self.toggle_shown, self.menushow)
        wxgui_api.bind_to_menu_view_update(self._handle_menu_view_update)

        organism_alarms_api.bind_to_alarm(self._handle_alarm)
        organism_alarms_api.bind_to_alarm_off(self._handle_alarm_off)
        wxgui_api.bind_to_close_database(self._handle_close_db)
示例#4
0
    def __init__(self, tasklist):
        self.tasklist = tasklist
        self.occview = tasklist.list_

        self.ID_EVENTS = wx.NewId()
        self.ID_SHOW = wx.NewId()
        self.ID_FOCUS = wx.NewId()
        self.ID_ALARMS = wx.NewId()
        self.ID_TOGGLE_NAVIGATOR = wx.NewId()
        self.ID_GAPS = wx.NewId()
        self.ID_OVERLAPS = wx.NewId()
        self.ID_AUTOSCROLL = wx.NewId()

        submenu = wx.Menu()
        self.alarms_submenu = AlarmsMenu(tasklist)

        config = coreaux_api.get_plugin_configuration('wxtasklist')(
                                                    'GlobalShortcuts')('View')


        self.events = wx.MenuItem(wxgui_api.get_menu_view(), self.ID_EVENTS,
                        '&Schedule', 'Schedule navigation actions',
                        subMenu=submenu)
        self.show = wx.MenuItem(submenu, self.ID_SHOW,
                                "Show &panel\t{}".format(config['show']),
                                "Show the schedule panel", kind=wx.ITEM_CHECK)
        self.focus = wx.MenuItem(submenu, self.ID_FOCUS,
                        "&Focus\t{}".format(config['focus']),
                        "Set focus on the schedule tab")
        self.alarms = wx.MenuItem(submenu, self.ID_ALARMS, '&Active alarms',
                                        'Set the visibility of active alarms',
                                        subMenu=self.alarms_submenu)
        self.navigator = wx.MenuItem(submenu, self.ID_TOGGLE_NAVIGATOR,
                        "Show &navigator\t{}".format(config['show_navigator']),
                        "Show or hide the navigator bar", kind=wx.ITEM_CHECK)
        self.gaps = wx.MenuItem(submenu, self.ID_GAPS,
                            "Show &gaps\t{}".format(config['toggle_gaps']),
                            "Show any unallocated time in the shown interval",
                            kind=wx.ITEM_CHECK)
        self.overlaps = wx.MenuItem(submenu, self.ID_OVERLAPS,
                "Show &overlappings\t{}".format(config['toggle_overlappings']),
                "Show time intervals used by more than one event",
                kind=wx.ITEM_CHECK)
        self.autoscroll = wx.MenuItem(submenu, self.ID_AUTOSCROLL,
                                            "Enable a&uto-scroll",
                                            "Auto-scroll to the first ongoing "
                                            "event when refreshing",
                                            kind=wx.ITEM_CHECK)

        self.events.SetBitmap(wxgui_api.get_menu_icon('@tasklist'))
        self.focus.SetBitmap(wxgui_api.get_menu_icon('@jump'))
        self.alarms.SetBitmap(wxgui_api.get_menu_icon('@activealarms'))

        wxgui_api.insert_menu_right_tab_group(self.events)
        submenu.AppendItem(self.show)
        submenu.AppendItem(self.focus)
        submenu.AppendSeparator()
        submenu.AppendItem(self.alarms)
        submenu.AppendItem(self.navigator)
        submenu.AppendItem(self.gaps)
        submenu.AppendItem(self.overlaps)
        submenu.AppendItem(self.autoscroll)

        wxgui_api.bind_to_menu(self.tasklist.toggle_shown, self.show)
        wxgui_api.bind_to_menu(self._focus, self.focus)
        wxgui_api.bind_to_menu(self._toggle_navigator, self.navigator)
        wxgui_api.bind_to_menu(self._show_gaps, self.gaps)
        wxgui_api.bind_to_menu(self._show_overlappings, self.overlaps)
        wxgui_api.bind_to_menu(self._enable_autoscroll, self.autoscroll)

        wxgui_api.bind_to_reset_menu_items(self._reset_items)
        wxgui_api.bind_to_menu_view_update(self._update_items)