Beispiel #1
0
  def about_clicked(self):
    about = Tix.Toplevel(width=600)## bg='#0f0' does not work
    about.title('About PyGlossary')
    about.resizable(False, False)
    about.wm_iconbitmap('@%s%spyglossary.xbm'%(srcDir,os.sep))
    ###
    msg1=Tix.Message(about, width=350, text='PyGlossary %s (Tkinter)'%VERSION,\
      font=('DejaVu Sans', 13, 'bold'))
    msg1.pack(fill='x', expand=True)
    ###
    msg2 = Tix.Message(about, width=350, text=\
'''A tool for workig with dictionary databases
Copyleft © 2008-2009 Saeed Rasooli
PyGlossary is licensed by the GNU General Public License version 3 (or later)''',\
      font=('DejaVu Sans', 9, 'bold'), justify=Tix.CENTER)
    msg2.pack(fill='x', expand=True)
    ###
    msg3=Tix.Message(about, width=350, text=homePage,\
      font=('DejaVu Sans', 8, 'bold'), fg='#3333ff')
    msg3.pack(fill='x', expand=True)
    ###
    msg4=Tix.Message(about, width=350,
      text='Install PyGTK to have a better interface!',\
      font=('DejaVu Sans', 8, 'bold'), fg='#00aa00')
    msg4.pack(fill='x', expand=True)
    ###########
    frame = Tix.Frame(about)
    closeB = Tix.Button(frame, text='Close', command=about.destroy,
                        bg='#ff0000', activebackground='#ff5050')
    closeB.pack(side='right')
    licenseB = Tix.Button(frame, text='License', 
                          command=self.about_license_clicked,
                          bg='#f0f000', activebackground='#f6f622')
    licenseB.pack(side='right')
    frame.pack(fill='x')
Beispiel #2
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())

        status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
        status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)

        # Create two mysterious widgets that need balloon help
        button1 = Tix.Button(w,
                             text='Something Unexpected',
                             command=self.quitcmd)
        button2 = Tix.Button(w, text='Something Else Unexpected')
        button2['command'] = lambda w=button2: w.destroy()
        button1.pack(side=Tix.TOP, expand=1)
        button2.pack(side=Tix.TOP, expand=1)

        # Create the balloon widget and associate it with the widgets that we want
        # to provide tips for:
        b = Tix.Balloon(w, statusbar=status)

        b.bind_widget(button1,
                      balloonmsg='Close Window',
                      statusmsg='Press this button to close this window')
        b.bind_widget(button2,
                      balloonmsg='Self-destruct button',
                      statusmsg='Press this button and it will destroy itself')
Beispiel #3
0
 def __init__(self, root, notebook):
     Tix.Frame.__init__(self, root)
     bbox = Tix.Frame(self)
     bts = [
         Tix.Button(bbox, text=t, command=c) for t, c in [
             ("<<", self.reverse),
             (">>", self.forward),
             ("+", self.plus),
             ("-", self.minus),
         ]
     ]
     bbox.pack(side=Tix.TOP, fill=Tix.X)
     for bt in bts:
         bt.pack(side=Tix.LEFT, fill=Tix.X)
     tlist = Tix.TList(self)
     tlist.pack(expand=1, fill=Tix.BOTH, pady=10, side=Tix.TOP)
     bbox = Tix.Frame(self)
     bts = [
         Tix.Button(bbox, text=t, command=c) for t, c in [
             ("Save", self.save),
             ("Load", self.load),
             ("Clear", self.clear),
         ]
     ]
     bbox.pack(side=Tix.TOP, fill=Tix.X)
     for bt in bts:
         bt.pack(side=Tix.LEFT, fill=Tix.X)
     self.tlist = tlist
     self.patlist = []
     self.notebook = notebook
Beispiel #4
0
def createCommonButtons(master):
    ok = Tix.Button(master, name='ok', text='OK', width=6,
                command=doDestroy)
    cancel = Tix.Button(master, name='cancel',
                    text='Cancel', width=6,
                    command=doDestroy)

    ok.pack(side=Tix.TOP, padx=2, pady=2)
    cancel.pack(side=Tix.TOP, padx=2, pady=2)
