Пример #1
0
def RunSample(w):
    # Create the label on the top of the dialog box
    #
    top = Tix.Label(
        w,
        padx=20,
        pady=10,
        bd=1,
        relief=Tix.RAISED,
        anchor=Tix.CENTER,
        text='This dialog box is\n a demonstration of the\n tixButtonBox widget'
    )

    # Create the button box and add a few buttons in it. Set the
    # -width of all the buttons to the same value so that they
    # appear in the same size.
    #
    # Note that the -text, -underline, -command and -width options are all
    # standard options of the button widgets.
    #
    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='OK',
            underline=0,
            width=5,
            command=lambda w=w: w.destroy())
    box.add('close',
            text='Cancel',
            underline=0,
            width=5,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #2
0
def Runtree(w, filename):
    top = tkinter_tix.Frame(w, relief=tkinter_tix.RAISED, bd=1)
    tree = tkinter_tix.Tree(top, options="hlist.columns 2")
    tree.pack(expand=1,
              fill=tkinter_tix.BOTH,
              padx=10,
              pady=10,
              side=tkinter_tix.LEFT)
    tree.hlist.configure(bg='white', font='Courier 10', indent=30)
    tree.hlist.configure(selectbackground='light yellow', gap=150)

    box = tkinter_tix.ButtonBox(w, orientation=tkinter_tix.HORIZONTAL)
    box.add('ok', text='OK', underline=0, command=w.destroy, width=6)
    box.add('exit', text='Exit', underline=0, command=w.destroy, width=6)
    box.pack(side=tkinter_tix.BOTTOM, fill=tkinter_tix.X)
    top.pack(side=tkinter_tix.TOP, fill=tkinter_tix.BOTH, expand=1)

    tree.bind_all(
        '<MouseWheel>', lambda event: tree.hlist.yview_scroll(
            int(-1 * event.delta / 120.), "units"))
    tree.bind_all('<Button-4>',
                  lambda event: tree.hlist.yview_scroll(int(-1), "units"))
    tree.bind_all('<Button-5>',
                  lambda event: tree.hlist.yview_scroll(int(+1), "units"))
    show_file(filename, tree)
    def __init__(self, mainhandler):
        Tix.Toplevel.__init__(self)
        self.title("Domain Creation Dialog")

        self.mainhandler = mainhandler

        self.name = Tix.LabelEntry(self, label="Domain name")
        self.name.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel())
        bbox.add("ok", text="Ok", command=lambda w=self: w.ok())
        bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.status = gui_errstr.ErrStr(self)
        self.status.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.conn = [
            ConnInfo(self, mainhandler),
            ConnInfo(self, mainhandler, False)
        ]
        self.conn[0].pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.conn[1].pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.name.entry.focus()

        self.bind("<Destroy>", self.OnDestroy)

        return
Пример #4
0
def RunTree(w, filename):
    top = tkinter_tix.Frame(w, relief=tkinter_tix.RAISED, bd=1)
    tree = tkinter_tix.Tree(top, options="hlist.columns 2")
    tree.pack(expand=1,
              fill=tkinter_tix.BOTH,
              padx=10,
              pady=10,
              side=tkinter_tix.LEFT)
    # print(tree.hlist.keys())   # use to see the available configure() options
    tree.hlist.configure(bg='white', font='Courier 10', indent=30)
    tree.hlist.configure(selectbackground='light yellow', gap=150)

    box = tkinter_tix.ButtonBox(w, orientation=tkinter_tix.HORIZONTAL)
    # box.add('ok', text='Ok', underline=0, command=w.destroy, width=6)
    box.add('exit', text='Exit', underline=0, command=w.destroy, width=6)
    box.pack(side=tkinter_tix.BOTTOM, fill=tkinter_tix.X)
    top.pack(side=tkinter_tix.TOP, fill=tkinter_tix.BOTH, expand=1)
    # https://stackoverflow.com/questions/17355902/python-tkinter-binding-mousewheel-to-scrollbar
    tree.bind_all(
        '<MouseWheel>',
        lambda event:  # Wheel in Windows
        tree.hlist.yview_scroll(int(-1 * event.delta / 120.), "units"))
    tree.bind_all(
        '<Button-4>',
        lambda event:  # Wheel up in Linux
        tree.hlist.yview_scroll(int(-1), "units"))
    tree.bind_all(
        '<Button-5>',
        lambda event:  # Wheel down in Linux
        tree.hlist.yview_scroll(int(+1), "units"))

    show_file(filename, tree)
Пример #5
0
    def RepresentationControl(self, w):
        # 4 buttons
        #new
        #insert
        #delete
        #view
        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('new',
                text='New',
                underline=0,
                width=5,
                command=lambda w=w: self.newRep())
        box.add('delete',
                text='Delete',
                underline=0,
                width=5,
                command=lambda w=w: self.deleteRep())
        box.add('view',
                text='View',
                underline=0,
                width=5,
                command=lambda w=w: self.viewFunction())

        ##        box.add('boundary', text='Bound', underline=0, width=5,
        ##                command=lambda w=w: self.viewBoundary())
        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        box.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #6
0
 def __init__(self, master=None):
     self.mandirs = ManDirectories()
     self.frame = Tix.Frame(master)
     self.section = Tix.StringVar()
     combo = Tix.ComboBox(self.frame,
                          label='Section: ',
                          dropdown=1,
                          editable=0,
                          variable=self.section,
                          command=self.UpdatePageList)
     pagelist = Tix.ScrolledListBox(self.frame, scrollbar='auto')
     self.listbox = pagelist.listbox
     self.listbox.bind('<Double-1>', self.ShowPage)
     temp = self.mandirs.section_names.keys()
     temp.sort()
     for s in temp:
         combo.insert(Tix.END, s)
     box = Tix.ButtonBox(self.frame, orientation=Tix.HORIZONTAL)
     box.add('show',
             text='Show Page ...',
             underline=0,
             width=13,
             command=self.ShowPage)
     box.add('aprop',
             text='Apropos ...',
             underline=0,
             width=13,
             command=self.Apropos)
     box.add('quit', text='Quit', underline=0, width=13, command=self.Quit)
     combo.pack(side=Tix.TOP, expand=0, fill=Tix.X)
     pagelist.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
     box.pack(side=Tix.BOTTOM, expand=0, fill=Tix.X)
     self.frame.pack(expand=1, fill=Tix.BOTH)
