Example #1
0
def zoom_height(top):
    geom = top.wm_geometry()
    m = re.match('(\\d+)x(\\d+)\\+(-?\\d+)\\+(-?\\d+)', geom)
    if not m:
        top.bell()
        return
    width, height, x, y = map(int, m.groups())
    newheight = top.winfo_screenheight()
    if sys.platform == 'win32':
        newy = 0
        newheight = newheight - 72
    elif macosxSupport.isAquaTk():
        newy = 22
        newheight = newheight - newy - 88
    else:
        newy = 0
        newheight = newheight - 88
    if height >= newheight:
        newgeom = ''
    else:
        newgeom = '%dx%d+%d+%d' % (width,
         newheight,
         x,
         newy)
    top.wm_geometry(newgeom)
Example #2
0
def zoom_height(top):
    geom = top.wm_geometry()
    m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
    if not m:
        top.bell()
        return
    width, height, x, y = map(int, m.groups())
    newheight = top.winfo_screenheight()
    if sys.platform == 'win32':
        newy = 0
        newheight = newheight - 72

    elif macosxSupport.isAquaTk():
        # The '88' below is a magic number that avoids placing the bottom
        # of the window below the panel on my machine. I don't know how
        # to calculate the correct value for this with tkinter.
        newy = 22
        newheight = newheight - newy - 88

    else:
        #newy = 24
        newy = 0
        #newheight = newheight - 96
        newheight = newheight - 88
    if height >= newheight:
        newgeom = ""
    else:
        newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
    top.wm_geometry(newgeom)
 def __init__(self, master, **options):
     # Create top frame, with scrollbar and listbox
     self.master = master
     self.frame = frame = Frame(master)
     self.frame.pack(fill="both", expand=1)
     self.vbar = vbar = Scrollbar(frame, name="vbar")
     self.vbar.pack(side="right", fill="y")
     self.listbox = listbox = Listbox(frame, exportselection=0,
         background="white")
     if options:
         listbox.configure(options)
     listbox.pack(expand=1, fill="both")
     # Tie listbox and scrollbar together
     vbar["command"] = listbox.yview
     listbox["yscrollcommand"] = vbar.set
     # Bind events to the list box
     listbox.bind("<ButtonRelease-1>", self.click_event)
     listbox.bind("<Double-ButtonRelease-1>", self.double_click_event)
     if macosxSupport.isAquaTk():
         listbox.bind("<ButtonPress-2>", self.popup_event)
         listbox.bind("<Control-Button-1>", self.popup_event)
     else:
         listbox.bind("<ButtonPress-3>", self.popup_event)
     listbox.bind("<Key-Up>", self.up_event)
     listbox.bind("<Key-Down>", self.down_event)
     # Mark as empty
     self.clear()
Example #4
0
 def __init__(self, master, flist, gui):
     if macosxSupport.isAquaTk():
         ScrolledList.__init__(self, master)
     else:
         ScrolledList.__init__(self, master, width=80)
     self.flist = flist
     self.gui = gui
     self.stack = []
Example #5
0
 def __init__(self, master, flist, gui):
     if macosxSupport.isAquaTk():
         # At least on with the stock AquaTk version on OSX 10.4 you'll
         # get an shaking GUI that eventually kills IDLE if the width
         # argument is specified.
         ScrolledList.__init__(self, master)
     else:
         ScrolledList.__init__(self, master, width=80)
     self.flist = flist
     self.gui = gui
     self.stack = []
Example #6
0
 def CreateWidgets(self):
     self.tabPages = TabbedPageSet(self, page_names=['Fonts/Tabs',
      'Highlighting',
      'Keys',
      'General'])
     frameActionButtons = Frame(self, pady=2)
     if macosxSupport.isAquaTk():
         paddingArgs = {}
     else:
         paddingArgs = {'padx': 6,
          'pady': 3}
     self.buttonOk = Button(frameActionButtons, text='Ok', command=self.Ok, takefocus=FALSE, **paddingArgs)
     self.buttonApply = Button(frameActionButtons, text='Apply', command=self.Apply, takefocus=FALSE, **paddingArgs)
     self.buttonCancel = Button(frameActionButtons, text='Cancel', command=self.Cancel, takefocus=FALSE, **paddingArgs)
     self.CreatePageFontTab()
     self.CreatePageHighlight()
     self.CreatePageKeys()
     self.CreatePageGeneral()
     self.buttonOk.pack(side=LEFT, padx=5)
     self.buttonApply.pack(side=LEFT, padx=5)
     self.buttonCancel.pack(side=LEFT, padx=5)
     frameActionButtons.pack(side=BOTTOM)
     Frame(self, height=2, borderwidth=0).pack(side=BOTTOM)
     self.tabPages.pack(side=TOP, expand=TRUE, fill=BOTH)
 def CreateWidgets(self):
     self.tabPages = TabbedPageSet(self, page_names=['Fonts/Tabs',
      'Highlighting',
      'Keys',
      'General'])
     frameActionButtons = Frame(self, pady=2)
     if macosxSupport.isAquaTk():
         paddingArgs = {}
     else:
         paddingArgs = {'padx': 6,
          'pady': 3}
     self.buttonOk = Button(frameActionButtons, text='Ok', command=self.Ok, takefocus=FALSE, **paddingArgs)
     self.buttonApply = Button(frameActionButtons, text='Apply', command=self.Apply, takefocus=FALSE, **paddingArgs)
     self.buttonCancel = Button(frameActionButtons, text='Cancel', command=self.Cancel, takefocus=FALSE, **paddingArgs)
     self.CreatePageFontTab()
     self.CreatePageHighlight()
     self.CreatePageKeys()
     self.CreatePageGeneral()
     self.buttonOk.pack(side=LEFT, padx=5)
     self.buttonApply.pack(side=LEFT, padx=5)
     self.buttonCancel.pack(side=LEFT, padx=5)
     frameActionButtons.pack(side=BOTTOM)
     Frame(self, height=2, borderwidth=0).pack(side=BOTTOM)
     self.tabPages.pack(side=TOP, expand=TRUE, fill=BOTH)