Beispiel #5
0
def MkSample(nb, name):
    w = nb.page(name)
    prefix = Tix.OptionName(w)
    if not prefix:
	prefix = ''
    w.option_add('*' + prefix + '*TixLabelFrame*label.padX', 4)

    lab = Tix.Label(w, text='Select a sample program:', anchor=Tix.W)
    lab1 = Tix.Label(w, text='Source:', anchor=Tix.W)

    slb = Tix.ScrolledHList(w, options='listbox.exportSelection 0')
    slb.hlist['command'] = lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'run')
    slb.hlist['browsecmd'] = lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'browse')

    stext = Tix.ScrolledText(w, name='stext')
    stext.text.bind('<1>', stext.text.focus())
    stext.text.bind('<Up>', lambda w=stext.text: w.yview(scroll='-1 unit'))
    stext.text.bind('<Down>', lambda w=stext.text: w.yview(scroll='1 unit'))
    stext.text.bind('<Left>', lambda w=stext.text: w.xview(scroll='-1 unit'))
    stext.text.bind('<Right>', lambda w=stext.text: w.xview(scroll='1 unit'))

    run = Tix.Button(w, text='Run ...', name='run', command=lambda args=0, w=w,slb=slb: Sample_Action(w, slb, 'run'))
    view = Tix.Button(w, text='View Source ...', name='view', command=lambda args=0,w=w,slb=slb: Sample_Action(w, slb, 'view'))

    lab.form(top=0, left=0, right='&'+str(slb))
    slb.form(left=0, top=lab, bottom=-4)
    lab1.form(left='&'+str(stext), top=0, right='&'+str(stext), bottom=stext)
    run.form(left=str(slb)+' 30', bottom=-4)
    view.form(left=run, bottom=-4)
    stext.form(bottom=str(run)+' -5', left='&'+str(run), right='-0', top='&'+str(slb))

    stext.text['bg'] = slb.hlist['bg']
    stext.text['state'] = 'disabled'
    stext.text['wrap'] = 'none'
    #XXX    stext.text['font'] = fixed_font

    slb.hlist['separator'] = '.'
    slb.hlist['width'] = 25
    slb.hlist['drawbranch'] = 0
    slb.hlist['indent'] = 10
    slb.hlist['wideselect'] = 1

    for type in ['widget', 'image']:
	if type != 'widget':
	    x = Tix.Frame(slb.hlist, bd=2, height=2, width=150,
			  relief=Tix.SUNKEN, bg=slb.hlist['bg'])
	    slb.hlist.add_child(itemtype=Tix.WINDOW, window=x, state='disabled')
	x = slb.hlist.add_child(itemtype=Tix.TEXT, state='disabled',
				text=comments[type])
	for key in stypes[type]:
	    slb.hlist.add_child(x, itemtype=Tix.TEXT, data=key,
				text=key)
    slb.hlist.selection_clear()

    run['state'] = 'disabled'
    view['state'] = 'disabled'
Beispiel #6
0
    def __create_widgets(self):
        _soptions = ("label.width 20 label.anchor w label.relief flat "
                     "menubutton.width 15 menubutton.relief groove ")
        _eoptions = ("entry.width 20 entry.relief groove "
                     "label.width 20 label.anchor w label.padx 0 ")

        _frame = Tix.Frame(self, borderwidth=2)
        _frame.grid(padx=2, pady=2, ipady=2, sticky="nesw")

        _w = Tix.OptionMenu(
            _frame,
            label=_("Type:"),            
            options=_soptions,
            )
        for opt in self.__type_list:
            _w.add_command(opt, label=opt)
        _w.config(variable=self.var_type)
        _w.grid(padx=2)

        _w = Tix.LabelEntry(
            _frame,
            label=_("Name:"),
            options=_eoptions,
            )
        _w.subwidget("entry").configure(textvariable=self.var_name)
        _w.grid(padx=0, ipady=2)
        _w.focus_set()

        _w = Tix.LabelEntry(
            _frame,
            label=_("Value:"),
            options=_eoptions,
            )
        _w.subwidget("entry").configure(textvariable=self.var_value)
        _w.grid(row=2, column=0, ipady=2)

        _frame = Tix.Frame(self, class_="Toolbar")
        _frame.grid()

        _w = Tix.Button(
            _frame,
            text=_("Insert"),
            command=self.__new_item,
            )
        _w.grid(row=0, column=0, padx=10, pady=4)

        _w = Tix.Button(
            _frame,
            text=_("Close"),
            command=self.withdraw,
            )
        _w.grid(row=0, column=1, padx=10, pady=10)