Пример #7
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # Create the tixDirTree and the tixLabelEntry widgets on the on the top
        # of the dialog box

        # bg = root.tk.eval('tix option get bg')
        # adding bg=bg crashes Windows pythonw tk8.3.3 Python 2.1.0

        top = Tix.Frame( w, relief=RAISED, bd=1)

        # Create the DirTree widget. By default it will show the current
        # directory
        #
        #
        top.dir = Tix.DirTree(top)
        top.dir.hlist['width'] = 40

        # When the user presses the ".." button, the selected directory
        # is "transferred" into the entry widget
        #
        top.btn = Tix.Button(top, text = "  >>  ", pady = 0)

        # We use a LabelEntry to hold the installation directory. The user
        # can choose from the DirTree widget, or he can type in the directory
        # manually
        #
        top.ent = Tix.LabelEntry(top, label="Installation Directory:",
                                  labelside = 'top',
                                  options = '''
                                  entry.width 40
                                  label.anchor w
                                  ''')

        self.dlist_dir = copy.copy(os.curdir)
        top.ent.entry['textvariable'] = self.dlist_dir
        top.btn['command'] = lambda dir=top.dir, ent=top.ent, self=self: \
                             self.copy_name(dir,ent)

        top.ent.entry.bind('<Return>', lambda self=self: self.okcmd () )

        top.pack( expand='yes', fill='both', side=TOP)
        top.dir.pack( expand=1, fill=BOTH, padx=4, pady=4, side=LEFT)
        top.btn.pack( anchor='s', padx=4, pady=4, side=LEFT)
        top.ent.pack( expand=1, fill=X, anchor='s', padx=4, pady=4, side=LEFT)

        # Use a ButtonBox to hold the buttons.
        #
        box = Tix.ButtonBox (w, orientation='horizontal')
        box.add ('ok', text='Ok', underline=0, width=6,
                     command = lambda self=self: self.okcmd () )
        box.add ('cancel', text='Cancel', underline=0, width=6,
                     command = lambda self=self: self.quitcmd () )

        box.pack( anchor='s', fill='x', side=BOTTOM)
Пример #8
0
    def __init__(self, name, root, columns):
        Tix.Toplevel.__init__(self)
        self.title(name)

        self.numcolumns = len(columns)

        stree = Tix.Tree(self,
                         options=("hlist.columns " + str(self.numcolumns) +
                                  " hlist.itemtype text" + " hlist.header 1" +
                                  " hlist.selectForeground black" +
                                  " hlist.selectBackground beige"),
                         width=500,
                         height=500)
        self.stree = stree
        tree = stree.hlist
        i = 0
        for c in columns:
            tree.header_create(i, text=c[0])
            tree.column_width(i, c[1])
            i += 1
            pass
        stree.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        if hasattr(self, "ok"):
            bbox.add("ok", text="Ok", command=self.ok)
            pass
        if hasattr(self, "save"):
            bbox.add("save", text="Save", command=self.save)
            pass
        if hasattr(self, "cancel"):
            bbox.add("cancel", text="Cancel", command=self.cancel)
            pass
        if hasattr(self, "refresh"):
            bbox.add("refresh", text="Refresh", command=self.refresh)
            pass
        if hasattr(self, "clear"):
            bbox.add("clear", text="Clear", command=self.clear)
            pass
        bbox.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        tree.bind("<Button-3>", self.TreeMenu)

        self.bind("<Destroy>", self.OnDestroy)

        self.bind("<MouseWheel>", self.Wheel)
        if (gui_winsys.winsys == "x11"):
            self.bind("<Button-4>", self.ButtonUp)
            self.bind("<Button-5>", self.ButtonDown)
            pass

        self.treeroot = ""
        self.tree = tree
        self.treehash = {}
        self.currkey = 0
        return
Пример #9
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25')
        group.entry.insert(0,'comp.lang.python')
        pane = Tix.PanedWindow(w, orientation='vertical')

        p1 = pane.add('list', min=70, size=100)
        p2 = pane.add('text', min=70)
        list = Tix.ScrolledListBox(p1)
        list.listbox['width'] = 80
        list.listbox['height'] = 5
        text = Tix.ScrolledText(p2)
        text.text['width'] = 80
        text.text['height'] = 20

        list.listbox.insert(Tix.END, "  12324 Re: Tkinter is good for your health")
        list.listbox.insert(Tix.END, "+ 12325 Re: Tkinter is good for your health")
        list.listbox.insert(Tix.END, "+ 12326 Re: Tix is even better for your health (Was: Tkinter is good...)")
        list.listbox.insert(Tix.END, "  12327 Re: Tix is even better for your health (Was: Tkinter is good...)")
        list.listbox.insert(Tix.END, "+ 12328 Re: Tix is even better for your health (Was: Tkinter is good...)")
        list.listbox.insert(Tix.END, "  12329 Re: Tix is even better for your health (Was: Tkinter is good...)")
        list.listbox.insert(Tix.END, "+ 12330 Re: Tix is even better for your health (Was: Tkinter is good...)")

        text.text['bg'] = list.listbox['bg']
        text.text['wrap'] = 'none'
        text.text.insert(Tix.END, """
    Mon, 19 Jun 1995 11:39:52        comp.lang.python              Thread   34 of  220
    Lines 353       A new way to put text and bitmaps together iNo responses
    [email protected]                Ioi K. Lam at University of Pennsylvania

    Hi,

    I have implemented a new image type called "compound". It allows you
    to glue together a bunch of bitmaps, images and text strings together
    to form a bigger image. Then you can use this image with widgets that
    support the -image option. For example, you can display a text string string
    together with a bitmap, at the same time, inside a TK button widget.
    """)
        text.text['state'] = 'disabled'

        list.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)
        text.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)

        group.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH)
        pane.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH, expand=1)

        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6,
                command=self.quitcmd)
        box.add('cancel', text='Cancel', underline=0, width=6,
                command=self.quitcmd)
        box.pack(side=Tix.BOTTOM, fill=Tix.X)
