Exemplo n.º 1
0
 def addsubmenu(self, label, title = ''):
     sub = Menu(self.bar, title, -1)
     item = self.additem(label, '\x1b', None, 'submenu')
     self.menu.SetItemMark(item, sub.id)
     sub._parent = self
     sub._parent_item = item
     return sub
Exemplo n.º 2
0
 def addsubmenu(self, label, title=""):
     sub = Menu(self.bar, title, -1)
     item = self.additem(label, "\x1B", None, "submenu")
     self.menu.SetItemMark(item, sub.id)
     sub._parent = self
     sub._parent_item = item
     return sub
Exemplo n.º 3
0
 def addsubmenu(self, label, title = ''):
     sub = Menu(self.bar, title, -1)
     item = self.additem(label, '\x1b', None, 'submenu')
     self.menu.SetItemMark(item, sub.id)
     sub._parent = self
     sub._parent_item = item
     return sub
Exemplo n.º 4
0
 def __init__(self):
     self.quitting = 0
     self.appleid = 1
     self.quitid = 2
     Menu.ClearMenuBar()
     self.applemenu = applemenu = Menu.NewMenu(self.appleid, '\x14')
     applemenu.AppendMenu('%s;(-' % self.getaboutmenutext())
     if MacOS.runtimemodel == 'ppc':
         applemenu.AppendResMenu('DRVR')
     applemenu.InsertMenu(0)
     self.quitmenu = Menu.NewMenu(self.quitid, 'File')
     self.quitmenu.AppendMenu('Quit')
     self.quitmenu.SetItemCmd(1, ord('Q'))
     self.quitmenu.InsertMenu(0)
     Menu.DrawMenuBar()
 def __init__(self):
     self.quitting = 0
     # Initialize menu
     self.appleid = 1
     self.quitid = 2
     Menu.ClearMenuBar()
     self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
     applemenu.AppendMenu("%s;(-" % self.getaboutmenutext())
     if MacOS.runtimemodel == 'ppc':
         applemenu.AppendResMenu('DRVR')
     applemenu.InsertMenu(0)
     self.quitmenu = Menu.NewMenu(self.quitid, "File")
     self.quitmenu.AppendMenu("Quit")
     self.quitmenu.SetItemCmd(1, ord("Q"))
     self.quitmenu.InsertMenu(0)
     Menu.DrawMenuBar()
Exemplo n.º 6
0
    def lowlevelhandler(self, event):
        what, message, when, where, modifiers = event
        h, v = where
        if what == kHighLevelEvent:
            msg = 'High Level Event: %r %r' % (code(message),
                                               code(h | v << 16))
            try:
                AE.AEProcessAppleEvent(event)
            except AE.Error as err:
                print 'AE error: ', err
                print 'in', msg
                traceback.print_exc()

            return
        if what == keyDown:
            c = chr(message & charCodeMask)
            if modifiers & cmdKey:
                if c == '.':
                    raise KeyboardInterrupt, 'Command-period'
                if c == 'q':
                    if hasattr(MacOS, 'OutputSeen'):
                        MacOS.OutputSeen()
                    self.quitting = 1
                    return
        elif what == mouseDown:
            partcode, window = Win.FindWindow(where)
            if partcode == inMenuBar:
                result = Menu.MenuSelect(where)
                id = result >> 16 & 65535
                item = result & 65535
                if id == self.appleid:
                    if item == 1:
                        EasyDialogs.Message(self.getabouttext())
                    elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
                        name = self.applemenu.GetMenuItemText(item)
                        Menu.OpenDeskAcc(name)
                elif id == self.quitid and item == 1:
                    if hasattr(MacOS, 'OutputSeen'):
                        MacOS.OutputSeen()
                    self.quitting = 1
                Menu.HiliteMenu(0)
                return
        if hasattr(MacOS, 'HandleEvent'):
            MacOS.HandleEvent(event)
        else:
            print 'Unhandled event:', event
Exemplo n.º 7
0
 def open(self):
     import W
     Dialog.open(self)
     self.app = W.getapplication()
     self.done = 0
     Menu.HiliteMenu(0)
     app = self.parent
     app.enablemenubar(0)
     try:
         self.mainloop()
     finally:
         app.enablemenubar(1)
