예제 #1
0
def GetType():
    """Ask user for distribution type"""
    while 1:
        d = Dlg.GetNewDialog(ID_DTYPE, -1)
        d.SetDialogDefaultItem(DTYPE_EXIST)
        d.SetDialogCancelItem(DTYPE_CANCEL)
        while 1:
            rv = ModalDialog(None)
            if rv in (DTYPE_EXIST, DTYPE_NEW, DTYPE_CANCEL):
                break
        del d
        if rv == DTYPE_CANCEL:
            sys.exit(0)
        if rv == DTYPE_EXIST:
            ##			macfs.SetFolder(':(MkDistr)')
            fss, ok = macfs.StandardGetFile('TEXT')
            if not ok:
                sys.exit(0)
            path = fss.as_pathname()
            basename = os.path.split(path)[-1]
            if basename[-8:] <> '.include':
                EasyDialogs.Message('That is not a distribution include file')
            else:
                return basename[:-8]
        else:
            name = EasyDialogs.AskString('Distribution name:')
            if name:
                return name
            sys.exit(0)
예제 #2
0
def do_dialog():
    """Post dialog and handle user interaction until quit"""
    my_dlg = Dlg.GetNewDialog(ID_MAIN, -1)
    while 1:
        n = Dlg.ModalDialog(None)
        if n == ITEM_LOOKUP_BUTTON:
            tp, h, rect = my_dlg.GetDialogItem(ITEM_LOOKUP_ENTRY)
            txt = Dlg.GetDialogItemText(h)

            tp, h, rect = my_dlg.GetDialogItem(ITEM_RESULT)
            Dlg.SetDialogItemText(h, dnslookup(txt))
        elif n == ITEM_QUIT_BUTTON:
            break
예제 #3
0
파일: splash.py 프로젝트: ystallonne/grins
def splash(arg=0, version=None):
    global firsttime, _dialog, _starttime
    if not firsttime:
        return
    if version and not arg:
        return
    if not arg:
        _dialog = None
        firsttime = 0
    else:
        if not _dialog:
            d = Dlg.GetNewDialog(RESOURCE_ID, -1)
            d.GetDialogWindow().ShowWindow()
            d.DrawDialog()
            _dialog = d
        setitem(ITEM_MSG, MESSAGE[arg])
예제 #4
0
def _ModalDialog(title,
                 dialogid,
                 text,
                 okcallback,
                 cancelcallback=None,
                 identity=None):
    d = Dlg.GetNewDialog(dialogid, -1)
    d.SetDialogDefaultItem(ITEM_QUESTION_OK)
    if cancelcallback:
        d.SetDialogCancelItem(ITEM_QUESTION_CANCEL)
    h = d.GetDialogItemAsControl(ITEM_QUESTION_TEXT)
    if not identity:
        d.HideDialogItem(ITEM_QUESTION_NOTAGAIN)
    text = _string2dialog(text)
    Dlg.SetDialogItemText(h, text)
    d.AutoSizeDialog()
    w = d.GetDialogWindow()
    w.ShowWindow()
    while 1:
        n = Dlg.ModalDialog(None)
        if n == ITEM_QUESTION_OK:
            if identity:
                ctl = d.GetDialogItemAsControl(ITEM_QUESTION_NOTAGAIN)
                if ctl.GetControlValue():
                    _dont_show_again_identities[identity] = 1
            del d
            del w
            if okcallback:
                func, arglist = okcallback
                apply(func, arglist)
            return
        elif n == ITEM_QUESTION_CANCEL:
            del d
            del w
            if cancelcallback:
                func, arglist = cancelcallback
                apply(func, arglist)
            return
        elif n == ITEM_QUESTION_NOTAGAIN:
            ctl = d.GetDialogItemAsControl(ITEM_QUESTION_NOTAGAIN)
            ctl.SetControlValue(not ctl.GetControlValue())
        else:
            print 'Unknown modal dialog item', n
예제 #5
0
def dodialog():
    d = Dlg.GetNewDialog(DIALOG_ID, -1)
    d.SetDialogDefaultItem(I_OK)
    d.SetDialogCancelItem(I_CANCEL)
    results = [0]*N_BUTTONS
    while 1:
        n = Dlg.ModalDialog(None)
        if n == I_OK:
            break
        if n == I_CANCEL:
            return []
        if n < N_BUTTONS:
            results[n] = (not results[n])
            h = d.GetDialogItemAsControl(n)
            h.SetControlValue(results[n])
    rv = []
    for i in range(len(results)):
        if results[i]:
            rv.append(i)
    return rv