Пример #10
0
def runMain(widget):
    mainFrame = Tix.Frame(widget, bd=1, relief=Tix.RAISED)
    widget.wm_minsize(600, 400)
    widget.title('Capture Manager Python Demo')
    mainFrame.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
    box = Tix.ButtonBox(widget, orientation=Tix.HORIZONTAL)
    box.add('viewer', text='Viewer', underline=0, width=6,
            command=lambda mainFrame=mainFrame: invokeViewer(mainFrame))
    box.add('recorder', text='Recorder', underline=0, width=6,
            command=lambda mainFrame=mainFrame: invokeRecorder(mainFrame))
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    mainFrame.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #11
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        global demo_maker, demo_thrust, demo_num_engines

        demo_maker = Tix.StringVar()
        demo_thrust = Tix.DoubleVar()
        demo_num_engines = Tix.IntVar()
        demo_maker.set('P&W')
        demo_thrust.set(20000.0)
        demo_num_engines.set(2)

        top = Tix.Frame(w, bd=1, relief=Tix.RAISED)

        # $w.top.a allows only integer values
        #
        # [Hint] The -options switch sets the options of the subwidgets.
        # [Hint] We set the label.width subwidget option of the Controls to 
        #        be 16 so that their labels appear to be aligned.
        #
        a = Tix.Control(top, label='Number of Engines: ', integer=1,
                        variable=demo_num_engines, min=1, max=4,
                        options='entry.width 10 label.width 20 label.anchor e')

        b = Tix.Control(top, label='Thrust: ', integer=0,
                        min='10000.0', max='60000.0', step=500,
                        variable=demo_thrust,
                        options='entry.width 10 label.width 20 label.anchor e')

        c = Tix.Control(top, label='Engine Maker: ', value='P&W',
                        variable=demo_maker,
                        options='entry.width 10 label.width 20 label.anchor e')

        # We can't define these in the init because the widget 'c' doesn't
        # exist yet and we need to reference it
        c['incrcmd'] = lambda w=c: adjust_maker(w, 1)
        c['decrcmd'] = lambda w=c: adjust_maker(w, -1)
        c['validatecmd'] = lambda w=c: validate_maker(w)

        a.pack(side=Tix.TOP, anchor=Tix.W)
        b.pack(side=Tix.TOP, anchor=Tix.W)
        c.pack(side=Tix.TOP, anchor=Tix.W)

        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6,
                command=self.okcmd)
        box.add('cancel', text='Cancel', underline=0, width=6,
                command=self.quitcmd)
        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #12
0
def RunSample(w):
    global demo_opt_from, demo_opt_to

    demo_opt_from = Tix.StringVar()
    demo_opt_to = Tix.StringVar()

    top = Tix.Frame(w, bd=1, relief=Tix.RAISED)

    from_file = Tix.OptionMenu(
        top,
        label="From File Format : ",
        variable=demo_opt_from,
        options='label.width  19 label.anchor e menubutton.width 15')

    to_file = Tix.OptionMenu(
        top,
        label="To File Format : ",
        variable=demo_opt_to,
        options='label.width  19 label.anchor e menubutton.width 15')

    # Add the available options to the two OptionMenu widgets
    #
    # [Hint] You have to add the options first before you set the
    #        global variables "demo_opt_from" and "demo_opt_to". Otherwise
    #        the OptionMenu widget will complain about "unknown options"!
    #
    for opt in options.keys():
        from_file.add_command(opt, label=options[opt])
        to_file.add_command(opt, label=options[opt])

    demo_opt_from.set('html')
    demo_opt_to.set('post')

    from_file.pack(side=Tix.TOP, anchor=Tix.W, pady=3, padx=6)
    to_file.pack(side=Tix.TOP, anchor=Tix.W, pady=3, padx=6)

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='Ok',
            underline=0,
            width=6,
            command=lambda w=w: ok_command(w))
    box.add('cancel',
            text='Cancel',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #13
0
    def createWidgets(self):
        self.LBL_LANGUAGE = Tix.Label(master=self, text=u'Целевой язык')
        self.LBL_LANGUAGE.grid(column=0, row=0)
        self.LANGUAGE_CHOOSER = Tix.ComboBox(master=self)
        self.LANGUAGE_CHOOSER.grid(row=0, column=1, columnspan=2, sticky='ew')
        self.LANGUAGE_MATCH = list()
        self.LANGUAGE_MATCH.append(('c99', 'C (ISO/IEC 9899:1999)'))
        self.LANGUAGE_MATCH.append(('c_plus_plus', 'C++ (ISO/IEC 14882:1998)'))
        self.LANGUAGE_CHOOSER.insert(0, 'C (ISO/IEC 9899:1999)')
        self.LANGUAGE_CHOOSER.insert(1, 'C++ (ISO/IEC 14882:1998)')
        self.LBL_ENCODING = Tix.Label(master=self, text=u'Кодировка файлов')
        self.LBL_ENCODING.grid(column=0, row=1)
        self.ENCODING_CHOOSER = Tix.ComboBox(master=self)
        self.ENCODING_CHOOSER.insert(0, u'cp866 (Windows OEM)')
        self.ENCODING_CHOOSER.insert(1, u'cp1251 (Windows ANSI)')
        self.ENCODING_CHOOSER.insert(2, u'koi8-r (FreeBSD)')
        self.ENCODING_CHOOSER.insert(3, u'utf-8 (Linux)')
        self.ENCODING_CHOOSER.grid(column=1, columnspan=2, sticky='ew', row=1)
        if os.name == "nt":
            self.ENCODING_CHOOSER['value'] = u'cp866 (Windows OEM)'
        else:
            self.ENCODING_CHOOSER['value'] = u'utf-8 (Linux)'
        self.LBL_TARGET_DIR = Tix.Label(master=self, text=u'Целевой каталог')
        self.LBL_TARGET_DIR.grid(column=0, row=2)
        self.TARGET_DIR = Tix.Entry(master=self)
        self.TARGET_DIR.grid(column=1, row=2)

        self.BTN_BROWSE = Tix.Button(master=self,
                                     text=u'...',
                                     command=self.browerTargetDir)
        self.BTN_BROWSE.grid(column=2, row=2)

        self.STATUS = Tix.Label(master=self, text='', fg='red')
        self.STATUS.grid(row=3, columnspan=3, sticky='ew')

        self.BOX = Tix.ButtonBox(master=self)
        self.BOX.grid(row=4, columnspan=3, sticky='ew')

        self.BTN_GO = Tix.Button(master=self.BOX,
                                 text=u'Конвертировать',
                                 bg="green",
                                 command=self.convert)
        self.BTN_GO.grid(column=0, row=0, sticky='ew')

        self.BTN_CLOSE = Tix.Button(master=self.BOX,
                                    text=u'Закрыть',
                                    bg="red",
                                    command=self.quit)
        self.BTN_CLOSE.grid(column=1, row=0, sticky='ew')
def RunTree(w, filename):
    top = Tix.Frame(w, relief=Tix.RAISED, bd=1)
    tree = Tix.Tree(top, options="hlist.columns 2")
    tree.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.LEFT)
    # print(tree.hlist.keys())   # use to see the available configure() options
    tree.hlist.configure(bg='white', font='Courier 10', indent=30)
    tree.hlist.configure(selectbackground='light yellow', gap=150)

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    # box.add('ok', text='Ok', underline=0, command=w.destroy, width=6)
    box.add('exit', text='Exit', underline=0, command=w.destroy, width=6)
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

    show_file(filename, tree)