Beispiel #7
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')
Beispiel #8
0
def RunSample(w):
    w.img0 = Tix.Image('pixmap', data=network_pixmap)
    if not w.img0:
        w.img0 = Tix.Image('bitmap', data=network_bitmap)
    w.img1 = Tix.Image('pixmap', data=hard_disk_pixmap)
    if not w.img0:
        w.img1 = Tix.Image('bitmap', data=hard_disk_bitmap)

    hdd = Tix.Button(w, padx=4, pady=1, width=120)
    net = Tix.Button(w, padx=4, pady=1, width=120)

    # Create the first image: we create a line, then put a string,
    # a space and a image into this line, from left to right.
    # The result: we have a one-line image that consists of three
    # individual items
    #
    # The tk.calls should be methods in Tix ...
    w.hdd_img = Tix.Image('compound', window=hdd)
    w.hdd_img.tk.call(str(w.hdd_img), 'add', 'line')
    w.hdd_img.tk.call(str(w.hdd_img), 'add', 'text', '-text', 'Hard Disk',
                      '-underline', '0')
    w.hdd_img.tk.call(str(w.hdd_img), 'add', 'space', '-width', '7')
    w.hdd_img.tk.call(str(w.hdd_img), 'add', 'image', '-image', w.img1)

    # Put this image into the first button
    #
    hdd['image'] = w.hdd_img

    # Next button
    w.net_img = Tix.Image('compound', window=net)
    w.net_img.tk.call(str(w.net_img), 'add', 'line')
    w.net_img.tk.call(str(w.net_img), 'add', 'text', '-text', 'Network',
                      '-underline', '0')
    w.net_img.tk.call(str(w.net_img), 'add', 'space', '-width', '7')
    w.net_img.tk.call(str(w.net_img), 'add', 'image', '-image', w.img0)

    # Put this image into the first button
    #
    net['image'] = w.net_img

    close = Tix.Button(w,
                       pady=1,
                       text='Close',
                       command=lambda w=w: w.destroy())

    hdd.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1)
    net.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1)
    close.pack(side=Tix.LEFT, padx=10, pady=10, fill=Tix.Y, expand=1)
