def __init__(self): self.template = "%s, %d point" self.fontsettings, self.tabsettings, self.windowsize = geteditorprefs() self.w = W.Dialog((328, 120), "Editor default settings") self.w.setfontbutton = W.Button((8, 8, 80, 16), "Set font\xc9", self.dofont) self.w.fonttext = W.TextBox((98, 10, -8, 14), self.template % (self.fontsettings[0], self.fontsettings[2])) self.w.picksizebutton = W.Button((8, 50, 80, 16), "Front window", self.picksize) self.w.xsizelabel = W.TextBox((98, 32, 40, 14), "Width:") self.w.ysizelabel = W.TextBox((148, 32, 40, 14), "Height:") self.w.xsize = W.EditText((98, 48, 40, 20), repr(self.windowsize[0])) self.w.ysize = W.EditText((148, 48, 40, 20), repr(self.windowsize[1])) self.w.cancelbutton = W.Button((-180, -26, 80, 16), "Cancel", self.cancel) self.w.okbutton = W.Button((-90, -26, 80, 16), "Done", self.ok) self.w.setdefaultbutton(self.w.okbutton) self.w.bind('cmd.', self.w.cancelbutton.push) self.w.open()
def setupwidgets(self, text): topbarheight = 24 popfieldwidth = 80 self.lastlineno = None # make an editor self.editgroup = W.Group((0, topbarheight + 1, 0, 0)) editor = W.PyEditor((0, 0, -15,-15), text, fontsettings = self.fontsettings, tabsettings = self.tabsettings, file = self.getfilename()) # make the widgets self.popfield = ClassFinder((popfieldwidth - 17, -15, 16, 16), [], self.popselectline) self.linefield = W.EditText((-1, -15, popfieldwidth - 15, 16), inset = (6, 1)) self.editgroup._barx = W.Scrollbar((popfieldwidth - 2, -15, -14, 16), editor.hscroll, max = 32767) self.editgroup._bary = W.Scrollbar((-15, 14, 16, -14), editor.vscroll, max = 32767) self.editgroup.editor = editor # add editor *after* scrollbars self.editgroup.optionsmenu = W.PopupMenu((-15, -1, 16, 16), []) self.editgroup.optionsmenu.bind('<click>', self.makeoptionsmenu) self.bevelbox = W.BevelBox((0, 0, 0, topbarheight)) self.hline = W.HorizontalLine((0, topbarheight, 0, 0)) self.infotext = W.TextBox((175, 6, -4, 14), backgroundcolor = (0xe000, 0xe000, 0xe000)) self.runbutton = W.BevelButton((6, 4, 80, 16), runButtonLabels[0], self.run) self.runselbutton = W.BevelButton((90, 4, 80, 16), runSelButtonLabels[0], self.runselection) # bind some keys editor.bind("cmdr", self.runbutton.push) editor.bind("enter", self.runselbutton.push) editor.bind("cmdj", self.domenu_gotoline) editor.bind("cmdd", self.domenu_toggledebugger) editor.bind("<idle>", self.updateselection) editor.bind("cmde", searchengine.setfindstring) editor.bind("cmdf", searchengine.show) editor.bind("cmdg", searchengine.findnext) editor.bind("cmdshiftr", searchengine.replace) editor.bind("cmdt", searchengine.replacefind) self.linefield.bind("return", self.dolinefield) self.linefield.bind("enter", self.dolinefield) self.linefield.bind("tab", self.dolinefield) # intercept clicks editor.bind("<click>", self.clickeditor) self.linefield.bind("<click>", self.clicklinefield)
def setupwidgets(self): DESCRIPTION_HEIGHT = 140 INSTALL_POS = -30 STATUS_POS = INSTALL_POS - (70 + DESCRIPTION_HEIGHT) self.w = W.Window((580, 600), "Python Install Manager", minsize=(400, 400), tabbable=0) self.w.titlebar = W.TextBox((4, 8, 60, 18), 'Packages:') self.w.hidden_button = W.CheckBox((-100, 4, 0, 18), 'Show Hidden', self.updatestatus) data = self.getbrowserdata() self.w.packagebrowser = W.MultiList((4, 24, 0, STATUS_POS - 2), data, self.listhit, cols=3) self.w.installed_l = W.TextBox((4, STATUS_POS, 70, 12), 'Installed:') self.w.installed = W.TextBox((74, STATUS_POS, 0, 12), '') self.w.message_l = W.TextBox((4, STATUS_POS + 20, 70, 12), 'Status:') self.w.message = W.TextBox((74, STATUS_POS + 20, 0, 12), '') self.w.homepage_button = W.Button((4, STATUS_POS + 40, 96, 18), 'View homepage', self.do_homepage) self.w.description_l = W.TextBox((4, STATUS_POS + 70, 70, 12), 'Description:') self.w.description = W.EditText( (74, STATUS_POS + 70, 0, DESCRIPTION_HEIGHT - 4)) self.w.divline = W.HorizontalLine((0, INSTALL_POS - 4, 0, 0)) self.w.verbose_button = W.CheckBox((84, INSTALL_POS + 4, 60, 18), 'Verbose') self.w.recursive_button = W.CheckBox((146, INSTALL_POS + 4, 120, 18), 'Install dependencies', self.updatestatus) self.w.recursive_button.set(1) self.w.force_button = W.CheckBox((268, INSTALL_POS + 4, 70, 18), 'Overwrite', self.updatestatus) self.w.user_button = W.CheckBox((340, INSTALL_POS + 4, 140, 18), 'For Current User Only', self.do_user) self.w.install_button = W.Button((4, INSTALL_POS + 4, 56, 18), 'Install:', self.do_install) self.w.open() self.w.description.enable(0)
def __init__(self, creator, eoln): self.rv = None self.eoln = eoln self.w = w = W.ModalDialog((260, 160), 'Save options') radiobuttons = [] w.label = W.TextBox((8, 8, 80, 18), "File creator:") w.ide_radio = W.RadioButton((8, 22, 160, 18), "PythonIDE", radiobuttons, self.ide_hit) w.interp_radio = W.RadioButton((8, 42, 160, 18), "MacPython-OS9 Interpreter", radiobuttons, self.interp_hit) w.interpx_radio = W.RadioButton((8, 62, 160, 18), "PythonLauncher", radiobuttons, self.interpx_hit) w.other_radio = W.RadioButton((8, 82, 50, 18), "Other:", radiobuttons) w.other_creator = W.EditText((62, 82, 40, 20), creator, self.otherselect) w.none_radio = W.RadioButton((8, 102, 160, 18), "None", radiobuttons, self.none_hit) w.cancelbutton = W.Button((-180, -30, 80, 16), "Cancel", self.cancelbuttonhit) w.okbutton = W.Button((-90, -30, 80, 16), "Done", self.okbuttonhit) w.setdefaultbutton(w.okbutton) if creator == 'Pyth': w.interp_radio.set(1) elif creator == W._signature: w.ide_radio.set(1) elif creator == 'PytX': w.interpx_radio.set(1) elif creator == '\0\0\0\0': w.none_radio.set(1) else: w.other_radio.set(1) w.eolnlabel = W.TextBox((168, 8, 80, 18), "Newline style:") radiobuttons = [] w.unix_radio = W.RadioButton((168, 22, 80, 18), "Unix", radiobuttons, self.unix_hit) w.mac_radio = W.RadioButton((168, 42, 80, 18), "Macintosh", radiobuttons, self.mac_hit) w.win_radio = W.RadioButton((168, 62, 80, 18), "Windows", radiobuttons, self.win_hit) if self.eoln == '\n': w.unix_radio.set(1) elif self.eoln == '\r\n': w.win_radio.set(1) else: w.mac_radio.set(1) w.bind("cmd.", w.cancelbutton.push) w.open()
def __init__(self): prefs = MacPrefs.GetPrefs(W.getapplication().preffilepath) try: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine except: (docpath, kind, case, word, tut, lib, ref, ext, api) = prefs.docsearchengine = \ ("", 0, 0, 0, 1, 1, 0, 0, 0) if docpath and not verifydocpath(docpath): docpath = "" self.w = W.Window((400, 200), "Search the Python Documentation") self.w.searchtext = W.EditText((10, 10, -100, 20), callback=self.checkbuttons) self.w.searchbutton = W.Button((-90, 12, 80, 16), "Search", self.search) buttons = [] gutter = 10 width = 130 bookstart = width + 2 * gutter self.w.phraseradio = W.RadioButton((10, 38, width, 16), "As a phrase", buttons) self.w.allwordsradio = W.RadioButton((10, 58, width, 16), "All words", buttons) self.w.anywordsradio = W.RadioButton((10, 78, width, 16), "Any word", buttons) self.w.casesens = W.CheckBox((10, 98, width, 16), "Case sensitive") self.w.wholewords = W.CheckBox((10, 118, width, 16), "Whole words") self.w.tutorial = W.CheckBox((bookstart, 38, -10, 16), "Tutorial") self.w.library = W.CheckBox((bookstart, 58, -10, 16), "Library reference") self.w.langueref = W.CheckBox((bookstart, 78, -10, 16), "Lanuage reference manual") self.w.extending = W.CheckBox((bookstart, 98, -10, 16), "Extending & embedding") self.w.api = W.CheckBox((bookstart, 118, -10, 16), "C/C++ API") self.w.setdocfolderbutton = W.Button((10, -30, 100, 16), "Set doc folder", self.setdocpath) if docpath: self.w.setdefaultbutton(self.w.searchbutton) else: self.w.setdefaultbutton(self.w.setdocfolderbutton) self.docpath = docpath if not docpath: docpath = "(please select the Python html documentation folder)" self.w.docfolder = W.TextBox((120, -28, -10, 16), docpath) [self.w.phraseradio, self.w.allwordsradio, self.w.anywordsradio][kind].set(1) self.w.casesens.set(case) self.w.wholewords.set(word) self.w.tutorial.set(tut) self.w.library.set(lib) self.w.langueref.set(ref) self.w.extending.set(ext) self.w.api.set(api) self.w.open() self.w.wholewords.enable(0) self.w.bind('<close>', self.close) self.w.searchbutton.enable(0)
import W def twothird(width, height): return (8, 8, width - 8, 2 * height / 3 - 4) def onethird(width, height): return (8, 2 * height / 3 + 4, width - 8, height - 22) def halfbounds1(width, height): return (0, 0, width / 2 - 4, height) def halfbounds2(width, height): return (width / 2 + 4, 0, width, height) window = W.Window((400, 400), "Sizable window with two lists", minsize=(200, 200)) window.listgroup = W.Group(twothird) window.listgroup.list1 = W.List(halfbounds1, range(13213, 13310)) window.listgroup.list2 = W.List(halfbounds2, range(800, 830)) window.et = W.EditText(onethird, "Wat nu weer?") window.open()
import W w = W.Window((600, 400), "Ha!", minsize=(240, 200)) w.panes = W.HorizontalPanes((8, 8, -30, -8), (0.3, 0.3, 0.4)) w.panes.blah1 = W.EditText(None, "eehhh...") w.panes.blah2 = W.EditText((8, 8, -8, -8), "xxx nou...") w.panes.panes = W.VerticalPanes(None, (0.3, 0.4, 0.3)) w.panes.panes.blah1 = W.EditText(None, "eehhh...") w.panes.panes.blah2 = W.Frame(None) w.panes.panes.blah2.t = W.EditText((0, 0, 0, 0), "nou...") w.panes.panes.blah3 = W.List(None, ["eehhh...", 'abc', 'def']) w.open()
import W from Carbon import Windows w = W.ModalDialog((100, 100)) w.ed = W.EditText((10, 10, 80, 50)) w.ok = W.Button((10, 70, 80, 16), "Ok", w.close) w.setdefaultbutton(w.ok) w.open()
import W w = W.Window((600, 400), "Ha!", minsize=(240, 200)) w.panes = W.HorizontalPanes((8, 8, -8, -20), (0.6, 0.4)) w.panes.panes = W.VerticalPanes(None, (0.3, 0.4, 0.3)) w.panes.panes.blah1 = W.EditText(None, "eehhh...") w.panes.panes.blah2 = W.EditText(None, "nou...") w.panes.panes.blah3 = W.List(None, ["eehhh...", 'abc', 'def']) w.panes.group = W.Group(None) w.panes.group.mytext = W.EditText((0, 24, 0, 0), "eehhh...") w.panes.group.button1 = W.Button((0, 0, 80, 16), "A Button") w.open()
window.et3.set(window.et1.get()) def cancel(): import EasyDialogs EasyDialogs.Message("Cancel!") # make a non-sizable window #window = W.Window((200, 300), "Fixed Size") # make a sizable window window = W.Window((200, 300), "Variable Size!", minsize=(200, 300)) # make some edit text widgets window.et1 = W.EditText((10, 10, 110, 110), "Hallo!", textcallback) window.et2 = W.EditText((130, 40, 60, 30), "one!") window.et3 = W.EditText((130, 80, -10, 40), "two?") # a button window.button = W.Button((-70, 10, 60, 16), "Close", callback) # a checkbox window.ch = W.CheckBox((10, 130, 160, 16), "Check (command \xa4)", checkcallback) # set of radio buttons (should become easier/nicer) thebuttons = [] window.r1 = W.RadioButton((10, 150, 180, 16), "Radio 1 (cmd 1)", thebuttons) window.r2 = W.RadioButton((10, 170, 180, 16), "Radio 2 (cmd 2)", thebuttons) window.r3 = W.RadioButton((10, 190, 180, 16), "Radio 3 (cmd 3)", thebuttons,
import W def twothird(width, height): return (8, 8, width - 8, 2*height/3 - 4) def onethird(width, height): return (8, 2*height/3 + 4, width - 8, height - 22) def halfbounds1(width, height): return (0, 0, width/2 - 4, height) def halfbounds2(width, height): return (width/2 + 4, 0, width, height) window = W.Window((400, 400), "Sizable window with two lists", minsize = (200, 200)) window.listgroup = W.Group(twothird) window.listgroup.list1 = W.List(halfbounds1, range(13213, 13310)) window.listgroup.list2 = W.List(halfbounds2, range(800, 830)) window.et = W.EditText(onethird, "Wat nu weer?") window.open()
import W # define some callbacks def callback(): window.close() def checkcallback(value): print "hit the checkbox", value def radiocallback(value): print "hit radiobutton #3", value def scrollcallback(value): widget = window.hbar if value == "+": widget.set(widget.get() - 1) elif value == "-": widget.set(widget.get() + 1) elif value == "++": widget.set(widget.get() - 10) elif value == "--": widget.set(widget.get() + 10) else: # in thumb widget.set(value) print "scroll...", widget.get() def textcallback(): window.et3.set(window.et1.get()) def cancel():
def __init__(self, possize, title, text = ""): W.Group.__init__(self, possize) self.title = W.TextBox((0, 0, 0, 16), title) self.edit = W.EditText((0, 16, 0, 0), text)
def __init__(self, fontsettings, tabsettings): leftmargin = 60 leftmargin2 = leftmargin - 16 self.w = W.ModalDialog((440, 180), 'Font settings') self.w.fonttitle = W.TextBox((10, 12, leftmargin2, 14), "Font:", TextEdit.teJustRight) self.w.pop = W.FontMenu((leftmargin, 10, 16, 16), self.setfont) self.w.fontname = W.TextBox((leftmargin + 20, 12, 150, 14)) self.w.sizetitle = W.TextBox((10, 38, leftmargin2, 14), "Size:", TextEdit.teJustRight) self.w.sizeedit = W.EditText((leftmargin, 35, 40, 20), "", self.checksize) styletop = 64 self.w.styletitle = W.TextBox((10, styletop + 2, leftmargin2, 14), "Style:", TextEdit.teJustRight) for i in range(len(_stylenames)): top = styletop + (i % 4) * 20 left = leftmargin + 80 * (i > 3) - 2 if i: self.w[i] = W.CheckBox((left, top, 76, 16), _stylenames[i], self.dostyle) else: self.w[i] = W.CheckBox((left, top, 70, 16), _stylenames[i], self.doplain) if tabsettings: self.lasttab, self.tabmode = tabsettings self.w.tabsizetitle = W.TextBox((10, -26, leftmargin2, 14), "Tabsize:", TextEdit.teJustRight) self.w.tabsizeedit = W.EditText((leftmargin, -29, 40, 20), "", self.checktab) self.w.tabsizeedit.set(repr(self.lasttab)) radiobuttons = [] self.w.tabsizechars = W.RadioButton((leftmargin + 48, -26, 55, 14), "Spaces", radiobuttons, self.toggletabmode) self.w.tabsizepixels = W.RadioButton( (leftmargin + 110, -26, 55, 14), "Pixels", radiobuttons, self.toggletabmode) if self.tabmode: self.w.tabsizechars.set(1) else: self.w.tabsizepixels.set(1) else: self.tabmode = None self.w.cancelbutton = W.Button((-180, -26, 80, 16), "Cancel", self.cancel) self.w.donebutton = W.Button((-90, -26, 80, 16), "Done", self.done) sampletext = "Sample text." self.w.sample = W.EditText((230, 10, -10, 130), sampletext, fontsettings=fontsettings, tabsettings=tabsettings) self.w.setdefaultbutton(self.w.donebutton) self.w.bind('cmd.', self.w.cancelbutton.push) self.w.bind('cmdw', self.w.donebutton.push) self.lastsize = fontsettings[2] self._rv = None self.set(fontsettings) self.w.open()