Пример #15
0
def RunSample(w):
    top = Tix.Frame(w, relief=Tix.RAISED, bd=1)
    tree = Tix.Tree(top, options='separator "/"')
    tree.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.LEFT)
    tree['opencmd'] = lambda dir=None, w=tree: opendir(w, dir)

    # The / directory is added in the "open" mode. The user can open it
    # and then browse its subdirectories ...
    adddir(tree, "/")

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok', text='Ok', underline=0, command=w.destroy, width=6)
    box.add('cancel', text='Cancel', underline=0, command=w.destroy, width=6)
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #16
0
    def __init__(self,
                 master=None,
                 query="Pick Directory",
                 startDir=None,
                 showHidden=0):
        self.dialog = Tkinter.Frame(master)
        toplevel = self.dialog.winfo_toplevel()
        toplevel.title(query)
        toplevel.protocol('WM_DELETE_WINDOW', self.cancel)
        try:
            self.dialog.tk.call('load', '', 'Tix')
        except Tkinter.TclError:
            self.dialog.tk.call('package', 'require', 'Tix')

        self.dir = Tkinter.StringVar(self.dialog)
        # initialize dir with legal directory
        self.dir.set(os.path.abspath(os.curdir))
        self.dir.trace_variable('w', self.updateDirList)

        keywds = {"value": self.dir.get(), "browsecmd": self.dirBrowse}
        if showHidden:
            keywds["showhidden"] = 1
        self.dirlist = apply(Tix.DirList, (self.dialog, ), keywds)
        self.dirlist.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        # now set dir to what we want it to start out as
        if startDir:
            self.dir.set(startDir)

        installdir = Tix.LabelEntry(self.dialog,
                                    label=query,
                                    labelside=Tkinter.TOP,
                                    pady=4,
                                    options="entry.width 30 label.anchor w")
        installdir.entry.config(textvariable=self.dir)
        #installdir.entry.bind('<Return>', ??)
        installdir.pack(side=Tkinter.TOP,
                        expand=1,
                        fill=Tkinter.X,
                        anchor=Tkinter.S,
                        padx=4,
                        pady=4)

        box = Tix.ButtonBox(self.dialog, orientation=Tkinter.HORIZONTAL)
        box.add('ok', text='OK', width=6, command=self.ok)
        box.add('cancel', text='Cancel', width=6, command=self.cancel)
        box.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)
        self.dialog.pack(fill=Tkinter.BOTH, expand=1)