Beispiel #9
0
def MkSWindow(w):
    global demo

    top = Tix.Frame(w, width=330, height=330)
    bot = Tix.Frame(w)
    msg = Tix.Message(top, font='-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*',
		      relief=Tix.FLAT, width=200, anchor=Tix.N,
		      text='The TixScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.')
    win = Tix.ScrolledWindow(top, scrollbar='auto')
    image = Tix.Image('photo', file=demo.dir + "/bitmaps/tix.gif")
    lbl = Tix.Label(win.window, image=image)
    lbl.pack(expand=1, fill=Tix.BOTH)

    win.place(x=30, y=150, width=190, height=120)

    rh = Tix.ResizeHandle(top, bg='black',
			  relief=Tix.RAISED,
			  handlesize=8, gridded=1, minwidth=50, minheight=30)
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x))
    top.propagate(0)
    msg.pack(fill=Tix.X)
    btn.pack(anchor=Tix.CENTER)
    top.pack(expand=1, fill=Tix.BOTH)
    bot.pack(fill=Tix.BOTH)
    win.bind('<Map>', func=lambda arg=0, rh=rh, win=win:
	     win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
Beispiel #10
0
    def build(self):
        # control variables
        self.copy_file = Tk.StringVar()

        # frame 0
        self.fr0 = Tix.Frame(self.toplevel)
        self.bu9 = Tix.Button(
            self.fr0,
            text="Cancel",
            command=self.cancel,
        )
        self.bu9.pack(padx=5, pady=5)

        # frame 4
        self.lf4 = Tk.LabelFrame(
            self.toplevel,
            text="Copy progress",
        )
        self.la4 = Tk.Label(self.lf4,
                            width=40,
                            anchor="w",
                            textvariable=self.copy_file)
        self.me4 = Tix.Meter(self.lf4, value=0.0)
        self.la4.pack(padx=5, pady=5)
        self.me4.pack(padx=5, pady=5)

        # pack frames
        self.lf4.pack(padx=5, pady=5)
        self.fr0.pack(side="bottom")
Beispiel #11
0
def MkSText(w):
    """The TixScrolledWindow widget allows you to scroll any kind of Tk
    widget. It is more versatile than a scrolled canvas widget."""
    top = Tix.Frame(w, width=330, height=330)
    bot = Tix.Frame(w)
    msg = Tix.Message(top,
                      relief=Tix.FLAT, width=200, anchor=Tix.N,
                      text='The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.')

    win = Tix.ScrolledText(top, scrollbar='auto')
    win.text['wrap'] = 'none'
    win.text.insert(Tix.END, '''When -scrollbar is set to "auto", the
scrollbars are shown only when needed.
Additional modifiers can be used to force a
scrollbar to be shown or hidden. For example,
"auto -y" means the horizontal scrollbar
should be shown when needed but the vertical
scrollbar should always be hidden;
"auto +x" means the vertical scrollbar
should be shown when needed but the horizontal
scrollbar should always be shown, and so on.'''
)
    win.place(x=30, y=150, width=190, height=100)

    rh = Tix.ResizeHandle(top, bg='black',
                          relief=Tix.RAISED,
                          handlesize=8, gridded=1, minwidth=50, minheight=30)
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SText_reset(w,x))
    top.propagate(0)
    msg.pack(fill=Tix.X)
    btn.pack(anchor=Tix.CENTER)
    top.pack(expand=1, fill=Tix.BOTH)
    bot.pack(fill=Tix.BOTH)
    win.bind('<Map>', func=lambda arg=0, rh=rh, win=win:
             win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
Beispiel #12
0
    def __build__(self, root, row):
        self.TkPhotoImage = Tix.PhotoImage(
            format=self.icon.format, data=self.icon.data
        )  # keep a reference! See http://effbot.org/tkinterbook/photoimage.htm
        self._value = Tix.StringVar(root)

        if not self.lastdir:
            self.lastdir = Tix.StringVar(root, self.initialdir)
        if self.opt.default is not None: self._value.set(self.opt.default)
        self.TkLabel = Tix.Label(root, text=self.opt.help + ':')
        self.TkEntry = Tix.Entry(root, textvariable=self._value)
        self.TkButton = Tix.Button(root,
                                   image=self.TkPhotoImage,
                                   command=Command(self.cmd, root,
                                                   self.opt.help, self.filter,
                                                   self.lastdir, self._value))
        self.TkLabel.grid(row=row, column=0, sticky=Tix.W, padx=2)
        self.TkEntry.grid(row=row, column=1, sticky=Tix.E + Tix.W, padx=2)
        self.TkButton.grid(row=row, column=2, sticky=Tix.E, padx=2)
        if self.tooltip:
            self.TkLabelToolTip = _ToolTip(self.TkLabel,
                                           delay=250,
                                           follow_mouse=1,
                                           text=self.tooltip)
            self.TkEntryToolTip = _ToolTip(self.TkEntry,
                                           delay=250,
                                           follow_mouse=1,
                                           text=self.tooltip)
            self.TkButtonToolTip = _ToolTip(self.TkButton,
                                            delay=250,
                                            follow_mouse=1,
                                            text=self.tooltip)

        self._value.trace('w', self.callback)
        self.enabled = self.enabled  #Force update
Beispiel #13
0
def MkSList(w):
    """This TixScrolledListBox is configured so that it uses scrollbars
    only when it is necessary. Use the handles to resize the listbox and
    watch the scrollbars automatically appear and disappear.  """
    top = Tix.Frame(w, width=300, height=330)
    bot = Tix.Frame(w)
    msg = Tix.Message(top,
                      relief=Tix.FLAT, width=200, anchor=Tix.N,
                      text='This TixScrolledListBox is configured so that it uses scrollbars only when it is necessary. Use the handles to resize the listbox and watch the scrollbars automatically appear and disappear.')

    list = Tix.ScrolledListBox(top, scrollbar='auto')
    list.place(x=50, y=150, width=120, height=80)
    list.listbox.insert(Tix.END, 'Alabama')
    list.listbox.insert(Tix.END, 'California')
    list.listbox.insert(Tix.END, 'Montana')
    list.listbox.insert(Tix.END, 'New Jersey')
    list.listbox.insert(Tix.END, 'New York')
    list.listbox.insert(Tix.END, 'Pennsylvania')
    list.listbox.insert(Tix.END, 'Washington')

    rh = Tix.ResizeHandle(top, bg='black',
                          relief=Tix.RAISED,
                          handlesize=8, gridded=1, minwidth=50, minheight=30)
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=list: SList_reset(w,x))
    top.propagate(0)
    msg.pack(fill=Tix.X)
    btn.pack(anchor=Tix.CENTER)
    top.pack(expand=1, fill=Tix.BOTH)
    bot.pack(fill=Tix.BOTH)
    list.bind('<Map>', func=lambda arg=0, rh=rh, list=list:
              list.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(list)))
