Ejemplo n.º 1
0
    def __init__(self, title):
        # init window
        Frame.__init__(self, None, ID_ANY, title, size=(800, 800))
        self.Bind(EVT_CLOSE, lambda x: self.Destroy())
        loc = Icon()
        loc.CopyFromBitmap(Bitmap('icon.ico', BITMAP_TYPE_ANY))
        self.SetIcon(loc)

        with SimpleSizer(self, VERTICAL) as sizer:
            new_element = OpenGLCanvas(self)
            sizer.Add(new_element)
Ejemplo n.º 2
0
    def __init__(self,
                 message: str,
                 label: str = None,
                 url: str = None,
                 **kwargs) -> None:
        super(HyperlinkDialog, self).__init__(parent=None, **kwargs)
        pane = self.GetContentsPane()

        text_ctrl = StaticText(pane, label=message)
        text_ctrl.SetFocus()
        text_ctrl.SetSizerProps(align="center")

        if url is not None:
            if label is None:
                label = url
            hyperlink = HyperlinkCtrl(pane, label=label, url=url)
            hyperlink.Bind(EVT_HYPERLINK, self.on_hyperlink)

        button_ok = Button(pane, label="OK")
        button_ok.Bind(EVT_BUTTON, self.on_ok)
        button_ok.SetSizerProps(align="center", border=(["top"], 10))

        self.SetIcon(
            Icon(ArtProvider.GetBitmap(ART_INFORMATION, ART_MESSAGE_BOX)))
        self.Fit()
        self.Centre()
Ejemplo n.º 3
0
    def _createApplicationIcon(self):

        if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM:
            fileName: str = PyutUtils.getResourcePath(
                packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico')
            icon: Icon = Icon(fileName, BITMAP_TYPE_ICO)
            self.SetIcon(icon)
Ejemplo n.º 4
0
    def __init__(self, parent, title, latestVersionTagName,
                 latestVersionChanges):

        super(NewVersionAlertDialog, self).__init__(parent,
                                                    wx.ID_ANY,
                                                    title,
                                                    size=(680, 290),
                                                    pos=(200, 150))

        bmp = MYDATA_ICONS.GetIcon("favicon", vendor="MyTardis")
        icon = EmptyIcon()
        icon.CopyFromBitmap(bmp)
        self.SetIcon(icon)

        # Panels placed vertically
        verticalSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(verticalSizer)

        mainPanel = wx.Panel(self)
        verticalSizer.Add(mainPanel)

        okButton = wx.Button(self, wx.ID_ANY, ' OK ')
        okButton.SetDefault()
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=okButton.GetId())
        verticalSizer.Add(okButton,
                          flag=wx.BOTTOM | wx.RIGHT | wx.ALIGN_RIGHT,
                          border=20)

        # Panels placed horizontally
        horizSizer = wx.FlexGridSizer(rows=1, cols=2, vgap=5, hgap=5)
        mainPanel.SetSizer(horizSizer)

        iconPanel = IconPanel(mainPanel)
        horizSizer.Add(iconPanel, flag=wx.EXPAND | wx.ALL, border=10)

        newVersionAlertPanel = NewVersionAlertPanel(mainPanel,
                                                    latestVersionTagName,
                                                    latestVersionChanges)
        horizSizer.Add(newVersionAlertPanel,
                       flag=wx.EXPAND | wx.TOP | wx.RIGHT,
                       border=10)

        horizSizer.Fit(mainPanel)
        verticalSizer.Fit(self)
Ejemplo n.º 5
0
    def __init__(self, frame):
        """
        @type frame: str, unicode
        @return: None
        """
        adv.TaskBarIcon.__init__(self)
        self.frame = frame

        # Set the image
        icon = Icon()
        icon.CopyFromBitmap(
            wx.Bitmap(os.path.join(get_base_dir(), "Resources/traybar.png"),
                      wx.BITMAP_TYPE_PNG))
        self.tbIcon = icon
        self.SetIcon(self.tbIcon, "Cryptobox")

        # bind some evts
        self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE)
        self.Bind(adv.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick)
Ejemplo n.º 6
0
 def __init__(self, window):
     TaskBarIcon.__init__(self)
     self.__window = window
     self.SetIcon(Icon(iconPath, BITMAP_TYPE_ICO))
     self.Bind(adv.EVT_TASKBAR_LEFT_DCLICK, self.ToggleWindow)
     ids = [
         self.ID_IMPORT, self.ID_NEW, self.ID_REFRESH_DNS, self.ID_TOGGLE,
         self.ID_EXIT, self.ID_ABOUT, self.ID_LUNCH_CHROME,
         self.ID_LUNCH_CHROME_CROS, self.ID_LUNCH_CHROME_NO_PLUGINS
     ]
     for itemId in ids:
         self.Bind(EVT_MENU, window.OnMenuClicked, id=itemId)