Пример #17
0
def RunSample(w):
    # We create the frame and the button, then we'll bind the PopupMenu
    # to both widgets. The result is, when you press the right mouse
    # button over $w.top or $w.top.but, the PopupMenu will come up.
    #
    top = Tix.Frame(w, relief=Tix.RAISED, bd=1)
    but = Tix.Button(
        top,
        text=
        'Press the right mouse button over this button or its surrounding area'
    )
    but.pack(expand=1, fill=Tix.BOTH, padx=50, pady=50)

    p = Tix.PopupMenu(top, title='Popup Test')
    p.bind_widget(top)
    p.bind_widget(but)

    # Set the entries inside the PopupMenu widget.
    # [Hint] You have to manipulate the "menu" subwidget.
    #        $w.top.p itself is NOT a menu widget.
    # [Hint] Watch carefully how the sub-menu is created
    #
    p.menu.add_command(label='Desktop', underline=0)
    p.menu.add_command(label='Select', underline=0)
    p.menu.add_command(label='Find', underline=0)
    p.menu.add_command(label='System', underline=1)
    p.menu.add_command(label='Help', underline=0)
    m1 = Tix.Menu(p.menu)
    m1.add_command(label='Hello')
    p.menu.add_cascade(label='More', menu=m1)

    but.pack(side=Tix.TOP, padx=40, pady=50)

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='Ok',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.add('cancel',
            text='Cancel',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #18
0
def RunSample(w):
    top = Tix.Label(w,
                    padx=20,
                    pady=10,
                    bd=1,
                    relief=Tix.RAISED,
                    anchor=Tix.CENTER,
                    text='Select directories you wish to update\n')
    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='OK',
            underline=0,
            width=5,
            command=lambda w=w: Finallist())
    box.add('close',
            text='Finish',
            underline=0,
            width=5,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Пример #19
0
    def create_main_widgets(self):

        combo_box = Tix.ComboBox(self)
        combo_box.grid(column=0, row=0, sticky='news', padx=4, pady=4)

        button_box = Tix.ButtonBox(self)
        button_box.add('button_1', text='Button_1')
        button_box.add('button_2', text='Button_2')
        button_box.grid(column=0, row=1, sticky='news', padx=4, pady=4)

        control = Tix.Control(self)
        control.grid(column=0, row=2, sticky='news', padx=4, pady=4)

        label_entry = Tix.LabelEntry(self, label="Label for entry")
        label_entry.grid(column=0, row=3, sticky='news', padx=4, pady=4)

        meter = Tix.Meter(self)
        meter.grid(column=0, row=4, sticky='news', padx=4, pady=4)

        options = Tix.OptionMenu(self)
        options.grid(column=0, row=5, sticky='news', padx=4, pady=4)

        file_entry = Tix.FileEntry(self)
        file_entry.grid(column=0, row=6, sticky='news', padx=4, pady=4)
Пример #20
0
    def __init__(self, name, columns):
        Tix.Toplevel.__init__(self)
        self.title(name)

        slist = SubList(self,
                        columns,
                        options=("hlist.header 1" + " hlist.itemtype text" +
                                 (" hlist.columns " + str(len(columns))) +
                                 " hlist.selectForeground black" +
                                 " hlist.selectBackground beige"),
                        width=600,
                        height=500)
        slist.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
        self.slist = slist

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        bbox = Tix.ButtonBox(self)
        if hasattr(self, "ok"):
            bbox.add("ok", text="Ok", command=self.ok)
            pass
        if hasattr(self, "save"):
            bbox.add("save", text="Save", command=self.save)
            pass
        if hasattr(self, "cancel"):
            bbox.add("cancel", text="Cancel", command=self.cancel)
            pass
        if hasattr(self, "clear"):
            bbox.add("clear", text="Clear", command=self.clear)
            pass
        bbox.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        self.bind("<Destroy>", self.OnDestroy)

        return
Пример #21
0
    def __init__(self, parent=None):
        self.myparent = parent
        self.myroot = self.myparent.myparent
        self.metermaybe = copy.deepcopy(self.myparent.meterlist)
        self.meterfr = tk.Toplevel(self.myroot, width=400, height=300)
        self.meterfr.title("Meter Changes")
        self.meterfr.rowconfigure(0, weight=1)
        self.meterfr.rowconfigure(1, weight=0)
        self.meterfr.columnconfigure(0, weight=1)
        self.meterbuttons = tk.ButtonBox(self.meterfr, width=400, height=300)
        self.meterbuttons.add('ok', text='OK', command=self.ok)
        self.meterbuttons.add('cancel', text='Cancel', command=self.cancel)
        self.meterbuttons.add('apply', text='Apply', command=self.apply)
        self.meterbuttons.add('sort', text='Sort', command=self.reorder)
        self.meterbuttons.grid(row=1, column=0, sticky='')
        self.canvas = tk.Canvas(self.meterfr, width=400, height=300)
        self.canvas.grid(row=0, column=0, sticky='nesw')
        self.canvas.rowconfigure(2, weight=1)
        self.canvas.columnconfigure(0, weight=1)
        self.toprow = tk.Frame(self.canvas)
        self.toprowoncanvas = self.canvas.create_window(0,
                                                        0,
                                                        window=self.toprow,
                                                        anchor="nw")
        self.toprow.columnconfigure(0, weight=0)
        self.toprow.columnconfigure(1, weight=1)
        self.botrow = tk.Frame(self.canvas, bd=3, relief="ridge")
        #        self.botrow.grid(row=1, column=0, sticky='we')
        self.botrow.columnconfigure(0, weight=0)
        self.botrow.columnconfigure(1, weight=1)
        bottomy = self.toprow.winfo_reqheight()
        #        print bottomy
        self.botrowoncanvas = self.canvas.create_window(0,
                                                        bottomy,
                                                        window=self.botrow,
                                                        anchor="nw")
        self.meterlinelist = []

        #        print self.metermaybe
        self.scroll = tk.Scrollbar(self.meterfr,
                                   orient='vertical',
                                   takefocus=0)
        self.canvas.config(yscrollcommand=self.scroll.set)
        self.canvas.config(scrollregion=self.canvas.bbox("all"))
        self.scroll.config(command=self.canvas.yview)
        self.meterfr.bind("<Button-4>",
                          lambda event, arg1="scroll", arg2=-1, arg3="units":
                          self.canvas.yview(arg1, arg2, arg3),
                          "+")
        self.meterfr.bind("<Button-5>",
                          lambda event, arg1="scroll", arg2=1, arg3="units":
                          self.canvas.yview(arg1, arg2, arg3),
                          "+")
        for meter in self.metermaybe:
            number = self.metermaybe.index(meter)
            newline = self.addmeterline(meter, number)

        self.addbar = tk.IntVar()
        self.addbar.set(1)
        self.addtop = tk.IntVar()
        self.addtop.set(4)
        self.addbottom = tk.IntVar()
        self.addbottom.set(4)
        self.blankbar = tk.Entry(self.botrow,
                                 width=4,
                                 textvariable=self.addbar)
        self.blankbar.focus_set()
        self.blankbar.select_range(0, "end")
        self.blankbar.grid(padx=10, sticky='')
        self.blanktop = tk.Entry(self.botrow,
                                 width=3,
                                 textvariable=self.addtop)
        self.blanktop.grid(row=0, column=1, padx=10, sticky='')
        self.blankbottom = tk.Entry(self.botrow,
                                    width=5,
                                    textvariable=self.addbottom)
        self.blankbottom.grid(row=0, column=2, padx=10, sticky='')

        self.blankaddmeter = tk.Button(self.botrow,
                                       text="Add Meter",
                                       command=self.newmeter)
        self.blankaddmeter.grid(row=0, column=4, padx=10, rowspan=1)

        self.meterfr.update_idletasks()
        self.meterfr.bind("<Return>", self.ok)
        self.meterfr.bind("<Escape>", self.cancel)
Пример #22
0
#!/usr/local/bin/python
Пример #23
0
    def ProbFunc(self, w):
        self.f_list = Tix.ComboBox(
            w,
            label="Function List: ",
            dropdown=0,
            command=lambda w=w: self.selectFunc(w),
            editable=1,
            variable=self.func,
            options=
            'listbox.height 3 label.padY 5 label.width 10 label.anchor ne')
        self.f_list.pack(side=Tix.TOP, anchor=Tix.W)
        self.f_list.insert(Tix.END, 'y**2*sin(pi*x)')
        self.f_list.insert(Tix.END, '((x-0.5)**2 + (y-0.5)**2 +1)**(1/2.0)')
        self.f_list.insert(Tix.END, 'cos(x*2*pi)*sin(y*2*pi)')
        self.f_list.insert(Tix.END, 'exp(-x)*(x+y**3)')
        self.f_list.insert(Tix.END, 'ln(1+(x-0.5)**2 +(y-0.5)**2)')
        self.f_list.set_silent('y**2*sin(pi*x)')
        self.f_list.pack(fill=Tix.X, padx=5, pady=3)
        x_order = Tix.DoubleVar()
        y_order = Tix.IntVar()
        #radio buttons decide whether the function is assigned to solution or source
        self.func_assign_option = Tix.Select(w,
                                             label='Assign function to:',
                                             allowzero=1,
                                             radio=1)
        self.func_assign_option.add(
            'solution', text='Solution')  #command=self.setSolAssign())
        self.func_assign_option.add('source', text='Source Function')
        self.func_assign_option.subwidget_list['solution'].invoke()
        self.func_assign_opt = self.func_assign_option["value"]

        xn = Tix.Control(w,
                         label='x order: ',
                         integer=1,
                         variable=x_order,
                         min=0,
                         max=3,
                         command=lambda w=w: self.select_X_order(w),
                         options='entry.width 5 label.width 6 label.anchor e')
        yn = Tix.Control(w,
                         label='y order: ',
                         integer=1,
                         variable=y_order,
                         min=0,
                         max=3,
                         command=lambda w=w: self.select_Y_order(w),
                         options='entry.width 5 label.width 6 label.anchor e')

        xn.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
        yn.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('diff',
                text='Differentiate',
                underline=0,
                width=9,
                command=self.differentiate_fn)
        box.pack(side=Tix.BOTTOM, padx=5, pady=3, fill=Tix.X)
        self.func_assign_option.pack(side=Tix.BOTTOM,
                                     padx=5,
                                     pady=3,
                                     fill=Tix.X)
Пример #24
0
    def __init__(self, parent=None):
        self.myparent = parent
        self.myroot = self.myparent.myparent
        self.tempomaybe = copy.deepcopy(self.myparent.tempolist)
        self.tempofr = tk.Toplevel(self.myroot, width=480, height=360)
        self.tempofr.title("Tempo Changes")
        self.tempofr.rowconfigure(0, weight=1)
        self.tempofr.rowconfigure(1, weight=0)
        self.tempofr.columnconfigure(0, weight=1)
        self.tempobuttons = tk.ButtonBox(self.tempofr, width=480, height=360)
        self.tempobuttons.add('ok', text='OK', command=self.ok)
        self.tempobuttons.add('cancel', text='Cancel', command=self.cancel)
        self.tempobuttons.add('apply', text='Apply', command=self.apply)
        self.tempobuttons.add('sort', text='Sort', command=self.reorder)
        self.tempobuttons.grid(row=1, column=0, sticky='')
        self.canvas = tk.Canvas(self.tempofr, width=480, height=360)
        self.canvas.grid(row=0, column=0, sticky='nesw')
        self.canvas.rowconfigure(2, weight=1)
        self.canvas.columnconfigure(0, weight=1)
        self.toprow = tk.Frame(self.canvas)
        self.toprowoncanvas = self.canvas.create_window(0,
                                                        0,
                                                        window=self.toprow,
                                                        anchor="nw")
        self.toprow.columnconfigure(0, weight=0)
        self.toprow.columnconfigure(1, weight=1)
        self.botrow = tk.Frame(self.canvas, bd=3, relief="ridge")
        #        self.botrow.grid(row=1, column=0, sticky='we')
        self.botrow.columnconfigure(0, weight=0)
        self.botrow.columnconfigure(1, weight=1)
        bottomy = self.toprow.winfo_reqheight()
        #        print bottomy
        self.botrowoncanvas = self.canvas.create_window(0,
                                                        bottomy,
                                                        window=self.botrow,
                                                        anchor="nw")
        self.tempolinelist = []

        #        print self.tempomaybe
        self.scroll = tk.Scrollbar(self.tempofr,
                                   orient='vertical',
                                   takefocus=0)
        self.canvas.config(yscrollcommand=self.scroll.set)
        self.canvas.config(scrollregion=self.canvas.bbox("all"))
        self.scroll.config(command=self.canvas.yview)
        self.tempofr.bind("<Button-4>",
                          lambda event, arg1="scroll", arg2=-1, arg3="units":
                          self.canvas.yview(arg1, arg2, arg3),
                          "+")
        self.tempofr.bind("<Button-5>",
                          lambda event, arg1="scroll", arg2=1, arg3="units":
                          self.canvas.yview(arg1, arg2, arg3),
                          "+")
        for tempo in self.tempomaybe:
            number = self.tempomaybe.index(tempo)
            newline = self.addtempoline(tempo, number)

        self.addbar = tk.IntVar()
        self.addbeat = tk.IntVar()
        self.addbpm = tk.DoubleVar()
        self.addunit = tk.IntVar()
        self.blankbar = tk.Entry(self.botrow,
                                 width=4,
                                 textvariable=self.addbar)
        self.blankbar.focus_set()
        self.blankbar.select_range(0, "end")
        self.blankbar.grid(padx=10, sticky='')
        self.blankbeat = tk.Entry(self.botrow,
                                  width=3,
                                  textvariable=self.addbeat)
        self.blankbeat.grid(row=0, column=1, padx=10, sticky='')
        self.blankbpm = tk.Entry(self.botrow,
                                 width=5,
                                 textvariable=self.addbpm)
        self.blankbpm.grid(row=0, column=2, padx=10, sticky='')
        self.blankunit = tk.ComboBox(self.botrow,
                                     editable=1,
                                     variable=self.addunit,
                                     listwidth=8)
        self.blankunit.entry.configure(width=3)
        self.blankunit.append_history(1)
        self.blankunit.append_history(2)
        self.blankunit.append_history(3)
        self.blankunit.append_history(4)
        self.blankunit.append_history(6)
        self.blankunit.append_history(8)
        self.blankunit.append_history(12)
        self.blankunit.append_history(16)
        self.blankunit.grid(row=0, column=3, padx=10, sticky='')

        self.blankaddtempo = tk.Button(self.botrow,
                                       text="Add Tempo",
                                       command=self.newtempo)
        self.blankaddtempo.grid(row=0, column=4, padx=10, rowspan=1)

        self.tempofr.update_idletasks()
        self.tempofr.bind("<Return>", self.ok)
        self.tempofr.bind("<Escape>", self.cancel)
Пример #25
0
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
Пример #26
0
    def __init__(self, parent=None):
        self.myparent = parent
        self.myroot = self.myparent.myparent
        self.regionmaybe = copy.deepcopy(self.myparent.regionlist)
        self.regionfr = tk.Toplevel(self.myroot, width=640, height=480)
        self.regionfr.title("Regions")
        self.regionfr.rowconfigure(0, weight=1)
        self.regionfr.rowconfigure(1, weight=0)
        self.regionfr.columnconfigure(0, weight=1)
        self.regionbuttons = tk.ButtonBox(self.regionfr, width=640, height=80)
        self.regionbuttons.add('ok', text='OK', command=self.ok)
        self.regionbuttons.add('cancel', text='Cancel', command=self.cancel)
        self.regionbuttons.add('apply', text='Apply', command=self.apply)
        self.regionbuttons.grid(row=1, column=0, sticky='ew')
        self.canvas = tk.Canvas(self.regionfr)
        self.canvas.grid(row=0, column=0, sticky='nesw')
        self.canvas.rowconfigure(2, weight=1)
        self.canvas.columnconfigure(0, weight=1)
        self.toprow = tk.Frame(self.canvas)
        self.toprowoncanvas = self.canvas.create_window(0,
                                                        0,
                                                        window=self.toprow,
                                                        anchor="nw")
        self.toprow.columnconfigure(0, weight=0)
        self.toprow.columnconfigure(1, weight=1)
        self.botrow = tk.Frame(self.canvas, bd=3, relief="ridge")
        #        self.botrow.grid(row=1, column=0, sticky='we')
        self.botrow.columnconfigure(0, weight=0)
        self.botrow.columnconfigure(1, weight=1)
        self.scroll = tk.Scrollbar(self.regionfr,
                                   orient='vertical',
                                   takefocus=0)
        self.canvas.config(yscrollcommand=self.scroll.set)
        self.canvas.config(scrollregion=self.canvas.bbox("all"))
        self.scroll.config(command=self.canvas.yview)
        self.regionfr.bind("<Button-4>",
                           lambda event, arg1="scroll", arg2=-1, arg3="units":
                           self.canvas.yview(arg1, arg2, arg3),
                           "+")
        self.regionfr.bind("<Button-5>",
                           lambda event, arg1="scroll", arg2=1, arg3="units":
                           self.canvas.yview(arg1, arg2, arg3),
                           "+")

        self.regionlinelist = []

        #        print self.regionmaybe
        for reg in self.regionmaybe:
            number = self.regionmaybe.index(reg)
            newline = self.addregionline(reg, number)

#        self.blankcolor = tk.Frame(self.botrow, width=40, height=40, bg='#999999')
#        self.blankcolor.grid(row=0, column=0, rowspan=2, padx=10)

#        self.blanknum = tk.Control(self.botrow, width=2, min=1, max=9999)
#        self.blanknum.grid(row=0, column=1, padx=20, sticky='w')
#        self.blankden = tk.Control(self.botrow, width=2, min=1, max=9999)
#        self.blankden.grid(row=1, column=1, padx=20, sticky='w')
#        self.blanksubmit = tk.Button(self.botrow, text="Submit")
#        self.blanksubmit.grid(row=0, column=2, padx=10, rowspan=2)

#        self.regionfr.update_idletasks()
#        bottomy = self.toprow.winfo_reqheight()
#        print bottomy
#        self.botrowoncanvas = self.canvas.create_window(0, bottomy, window=self.botrow, anchor="nw")
        self.regionfr.bind("<Return>", self.ok)
        self.regionfr.bind("<Escape>", self.cancel)
Пример #27
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # We create the frame and the ScrolledHList widget
        # at the top of the dialog box
        #
        top = Tix.Frame( w, relief=Tix.RAISED, bd=1)

        # Put a simple hierachy into the HList (two levels). Use colors and
        # separator widgets (frames) to make the list look fancy
        #
        top.a = Tix.ScrolledHList(top)
        top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)

        # This is our little relational database
        #
        bosses = [
            ('jeff',  'Jeff Waxman'),
            ('john',  'John Lee'),
            ('peter', 'Peter Kenson')
        ]

        employees = [
            ('alex',  'john',  'Alex Kellman'),
            ('alan',  'john',  'Alan Adams'),
            ('andy',  'peter', 'Andreas Crawford'),
            ('doug',  'jeff',  'Douglas Bloom'),
            ('jon',   'peter', 'Jon Baraki'),
            ('chris', 'jeff',  'Chris Geoffrey'),
            ('chuck', 'jeff',  'Chuck McLean')
        ]

        hlist=top.a.hlist

        # Let configure the appearance of the HList subwidget
        #
        hlist.config( separator='.', width=25, drawbranch=0, indent=10)

        count=0
        for boss,name in bosses :
            if count :
                f=Tix.Frame(hlist, name='sep%d' % count, height=2, width=150,
                    bd=2, relief=Tix.SUNKEN )

                hlist.add_child( itemtype=Tix.WINDOW,
                    window=f, state=Tix.DISABLED )

            hlist.add(boss, itemtype=Tix.TEXT, text=name)
            count = count+1


        for person,boss,name in employees :
            # '.' is the separator character we chose above
            #
            key= boss    + '.'     + person
            #    ^^^^                ^^^^^^
            #    parent entryPath /  child's name

            hlist.add( key, text=name )

            # [Hint] Make sure the keys (e.g. 'boss.person') you choose
            #    are unique names. If you cannot be sure of this (because of
            #    the structure of your database, e.g.) you can use the
            #    "add_child" command instead:
            #
            #  hlist.addchild( boss,  text=name)
            #                  ^^^^
            #                  parent entryPath


        # Use a ButtonBox to hold the buttons.
        #
        box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
        box.add( 'ok',  text='Ok', underline=0,  width=6,
            command = self.okcmd)

        box.add( 'cancel', text='Cancel', underline=0, width=6,
            command = self.quitcmd)

        box.pack( side=Tix.BOTTOM, fill=Tix.X)
        top.pack( side=Tix.TOP,    fill=Tix.BOTH, expand=1 )