Beispiel #14
0
 def _build_calendar(self):
     # Create frame and widgets.
     # Add header.
     hframe = TKx.Frame(self)
     hframe.pack(fill='x', expand=1)
     self.month_str = TKx.StringVar()
     lbtn = TKx.Button(hframe, text=u'\u25b2', command=self._prev_month)
     rbtn = TKx.Button(hframe, text=u'\u25bc', command=self._next_month)
     lbtn.pack(side='left')
     rbtn.pack(side='right')
     tl = TKx.Label(hframe, textvariable=self.month_str)
     tl.pack(side='top')
     self.top_label = tl
     self._set_month_str()
     self.days_frame = TKx.Frame(self)
     self.days_frame.pack(fill='x', expand=1)
Beispiel #15
0
    def view_info(self):
        top = self.skyeye_body("System information")

        tmp = Tix.Frame(top, padx=10, pady=15)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Below are the information of the whole system:')
        b.grid(row=0, padx=5, pady=3, sticky=W + E)

        str = ""

        str += "Cpu \t\t: %s\n" % self.cpu
        str += "Mainboard \t: %s\n" % self.board
        str += "Net \t\t: %s\n" % self.net
        str += "Lcd \t\t: %s\n" % self.lcd
        str += "Flash \t\t: %s\n" % self.flash

        for x in self.membank:
            str += "membank \t : "

            str += "map=" + x["map"] + ","
            str += "type=" + x["type"] + ","
            str += "addr=" + x["addr"] + ","
            str += "size=" + x["size"]

            if x["file"] != "":
                str += ",file=" + x["file"]
            str += "\n"

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='%s' % str)
        b.grid(row=1, padx=5, pady=3, sticky=W + E)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Would you want to reset ALL?')
        b.grid(row=2, padx=5, pady=3, sticky=W + E)

        reset = Tix.Button(tmp,
                           text="OK",
                           command=self.reset_all,
                           width=5,
                           bg="red",
                           fg="white")
        reset.grid(row=3, padx=5, pady=3)

        tmp.grid(padx=5, pady=25)

        self.message("System information is :\n" + str)

        self.skyeye_redobody()