Exemplo n.º 8
0
def _setmenu(control, items):
    mhandle = control.GetControlData_Handle(Controls.kControlMenuPart, Controls.kControlPopupButtonMenuHandleTag)
    menu = Menu.as_Menu(mhandle)
    for item in items:
        if type(item) == type(()):
            label = item[0]
        else:
            label = item
        if label[-1] == '=' or label[-1] == ':':
            label = label[:-1]
        menu.AppendMenu(label)

    control.SetControlMinimum(1)
    control.SetControlMaximum(len(items) + 1)
Exemplo n.º 9
0
 def makeusermenus(self):
     self.filemenu = m = Menu(self.menubar, 'File')
     self.saveitem = MenuItem(m, 'Save', 'S', self.save)
     Separator(m)
     self.optionsmenu = mm = SubMenu(m, 'Options')
     self.opt1 = CheckItem(mm, 'Arguments', 'A')
     self.opt2 = CheckItem(mm, 'Being hit on the head lessons', (kMenuOptionModifier, 'A'))
     self.opt3 = CheckItem(mm, 'Complaints', (kMenuOptionModifier | kMenuNoCommandModifier, 'A'))
     Separator(m)
     self.itemeh = MenuItem(m, 'Enable Help', None, self.enablehelp)
     self.itemdbg = MenuItem(m, 'Debug', None, self.debug)
     Separator(m)
     self.quititem = MenuItem(m, 'Quit', 'Q', self.quit)
     return
Exemplo n.º 10
0
 def do_key(self, event):
     (what, message, when, where, modifiers) = event
     #w = Win.FrontWindow()
     #if w <> self.wid:
     #       return
     c = chr(message & Events.charCodeMask)
     if modifiers & Events.cmdKey:
         self.app.checkmenus(self)
         result = Menu.MenuKey(ord(c))
         id = (result >> 16) & 0xffff  # Hi word
         item = result & 0xffff  # Lo word
         if id:
             self.app.do_rawmenu(id, item, None, event)
             return
     self.do_char(c, event)
Exemplo n.º 11
0
def _setmenu(control, items):
    mhandle = control.GetControlData_Handle(
        Controls.kControlMenuPart, Controls.kControlPopupButtonMenuHandleTag)
    menu = Menu.as_Menu(mhandle)
    for item in items:
        if type(item) == type(()):
            label = item[0]
        else:
            label = item
        if label[-1] == '=' or label[-1] == ':':
            label = label[:-1]
        menu.AppendMenu(label)

    control.SetControlMinimum(1)
    control.SetControlMaximum(len(items) + 1)
Exemplo n.º 12
0
 def makeusermenus(self):
     self.filemenu = m = Menu(self.menubar, "File")
     self.saveitem = MenuItem(m, "Save", "S", self.save)
     Separator(m)
     self.optionsmenu = mm = SubMenu(m, "Options")
     self.opt1 = CheckItem(mm, "Arguments", "A")
     self.opt2 = CheckItem(mm, "Being hit on the head lessons",
                           (kMenuOptionModifier, "A"))
     self.opt3 = CheckItem(
         mm, "Complaints",
         (kMenuOptionModifier | kMenuNoCommandModifier, "A"))
     Separator(m)
     self.itemeh = MenuItem(m, "Enable Help", None, self.enablehelp)
     self.itemdbg = MenuItem(m, "Debug", None, self.debug)
     Separator(m)
     self.quititem = MenuItem(m, "Quit", "Q", self.quit)
Exemplo n.º 13
0
"""Easy to use dialogs.
Exemplo n.º 14
0
"""Easy to use dialogs.
Exemplo n.º 15
0
"""MiniAEFrame - A minimal AppleEvent Application framework.
Exemplo n.º 16
0
"""'echo' -- an AppleEvent handler which handles all events the same.
Exemplo n.º 17
0
 def makeusermenus(self):
     self.filemenu = m = Menu(self.menubar, 'File')
     self._quititem = MenuItem(m, 'Quit', 'Q', self._quit)