예제 #6
0
파일: macfreezegui.py 프로젝트: mmrvka/xbmc
def dialog(script=None):

    # Invent the various names
    if not script:
        fss, ok = macfs.PromptGetFile("Script?", "TEXT")
        if not ok:
            sys.exit(0)
        script = fss.as_pathname()
    basename, ext = os.path.splitext(script)
    if ext:
        appletname = basename
        rsrcname = basename + 'modules.rsrc'
    else:
        appletname = script + '.applet'
        rsrcname = script + 'modules.rsrc'
    dirname, basebase = os.path.split(basename)
    dirname = os.path.join(dirname, 'build.'+basebase)

    # Get the dialog, possibly opening the resource file (if needed)
    macresource.need('DLOG', ID_MAINDIALOG, 'macfreeze.rsrc')
    d = Dlg.GetNewDialog(ID_MAINDIALOG, -1)
    if d == None:
        EasyDialogs.Message("Dialog resource not found or faulty")
        sys.exit(1)

    # Fill the dialog
    d.SetDialogDefaultItem(ITEM_OK)
    d.SetDialogCancelItem(ITEM_CANCEL)

    _dialogsetfile(d, ITEM_SCRIPTNAME, script)
    _dialogsetfile(d, ITEM_SOURCEDIRNAME, dirname)
    _dialogsetfile(d, ITEM_RESOURCENAME, rsrcname)
    _dialogsetfile(d, ITEM_APPLETNAME, appletname)

    gentype = ITEM_GENSOURCE
    _dialogradiogroup(d, ITEM_GENSOURCE)

    # Interact
    d.GetDialogWindow().SetWTitle("Standalone application creation options")
    d.GetDialogWindow().ShowWindow()
    d.DrawDialog()
    while 1:
        item = Dlg.ModalDialog(None)
        if item == ITEM_OK:
            break
        elif item == ITEM_CANCEL:
            sys.exit(0)
        elif item in RADIO_GROUPING.keys():
            gentype = item
            _dialogradiogroup(d, item)
        elif item == ITEM_SCRIPTBROWSE:
            fss, ok = macfs.PromptGetFile("Script?")
            if ok:
                script = fss.as_pathname()
                _dialogsetfile(d, ITEM_SCRIPTNAME, script)
        elif item == ITEM_SOURCEDIRBROWSE:
            fss, ok = macfs.StandardPutFile("Output folder name", os.path.split(dirname)[1])
            if ok:
                dirname = fss.as_pathname()
                _dialogsetfile(d, ITEM_SOURCEDIRNAME, dirname)
        elif item == ITEM_RESOURCEBROWSE:
            fss, ok = macfs.StandardPutFile("Resource output file", os.path.split(rsrcname)[1])
            if ok:
                rsrcname = fss.as_pathname()
                _dialogsetfile(d, ITEM_RESOURCENAME, rsrcname)
        elif item == ITEM_APPLETBROWSE:
            fss, ok = macfs.StandardPutFile("Applet output file", os.path.split(appletname)[1])
            if ok:
                appletname = fss.as_pathname()
                _dialogsetfile(d, ITEM_APPLETNAME, appletname)
        else:
            pass
    tp, h, rect = d.GetDialogItem(ITEM_DEBUG)
    debug = Dlg.GetDialogItemText(h)
    try:
        debug = string.atoi(string.strip(debug))
    except ValueError:
        EasyDialogs.Message("Illegal debug value %r, set to zero."%(debug,))
        debug = 0
    if gentype == ITEM_GENSOURCE:
        return 'source', script, dirname, debug
    elif gentype == ITEM_GENRESOURCE:
        return 'resource', script, rsrcname, debug
    elif gentype == ITEM_GENAPPLET:
        return 'applet', script, appletname, debug
    elif gentype == ITEM_GENINFO:
        return 'info', script, '', debug
    raise 'Error in gentype', gentype
예제 #7
0
"""Sample program performing domain name lookups and showing off EasyDialogs,
예제 #8
0
import FrameWork
예제 #9
0
"""Create a standalone application from a Python script.
예제 #10
0
from Carbon import Dlg
from Carbon import Res

splash = Dlg.GetNewDialog(468, -1)
splash.DrawDialog()

from Carbon import Qd, TE, Fm

from Carbon import Win
from Carbon.Fonts import *
from Carbon.QuickDraw import *
from Carbon.TextEdit import teJustCenter
import string
import sys

_about_width = 440
_about_height = 340

_keepsplashscreenopen = 0

abouttext1 = """The Python Integrated Development Environment for the Macintosh\xaa
Version: %s
Copyright 1997-2001 Just van Rossum, Letterror. <*****@*****.**>
Python %s
%s
See: <http://www.python.org/> for information and documentation."""

flauwekul = [
    "Goodday, Bruce.", "What's new?", "Nudge, nudge, say no more!",
    "No, no sir, it's not dead. It's resting.", "Albatros!", "It's . . .",
    "Is your name not Bruce, then?",
예제 #11
0
"""Import a module while pretending its name is __main__. This
예제 #12
0
#
예제 #13
0
파일: run.py 프로젝트: mcyril/ravel-ftn
# Script (applet) to run any Python command
예제 #14
0
"""macfreezegui - The GUI for macfreeze"""
예제 #15
0
 def do_about(self, *args):
     f = Dlg.GetNewDialog(ID_ABOUT, -1)
     while 1:
         n = Dlg.ModalDialog(None)
         if n == 1:
             return
예제 #16
0
def about():
    global splash, splashresfile, _keepsplashscreenopen
    _keepsplashscreenopen = 1
    splash = Dlg.GetNewDialog(468, -1)
    splash.DrawDialog()
    wait()
예제 #17
0
#