Beispiel #16
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)
Beispiel #17
0
def MkSWindow(w):
    """The ScrolledWindow widget allows you to scroll any kind of Tk
    widget. It is more versatile than a scrolled canvas widget.
    """
    global demo

    text = 'The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.'

    file = os.path.join(demo.dir, 'bitmaps', 'tix.gif')
    if not os.path.isfile(file):
        text += ' (Image missing)'

    top = Tix.Frame(w, width=330, height=330)
    bot = Tix.Frame(w)
    msg = Tix.Message(top, relief=Tix.FLAT, width=200, anchor=Tix.N, text=text)

    win = Tix.ScrolledWindow(top, scrollbar='auto')

    if 0:
        global image1
        # This image is not showing up in the Label unless it is set to a
        # global variable - no problem under Tcl/Tix. I assume it is being
        # garbage collected somehow, even though the Tcl command 'image names'
        # shows that as far as Tcl is concerned, the image exists and is
        # called pyimage1. What I find curious is that this if 0: branch
        # works only if image1 is global, *even though I give Label a string*.
        image1 = Tix.Image('photo', file=file)
    else:
        # No need for image1 to be global if I do it in pure Tcl.
        # When I do it in pure Tcl the image shows up in the Label.
        # The tcl command 'image names' shows as far as Tcl is concerned,
        # the image exists and is called image1. So I assume the problem
        # lies Tkinter.py Image.__init__, where the image gets the name
        # pyimage1, instead of what Tcl would have called it - image1.
        image1 = win.tk.eval('image create photo -file {%s}' % file)

    lbl = Tix.Label(win.window, image='%s' % image1)
    lbl.pack(expand=1, fill=Tix.BOTH)

    win.place(x=30, y=150, width=190, height=120)

    rh = Tix.ResizeHandle(top,
                          bg='black',
                          relief=Tix.RAISED,
                          handlesize=8,
                          gridded=1,
                          minwidth=50,
                          minheight=30)
    btn = Tix.Button(bot,
                     text='Reset',
                     command=lambda w=rh, x=win: SWindow_reset(w, x))
    top.propagate(0)
    msg.pack(fill=Tix.X)
    btn.pack(anchor=Tix.CENTER)
    top.pack(expand=1, fill=Tix.BOTH)
    bot.pack(fill=Tix.BOTH)
    win.bind('<Map>',
             func=lambda arg=0, rh=rh, win=win: win.tk.call(
                 'tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
Beispiel #18
0
def testGainSlider():
    root = Tix.Tk()
    root.title('testGainSlider')
    foo = GainSlider(root, ['kp', 'kd'], 'foo', [1000, 100], [100, 10])
    foo.pack(expand=True, fill=Tix.X)
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #19
0
 def __init__(self, parent, proxies):
     Tix.Frame.__init__(self, parent)
     self.proxies = proxies
     self.button = Tix.Button(self,
                              text='Initialize',
                              bg='#66cc66',
                              command=self.Initialize)
     self.button.pack(side=Tix.TOP, expand=True, fill=Tix.X)
Beispiel #20
0
    def net_lcd_flash_ok(self, event=None):
        self.device_once = 1
        top = self.skyeye_body("Peripherial")

        tmp = Tix.Frame(top)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Below are the information of peripherials:')
        b.grid(row=0, padx=5, pady=3, sticky=W + E)

        self.net = self.net_v.get()[2:-3]
        str = ""
        if self.net != "":
            str += "\tNet\t: %s\n" % self.net
        else:
            str += "\tNet\t: disabled\n"

        self.lcd = self.lcd_v.get()[2:-3]
        if self.lcd != "":
            str += "\tLcd\t: %s\n" % self.lcd
        else:
            str += "\tLcd\t: disabled\n"

        self.flash = self.flash_v.get()[2:-3]
        if self.flash != "":
            str += "\tFlash\t: %s\n" % self.flash
        else:
            str += "\tFlash\t: disabled\n"

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='%s' % str)
        b.grid(row=1, padx=5, pady=3, sticky=W + E)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Would you want to reset?')
        b.grid(row=2, padx=5, pady=3, sticky=W + E)

        reset = Tix.Button(tmp,
                           text="OK",
                           command=self.reset_device,
                           width=5,
                           bg="red",
                           fg="white")
        reset.grid(row=3, padx=5, pady=3)

        tmp.grid(padx=5, pady=10)

        self.message("Peripherial information:\n" + str)
        self.skyeye_redobody()
Beispiel #21
0
def testGainSetter():
    root = Tix.Tk()
    root.title('testGainSetter')
    foo = GainSetter(root, 1000, 80)
    foo.pack(expand=True, fill=Tix.X)
    foo.Reset(['toto', 'tutu'], [20, 100], [19, 22])
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #22
0
def testBunchOfGainSliders():
    root = Tix.Tk()
    root.title('testBunchOfGainSliders')
    foo = BunchOfGainSliders(root, ['kp', 'kd'], [1000, 100])
    foo.pack(expand=True, fill=Tix.X)
    foo.Reset(['toto', 'tutu'], [[200, 20], [333, 33]])
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #23
0
 def __init__(self):
     self.top = Tix.Toplevel()
     frame = Tix.Frame(self.top)
     frame2 = Tix.Frame(frame)
     self.apropos_str = Tix.StringVar()
     btn = Tix.Button(frame2, text='Apropos:', command=self.Apropos)
     entry = Tix.Entry(frame2, relief=Tix.SUNKEN, width=20)
     entry['textvariable'] = self.apropos_str
     entry.bind('<Return>', self.Apropos)
     btn.pack(side=Tix.LEFT, expand=0)
     entry.pack(side=Tix.RIGHT, expand=1, fill=Tix.X)
     frame2.pack(side=Tix.TOP, expand=0, fill=Tix.X)
     self.stext = Tix.ScrolledText(frame)
     self.stext.text.tag_config('!', font=BOLDFONT)
     btn = Tix.Button(frame, text='Close', command=self.Quit)
     self.stext.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
     btn.pack(side=Tix.BOTTOM, expand=0, fill=Tix.X)
     frame.pack(expand=1, fill=Tix.BOTH)
Beispiel #24
0
def testGoalSlider():
    root = Tix.Tk()
    root.title('testGoalSlider')
    foo = GoalSlider(root, 'foo', 'm', -100, 0, -80, -60)
    foo.pack(expand=True, fill=Tix.X)
    bar = GoalSlider(root, 'bar', 'rad', -math.pi, math.pi, -0.1, 0.05)
    bar.pack(expand=True, fill=Tix.X)
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #25
0
def testBunchOfGoalSliders():
    root = Tix.Tk()
    root.title('testBunchOfGoalSliders')
    foo = BunchOfGoalSliders(root)
    foo.pack(expand=True, fill=Tix.X)
    foo.Reset(['toto', 'tutu'], ['rad', 'bananas'], [20, -20], [19, -22],
              [-100, -500], [50, 100])
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #26
0
def testGoalSetter():
    root = Tix.Tk()
    root.title('testGoalSetter')
    foo = GoalSetter(root)
    foo.pack(expand=True, fill=Tix.X)
    foo.Reset(['toto', 'tutu'], ['apples', 'radians'], [20, -20], [19, -22],
              [-100, -500], [50, 100])
    quitter = Tix.Button(root, text='QUIT', command=root.quit)
    quitter.pack()
    root.mainloop()
Beispiel #27
0
    def memory_ok(self, event=None):
        self.memory_once = 1

        top = self.skyeye_body("Memory")

        tmp = Tix.Frame(top)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Below are the information of memory:')
        b.grid(row=0, padx=5, pady=3, sticky=W + E)

        str = ""
        for x in self.membank:
            str += "membank:"

            str += "map=" + x["map"] + ","
            str += "type=" + x["type"] + ","
            str += "addr=" + x["addr"] + ","
            str += "size=" + x["size"]

            if x["file"] != "":
                str += ",file=" + x["file"]
            str += "\n"

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='%s' % str)
        b.grid(row=1, padx=5, pady=3, sticky=W + E)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Would you want to reset?')
        b.grid(row=2, padx=5, pady=3, sticky=W + E)

        reset = Tix.Button(tmp,
                           text="OK",
                           command=self.reset_memory,
                           width=5,
                           bg="red",
                           fg="white")
        reset.grid(row=3, padx=5, pady=3)

        tmp.grid(padx=5, pady=10)

        self.message("Memory information is :\n" + str)

        self.skyeye_redobody()