Exemplo n.º 18
0
    def __init__(self, parent, id, title):

        self.progress = None	# Current progress dialog (or None)
        self.logname = None
        
        wx.Frame.__init__(self,parent,id,title)

        if platform=='win32':
            self.SetIcon(wx.Icon(executable, wx.BITMAP_TYPE_ICO))
        elif platform.lower().startswith('linux'):	# PNG supported by GTK
            icons=wx.IconBundle()
            icons.AddIconFromFile('Resources/%s.png' % appname, wx.BITMAP_TYPE_PNG)
            icons.AddIconFromFile('Resources/%s-128.png'% appname, wx.BITMAP_TYPE_PNG)
            self.SetIcons(icons)
        elif platform=='darwin':
            # icon pulled from Resources via Info.plist (except for MessageBox icon). Need minimal menu
            menubar = wx.MenuBar()
            helpmenu = wx.Menu()
            helpmenu.Append(wx.ID_HELP, '%s Help\tCtrl-?'  % appname)
            wx.EVT_MENU(self, wx.ID_HELP, self.onHelp)
            helpmenu.Append(wx.ID_ABOUT, 'About %s'  % appname)
            wx.EVT_MENU(self, wx.ID_ABOUT, self.onAbout)
            # ID_EXIT moved to application menu
            helpmenu.Append(wx.ID_EXIT, u'Quit %s\tCtrl-Q' % appname)
            wx.EVT_MENU(self, wx.ID_EXIT, self.onClose)
            menubar.Append(helpmenu, '&Help')
            self.SetMenuBar(menubar)

        panel0 = wx.Panel(self,-1)
        panel1 = wx.Panel(panel0,-1)
        panel2 = wx.Panel(panel0,-1)
        panel3 = wx.Panel(panel0,-1)

        # 1st panel
        self.fspath=wx.TextCtrl(panel1, -1, fspath)
        self.fsbrowse=wx.Button(panel1, FSBROWSE, browse)
        self.lbpath=wx.TextCtrl(panel1, -1, lbpath)
        self.lbbrowse=wx.Button(panel1, LBBROWSE, browse)
        self.xppath=wx.TextCtrl(panel1, -1, xppath)
        self.xpbrowse=wx.Button(panel1, XPBROWSE, browse)
        grid1 = wx.FlexGridSizer(3, 3, 7, 7)
        grid1.AddGrowableCol(1,proportion=1)
        grid1.SetFlexibleDirection(wx.HORIZONTAL)
        grid1.Add(wx.StaticText(panel1, -1, "MSFS scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.fspath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.fsbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "Additional MSFS libraries: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.lbpath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.lbbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "X-Plane scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.xppath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.xpbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        panel1.SetSizer(grid1)

        wx.EVT_BUTTON(self, FSBROWSE, self.onFSbrowse)
        wx.EVT_BUTTON(self, LBBROWSE, self.onLBbrowse)
        wx.EVT_BUTTON(self, XPBROWSE, self.onXPbrowse)

        # 2nd panel
        self.xpver  = wx.RadioBox(panel2,-1, "Minimum X-Plane version:",
                                  choices=["v8", "v9", "v10"])
        self.xpver.SetSelection(2)	# v10 default
        self.season = wx.RadioBox(panel2,-1, "Season:",
                                  choices=["Spring", "Summer",
                                           "Autumn", "Winter"])
        self.dumplib= wx.CheckBox(panel2,-1, "Just extract library objects")
        # use panel and sizer so tab order works normally
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        box2.Add(self.xpver, 0)
        box2.Add(self.season, 0, wx.LEFT, 10)
        box2.Add([0,0], 1, wx.LEFT, 10)	# push following buttons to right
        box2.Add(self.dumplib, 0, wx.TOP|wx.EXPAND, 8)
        panel2.SetSizer(box2)

        wx.EVT_CHECKBOX(self, self.dumplib.GetId(), self.onDump)

        
        # 3rd panel - adjust order of buttons per Windows or Mac conventions
        if platform=='darwin':
            button31=wx.Button(panel3, wx.ID_EXIT)
            button32=wx.Button(panel3, wx.ID_APPLY, "Convert")
            button33=wx.Button(panel3, wx.ID_HELP)
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add([24,0], 0)	# cosmetic - balance button31
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button32.SetDefault()
        else:
            button31=wx.Button(panel3, wx.ID_HELP)
            if platform=='win32':
                button32=wx.Button(panel3, wx.ID_EXIT)
            else:
                button32=wx.Button(panel3, wx.ID_CLOSE)
            button33=wx.Button(panel3, wx.ID_APPLY, "Convert")
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button33.SetDefault()
        panel3.SetSizer(box3)
        
        wx.EVT_BUTTON(self, wx.ID_HELP, self.onHelp)
        wx.EVT_BUTTON(self, wx.ID_APPLY, self.onConvert)
        wx.EVT_BUTTON(self, wx.ID_CLOSE, self.onClose)
        wx.EVT_BUTTON(self, wx.ID_EXIT, self.onClose)


        # Top level
        box0 = wx.BoxSizer(wx.VERTICAL)
        box0.Add(panel1, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel2, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel3, 0, wx.ALL|wx.EXPAND, 7)
        panel0.SetSizer(box0)

        border = wx.BoxSizer()
        border.Add(panel0, 1, wx.EXPAND)
        self.SetSizer(border)

        # Go
        sz=self.GetBestSize()
        if wx.VERSION<(2,6):
            # Hack - Can't get min size to work properly in 2.5
            height=sz.height+42
        else:
            height=sz.height            
        self.SetSize((800, height))
        # +50 is a hack cos I can't work out how to change minsize of TextCtrl
        self.SetSizeHints(sz.width, height, -1, height)
        self.Show(True)

        if platform=='darwin':
            # Change name on application menu. Can't do this in wx.
            try:	# Carbon
                from Carbon import Menu
                Menu.GetMenuHandle(1).SetMenuTitleWithCFString(appname)		# wxMac always uses id 1.
            except:
                try:	# Cocoa
                    import AppKit
                    # doesn't work: AppKit.NSApp.mainMenu().itemAtIndex_(0).submenu().setTitle_(appname)	 http://www.mail-archive.com/[email protected]/msg43196.html
                    AppKit.NSBundle.mainBundle().infoDictionary()['CFBundleName']=appname
                except:
                    if __debug__: print_exc()

        if newfsroot: myMessageBox('Install MSFS sceneries under: \n%s ' % newfsroot, 'Created a fake MSFS installation.', wx.ICON_INFORMATION|wx.OK, self)
         traceback.print_exc()
     return
 elif what == keyDown:
     c = chr(message & charCodeMask)
     if modifiers & cmdKey:
         if c == '.':
             raise KeyboardInterrupt, "Command-period"
         if c == 'q':
             if hasattr(MacOS, 'OutputSeen'):
                 MacOS.OutputSeen()
             self.quitting = 1
             return
 elif what == mouseDown:
     partcode, window = Win.FindWindow(where)
     if partcode == inMenuBar:
         result = Menu.MenuSelect(where)
         id = (result >> 16) & 0xffff  # Hi word
         item = result & 0xffff  # Lo word
         if id == self.appleid:
             if item == 1:
                 EasyDialogs.Message(self.getabouttext())
             elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
                 name = self.applemenu.GetMenuItemText(item)
                 Menu.OpenDeskAcc(name)
         elif id == self.quitid and item == 1:
             if hasattr(MacOS, 'OutputSeen'):
                 MacOS.OutputSeen()
             self.quitting = 1
         Menu.HiliteMenu(0)
         return
 # Anything not handled is passed to Python/SIOUX
Exemplo n.º 20
0
 def makeusermenus(self):
     self.filemenu = m = Menu(self.menubar, "File")
     self._quititem = MenuItem(m, "Quit", "Q", self._quit)
Exemplo n.º 21
0
"A sort of application framework for the Mac"
Exemplo n.º 22
0
"""AEservertest - Test AppleEvent server interface