def __init__(self, parent, prefixes, name, maxvals, gains): if (len(prefixes) != len(maxvals)) or (len(prefixes) != len(gains)): raise 'you gave me %d prefixes, %d maxvals, and %d gains' % ( len(prefixes), len(maxvals), len(gains)) Tix.Frame.__init__(self, parent) self.name = Tix.Label(self, text='name: %s' % name, anchor='w') self.name.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.gain_var = [] self.gain_label = [] self.gain_scale = [] self.master_var = [] for ii in xrange(len(prefixes)): gv = Tix.DoubleVar(self) gv.set(gains[ii]) frame = Tix.Frame(self) Tix.Label(frame, text=prefixes[ii], width=6).pack(side=Tix.LEFT) gs = Tix.Scale(frame, orient=Tix.HORIZONTAL, variable=gv, showvalue=0, from_=0, to=maxvals[ii]) gs.pack(side=Tix.LEFT, expand=True, fill=Tix.X) gl = Tix.Label(frame, textvariable=gv, width=12) gl.pack(side=Tix.LEFT) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.gain_var.append(gv) self.gain_label.append(gl) self.gain_scale.append(gs) self.master_var.append(None)
def __init__(self, parent, name, unit, lower, upper, value): Tix.Frame.__init__(self, parent) self.unit_scale = 1 if unit == 'rad' or unit == 'radians': unit = 'deg' self.unit_scale = math.pi / 180 elif unit == 'm' or unit == 'meters': unit = 'mm' self.unit_scale = 0.001 lower /= self.unit_scale upper /= self.unit_scale value /= self.unit_scale Tix.Label(self, text = '%s [%s] (%5.2f to %5.2f)' % (name, unit, lower, upper), anchor = 'w')\ .pack(side = Tix.TOP, expand = True, fill = Tix.X) self.value_var = Tix.DoubleVar(self) self.value_var.set(value) frame = Tix.Frame(self) Tix.Label(frame, text='value', width=6).pack(side=Tix.LEFT) self.value_scale = Tix.Scale(frame, orient=Tix.HORIZONTAL, variable=self.value_var, showvalue=0, from_=lower, to=upper, command=self._UpdateValueLabel) self.value_scale.pack(side=Tix.LEFT, expand=True, fill=Tix.X) self.FORMAT = '%5.2f' self.value_label = Tix.Label(frame, text=self.FORMAT % value, width=12) self.value_label.pack(side=Tix.LEFT) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.lower = lower self.upper = upper self.master_var = None
def __init__(self, master): Tk.Frame.__init__(self, master) self.tktime = TkTime(self, bg='black', fg='white', insertbackground='white', parsed_color='blue', special_symbols=[NotPresent]) self.tktime.pack(side='top', fill='both', expand=1) contextframe = Tk.Frame(self) contexttext = Tk.Label(contextframe, text='Context') contexttext.pack(side='left', ipadx=0, ipady=0, padx=0, pady=0) self.context = TkTime(contextframe) dispatcher.connect(self.context_selector, "selection made", sender=self.context) dispatcher.connect(self.context_has_parses, "new segment parses", sender=self.context) self.context['height'] = 23 # errr... self.context.pack(side='left', fill='x', expand=0) self.contextlabel = Tk.Label(contextframe) self.contextlabel.pack(side='left', ipadx=0, ipady=0, padx=0, pady=0, expand=1) contextframe.pack(side='top', fill='both', expand=0) self.context.text.bind("<KeyRelease>", self.typed_in_context, '+')
def body( self, master ): theRow = 0 Tix.Label( master, text="Font Family" ).grid( row=theRow, column=0 ) Tix.Label( master, text="Font Size" ).grid( row=theRow, column=2 ) theRow += 1 # Font Families fontList = Tix.ComboBox( master, command=self.selectionChanged, dropdown=False, editable=False, selectmode=Tix.IMMEDIATE, variable=self._family ) fontList.grid( row=theRow, column=0, columnspan=2, sticky=Tix.N+Tix.S+Tix.E+Tix.W, padx=10 ) first = None familyList = list(tkFont.families( )) familyList.sort() for family in familyList: if family[0] == '@': continue if first is None: first = family fontList.insert( Tix.END, family ) fontList.configure( value=first ) # Font Sizes sizeList = Tix.ComboBox( master, command=self.selectionChanged, dropdown=False, editable=False, selectmode=Tix.IMMEDIATE, variable=self._sizeString ) sizeList.grid( row=theRow, column=2, columnspan=2, sticky=Tix.N+Tix.S+Tix.E+Tix.W, padx=10 ) for size in xrange( 6,31 ): sizeList.insert( Tix.END, '%d' % size ) sizeList.configure( value='9' ) # Styles if self._showStyles is not None: theRow += 1 if self._showStyles in ( FontChooser.ALL, FontChooser.BASIC ): Tix.Label( master, text='Styles', anchor=Tix.W ).grid( row=theRow, column=0, pady=10, sticky=Tix.W ) theRow += 1 Tix.Checkbutton( master, text="bold", command=self.selectionChanged, offvalue='normal', onvalue='bold', variable=self._weight ).grid(row=theRow, column=0) Tix.Checkbutton( master, text="italic", command=self.selectionChanged, offvalue='roman', onvalue='italic', variable=self._slant ).grid(row=theRow, column=1) if self._showStyles == FontChooser.ALL: Tix.Checkbutton( master, text="underline", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isUnderline ).grid(row=theRow, column=2) Tix.Checkbutton( master, text="overstrike", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isOverstrike ).grid(row=theRow, column=3) # Sample Text theRow += 1 Tix.Label( master, text='Sample Text', anchor=Tix.W ).grid( row=theRow, column=0, pady=10, sticky=Tix.W ) theRow += 1 self.sampleText = Tix.Text( master, height=11, width=70 ) self.sampleText.insert( Tix.INSERT, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz', 'fontStyle' ) self.sampleText.config( state=Tix.DISABLED ) self.sampleText.tag_config( 'fontStyle', font=self._currentFont ) self.sampleText.grid( row=theRow, column=0, columnspan=4, padx=10 )
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'
def __init__(self, parent, name, unit, lower, upper, goal, actual): Tix.Frame.__init__(self, parent) self.unit_scale = 1 if unit == 'rad' or unit == 'radians': unit = 'deg' self.unit_scale = math.pi / 180 elif unit == 'm' or unit == 'meters': unit = 'mm' self.unit_scale = 0.001 lower /= self.unit_scale upper /= self.unit_scale goal /= self.unit_scale actual /= self.unit_scale Tix.Label(self, text = '%s [%s] (%5.2f to %5.2f)' % (name, unit, lower, upper), anchor = 'w')\ .pack(side = Tix.TOP, expand = True, fill = Tix.X) self.goal_var = Tix.DoubleVar(self) self.goal_var.set(goal) frame = Tix.Frame(self) Tix.Label(frame, text='goal', width=6).pack(side=Tix.LEFT) self.goal_scale = Tix.Scale(frame, orient=Tix.HORIZONTAL, variable=self.goal_var, showvalue=0, from_=lower, to=upper, command=self._UpdateGoalLabel) self.goal_scale.pack(side=Tix.LEFT, expand=True, fill=Tix.X) self.FORMAT = '%5.2f' self.goal_label = Tix.Label(frame, text=self.FORMAT % goal, width=12) self.goal_label.pack(side=Tix.LEFT) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.actual_var = Tix.DoubleVar(self) self.actual_var.set(actual) frame = Tix.Frame(self) Tix.Label(self, text='actual', width=6).pack(side=Tix.LEFT) self.actual_scale = Tix.Scale(self, orient=Tix.HORIZONTAL, state=Tix.DISABLED, sliderrelief=Tix.FLAT, sliderlength=3, variable=self.actual_var, showvalue=0, from_=lower, to=upper, command=self._UpdateGoalLabel) self.actual_scale.pack(side=Tix.LEFT, expand=True, fill=Tix.X) self.actual_label = Tix.Label(frame, text=self.FORMAT % actual, width=12) self.actual_label.pack(side=Tix.LEFT) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.lower = lower self.upper = upper self.master_var = None
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 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)))
def MkMainStatus(top): global demo w = Tix.Frame(top, relief=Tix.RAISED, bd=1) demo.statusbar = Tix.Label(w, relief=Tix.SUNKEN, bd=1, font='-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*') demo.statusbar.form(padx=3, pady=3, left=0, right='%70') return w
def __init__(self, parent): Tix.Frame.__init__(self, parent) self.slider = [] self.master_override = Tix.IntVar(self) self.master_override.set(0) frame = Tix.Frame(self) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.master_check = Tix.Checkbutton(frame, text='override', variable=self.master_override, command=self.Toggle) self.master_check.pack(side=Tix.LEFT) self.master_var = Tix.DoubleVar(self) self.master_var.set(0) self.master_scale = Tix.Scale(frame, orient=Tix.HORIZONTAL, variable=self.master_var, showvalue=0, from_=0, to=100, command=self._UpdateMaster) self.master_scale.pack(side=Tix.LEFT, expand=True, fill=Tix.X) Tix.Label(frame, textvariable=self.master_var, width=12).pack(side=Tix.LEFT) self.gframe = Tix.Frame(self) self.gframe.pack(side=Tix.TOP, expand=True, fill=Tix.X)
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')
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)
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
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)))
def MkMainStatus(self): global test top = self.root w = Tix.Frame(top, relief=Tix.RAISED, bd=1) test.statusbar = Tix.Label(w, relief=Tix.SUNKEN, bd=1) test.statusbar.form(padx=3, pady=3, left=0, right='%70') return w
def _build_dategrid(self): # Prepare data. datematrix = self._cal.monthdatescalendar(self.year, self.month) for i in range(self.postweeks + 6 - len(datematrix)): # Get first day in list. d = datematrix[-1][-1] # Add a list of seven days prior to first in datematrix. datematrix.append([d + self.timedelta(x) for x in range(1, 8)]) for i in range(self.preweeks): # Get first day in list. d = datematrix[0][0] # Add a list of seven days prior to first in datematrix. datematrix.insert(0, [d - self.timedelta(x) for x in range(7, 0, -1)]) # Clear out date frame. for child in self.days_frame.winfo_children(): child.destroy() # Add day headers and day radiobuttons. for col, text in enumerate(calendar.day_abbr): tl = TKx.Label(self.days_frame, text=text[:2]) tl.grid(row=0, column=(col + 1) % 7, sticky='nsew') for row, week in enumerate(datematrix): for col, day in enumerate(week): text = str(day.day) if text == '1' and self.months_on_calendar: text = calendar.month_name[day.month][:3] # + u'\n1' if self.userange: trb = TKx.Checkbutton( self.days_frame, text=text, padx=4, indicator=False, onvalue=day, ) else: trb = TKx.Radiobutton( self.days_frame, text=text, padx=4, indicator=False, variable=self.strvar, value=day, ) trb['command'] = self._set_month_str trb.grid(row=row + 1, column=col, sticky='nsew') self.days_frame.columnconfigure(col, weight=1) if self.sel_bg: trb.config(selectcolor=self.sel_bg) if self.userange: trb.bind('<1>', lambda e, x=day: self._edit_range(e, x)) self._set_month_str() self._color_buttons() self._color_date_range()
def __init__(self, parent, lower, upper): Tix.Frame.__init__(self, parent) Tix.Label(self, text = 'goal').pack(side = Tix.TOP, expand = True, fill = Tix.X) goal = (lower + upper) / 2.0 self.goal_var = Tix.DoubleVar(self) self.goal_var.set(goal) frame = Tix.Frame(self) Tix.Label(frame, text = 'goal', width = 6).pack(side = Tix.LEFT) self.goal_scale = Tix.Scale(frame, orient = Tix.HORIZONTAL, variable = self.goal_var, showvalue = 0, from_ = lower, to = upper, command = self._UpdateGoalLabel) self.goal_scale.pack(side = Tix.LEFT, expand = True, fill = Tix.X) self.FORMAT = '%5.2f' self.goal_label = Tix.Label(frame, text = self.FORMAT % goal, width = 12) self.goal_label.pack(side = Tix.LEFT) frame.pack(side = Tix.TOP, expand = True, fill = Tix.X) self.lower = lower self.upper = upper
def __build__(self,root,row): ''' Build a combobox @type root: C{Tix.Tk} @param root: Root Tk instance. @type row: C{int} @param row: Grid row to place the file browser in. ''' self.TkPhotoImage = Tix.PhotoImage(format=self.icon.format,data=self.icon.data) # keep a reference! See http://effbot.org/tkinterbook/photoimage.htm if self.multiselect: self._value = Tix.StringVar(root) self.dummy = Tix.StringVar(root) self.TkComboBox=Tix.ComboBox(root, dropdown=1, command=self.__updatemulti__,selectmode='immediate',editable=1,variable=self.dummy,options='listbox.height 6 listbox.background white') self.TkComboBox.subwidget('slistbox').subwidget('listbox').configure(selectmode='extended') else: self._value = Tix.StringVar(root) self.TkComboBox=Tix.ComboBox(root, command=self.callback, dropdown=1, editable=1,variable=self._value,options='listbox.height 6 listbox.background white') self.TkLabel=Tix.Label(root, text=self.label+':') for o in self.options:self.TkComboBox.insert(Tix.END, o) if self.opt.default is not None: selected=self.opt.default else: selected=self.options[0] self.TkComboBox.set_silent(selected) self._value.set(selected) self.TkComboBox.subwidget('entry').bind('<Key>', lambda e: 'break') self.TkImage = Tix.Label(root,image=self.TkPhotoImage) self.TkLabel.grid(row=row, column=0,sticky=Tix.W, padx=2) self.TkComboBox.grid(row=row, column=1,sticky=Tix.E+Tix.W) self.TkImage.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.TkDropListToolTip=_ToolTip(self.TkComboBox, delay=250, follow_mouse=1, text=self.tooltip) self.TkImageToolTip=_ToolTip(self.TkImage, delay=250, follow_mouse=1, text=self.tooltip) #self._value.trace('w',self.callback) self.enabled=self.enabled #Force update
def LoadConfigScreen(): s = Tix.Toplevel() s.protocol("WM_DELETE_WINDOW", on_closing) s.title("Table InfExtractor") s.geometry('{}x{}'.format(500, 500)) topframe = Tix.Frame(s, height=10) topframe.pack() frame = Tix.Frame(s) frame.pack() newproject = Tix.Radiobutton(frame, text="Create New Project", variable=variab, value="NP", command=lambda: EnableLEntity(E2, Lb3)) newproject.pack() newprojectFrame = Tix.Frame(frame, height=100) names = Tix.StringVar() label_projectName = Tix.Label(newprojectFrame, textvariable=names) names.set("Project Name") label_projectName.pack(side=Tix.LEFT) E2 = Tix.Entry(newprojectFrame, bd=5) E2.pack(side=Tix.LEFT) newprojectFrame.pack() loadproject = Tix.Radiobutton(frame, text="Load Project", variable=variab, value="LP", command=lambda: EnableLB(Lb3, E2)) loadproject.pack() loadprojectFrame = Tix.Frame(frame, height=100) loadprojectFrame.pack() Lb3 = Tix.Listbox(loadprojectFrame, width=80, height=20) projects = FileManipulationHelper.readProjects() i = 1 for p in projects: Lb3.insert(i, p) i = i + 1 Lb3.pack() Lb3.configure(exportselection=False) Lb3.configure(state=Tix.DISABLED) variab.set("NP") newproject.select() BottomFrame = Tix.Frame(s, height=10) BottomFrame.pack() NextButtonFrame = Tix.Frame(s) NextButtonFrame.pack() NextButton = Tix.Button( NextButtonFrame, text="Next", fg="black", command=lambda: FinishFirstScreen(variab, E2, Lb3, s)) NextButton.pack()
def __init__(self, parent): Tix.Frame.__init__(self, parent, bd=2, relief=Tix.RIDGE) frame = Tix.Frame(self) self.button = Tix.Button(frame, text='SetGoal', command=self.SetGoal) self.button.pack(side=Tix.LEFT) self.labeltext = Tix.StringVar(self) self.labeltext.set('(no status yet)') self.label = Tix.Label(frame, textvariable=self.labeltext) self.label.pack(side=Tix.LEFT, expand=True, fill=Tix.X) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.goal_slider = GoalSlider(self, -100, 100) self.goal_slider.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.set_goal = None
def __build__(self,root,row): self._value = Tix.BooleanVar(root) self._value.set(self.opt.default) self.TkLabel=Tix.Label(root, text=self.label+':') self.TkCheckbutton=Tix.Checkbutton(root, variable=self._value) self.TkLabel.grid(row=row, column=0,sticky=Tix.W) self.TkCheckbutton.grid(row=row, column=1,sticky=Tix.W) if self.tooltip: self.TkLabelToolTip=_ToolTip(self.TkLabel, delay=250, follow_mouse=1, text=self.tooltip) self.TkCheckbuttonToolTip=_ToolTip(self.TkCheckbutton, delay=250, follow_mouse=1, text=self.tooltip) self._value.trace('w',self.callback) self.enabled=self.enabled #Force update
def __init__(self, parent, kpmax, kdmax): Tix.Frame.__init__(self, parent, bd=2, relief=Tix.RIDGE) frame = Tix.Frame(self) self.button = Tix.Button(frame, text='SetGains', command=self.SetGains) self.button.pack(side=Tix.LEFT) self.labeltext = Tix.StringVar(self) self.labeltext.set('(no status yet)') self.label = Tix.Label(frame, textvariable=self.labeltext) self.label.pack(side=Tix.LEFT, expand=True, fill=Tix.X) frame.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.gains = BunchOfGainSliders(self, ['kp', 'kd'], [kpmax, kdmax]) self.gains.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.set_gains = None
def MkPanedWindow(w): msg = Tix.Message(w, font='-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*', relief=Tix.FLAT, width=240, anchor=Tix.N, text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.') group = Tix.Label(w, text='Newsgroup: 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) text = Tix.ScrolledText(p2) list.listbox.insert(Tix.END, " 12324 Re: TK is good for your health") list.listbox.insert(Tix.END, "+ 12325 Re: TK is good for your health") list.listbox.insert(Tix.END, "+ 12326 Re: Tix is even better for your health (Was: TK is good...)") list.listbox.insert(Tix.END, " 12327 Re: Tix is even better for your health (Was: TK is good...)") list.listbox.insert(Tix.END, "+ 12328 Re: Tix is even better for your health (Was: TK is good...)") list.listbox.insert(Tix.END, " 12329 Re: Tix is even better for your health (Was: TK is good...)") list.listbox.insert(Tix.END, "+ 12330 Re: Tix is even better for your health (Was: TK 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.tcl 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. This way you can display very fancy stuffs in your GUI. For example, you can display a text string string together with a bitmap, at the same time, inside a TK button widget. A screenshot of compound images can be found at the bottom of this page: http://www.cis.upenn.edu/~ioi/tix/screenshot.html You can also you is in other places such as putting fancy bitmap+text in menus, tabs of tixNoteBook widgets, etc. This feature will be included in the next release of Tix (4.0b1). Count on it to make jazzy interfaces!""") list.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6) text.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6) msg.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH) 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)
def __build__(self,root,row): self._value = Tix.StringVar(root) if self.opt.default is not None:self._value.set(self.opt.default) self.TkLabel=Tix.Label(root, text=self.label+':') self.TkEntry=Tix.Entry(root, textvariable=self._value) #self.TkEntry.bind('<Key>', self.keypress) self.TkLabel.grid(row=row, column=0,sticky=Tix.W) self.TkEntry.grid(row=row, column=1,sticky=Tix.E+Tix.W, 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._value.trace('w',self.callback) self.enabled=self.enabled #Force update
def BlackListWindow(project_name, rule_name): BlackListWindow = Tix.Toplevel() BlackListWindow.title("Edit Black List") BlackListWindow.geometry('{}x{}'.format(450, 250)) itemsFrame = Tix.Frame(BlackListWindow) itemsFrame.pack() namerule_label = Tix.Label( itemsFrame, text="List of terms in blacklist").grid(row=0, sticky='w') list = Tix.Text(itemsFrame, height=10, width=50) list.grid(row=1, sticky='w') saveButton = Tix.Button( itemsFrame, text="Save", fg="black", command=lambda: SaveBlackList(list.get("1.0", Tix.END), BlackListWindow )).grid(row=2, sticky='w')
def __init__(self, parent, goal_setter, gain_setter, controller_selector): Tix.Frame.__init__(self, parent) self.goal_setter = goal_setter self.gain_setter = gain_setter self.controller_selector = controller_selector self.button = Tix.Button(self, text='Initialize', bg='#66cc66', command=self.Initialize) self.button.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.labeltext = Tix.StringVar(self) self.labeltext.set('(not initialized yet)') self.label = Tix.Label(self, textvariable=self.labeltext, anchor='w') self.label.pack(side=Tix.TOP, expand=True, fill=Tix.X) self.get_info = None self.get_state = None
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)
def MkWelcomeText(top): global demo w = Tix.ScrolledWindow(top, scrollbar='auto') win = w.window title = Tix.Label(win, font='-*-times-bold-r-normal-*-18-*-*-*-*-*-*-*', bd=0, width=30, anchor=Tix.N, text='Welcome to TIX Version 4.0 from Python Version 1.3') msg = Tix.Message(win, font='-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*', bd=0, width=400, anchor=Tix.N, text='Tix 4.0 is a set of mega-widgets based on TK. This program \ demonstrates the widgets in the Tix widget set. You can choose the pages \ in this window to look at the corresponding widgets. \n\n\ To quit this program, choose the "File | Exit" command.') title.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10) msg.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10) demo.welmsg = msg return w
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') image1 = win.window.image_create('photo', file=file) lbl = Tix.Label(win.window, image=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)))
def __init__(self, parent, region, number): self.myparent = parent self.region = region self.number = number self.frame = tk.Frame(self.myparent.toprow, bd=4, relief='ridge') self.frame.grid(row=self.number, column=0, sticky='ew') self.numberwidget = tk.Label(self.frame, text=self.number) self.numberwidget.grid(row=0, column=0, rowspan=2, padx=10) self.color = tk.StringVar() self.color.set(self.region.color) # self.color.trace("w", self.colorchange) self.colorwidget = tk.Frame(self.frame, width=40, height=40, bg=self.color.get()) self.colorwidget.grid(row=0, column=1, rowspan=2, padx=10) self.colorwidget.bind("<Button-1>", self.colorchoose) # self.num = tk.IntVar() # self.num.set(self.region.num) # self.num.trace("w", self.numchange) # self.numlabel = tk.Label(self.frame, text="Num") # self.numlabel.grid(row=0, column=2, padx=4, sticky='e') # self.numwidget = tk.Control(self.frame, min=1, max=99999, width=4, variable=self.num) # self.numwidget.grid(row=0, column=3, padx=10) # self.den = tk.IntVar() # self.den.set(self.region.den) # self.den.trace("w", self.denchange) # self.denlabel = tk.Label(self.frame, text="Den") # self.denlabel.grid(row=1, column=2, padx=4, sticky='e') # self.denwidget = tk.Control(self.frame, min=1, max=99999, width=4, variable=self.den) # self.denwidget.grid(row=1, column=3, padx=10) self.myparent.canvas.config( scrollregion=self.myparent.canvas.bbox("all")) self.myparent.canvas.yview_moveto(1.0) if self.myparent.scroll.winfo_ismapped(): # print self.page.scroll.get() pass else: self.myparent.regionfr.update_idletasks() # print self.page.scroll.get() if self.myparent.scroll.get() != (0.0, 1.0): self.myparent.scroll.grid(row=0, column=1, sticky='ns')