Beispiel #28
0
def RunSample(w):
    status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
    status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)

    # Create two mysterious widgets that need balloon help
    button1 = Tix.Button(w, text='Something Unexpected',
			 command=lambda w=w: w.destroy())
    button2 = Tix.Button(w, text='Something Else Unexpected')
    button2['command'] = lambda w=button2: w.destroy()
    button1.pack(side=Tix.TOP, expand=1)
    button2.pack(side=Tix.TOP, expand=1)

    # Create the balloon widget and associate it with the widgets that we want
    # to provide tips for:
    b = Tix.Balloon(w, statusbar=status)

    b.bind_widget(button1, balloonmsg='Close Window',
		  statusmsg='Press this button to close this window')
    b.bind_widget(button2, balloonmsg='Self-destruct button',
		  statusmsg='Press this button and it will destroy itself')
Beispiel #29
0
 def __init__(self, parent, name, get_mode, set_mode):
     Tix.Frame.__init__(self, parent, bd=2, relief=Tix.RIDGE)
     self.name = name
     self.get_mode = get_mode
     self.set_mode = set_mode
     self.set_btn = Tix.Button(self,
                               text='Set %s (%d)' % (name, set_mode),
                               command=self.Set)
     self.set_btn.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.get_btn = Tix.Button(self,
                               text='Get %s (%d)' % (name, get_mode),
                               command=self.Get)
     self.get_btn.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.labeltext = Tix.StringVar(self)
     self.labeltext.set('(no status yet)')
     self.label = Tix.Label(self, textvariable=self.labeltext)
     self.label.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.sliders = SliderStack(self)
     self.sliders.pack(side=Tix.TOP, expand=True, fill=Tix.X)
     self.task_posture_ui_srv = None
Beispiel #30
0
    def __init__(self, master, name, contents):
        Tk.Frame.__init__(self, master)
        make_attributes_from_args('name', 'contents')

        self.button = Tk.Button(self, text=name)
        self.button.pack(side='left')
        self.combo = Tk.ComboBox(self)
        self.combo.pack(side='left')
        self.pack(side='left')

        self.listbox = self.combo.slistbox.listbox
        self.strings_to_parse = {}