Ejemplo n.º 7
0
    def __init__(self):
        TaskBarIcon.__init__(self)
        self.SetIcon(Icon(self.ICON), self.TITLE)  # 设置图标和标题
        self.Bind(EVT_MENU, self.onAbout, id=self.ID_ABOUT)  # 绑定“关于”选项的点击事件
        self.Bind(EVT_MENU, self.onExit, id=self.ID_EXIT)  # 绑定“退出”选项的点击事件
        self.Bind(EVT_MENU, self.onUpload, id=self.ID_UPLOAD)
        self.Bind(EVT_MENU, self.OnLogin, id=self.ID_LOGIN)

        self.frame = Frame(parent=None, title='登录', size=(285, 160))
        self.frame.Bind(EVT_CLOSE, lambda event: self.frame.Show(False))

        panel = Panel(self.frame, -1)
        label_user = StaticText(panel, -1, "账号:", pos=(10, 10))
        label_pass = StaticText(panel, -1, "密码:", pos=(10, 50))

        self.entry_user = TextCtrl(panel, -1, size=(210, 20), pos=(50, 10))
        self.entry_pass = TextCtrl(panel, -1, size=(210, 20), pos=(50, 50), style=TE_PASSWORD)

        self.but_login = Button(panel, -1, "登陆", size=(50, 30), pos=(10, 80))
        self.but_register = Button(panel, -1, "注册SM.MS账号", size=(110, 30), pos=(150, 80))
        self.but_not_login = Button(panel, -1, "免登陆使用", size=(80, 30), pos=(65, 80))

        self.but_login.Bind(EVT_BUTTON, self.on_but_login)
        self.but_register.Bind(EVT_BUTTON, self.on_but_register)
        self.but_not_login.Bind(EVT_BUTTON, self.on_but_not_login)

        self.frame.Center()
        token = init_config()
        if token == '0':
            self.frame.Show(True)
        else:
            self.frame.Show(False)

        self.frame.SetMaxSize((285, 160))
        self.frame.SetMinSize((285, 160))
        ThreadKey(self)

        self.frame2 = Trans(parent=None, title='上传中', size=(50, 20))
        self.frame2.Center()
        self.frame2.Show(False)

        self.frame3 = Trans(parent=None, title='上传成功', size=(50, 20))
        self.frame3.Center()
        self.frame3.Show(False)

        self.frame4 = Trans(parent=None, title='上传失败', size=(50, 20))
        self.frame4.Center()
        self.frame4.Show(False)

        self.frame5 = Trans(parent=None, title='每分钟限制上传20张,请等待冷却', size=(200, 20))
        self.frame5.Center()
        self.frame5.Show(False)
Ejemplo n.º 8
0
    def __init__(self, application, controller):
        size = application.settings.get('mainframe size', (1100, 700))
        wx.Frame.__init__(self,
                          parent=None,
                          id=wx.ID_ANY,
                          title='RIDE',
                          pos=application.settings.get('mainframe position',
                                                       (50, 30)),
                          size=size,
                          style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER)

        # set Left to Right direction (while we don't have localization)
        self.SetLayoutDirection(wx.Layout_LeftToRight)
        # self.SetLayoutDirection(wx.Layout_RightToLeft)

        self._mgr = aui.AuiManager()

        # tell AuiManager to manage this frame
        self._mgr.SetManagedWindow(self)

        # set frame icon
        # self.SetIcon(Icon('widgets/robot.ico')) # Maybe is not needed
        # self.SetMinSize(size)
        self.SetMinSize(wx.Size(400, 300))

        self.ensure_on_screen()
        if application.settings.get('mainframe maximized', False):
            self.Maximize()
        self._application = application
        self._controller = controller
        self.favicon = Icon(
            os.path.join(os.path.dirname(__file__), "..", "widgets",
                         "robot.ico"), wx.BITMAP_TYPE_ICO, 256, 256)
        self.SetIcon(self.favicon)
        self._init_ui()
        self._plugin_manager = PluginManager(self.notebook)
        self._review_dialog = None
        self._view_all_tags_dialog = None
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOVE, self.OnMove)
        self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize)
        if wx.VERSION >= (3, 0, 3, ''):  # DEBUG wxPhoenix
            self.Bind(wx.EVT_DIRCTRL_FILEACTIVATED, self.OnOpenFile)
            self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnMenuOpenFile)
        self._subscribe_messages()
        #print("DEBUG: Call register_tools, actions: %s" % self.actions.__repr__())
        if PY2:
            wx.CallLater(100, self.actions.register_tools)  # DEBUG
        else:
            wx.CallAfter(self.actions.register_tools)  # DEBUG
Ejemplo n.º 9
0
    def __init__(self, *args, **kw):
        super().__init__(*args, **kw)
        self.sm = SettingManeger()

        icon_file = get_data_safety(self.sm.setting, ICON_FILE)
        if icon_file is not None and exists(icon_file):
            icon = Icon(find_data_file(icon_file))
            self.SetIcon(icon)
        self.menubar, self.language_menu_item_list = self.create_menubar(
            self.sm.language_list)
        self.SetMenuBar(self.menubar)

        if 0 <= len(
                self.language_menu_item_list) - 1 <= self.sm.language_index:
            self.language_menu_item_list[self.sm.language_index].Check()

        self.panel = Panel(self)
        self.preview_button = NormalButton(self.panel,
                                           label=SHOW_LABEL,
                                           size=(40, 40),
                                           pos=(10, 10))
        self.separeter_line = StaticLine(self.panel, size=(3000, 2))
        self.add_button = NormalButton(self.panel,
                                       label=ADD_LABEL,
                                       size=(40, 40))

        self.timer_display = TimerDisplay(self, parent=self.panel)
        self.contents_display = ContentsDisplay(self,
                                                self.timer_display,
                                                parent=self.panel,
                                                style=ALWAYS_SHOW_SB)

        self.preview_window = PreviewWindow(self.sm,
                                            self.contents_display,
                                            parent=self)
        welcome_contents = self.sm.welcome_contents_list[
            self.sm.
            language_index] if self.sm.welcome_contents_list is not None else ERROR_MESSAGE
        self.welcome_window = ScrolledWindow(welcome_contents, parent=self)
        about_contents = self.sm.about_contents_list[
            self.sm.
            language_index] if self.sm.about_contents_list is not None else ERROR_MESSAGE
        self.about_window = ScrolledWindow(about_contents, parent=self)

        self.reset()

        self.change_language()
        self.connect()
        self.set_color()
        self.layout()