Example #8
0
def main():
    global use_subprocess
    global root
    global flist
    capture_warnings(True)
    use_subprocess = True
    enable_shell = False
    enable_edit = False
    debug = False
    cmd = None
    script = None
    startup = False
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'c:deihnr:st:')
    except getopt.error as msg:
        sys.stderr.write('Error: %s\n' % str(msg))
        sys.stderr.write(usage_msg)
        sys.exit(2)

    for o, a in opts:
        if o == '-c':
            cmd = a
            enable_shell = True
        if o == '-d':
            debug = True
            enable_shell = True
        if o == '-e':
            enable_edit = True
        if o == '-h':
            sys.stdout.write(usage_msg)
            sys.exit()
        if o == '-i':
            enable_shell = True
        if o == '-n':
            use_subprocess = False
        if o == '-r':
            script = a
            if os.path.isfile(script):
                pass
            else:
                print 'No script file: ', script
                sys.exit()
            enable_shell = True
        if o == '-s':
            startup = True
            enable_shell = True
        if o == '-t':
            PyShell.shell_title = a
            enable_shell = True

    if args and args[0] == '-':
        cmd = sys.stdin.read()
        enable_shell = True
    for i in range(len(sys.path)):
        sys.path[i] = os.path.abspath(sys.path[i])

    if args and args[0] == '-':
        sys.argv = [''] + args[1:]
    elif cmd:
        sys.argv = ['-c'] + args
    elif script:
        sys.argv = [script] + args
    elif args:
        enable_edit = True
        pathx = []
        for filename in args:
            pathx.append(os.path.dirname(filename))

        for dir in pathx:
            dir = os.path.abspath(dir)
            if dir not in sys.path:
                sys.path.insert(0, dir)

    else:
        dir = os.getcwd()
        if dir not in sys.path:
            sys.path.insert(0, dir)
    edit_start = idleConf.GetOption('main', 'General', 'editor-on-startup', type='bool')
    enable_edit = enable_edit or edit_start
    enable_shell = enable_shell or not enable_edit
    root = Tk(className='Idle')
    icondir = os.path.join(os.path.dirname(__file__), 'Icons')
    if system() == 'Windows':
        iconfile = os.path.join(icondir, 'idle.ico')
        root.wm_iconbitmap(default=iconfile)
    elif TkVersion >= 8.5:
        ext = '.png' if TkVersion >= 8.6 else '.gif'
        iconfiles = [ os.path.join(icondir, 'idle_%d%s' % (size, ext)) for size in (16, 32, 48) ]
        icons = [ PhotoImage(file=iconfile) for iconfile in iconfiles ]
        root.tk.call('wm', 'iconphoto', str(root), '-default', *icons)
    fixwordbreaks(root)
    root.withdraw()
    flist = PyShellFileList(root)
    macosxSupport.setupApp(root, flist)
    if enable_edit:
        if not (cmd or script):
            for filename in args[:]:
                if flist.open(filename) is None:
                    args.remove(filename)

            if not args:
                flist.new()
    if enable_shell:
        shell = flist.open_shell()
        if not shell:
            return
        if macosxSupport.isAquaTk() and flist.dict:
            shell.top.lower()
    else:
        shell = flist.pyshell
    if debug:
        shell.open_debugger()
    if startup:
        filename = os.environ.get('IDLESTARTUP') or os.environ.get('PYTHONSTARTUP')
        if filename and os.path.isfile(filename):
            shell.interp.execfile(filename)
    if cmd or script:
        shell.interp.runcommand('if 1:\n            import sys as _sys\n            _sys.argv = %r\n            del _sys\n            \n' % (sys.argv,))
        if cmd:
            shell.interp.execsource(cmd)
        elif script:
            shell.interp.prepend_syspath(script)
            shell.interp.execfile(script)
    elif shell:
        tkversionwarning = macosxSupport.tkVersionWarning(root)
        if tkversionwarning:
            shell.interp.runcommand("print('%s')" % tkversionwarning)
    while flist.inversedict:
        root.mainloop()

    root.destroy()
    capture_warnings(False)
    return