Пример #28
0
    def __init__(self,
                 name,
                 default,
                 count,
                 handler,
                 labels=None,
                 longtext=False):
        self.handler = handler
        Tix.Toplevel.__init__(self)
        self.title(name)
        self.longtext = longtext

        sw = Tix.ScrolledWindow(self)
        self.values = sw.window
        if (labels == None):
            if (count == 1):
                label = Tix.Label(self.values, text="Value:")
            else:
                label = Tix.Label(self.values, text="Value(s):")
                pass
            label.grid(row=0, column=0, sticky="e")
            self.fields = []
            row = 0
            for i in range(0, count):
                if (isbool(default[i])):
                    field = Tix.BooleanVar()
                    field.set(default[i])
                    w = Tix.Checkbutton(self.values, variable=field)
                    pass
                elif longtext:
                    field = Tix.Text(self.values)
                    field.insert("1.0", str(default[i]))
                    w = field
                else:
                    field = Tix.Entry(self.values)
                    field.insert("0", str(default[i]))
                    w = field
                    pass
                w.grid(row=row, column=1, sticky="ew")
                row += 1
                self.fields.append(field)
                pass
            pass
        else:
            self.fields = []
            row = 0
            for i in range(0, count):
                label = Tix.Label(self.values, text=labels[i])
                label.grid(row=row, column=0)
                if (isbool(default[i])):
                    field = Tix.BooleanVar()
                    field.set(default[i])
                    w = Tix.Checkbutton(self.values, variable=field)
                    pass
                elif longtext:
                    field = Tix.Text(self.values)
                    field.insert("1.0", str(default[i]))
                    w = field
                else:
                    field = Tix.Entry(self.values)
                    field.insert("0", str(default[i]))
                    w = field
                    pass
                self.fields.append(field)
                w.grid(row=row, column=1, sticky="ew")
                row += 1
                pass
            pass

        sw.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        bbox = Tix.ButtonBox(self)
        bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel())
        bbox.add("ok", text="Ok", command=lambda w=self: w.ok())
        bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.bind("<Destroy>", self.OnDestroy)
        return