Ejemplo n.º 10
0
    def __init__(self, parent, dpi=(1, 1)):
        Dialog.__init__(self,
                        parent,
                        id=ID_ANY,
                        title=u" 关于 mHosts - v%s" % Settings.version(),
                        pos=DefaultPosition,
                        style=DEFAULT_DIALOG_STYLE | FRAME_FLOAT_ON_PARENT,
                        size=Size(400 * dpi[0], 300 * dpi[1]))
        self.SetSizeHints(DefaultSize, DefaultSize)
        self.SetIcon(Icon(iconPath, BITMAP_TYPE_ICO))
        bSizer2 = BoxSizer(VERTICAL)

        self.aboutDialog = AboutView(self, self.GetSize())
        bSizer2.Add(self.aboutDialog, 0, EXPAND, 0)

        self.SetSizer(bSizer2)
        self.Layout()

        self.Centre(BOTH)
Ejemplo n.º 11
0
    def __init__(self, frame):
        wx.TaskBarIcon.__init__(self)
        self.frame = frame
        self.id = AutoId()
        # Set the image
        self.icons = itertools.cycle(glob.glob('*.ico'))
        self.tbIcon = Icon(self.icons.next())

        self.SetIcon(self.tbIcon, "PhoneToPc ")

        # bind some evts
        self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.id.TBMENU_CLOSE)
        self.Bind(wx.EVT_MENU,
                  self.OnChangeIcon,
                  id=self.id.SUBMENU_CHANGE_ICON)
        self.Bind(wx.EVT_MENU, self.OnShowFrame, id=self.id.TBMENU_RESTORE)
        self.Bind(wx.EVT_MENU,
                  self.OnBatteryChange,
                  id=self.id.SUBMENU_CHANGE_BATTERY)
        self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick)
Ejemplo n.º 12
0
    def __init__(self, frame):
        """Constructor"""
        TaskBarIcon.__init__(self)
        self.frame = frame

        bmp = MYDATA_ICONS.GetIcon("favicon", vendor="MyTardis")
        self.icon = EmptyIcon()
        self.icon.CopyFromBitmap(bmp)

        self.SetIcon(self.icon, "MyData")

        # Mouse event handling set up in MyData class's OnInit method.
        # self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick)

        self.menu = None
        self.aboutMyDataMenuItem = None
        self.syncNowMenuItem = None
        self.myTardisMainWindowMenuItem = None
        self.myTardisSettingsMenuItem = None
        self.myTardisHelpMenuItem = None
        self.exitMyDataMenuItem = None
Ejemplo n.º 13
0
 def __init__(self):
     """Constructor"""
     Dialog.__init__(self, None, title="Bad Cop", size=Size(500, 100))
     ico = Icon('logo.ico', BITMAP_TYPE_ICO)
     self.SetIcon(ico)
     self.message = StaticText(
         self, label="Click Profile, then insert device and click Test")
     self.profile = Button(self, label="Profile")
     self.test = Button(self, label="Test")
     self.test.Disable()
     self.profile.Bind(EVT_BUTTON, self.profileusb)
     self.test.Bind(EVT_BUTTON, self.testusb)
     self.Bind(EVT_CLOSE, self.onclose)
     main_sizer = BoxSizer(VERTICAL)
     t_sizer = BoxSizer(HORIZONTAL)
     p_sizer = BoxSizer(HORIZONTAL)
     t_sizer.Add(self.message, 0, ALL | CENTER, 5)
     p_sizer.Add(self.profile, 0, ALL | CENTER, 5)
     p_sizer.Add(self.test, 0, ALL | CENTER, 5)
     main_sizer.Add(p_sizer, 0, ALL | CENTER, 5)
     main_sizer.Add(t_sizer, 0, ALL | EXPAND | CENTER, 5)
     self.SetSizer(main_sizer)
Ejemplo n.º 14
0
    def __init__(self, parent: Window, wxID: int, title: str):
        """

        Args:
            parent:     parent window
            wxID:         wx ID of this frame
            title:      Title to display
        """
        super().__init__(parent, wxID, title, DefaultPosition,
                         Size(FrameWidth, FrameHeight))

        self.logger: Logger = getLogger(__name__)
        # iconFileName: str    = resource_filename(IMAGE_RESOURCES_PACKAGE, 'pyut.ico')
        # icon:         Icon   = Icon(iconFileName, BITMAP_TYPE_ICO)
        #
        # self.SetIcon(icon)
        if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM:

            fileName: str = PyutUtils.getResourcePath(
                packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico')
            icon: Icon = Icon(fileName, BITMAP_TYPE_ICO)
            self.SetIcon(icon)

        self.Center(BOTH)

        longTextStr: str = PyutUtils.retrieveResourceText(
            ResourceTextType.KUDOS_TEXT_TYPE)
        self._textToShow: List[str] = longTextStr.split('\n')
        # Animation panel
        self._panel: Panel = Panel(self,
                                   ID_ANY,
                                   size=(FrameWidth, FrameHeight))

        # Picture and text
        # bmp = Bitmap("img" + os.sep + "pyut.bmp", BITMAP_TYPE_BMP)
        # fileName = resource_filename(IMAGE_RESOURCES_PACKAGE, 'pyut.bmp')
        fileName: str = PyutUtils.getResourcePath(IMAGE_RESOURCES_PACKAGE,
                                                  'pyut.png')
        # bmp = Bitmap(fileName, BITMAP_TYPE_PNG)

        self._picture: StaticBitmap = StaticBitmap(
            self, ID_ANY, ImgPyut.embeddedImage.GetBitmap())
        summaryText: str = "2020 The PyUt team and Humberto Sanchez II.\nPublished under the GNU General Public License"
        self._label: StaticText = StaticText(self,
                                             ID_ANY,
                                             summaryText,
                                             style=CAPTION)

        # Main sizer
        self.SetAutoLayout(True)
        sizer = BoxSizer(VERTICAL)
        sizer.Add(self._picture, 0, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._panel, 1, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._label, 0, ALL | ALIGN_CENTER, 5)

        btnOk: Button = Button(self, ID_OK, "&Ok")
        sizer.Add(btnOk, 0, ALL | ALIGN_CENTER, 5)
        self.SetSizer(sizer)
        sizer.Fit(self)

        self._textPosition = 0.0  # Current position

        self._timer: Timer = Timer(self)
        self.Bind(EVT_TIMER, self._onTimer, self._timer)

        self.Bind(EVT_BUTTON, self._onOk, btnOk)
        self._panel.Bind(EVT_PAINT, self.OnRefreshPanel)
        self.Bind(EVT_CLOSE, self._onOk)
Ejemplo n.º 15
0
    def __init__(self, parent, dpi=(1, 1)):
        Frame.__init__(self,
                       parent,
                       id=ID_ANY,
                       title=u" mHosts - v" + Settings.version(),
                       pos=DefaultPosition,
                       size=Size(700 * dpi[0], 500 * dpi[1]),
                       style=DEFAULT_FRAME_STYLE | SYSTEM_MENU | TAB_TRAVERSAL)
        self.SetIcon(Icon(iconPath, BITMAP_TYPE_ICO))
        self.SetSizeHints(Size(500 * dpi[0], 350 * dpi[1]))
        self.menuBar = MenuBar(0)
        self.menuFile = Menu()
        self.menuItemNew = MenuItem(self.menuFile, ID_ANY, u"新建(&N)",
                                    EmptyString, ITEM_NORMAL)
        self.menuItemImport = MenuItem(self.menuFile, ID_ANY, u"导入(&I)",
                                       EmptyString, ITEM_NORMAL)
        if sys.platform != "linux":
            self.menuItemImport.Enable(False)
        self.menuFile.Append(self.menuItemNew)
        self.menuFile.Append(self.menuItemImport)

        self.menuFile.AppendSeparator()

        self.menuItemExit = MenuItem(self.menuFile, ID_ANY, u"退出(&Q)",
                                     EmptyString, ITEM_NORMAL)
        self.menuFile.Append(self.menuItemExit)

        self.menuBar.Append(self.menuFile, u"文件(&F)")

        self.menuHelp = Menu()

        self.menuItemSettings = MenuItem(self.menuHelp, ID_ANY, u"首选项(&P)",
                                         EmptyString, ITEM_NORMAL)
        if sys.platform != "linux":
            self.menuItemSettings.Enable(False)
        self.menuHelp.Append(self.menuItemSettings)

        self.menuItemHelpDoc = MenuItem(self.menuHelp, ID_ANY, u"帮助文档(&D)",
                                        EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemHelpDoc)

        self.menuItemCheckUpdate = MenuItem(self.menuHelp, ID_ANY, u"检查更新(&U)",
                                            EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemCheckUpdate)

        self.menuItemAbout = MenuItem(self.menuHelp, ID_ANY, u"关于(&A)",
                                      EmptyString, ITEM_NORMAL)
        self.menuHelp.Append(self.menuItemAbout)

        self.menuBar.Append(self.menuHelp, u"帮助(&H)")

        self.SetMenuBar(self.menuBar)

        self.statusBar = StatusBar(self, ID_ANY, STB_SIZEGRIP)
        statusBarFont = Font(10, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL,
                             FONTWEIGHT_NORMAL, False, EmptyString)
        self.statusBar.SetFont(statusBarFont)
        self.SetStatusBar(self.statusBar)

        bSizer1 = BoxSizer(HORIZONTAL)

        self.images = {}

        self.imageList = ImageList(width=12, height=12)
        iconList = GetIcons().items()
        for name, bitmap in iconList:
            self.images[name] = self.imageList.Add(bitmap)

        self.hostsTree = TreeCtrl(self, ID_ANY, Point(0, 0),
                                  Size(180 * dpi[0], -1), TR_DEFAULT_STYLE)
        self.hostsTree.SetImageList(self.imageList)
        bSizer1.Add(self.hostsTree, 0, EXPAND, 5)

        # self.hostsListView = CheckListBox(self, size=Size(size[0] / 9, -1))
        # bSizer1.Add(self.hostsListView, 0, EXPAND, 5)

        # WARNING: wxPython code generation isn't supported for this widget yet.
        self.codeEditor = CodeView(self, dpi)
        bSizer1.Add(self.codeEditor, 1, EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(BOTH)

        # Connect Events
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemNew.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemExit.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemAbout.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemHelpDoc.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemSettings.GetId())
        self.Bind(EVT_MENU, self.OnMenuClicked, id=self.menuItemImport.GetId())
        self.Bind(EVT_MENU,
                  self.OnMenuClicked,
                  id=self.menuItemCheckUpdate.GetId())
Ejemplo n.º 16
0
 def OnChangeIcon(self, evt):
     self.tbIcon = Icon(self.icons.next())
     self.SetIcon(self.tbIcon, "Icon changed")
     self.ShowBalloon("Test", "Icon changed", 5, wx.ICON_WARNING)
Ejemplo n.º 17
0
class MyDataTaskBarIcon(TaskBarIcon):
    """
    Provides a system tray icon (Windows)
    or menubar icon (Mac OS X) for MyData.
    """

    # pylint: disable=too-many-instance-attributes
    def __init__(self, frame, settingsModel):
        """Constructor"""
        TaskBarIcon.__init__(self)
        self.frame = frame
        self.settingsModel = settingsModel

        bmp = MYDATA_ICONS.GetIcon("favicon", vendor="MyTardis")
        self.icon = EmptyIcon()
        self.icon.CopyFromBitmap(bmp)

        self.SetIcon(self.icon, "MyData")

        # Mouse event handling set up in MyData class's OnInit method.
        # self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick)

        self.menu = None
        self.aboutMyDataMenuItem = None
        self.syncNowMenuItem = None
        self.myTardisMainWindowMenuItem = None
        self.myTardisSettingsMenuItem = None
        self.myTardisHelpMenuItem = None
        self.exitMyDataMenuItem = None

    def CreatePopupMenu(self):
        """
        Overrides method in parent class to provide a Popup Menu
        when the user clicks on MyData's system tray (or menubar) icon.
        """
        self.menu = wx.Menu()

        self.aboutMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                               "About MyData")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.aboutMyDataMenuItem)
        else:
            self.menu.AppendItem(self.aboutMyDataMenuItem)
        self.Bind(wx.EVT_MENU,
                  wx.GetApp().OnAbout, self.aboutMyDataMenuItem,
                  self.aboutMyDataMenuItem.GetId())

        self.menu.AppendSeparator()

        self.syncNowMenuItem = wx.MenuItem(self.menu, wx.NewId(), "Sync Now")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.syncNowMenuItem)
        else:
            self.menu.AppendItem(self.syncNowMenuItem)
        self.Bind(wx.EVT_MENU, self.OnSyncNow, self.syncNowMenuItem,
                  self.syncNowMenuItem.GetId())

        self.menu.AppendSeparator()

        self.myTardisMainWindowMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                      "MyData Main Window")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.myTardisMainWindowMenuItem)
        else:
            self.menu.AppendItem(self.myTardisMainWindowMenuItem)
        self.Bind(wx.EVT_MENU, self.OnMyDataMainWindow,
                  self.myTardisMainWindowMenuItem)

        self.myTardisSettingsMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                    "MyData Settings")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.myTardisSettingsMenuItem)
        else:
            self.menu.AppendItem(self.myTardisSettingsMenuItem)
        self.Bind(wx.EVT_MENU, self.OnMyDataSettings,
                  self.myTardisSettingsMenuItem)

        self.menu.AppendSeparator()

        self.myTardisHelpMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                "MyData Help")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.myTardisHelpMenuItem)
        else:
            self.menu.AppendItem(self.myTardisHelpMenuItem)
        self.Bind(wx.EVT_MENU, self.OnMyDataHelp, self.myTardisHelpMenuItem)

        self.menu.AppendSeparator()

        self.exitMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                              "Exit MyData")
        if wx.version().startswith("3.0.3.dev"):
            self.menu.Append(self.exitMyDataMenuItem)
        else:
            self.menu.AppendItem(self.exitMyDataMenuItem)
        self.Bind(wx.EVT_MENU, self.OnExit, self.exitMyDataMenuItem)

        return self.menu

    def GetSyncNowMenuItem(self):
        """
        Returns the "Sync Now" menu item.
        """
        if hasattr(self, "syncNowMenuItem"):
            return self.syncNowMenuItem
        else:
            return None

    def OnMyDataMainWindow(self, event):
        """
        Called when the "MyData Main Window" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        self.frame.Show(True)
        self.frame.Raise()
        event.Skip()

    def OnMyDataSettings(self, event):
        """
        Called when the "MyData Settings" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        self.frame.Show(True)
        self.frame.Raise()
        wx.GetApp().OnSettings(event)
        event.Skip()

    # pylint: disable=no-self-use
    def OnSyncNow(self, event):
        """
        Called when the "Sync Now" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        logger.debug("Sync Now called from task bar menu item.")
        wx.GetApp().ScanFoldersAndUpload(event)

    # pylint: disable=no-self-use
    def OnMyDataHelp(self, event):
        """
        Called when the "MyData Help" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        new = 2  # Open in a new tab, if possible
        url = "http://mydata.readthedocs.org/en/latest/"
        webbrowser.open(url, new=new)
        event.Skip()

    def OnExit(self, event):
        """
        Called when the "Exit MyData" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        started = wx.GetApp().foldersController.Started()
        completed = wx.GetApp().foldersController.Completed()
        canceled = wx.GetApp().foldersController.Canceled()
        failed = wx.GetApp().foldersController.Failed()

        self.frame.Show(True)
        self.frame.Raise()
        message = "Are you sure you want to quit MyData?"
        if started and not completed and not canceled and not failed:
            message += "\n\n" \
                "MyData will attempt to shut down any uploads currently " \
                "in progress before exiting."
        confirmationDialog = \
            wx.MessageDialog(self.frame, message, "MyData",
                             wx.YES | wx.NO | wx.ICON_QUESTION)
        okToExit = confirmationDialog.ShowModal()
        if okToExit == wx.ID_YES:
            # See also: wx.GetApp().ShutDownCleanlyAndExit(event)
            # pylint: disable=protected-access
            os._exit(0)
        event.Skip()
Ejemplo n.º 18
0
    def __init__(self):
        self.files = []
        self.path = None

        # init window
        Frame.__init__(self, None, ID_ANY, "CUT", size=(688, 800))
        self.Bind(EVT_CLOSE, lambda x: self.Destroy())
        loc = Icon()
        loc.CopyFromBitmap(Bitmap('icon.ico', BITMAP_TYPE_ANY))
        self.SetIcon(loc)
        self.panel = Panel(self, EXPAND)
        self.sizer = BoxSizer(VERTICAL)
        self.sizer.Add(
            FileInput(self.panel,
                      text_button="Open File",
                      callback=self._set_file,
                      file_type=file_exts,
                      text_title="OPEN",
                      text_open_file="File"), 1, EXPAND)

        #  Create Input fields
        self._start_input = TimeInput(self.panel, label='START')
        self._end_input = TimeInput(self.panel, label='END')
        self._scale_input = SimpleInput(self.panel,
                                        label='Width:Height',
                                        initial='-1:-1')
        self._webm_input = SimpleInput(self.panel,
                                       label='WEBM Quality',
                                       initial='36')
        self._framerate_input = SimpleInput(self.panel,
                                            label='INPUT FRAMES FRAMERATE',
                                            initial='')

        # Create check inputs
        font = Font(20, MODERN, NORMAL, NORMAL, False, u'Consolas')

        self._audio_select = StandardSelection(parent=self.panel,
                                               options=list(
                                                   audio_options.keys()),
                                               callback=None,
                                               title='Audio codec')

        self._video_select = StandardSelection(parent=self.panel,
                                               options=list(
                                                   video_options.keys()),
                                               callback=None,
                                               title='Video format')

        # Add inputs to self.sizer
        self.sizer.Add(self._video_select, 1, EXPAND)
        self.sizer.Add(self._audio_select, 1, EXPAND)
        self.sizer.Add(
            FileInput(self.panel,
                      text_button="Clone time",
                      callback=self._clone_time,
                      file_type=file_exts,
                      text_title="OPEN",
                      text_open_file="File"), 1, EXPAND)
        self.sizer.Add(self._start_input, 1, EXPAND)
        self.sizer.Add(self._end_input, 1, EXPAND)
        self.sizer.Add(self._scale_input, 1, EXPAND)
        self.sizer.Add(self._webm_input, 1, EXPAND)
        self.sizer.Add(self._framerate_input, 1, EXPAND)

        # Add Button
        self.sizer.Add(
            SimpleButton(self.panel,
                         text_button='CUT',
                         callback=self._submit_task), 1, EXPAND)
        self.panel.SetSizer(self.sizer)
Ejemplo n.º 19
0
class MyDataTaskBarIcon(TaskBarIcon):
    """
    Provides a system tray icon (Windows)
    or menubar icon (Mac OS X) for MyData.
    """
    def __init__(self, frame):
        """Constructor"""
        TaskBarIcon.__init__(self)
        self.frame = frame

        bmp = MYDATA_ICONS.GetIcon("favicon", vendor="MyTardis")
        self.icon = EmptyIcon()
        self.icon.CopyFromBitmap(bmp)

        self.SetIcon(self.icon, "MyData")

        # Mouse event handling set up in MyData class's OnInit method.
        # self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.OnTaskBarLeftClick)

        self.menu = None
        self.aboutMyDataMenuItem = None
        self.syncNowMenuItem = None
        self.myTardisMainWindowMenuItem = None
        self.myTardisSettingsMenuItem = None
        self.myTardisHelpMenuItem = None
        self.exitMyDataMenuItem = None

    def CreatePopupMenu(self):
        """
        Overrides method in parent class to provide a Popup Menu
        when the user clicks on MyData's system tray (or menubar) icon.
        """
        self.menu = wx.Menu()

        self.aboutMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                               "About MyData")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.aboutMyDataMenuItem)
        else:
            self.menu.AppendItem(self.aboutMyDataMenuItem)
        self.Bind(wx.EVT_MENU, self.frame.OnAbout, self.aboutMyDataMenuItem,
                  self.aboutMyDataMenuItem.GetId())

        self.menu.AppendSeparator()

        self.syncNowMenuItem = wx.MenuItem(self.menu, wx.NewId(), "Sync Now")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.syncNowMenuItem)
        else:
            self.menu.AppendItem(self.syncNowMenuItem)
        self.Bind(wx.EVT_MENU, MyDataTaskBarIcon.OnSyncNow,
                  self.syncNowMenuItem, self.syncNowMenuItem.GetId())

        self.menu.AppendSeparator()

        self.myTardisMainWindowMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                      "MyData Main Window")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.myTardisMainWindowMenuItem)
        else:
            self.menu.AppendItem(self.myTardisMainWindowMenuItem)
        self.Bind(wx.EVT_MENU, self.OnMyDataMainWindow,
                  self.myTardisMainWindowMenuItem)

        self.myTardisSettingsMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                    "MyData Settings")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.myTardisSettingsMenuItem)
        else:
            self.menu.AppendItem(self.myTardisSettingsMenuItem)
        self.Bind(wx.EVT_MENU, self.OnMyDataSettings,
                  self.myTardisSettingsMenuItem)

        self.menu.AppendSeparator()

        self.myTardisHelpMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                                "MyData Help")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.myTardisHelpMenuItem)
        else:
            self.menu.AppendItem(self.myTardisHelpMenuItem)
        self.Bind(wx.EVT_MENU, MyDataTaskBarIcon.OnMyDataHelp,
                  self.myTardisHelpMenuItem)

        self.menu.AppendSeparator()

        self.exitMyDataMenuItem = wx.MenuItem(self.menu, wx.NewId(),
                                              "Exit MyData")
        if 'phoenix' in wx.PlatformInfo:
            self.menu.Append(self.exitMyDataMenuItem)
        else:
            self.menu.AppendItem(self.exitMyDataMenuItem)
        self.Bind(wx.EVT_MENU, self.OnExit, self.exitMyDataMenuItem)

        return self.menu

    def GetSyncNowMenuItem(self):
        """
        Returns the "Sync Now" menu item.
        """
        return getattr(self, "syncNowMenuItem", None)

    def OnMyDataMainWindow(self, event):
        """
        Called when the "MyData Main Window" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        self.frame.Show(True)
        self.frame.Iconize(False)
        self.frame.Raise()
        event.Skip()

    def OnMyDataSettings(self, event):
        """
        Called when the "MyData Settings" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        self.frame.Show(True)
        self.frame.Iconize(False)
        self.frame.Raise()
        OnSettings(event)
        event.Skip()

    @staticmethod
    def OnSyncNow(event):
        """
        Called when the "Sync Now" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        logger.debug("Sync Now called from task bar menu item.")
        ManuallyTriggerScanFoldersAndUpload(event)

    @staticmethod
    def OnMyDataHelp(event):
        """
        Called when the "MyData Help" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        new = 2  # Open in a new tab, if possible
        url = "http://mydata.readthedocs.org/en/latest/"
        webbrowser.open(url, new=new)
        event.Skip()

    def OnExit(self, event):
        """
        Called when the "Exit MyData" menu item is
        selected from MyData's system tray / menu bar icon menu.
        """
        self.frame.Show(True)
        self.frame.Iconize(False)
        self.frame.Raise()
        message = "Are you sure you want to quit MyData?"
        if wx.GetApp().Processing():
            message += "\n\n" \
                "MyData will attempt to shut down any uploads currently " \
                "in progress before exiting."
        confirmationDialog = \
            wx.MessageDialog(self.frame, message, "MyData",
                             wx.YES | wx.NO | wx.ICON_QUESTION)
        okToExit = confirmationDialog.ShowModal()
        if okToExit == wx.ID_YES:
            wx.GetApp().ShutDownCleanlyAndExit(event, confirm=False)
        event.StopPropagation()
Ejemplo n.º 20
0
    def __init__(self, parent: Window, wxID: int, title: str):
        """

        Args:
            parent:     parent window
            wxID:       wx ID of this frame
            title:      Title to display
        """
        self._prefs: PyutPreferences = PyutPreferences()

        appSize: Size = Size(self._prefs.startupWidth,
                             self._prefs.startupHeight)

        super().__init__(parent=parent,
                         id=wxID,
                         title=title,
                         size=appSize,
                         style=DEFAULT_FRAME_STYLE | FRAME_EX_METAL)

        self.logger: Logger = getLogger(__name__)
        # Create the application's icon
        if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM:

            fileName: str = PyutUtils.getResourcePath(
                packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico')
            icon: Icon = Icon(fileName, BITMAP_TYPE_ICO)
            self.SetIcon(icon)

        self.SetThemeEnabled(True)

        if self._prefs.centerAppOnStartUp is True:
            self.Center(BOTH)  # Center on the screen
        else:
            appPosition: Tuple[int, int] = self._prefs.appStartupPosition
            self.SetPosition(pt=appPosition)

        self.CreateStatusBar()

        # Properties
        from org.pyut.plugins.PluginManager import PluginManager  # Plugin Manager should not be in plugins directory

        self.plugMgr: PluginManager = PluginManager()
        self.plugins: SharedTypes.PluginMap = cast(SharedTypes.PluginMap,
                                                   {})  # To store the plugins
        self._toolboxIds: SharedTypes.ToolboxIdMap = cast(
            SharedTypes.ToolboxIdMap, {})  # Association toolbox id -> category
        self.mnuFile: Menu = cast(Menu, None)

        self._clipboard = []
        self._currentDirectory = getcwd()

        self._lastDir = self._prefs["LastDirectory"]
        if self._lastDir is None:  # Assert that the path is present
            self._lastDir = getcwd()

        self._ctrl = getMediator()
        self._ctrl.registerStatusBar(self.GetStatusBar())
        self._ctrl.resetStatusText()
        self._ctrl.registerAppFrame(self)

        # Last opened Files IDs
        self.lastOpenedFilesID = []
        for index in range(self._prefs.getNbLOF()):
            self.lastOpenedFilesID.append(PyutUtils.assignID(1)[0])

        self._mainFileHandlingUI: MainUI = MainUI(self, self._ctrl)
        self._ctrl.registerFileHandling(self._mainFileHandlingUI)

        # Initialization
        self._initPyutTools()  # Toolboxes, toolbar
        self._initMenu()  # Menu
        self._initPrinting()  # Printing data

        # Accelerators init. (=Keyboards shortcuts)
        acc = self._createAcceleratorTable()
        accel_table = AcceleratorTable(acc)
        self.SetAcceleratorTable(accel_table)

        self._ctrl.registerAppPath(self._currentDirectory)

        # set application title
        self._mainFileHandlingUI.newProject()
        self._ctrl.updateTitle()

        # Init tips frame
        self._alreadyDisplayedTipsFrame = False
        self.Bind(EVT_ACTIVATE, self._onActivate)
Ejemplo n.º 21
0
 def set_icon(self, path):
     #		icon = wx.Icon(wx.Bitmap(path))
     self.SetIcon(Icon(), TRAY_TOOLTIP)
Ejemplo n.º 22
0
 def __init__(self, frame, icon_path, tooltip, left_click):
     self.frame = frame
     self.left_click = left_click
     super().__init__()
     self.SetIcon(Icon(icon_path), tooltip)
     self.Bind(EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
Ejemplo n.º 23
0
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, APPNAME)
        self.SetSize(wx.Size(1000, 600))
        self.statusbar = wx.StatusBar(self)
        if sys.platform.startswith("win"):
            self.statusbar.SetSize(wx.Size(-1, 28))
        else:
            self.statusbar.SetSize(wx.Size(-1, 18))
        self.statusbar.SetFieldsCount(2)
        self.SetStatusBar(self.statusbar)
        self.statusbar.SetStatusWidths([-1, 60])

        self.mydataApp = wx.GetApp()

        self.panel = wx.Panel(self)

        if sys.platform.startswith("darwin"):
            self.CreateMacMenu()

        self.toolbar = MyDataToolbar(self)

        bmp = MYDATA_ICONS.GetIcon("favicon", vendor="MyTardis")
        icon = EmptyIcon()
        icon.CopyFromBitmap(bmp)
        self.SetIcon(icon)

        if 'phoenix' in wx.PlatformInfo:
            self.tabbedView = AuiNotebook(self.panel, agwStyle=AUI_NB_TOP)
        else:
            self.tabbedView = AuiNotebook(self.panel, style=AUI_NB_TOP)
        # Without the following line, the tab font looks
        # too small on Mac OS X:
        self.tabbedView.SetFont(self.panel.GetFont())
        self.Bind(EVT_AUINOTEBOOK_PAGE_CHANGING, self.OnNotebookPageChanging,
                  self.tabbedView)

        self.dataViews = dict()
        if DATAVIEW_MODELS:
            self.AddDataViews()

        self.logView = LogView(self.tabbedView)
        self.tabbedView.AddPage(self.logView, "Log")

        sizer = wx.BoxSizer()
        sizer.Add(self.tabbedView, 1, flag=wx.EXPAND)
        self.panel.SetSizer(sizer)

        sizer = wx.BoxSizer()
        sizer.Add(self.panel, 1, flag=wx.EXPAND)
        self.SetSizer(sizer)

        self.tabbedView.SendSizeEvent()

        self.panel.SetFocus()

        self.taskBarIcon = MyDataTaskBarIcon(self)
        if sys.platform.startswith("linux"):
            self.taskBarIcon.Bind(EVT_TASKBAR_LEFT_DOWN,
                                  self.OnTaskBarLeftClick)
        else:
            self.taskBarIcon.Bind(EVT_TASKBAR_LEFT_UP, self.OnTaskBarLeftClick)

        self.Bind(wx.EVT_MENU, self.taskBarIcon.OnExit, id=wx.ID_EXIT)

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_ICONIZE, self.OnMinimize)