Пример #29
0
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
Пример #30
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # We create the frame and the ScrolledHList widget
        # at the top of the dialog box
        #
        top = Tix.Frame(w, relief=Tix.RAISED, bd=1)

        # Put a simple hierachy into the HList (two levels). Use colors and
        # separator widgets (frames) to make the list look fancy
        #
        top.a = Tix.ScrolledHList(top,
                                  options='hlist.columns 3 hlist.header 1')
        top.a.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)

        hlist = top.a.hlist

        # Create the title for the HList widget
        #       >> Notice that we have set the hlist.header subwidget option to true
        #      so that the header is displayed
        #

        boldfont = hlist.tk.call('tix', 'option', 'get', 'bold_font')

        # First some styles for the headers
        style = {}
        style['header'] = Tix.DisplayStyle(Tix.TEXT,
                                           refwindow=hlist,
                                           anchor=Tix.CENTER,
                                           padx=8,
                                           pady=2,
                                           font=boldfont)

        hlist.header_create(0,
                            itemtype=Tix.TEXT,
                            text='Name',
                            style=style['header'])
        hlist.header_create(1,
                            itemtype=Tix.TEXT,
                            text='Position',
                            style=style['header'])

        # Notice that we use 3 columns in the hlist widget. This way when the user
        # expands the windows wide, the right side of the header doesn't look
        # chopped off. The following line ensures that the 3 column header is
        # not shown unless the hlist window is wider than its contents.
        #
        hlist.column_width(2, 0)

        # This is our little relational database
        #
        boss = ('doe', 'John Doe', 'Director')

        managers = [('jeff', 'Jeff Waxman', 'Manager'),
                    ('john', 'John Lee', 'Manager'),
                    ('peter', 'Peter Kenson', 'Manager')]

        employees = [('alex', 'john', 'Alex Kellman', 'Clerk'),
                     ('alan', 'john', 'Alan Adams', 'Clerk'),
                     ('andy', 'peter', 'Andreas Crawford', 'Salesman'),
                     ('doug', 'jeff', 'Douglas Bloom', 'Clerk'),
                     ('jon', 'peter', 'Jon Baraki', 'Salesman'),
                     ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'),
                     ('chuck', 'jeff', 'Chuck McLean', 'Cleaner')]

        style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)

        style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT,
                                              padx=8,
                                              refwindow=hlist)

        # Let configure the appearance of the HList subwidget
        #
        hlist.config(separator='.', width=25, drawbranch=0, indent=10)
        hlist.column_width(0, chars=20)

        # Create the boss
        #
        hlist.add('.',
                  itemtype=Tix.TEXT,
                  text=boss[1],
                  style=style['mgr_name'])
        hlist.item_create('.',
                          1,
                          itemtype=Tix.TEXT,
                          text=boss[2],
                          style=style['mgr_posn'])

        # Create the managers
        #

        for key, name, posn in managers:
            e = '.' + key
            hlist.add(e, itemtype=Tix.TEXT, text=name, style=style['mgr_name'])
            hlist.item_create(e,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['mgr_posn'])

        for key, mgr, name, posn in employees:
            # "." is the separator character we chose above

            entrypath = '.' + mgr + '.' + key

            #           ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^
            #       parent entryPath / child's name

            hlist.add(entrypath, text=name, style=style['empl_name'])
            hlist.item_create(entrypath,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['empl_posn'])

        # Use a ButtonBox to hold the buttons.
        #
        box = Tix.ButtonBox(top, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.okcmd)

        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)

        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)