def __init__(self, container, callback): ttk.Frame.__init__(self, container) label = ttk.Label(self, text='Measurements in') self.option_value = StringVar() option_perntge = ttk.Radiobutton( self, text='Percentage', variable=self.option_value, value='percentage', width=10, command=lambda: callback(self.option_value.get()) ) option_pixel = ttk.Radiobutton( self, text='Pixels', variable=self.option_value, value='pixel', width=5, command=lambda: callback(self.option_value.get()) ) self.option_value.set('percentage') label.grid(row=0, column=0) option_perntge.grid(row=0, column=1) option_pixel.grid(row=0, column=2)
def __init__(self, parent): mainframe = ttk.Frame(root, padding="12 12 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) filename = StringVar() dtc = StringVar() svm = StringVar() rfc = StringVar() ttk.Button(mainframe, text="Play sample Nº 1", command=lambda:play_sample('lana.wav')).grid(column=0, row=0, sticky=W) ttk.Button(mainframe, text="Play sample Nº 2", command=lambda:play_sample('corey.wav')).grid(column=0, row=1, sticky=W) ttk.Button(mainframe, text="Play sample Nº 3", command=lambda:play_sample('mia.wav')).grid(column=0, row=2, sticky=W) ttk.Button(mainframe, text="Play sample Nº 4", command=lambda:play_sample('emily.wav')).grid(column=0, row=3, sticky=W) ttk.Button(mainframe, text="Play sample Nº 5", command=lambda:play_sample('stephen.wav')).grid(column=0, row=4, sticky=W) ttk.Radiobutton(mainframe, text="Sample Nº 1", variable=filename, value='lana.wav').grid(column=3, row=0, sticky=E) ttk.Radiobutton(mainframe, text="Sample Nº 2", variable=filename, value='corey.wav').grid(column=3, row=1, sticky=E) ttk.Radiobutton(mainframe, text="Sample Nº 3", variable=filename, value='mia.wav').grid(column=3, row=2, sticky=E) ttk.Radiobutton(mainframe, text="Sample Nº 4", variable=filename, value='emily.wav').grid(column=3, row=3, sticky=E) ttk.Radiobutton(mainframe, text="Sample Nº 5", variable=filename, value='stephen.wav').grid(column=3, row=4, sticky=E) ttk.Button(mainframe, text="Classify from sample", command=lambda:classify(dtc, svm, rfc, filename, mainframe, False)).grid(column=3, row=5, sticky=W) ttk.Button(mainframe, text="Classify form microphone", command=lambda:record_and_classify(dtc, svm, rfc, mainframe, True)).grid(column=3, row=6, sticky=W) ttk.Label(mainframe, text= "Decision Tree: ").grid(column=2, row=7, sticky=E) ttk.Label(mainframe, text= "Support Vector Machine: ").grid(column=2, row=8, sticky=E) ttk.Label(mainframe, text= "Random Forest: ").grid(column=2, row=9, sticky=E) ttk.Label(mainframe, textvariable=dtc).grid(column=3, row=7, sticky=E) ttk.Label(mainframe, textvariable=svm).grid(column=3, row=8, sticky=E) ttk.Label(mainframe, textvariable=rfc).grid(column=3, row=9, sticky=E)
def build_input_frame(self): """ The build_input_frame method builds the interface for the input frame """ # Frame Init self.input_frame = ttk.Frame(self.root) self.input_frame.config(padding=(30, 0)) self.input_frame.pack() # Input Value ttk.Label(self.input_frame, text="Enter Time Value").grid(row=0, column=0) self.input_time = StringVar() ttk.Entry(self.input_frame, textvariable=self.input_time, width=25).grid(row=0, column=1, padx=5) # Radiobuttons self.time_type = StringVar() self.time_type.set('raw') ttk.Radiobutton(self.input_frame, text="Raw Value", variable=self.time_type, value="raw").grid(row=1, column=0, padx=5) ttk.Radiobutton(self.input_frame, text="Formatted Value", variable=self.time_type, value="formatted").grid(row=1, column=1, padx=5) # Button ttk.Button(self.input_frame, text="Run", command=self.convert).grid(row=2, columnspan=2, pady=5)
def create_input_select_radios(self, parent): radio_frame = ttk.Frame(parent) radio_frame.grid(row=1, column=1, stick='N') # Create radio buttons self.widget_variables['input_type_radio_var'] = Tkinter.IntVar() radio_none = ttk.Radiobutton( radio_frame, text='None', variable=self.widget_variables['input_type_radio_var'], value=-1) radio_none.grid(row=1, column=1, stick='W') radio_keyboard = ttk.Radiobutton( radio_frame, text='Keyboard', variable=self.widget_variables['input_type_radio_var'], value=self.KEYBOARD_FRAME) radio_keyboard.grid(row=2, column=1, stick='W') radio_joystick = ttk.Radiobutton( radio_frame, text='Joystick', variable=self.widget_variables['input_type_radio_var'], value=self.JOYSTICK_FRAME) radio_joystick.grid(row=3, column=1, stick='W') radio_mouse = ttk.Radiobutton( radio_frame, text='Mouse', variable=self.widget_variables['input_type_radio_var'], value=self.MOUSE_FRAME, state=DISABLE) radio_mouse.grid(row=4, column=1, stick='W') self.widget_variables['input_type_radio_var'].trace( 'w', self.input_type_radio_changed_callback) return radio_frame
def test_invoke(self): success = [] def cb_test(): success.append(1) return "cb test called" myvar = Tkinter.IntVar() cbtn = ttk.Radiobutton(command=cb_test, variable=myvar, value=0) cbtn2 = ttk.Radiobutton(command=cb_test, variable=myvar, value=1) res = cbtn.invoke() self.assertEqual(res, "cb test called") self.assertEqual(cbtn['value'], myvar.get()) self.assertEqual(myvar.get(), cbtn.tk.globalgetvar(cbtn['variable'])) self.assertTrue(success) cbtn2['command'] = '' res = cbtn2.invoke() self.assertEqual(res, '') self.assertFalse(len(success) > 1) self.assertEqual(cbtn2['value'], myvar.get()) self.assertEqual(myvar.get(), cbtn.tk.globalgetvar(cbtn['variable'])) self.assertEqual(str(cbtn['variable']), str(cbtn2['variable']))
def body(self, master): self.combo_x = ttk.Combobox(master, values=self.fields) self.combo_y = ttk.Combobox(master, values=self.fields) ttk.Label(master, text='Y axis').grid(column=1, row=1, sticky=tk.W) self.combo_y.grid(row=2, column=1, sticky=(tk.N, tk.W, tk.E, tk.S)) ttk.Label(master, text='X axis').grid(column=1, row=3, sticky=tk.W) self.combo_x.grid(row=4, column=1, sticky=(tk.N, tk.W, tk.E, tk.S)) self.typeVar = tk.StringVar() self.typeVar.set('-') self.lineButton = ttk.Radiobutton(master, text='Line', variable=self.typeVar, value='-') self.pointsButton = ttk.Radiobutton(master, text='Scatter', variable=self.typeVar, value='o') self.lineButton.grid(column=1, row=5, sticky=(tk.N, tk.W, tk.E, tk.S)) self.pointsButton.grid(column=1, row=6, sticky=(tk.N, tk.W, tk.E, tk.S)) return self.combo_y # initial focus
def __init__(self) : self.root = Tk() self.root.minsize(740, 300) self.root.maxsize(740,300) self.root.geometry("740x300+300+300") self.root.title("Fibre Check") self.root = ttk.Frame(self.root, padding=(9,9,9,9)) self.frame = ttk.Frame(self.root, borderwidth=5, relief="groove", width=500, height=180) #self.label = ttk.Label(self.root, text='Full name:').grid(column=3, row=3, sticky= W) self.rbuttons = IntVar() self.details = IntVar() #create radious buttons to choose between install and compare images ttk.Radiobutton(self.root, text="Import Image", variable=self.rbuttons, command=self.cb_check, value= 0).grid(column=1, row=0) ttk.Radiobutton(self.root, text="Compare Image", variable=self.rbuttons, command=self.cb_check, state= ACTIVE, value=1).grid(column=2, row=0) # ttk.Radiobutton(self.root, text="Plot Prosses", variable=self.details, value= 0).grid(column=1, row=5) # ttk.Radiobutton(self.root, text="Quiet", variable=self.details, state= ACTIVE, value=1).grid(column=0, row=5) self.check_1 = IntVar() self.check_2 = IntVar() self.check_3 = IntVar() self.check_4 = IntVar() self.check_5 = IntVar() self.check_6 = IntVar() self.check_7 = IntVar() self.check_8 = IntVar() self.check_9 = IntVar() ttk.Button(self.root, text='Quit', command=self.root.quit, style='Fun.TButton').grid(column=6, row=4) ttk.Button(self.root, text='RUN', command=self.allstates, style='Fun.TButton').grid(column=5, row=4) ttk.Button(self.root,text='File Open', command=self.callback, style='Fun.TButton').grid(column=4, row=4) app = VisibleImage(self.root) self.root.grid(column=0, row=0, sticky=(N, S, E, W)) self.root.columnconfigure(0, weight=1) self.root.rowconfigure(0, weight=1) self.root.columnconfigure(0, weight=3) self.root.columnconfigure(1, weight=3) self.root.columnconfigure(2, weight=3) self.root.columnconfigure(3, weight=1) self.root.columnconfigure(0, weight=0) self.root.columnconfigure(4, weight=1) self.root.rowconfigure(1, weight=1) self.root.mainloop()
def buttonbox(self): ''' Initializes most of the GUI components. Called by the constructor. ''' self.title("Collimator") self.box = Frame(self) self.box.grid(column=0,row=0) self.plateHeight = 0.0 self.collimatorBlank = 0.0 self.collimatorBlankShape = "Circle" shapeSelectFrame=ttk.Labelframe(self.box,text="Select apperature shape") shapeSelectFrame.grid(row=0,column=0,padx=5,pady=5,columnspan=3) self.shape = StringVar() self.shape.set(HeightSelector.CIRCLE) circle = ttk.Radiobutton(shapeSelectFrame, text='Circle', variable=self.shape, value=HeightSelector.CIRCLE,command=self.selection) square = ttk.Radiobutton(shapeSelectFrame, text='Square', variable=self.shape, value=HeightSelector.SQUARE,command=self.selection) rectangle = ttk.Radiobutton(shapeSelectFrame, text='Rectangle', variable=self.shape, value=HeightSelector.RECTANGLE,command=self.selection) circle.grid(row=0,column=0) square.grid(row=0,column=1) rectangle.grid(row=0,column=2) self.dimensionLabel=ttk.Label(self.box,text="Diameter: ") self.dimensionLabel.grid(row=1,column=0) self.dimensionVariable=StringVar() self.dimensionEntry=Entry(self.box,textvariable=self.dimensionVariable) self.dimensionEntry.config(highlightcolor="GOLD", bd=2, highlightthickness=1, relief=GROOVE) self.dimensionEntry.grid(column=1,row=1) dimensionUnits=ttk.Label(self.box,text="mm") dimensionUnits.grid(row=1,column=2) self.circleImg=PhotoImage(file="circle.gif") self.rectangleImg=PhotoImage(file="rectangle.gif") self.squareImg=PhotoImage(file="square.gif") self.imageLabel=ttk.Label(self.box,image=self.circleImg) self.imageLabel.grid(row=2,column=0,columnspan=3,pady=5) buttonFrame=ttk.Frame(self.box) buttonFrame.grid(column=0,row=3,columnspan=3) w = ttk.Button(buttonFrame, text="OK", width=10, command=self.ok, default=ACTIVE) w.grid(column=0,row=0, padx=5, pady=5,sticky=(E)) w = ttk.Button(buttonFrame, text="cancel", width=10, command=self.cancel) w.grid(column=1,row=0, padx=5, pady=5,sticky=(W)) self.bind("<Return>", self.ok) self.bind("<Escape>", self.cancel) self.height = 564.5 self.bottomLimit = 423.0 self.topLimit = 203.7 self.topRatio = self.height/self.topLimit self.bottomRatio = self.height/self.bottomLimit self.squareSizes = [24.0,14.0,9.0,5.0,3.0] #size of the square blanks in descending size self.circleSizes = [8.0,4.0,2.0,1.6,1.0,0.5] #size of the circle blanks in descending size self.rectangleSizes = [6.0,3.0] #side of the rectangle blanks in descending size self.message = ""
def build_entries(self): frm = self.settings_menu for index, setting_pack in enumerate(self.setting_packs): section,setting,stvar, set_type, empty_widget_list,rown = setting_pack def_lambda = lambda index = index: self._ux_settings_changed(index) if set_type == "dirloc" or set_type == "fileloc": widget = ttk.Button(frm,command=def_lambda,textvariable=stvar) widget.grid(row=rown,column=1,sticky="w",columnspan=15) empty_widget_list.append(widget) elif set_type == "bool": on_widget = ttk.Radiobutton(frm, variable=stvar, text="On",value="True", command=def_lambda) on_widget.grid(row=rown,column=1,sticky="w",padx=(0,5),columnspan=10) empty_widget_list.append(on_widget) off_widget = ttk.Radiobutton(frm, variable=stvar, text="Off",value="False", command=def_lambda) off_widget.grid(row=rown,column=3,sticky="w",padx=(0,5),columnspan=10) empty_widget_list.append(off_widget) elif set_type == "colors": split_colors = stvar.get().split("-") for clindex, color in enumerate(split_colors): settingrowcolumn = (index,clindex) color_lambda = lambda settingrowcolumn=settingrowcolumn: self.set_new_color(settingrowcolumn) butt = tk.Button(frm, width=2, command=color_lambda, background=split_colors[clindex]) butt.grid(row=rown,column=clindex+1,sticky="w",padx=(0,5),pady=7) empty_widget_list.append(butt) elif set_type == "date": date_widget = ttk.Button(frm,command=def_lambda,textvariable=stvar) date_widget.grid(row=rown,column=1,sticky="w",columnspan=15) empty_widget_list.append(date_widget) elif set_type == "int": days_widget = tk.Spinbox(frm, from_=0.0, to=30.0, wrap=True, width=4, validate="key", state="readonly", textvariable = stvar, command=def_lambda) days_widget.grid(row=rown,column=1,sticky="w",columnspan=15) empty_widget_list.append(days_widget) elif set_type == "event_dates": self.evnt_indx = index edit_events_button = ttk.Button(frm,command=self.open_events_list,text="See Events List") edit_events_button.grid(row=rown,column=1,sticky="w",columnspan=10) empty_widget_list.append(edit_events_button) elif set_type == "phone_numbers": self.nums_indx = index edit_numbers_button = ttk.Button(frm, command=self.open_numbers_list, text="See Ignore Numbers List") edit_numbers_button.grid(row=rown,column=1,sticky="w",columnspan=10) empty_widget_list.append(edit_numbers_button)
def __init_hottea_details__(self): labelframe = ttk.LabelFrame(self.hf, text="Order Details") labelframe.pack(side=LEFT, fill=BOTH, expand=TRUE, padx=10, pady=10) f1 = ttk.Frame(labelframe) # order details frame f2 = ttk.Frame(labelframe) # add to cart button frame f3 = ttk.Frame(f1) # size frame f4 = ttk.Frame(f1) # quantity frame f5 = ttk.Frame(f1) f5.pack(side=TOP, fill=BOTH) f1.pack(side=TOP, fill=BOTH) f2.pack(side=TOP, fill=BOTH) f3.pack(side=LEFT, fill=BOTH, expand=TRUE) f4.pack(side=LEFT, fill=BOTH, expand=TRUE) labelframe_chosenflavor = ttk.LabelFrame(f5, text="Chosen Flavor") labelframe_size = ttk.LabelFrame(f3, text="Size") labelframe_numdrink = ttk.LabelFrame(f4, text="Number of Drinks") btn_addtocart = ttk.Button(f2, text="Add Order to Cart", command=lambda: self.add_to_cart('h')) labelframe_chosenflavor.pack(side=TOP, fill=BOTH, expand=TRUE, padx=5, pady=5) labelframe_size.pack(side=TOP, fill=BOTH, padx=10, pady=10) labelframe_numdrink.pack(side=TOP, fill=BOTH, padx=10, pady=10) btn_addtocart.pack(side=TOP, fill=BOTH, expand=TRUE, padx=10, pady=10, ipady=20) label_chosenflavor = ttk.Label(labelframe_chosenflavor, textvariable=self.h_str) label_chosenflavor.pack(side=LEFT, fill=BOTH, padx=10, pady=10) radiobutton_l = ttk.Radiobutton(labelframe_size, text="Large (L)", command=lambda: self.set_size('Large')) radiobutton_xl = ttk.Radiobutton( labelframe_size, text="Extra Large (XL)", command=lambda: self.set_size('Extra LArge')) radiobutton_l.pack(side=LEFT, fill=BOTH, padx=10, pady=10) radiobutton_xl.pack(side=LEFT, fill=BOTH, padx=10, pady=10) label_quantity = ttk.Label(labelframe_numdrink, text="Quantity", anchor=tk.E) self.entry_quantity_h = ttk.Entry(labelframe_numdrink) label_quantity.pack(side=LEFT, fill=BOTH, padx=10, pady=10) self.entry_quantity_h.pack(side=LEFT, fill=BOTH, padx=10, pady=10)
def labelframe_order_details_hottea(self, f): labelframe = ttk.LabelFrame(f, text="Order Details") labelframe.pack(side=LEFT, fill=BOTH, expand=TRUE, padx=10, pady=10) f1 = ttk.Frame(labelframe) # order details frame f2 = ttk.Frame(labelframe) # add to cart button frame f3 = ttk.Frame(f1) # size frame f4 = ttk.Frame(f1) # quantity frame f5 = ttk.Frame(f1) f5.pack(side=TOP, fill=BOTH) f1.pack(side=TOP, fill=BOTH) f2.pack(side=TOP, fill=BOTH) f3.pack(side=LEFT, fill=BOTH, expand=TRUE) f4.pack(side=LEFT, fill=BOTH, expand=TRUE) labelframe_chosenflavor = ttk.LabelFrame(f5, text="Chosen Flavor") labelframe_size = ttk.LabelFrame(f3, text="Size") labelframe_numdrink = ttk.LabelFrame(f4, text="Number of Drinks") btn_addtocart = ttk.Button(f2, text="Add Order to Cart", command=None) labelframe_chosenflavor.pack(side=TOP, fill=BOTH, expand=TRUE, padx=5, pady=5) labelframe_size.pack(side=TOP, fill=BOTH, padx=10, pady=10) labelframe_numdrink.pack(side=TOP, fill=BOTH, padx=10, pady=10) btn_addtocart.pack(side=TOP, fill=BOTH, expand=TRUE, padx=10, pady=10, ipady=20) label_chosenflavor = ttk.Label(labelframe_chosenflavor) label_chosenflavor.pack(side=LEFT, fill=BOTH, padx=10, pady=10) radiobox_L = ttk.Radiobutton(labelframe_size, text="Large (L)", value=0, command=None) radiobox_XL = ttk.Radiobutton(labelframe_size, text="Extra Large (XL)", value=1, command=None) radiobox_L.pack(side=LEFT, fill=BOTH, padx=10, pady=10) radiobox_XL.pack(side=LEFT, fill=BOTH, padx=10, pady=10) label_quantity = ttk.Label(labelframe_numdrink, text="Quantity", anchor=tk.E) entry_quantity = ttk.Entry(labelframe_numdrink) label_quantity.pack(side=LEFT, fill=BOTH, padx=10, pady=10) entry_quantity.pack(side=LEFT, fill=BOTH, padx=10, pady=10) return label_chosenflavor
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs): self.rb_fastq = ttk.Radiobutton(master, text="FASTQ File Mode", variable=self.mode, value="FASTQ", command=self.fastq_mode) self.rb_fastq.grid(row=row, column=0, columnspan=columns, sticky="ew") self.rb_counts = ttk.Radiobutton(master, text="Count File Mode", variable=self.mode, value="Counts", command=self.counts_mode) self.rb_counts.grid(row=row + 1, column=0, columnspan=columns, sticky="ew") return 2
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.filename = 'No Image Chosen' self.filename_display = ttk.Label(self, text=self.filename, font=userfont) self.filename_display.pack(pady=5) b = ttk.Button(self, text="Choose Image", command=self.activate_textBox) b.pack(pady=10) scrollbar = Scrollbar(self) scrollbar.pack(side=RIGHT, fill=Y) self.area = Text(self, yscrollcommand=scrollbar.set, background='gray', foreground=userstyle, font=userfont, insertbackground='black', insertwidth=5, selectbackground='blue') self.area.pack(expand=True, fill='both') self.area.tag_config("system_alert", foreground=systemstyle, background='white') scrollbar.config(command=self.area.yview) self.area.config(state="disabled") self.var = IntVar() self.R1 = ttk.Radiobutton(self, text="Encode", variable=self.var, value=1, command=self.encode_priviliges) self.R1.pack(pady=5) self.R2 = ttk.Radiobutton(self, text="Decode", variable=self.var, value=2, command=self.decode_priviliges) self.R2.pack(pady=5) self.submit = ttk.Button(self, text="Submit", command=lambda: \ threading.Thread(target=self.submit_func).start()) self.submit.pack(pady=10) self.submit.config(state='disabled')
def main(): """Load the gui""" top = Tkinter.Tk() frame = ttk.Frame(top) frame.grid() command = Tkinter.StringVar(top, 'buy') group = ttk.LabelFrame(frame, text='Listing type') group.grid(row=0, column=0) for opt in 'buy', 'rent', 'sold': ttk.Radiobutton(group, text=opt, variable=command, value=opt).grid() search = ttk.Entry(frame) search.grid(row=0, column=1) def export(): """Run the real estate program""" types = 'CSV {.csv}', 'Text {.txt}', 'All *' filehandle = tkFileDialog.asksaveasfile(filetypes=types) if filehandle: realestate.realestate(command.get(), search.get(), filehandle) filehandle.close() button = ttk.Button(frame, text='Fetch', command=export) button.grid(row=0, column=2) for child in frame.winfo_children(): child.grid_configure(padx=5, pady=5) top.mainloop()
def __init__(self, parent, variable): TK.Frame.__init__(self, parent) self.__radio = ttk.Radiobutton(self, text="Append to Review", variable=variable, value=self.ID) self.__radio.pack(side=TK.TOP, ipadx=3) treeview = ttk.Treeview(self, columns=('Date', 'Project', 'Title'), selectmode=TK.BROWSE, displaycolumns='#all') treeview.column('#0', stretch=0, width=5) treeview.column('Date', stretch=0, width=80) treeview.column('Project', stretch=0, width=80) for i in xrange(15): values = [ '{}/01/1989'.format(i), 'Project_{}'.format(i % 2), 'CR_{}'.format(i) ] treeview.insert('', 'end', values=values) treeview.pack(side=TK.LEFT, fill=TK.BOTH, expand=1) self.pack(anchor=TK.NW, fill=TK.BOTH, padx=5, pady=5)
def setup_project_ui(self, frame): label = ttk.Label(frame, relief='flat', text='Choose Integrated Development Environment:') label.pack(fill=X, pady=5) separator = ttk.Separator(frame) separator.pack(fill=X) self.ide = StringVar() self.ide.set("mdk4") # initialize for text, mode in IDE: radiobutton = ttk.Radiobutton(frame, text=text, variable=self.ide, value=mode) radiobutton.pack(fill=X, padx=10) bottom = ttk.Frame(frame) bottom.pack(side=BOTTOM, fill=X) button = ttk.Button(bottom, text="Make Project", command=self.do_make_project) button.pack(side=RIGHT, padx=10, pady=10)
def create_input_widget(self, target_content_area): self.options_container = ttk.Labelframe(target_content_area) self.options_container.pack(side=tk.BOTTOM, fill=tk.X, padx=10) for index, option_name in enumerate(self.item_names): frame = ttk.Frame(self.options_container) frame.pack(fill=tk.X) radiobutton = ttk.Radiobutton(frame, text=option_name, variable=self.ttk_radio_button_value, command=self.on_clicked, value=self.item_values[index]) radiobutton.bind("<ButtonRelease-3>", lambda event: self.set_default_value( )) # bind right-click -> default value radiobutton.pack(side=LEFT) try: if self.item_descriptions[index]: lbl_checkbox_desc = tk.Label(frame, text="(%s)" % self.item_descriptions[index], font="-slant italic -size 9") lbl_checkbox_desc.pack(side=LEFT) except: pass
def __init__(self, parent, *args, **kwargs): ttk.Frame.__init__(self, parent, *args, **kwargs) self.search_type = tk.StringVar() self.search_string = tk.StringVar() self.search_type.set("both") self.label = ttk.Label(self, text="Search:") self.entry = SearchBox(self, textvariable=self.search_string, width=40) self.radio1 = ttk.Radiobutton(self, text="Name only", value="name", variable=self.search_type) self.radio2 = ttk.Radiobutton(self, text="Name and Documentation", value="both", variable=self.search_type) self.entry.pack(side="left", expand=False, padx=4) self.radio1.pack(side="left", padx=(0,8)) self.radio2.pack(side="left", padx=(0,8)) self.search_string.trace("w", self._on_search) self.search_type.trace("w", self._on_type)
def _init_ui(self): ttk.Label(self._parent, text='Polarization control:').grid(column=0, row=0, columnspan=2, sticky=W) self._rbtPolMode = ttk.Radiobutton(self._parent, text='Polarization mode', variable=self._varMode, value=self.POL_MODE) self._rbtPolMode.grid(column=0, row=1, sticky=W, padx=10, pady=5) self._rbtNmrMode = ttk.Radiobutton(self._parent, text='NMR mode', variable=self._varMode, value=self.NMR_MODE) self._rbtNmrMode.grid(column=0, row=2, sticky=W, padx=10, pady=5) self._varMode.trace('w', self._varMode_onchange) self._varMode.set(self.NMR_MODE)
def body(self, master): message = ttk.Label(master, text="SeqLib type:") message.grid(column=0, row=0) for i, k in enumerate(seqlib_label_text.keys()): rb = ttk.Radiobutton(master, text=seqlib_label_text[k], variable=self.element_tkstring, value=k) rb.grid(column=0, row=(i + 1), sticky="w") if i == 0: rb.invoke()
def Radiobutton(*args, **kwargs): if ttk is None: TK.Radiobutton(*args, **kwargs) else: if 'offrelief' in kwargs: kwargs.pop('offrelief') if 'selectcolor' in kwargs: kwargs.pop('selectcolor') if 'indicatoron' in kwargs: kwargs.pop('indicatoron') b = ttk.Radiobutton(*args, **kwargs) b.configure(style='MENU.TRadiobutton') return b
def body(self, master): row_no = self.name_tk.body(master, 0) row_no += self.output_directory_tk.body(master, row_no) element_types = ttk.Frame(master, padding=(3, 3, 12, 12)) element_types.grid(column=0, row=row_no, sticky="nsew", columnspan=DEFAULT_COLUMNS) message = ttk.Label(element_types, text="Root object type:") message.grid(column=0, row=0) label = ttk.Label(element_types, text="Experiment") label.grid(column=0, row=1, sticky="w") rb = ttk.Radiobutton( element_types, text="Experiment", variable=self.element_tkstring, value="Experiment", ) rb.grid(column=0, row=2, sticky="w") rb.invoke() label = ttk.Label(element_types, text="Selection") label.grid(column=0, row=3, sticky="w") rb = ttk.Radiobutton( element_types, text="Selection", variable=self.element_tkstring, value="Selection", ) rb.grid(column=0, row=4, sticky="w") label = ttk.Label(element_types, text="SeqLib") label.grid(column=0, row=5, sticky="w") for i, k in enumerate(SEQLIB_LABEL_TEXT.keys()): rb = ttk.Radiobutton( element_types, text=SEQLIB_LABEL_TEXT[k], variable=self.element_tkstring, value=k, ) rb.grid(column=0, row=(i + 6), sticky="w")
def create_keysets_ui(self): # Keyset frame keyset_frame = ttk.LabelFrame(self, text='Keyset') keyset_frame.grid(row=6, column=1, stick='W', padx=20) ttk.Radiobutton(keyset_frame, text='None', value=0, variable=self.widget_variables['keyset']).grid( row=1, column=0) for col in range(1, self.__num_keysets + 1): keyset = col ttk.Radiobutton(keyset_frame, text=keyset, value=keyset, variable=self.widget_variables['keyset']).grid( row=1, column=col) self.widget_variables['keyset'].trace('w', self.keyset_changed_callback) return
def __init__(self, parent, pydef_object, figure, init_subplot_nb): """ :param parent: parent window :param pydef_object: a Cell or Defect_Study object :param figure: a PyDEF Figure object :param init_subplot_nb: a Tkinter IntVar object""" tk.Toplevel.__init__(self, parent) self.title('Position of "%s" in figure "%s"' % (pydef_object.ID, figure.name)) self.resizable(False, False) self.icon = parent.icon self.tk.call('wm', 'iconphoto', self._w, self.icon) self.main_frame = ttk.Frame(self) self.main_frame.pack(expand=True, fill='both') self.main_frame.grid_columnconfigure(0, weight=1) # -------------------------------------------------- SUBPLOTS -------------------------------------------------- self.subplot_frame = ttk.Frame(self.main_frame) self.subplot_frame.grid(row=0, column=0, sticky='nswe') self.subplot_nb = tk.IntVar() self.subplot_nb.set(init_subplot_nb.get()) for f in range(1, figure.nb_rows + 1): for g in range(1, figure.nb_cols + 1): frame = ttk.LabelFrame(self.subplot_frame, width=100, height=100) frame.grid(row=f, column=g, padx=10) frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) frame.grid_propagate(False) ttk.Radiobutton(frame, text=(f-1) * figure.nb_cols + g, variable=self.subplot_nb, value=(f-1) * figure.nb_cols + g).grid(sticky='ns') [self.subplot_frame.grid_columnconfigure(g, weight=1) for g in range(1, figure.nb_cols + 1)] # --------------------------------------------------- BUTTONS -------------------------------------------------- self.button_frame = ttk.Frame(self.main_frame) self.button_frame.grid(row=1, column=0, pady=10) def save_subplot_nb(): """Save the subplot number chosen to the init_subplot_nb variable """ init_subplot_nb.set(self.subplot_nb.get()) self.destroy() ttk.Button(self.button_frame, text='Cancel', command=self.destroy).grid(row=0, column=0, padx=5) ttk.Button(self.button_frame, text='OK', command=save_subplot_nb).grid(row=0, column=1, padx=5) self.bind('<Control-w>', lambda event: self.destroy()) ukf.centre_window(self)
def init_mode_panel(self, frame): # Toggle between streaming and simulating modePanel = ttk.Frame(master=frame) modePanel.pack(side='left') ttk.Frame(master=modePanel, width=10).grid(row=0, rowspan=2, column=0) ttk.Label(master=modePanel, text='Input Modus: ').grid(row=0, column=1, sticky='w') self.rb_sim = ttk.Radiobutton(master=modePanel, text='Files', variable='Mode', value='sim') self.rb_stream = ttk.Radiobutton(master=modePanel, text='Headsets', variable='Mode', value='stream') self.rb_sim.grid(row=0, column=2) self.rb_stream.grid(row=0, column=3) # Select the visualisation type ttk.Label(master=modePanel, text='Display Modus: ').grid(row=1, column=1, sticky='w') self.cb_display_value = StringVar() self.cb_display = ttk.Combobox(master=modePanel, textvariable=self.cb_display_value, state='readonly') self.cb_display['values'] = (VisualisationTypes.TIME, VisualisationTypes.FREQUENCY, VisualisationTypes.FREQUENCY_BAND, VisualisationTypes.AROUSEL, VisualisationTypes.VALENCE) self.cb_display.current(0) self.cb_display.grid(row=1, column=2) self.b_display_settings = ttk.Button(master=modePanel, text='Settings...') self.b_display_settings.grid(row=1, column=3)
def add_button(self, radio_name, in_value): """Adds a new button to the radiobox.""" rbutton = ttk.Radiobutton(self.Container, text=radio_name, value=in_value, variable=self.radio_value) rbutton.grid(column=self.r_column, row=self.r_row) if self.button_alignment == 'horizontal': self.r_column += 1 else: self.r_row += 1
def _setup_Display_Frame_Widgets(self): self.Display_Disp_Frame = ttk.Labelframe(self.parent, text="Display", relief=tk.GROOVE, borderwidth=1) self.Display_Disp_Frame.pack(padx=10, pady=0, fill=tk.BOTH, expand=True) self.Display_Disp_volts_In_Frame = ttk.Labelframe( self.Display_Disp_Frame, text="Volts In") self.Display_Disp_volts_In_Frame.pack( side=tk.LEFT, padx=10, ) self.eb_Display_Volts_In = ttk.Entry(self.Display_Disp_volts_In_Frame, font=('Arial', 24, 'bold'), width=8) self.eb_Display_Volts_In.pack() self.Display_Disp_volts_Out_Frame = ttk.Labelframe( self.Display_Disp_Frame, text="Volts Out") self.Display_Disp_volts_Out_Frame.pack( side=tk.LEFT, padx=10, ) self.eb_Display_Volts_Out = ttk.Entry( self.Display_Disp_volts_Out_Frame, font=('Arial', 24, 'bold'), width=8) self.eb_Display_Volts_Out.pack() self.Display_Disp_Current_Frame = ttk.Labelframe( self.Display_Disp_Frame, text="Current") self.Display_Disp_Current_Frame.pack( side=tk.LEFT, padx=10, ) self.eb_Display_Current = ttk.Entry(self.Display_Disp_Current_Frame, font=('Arial', 24, 'bold'), width=8) self.eb_Display_Current.pack() self.Output_Enable_IntVar = tk.IntVar() self.rb_Output_On = ttk.Radiobutton(self.Display_Disp_Frame, text="Enable Output", variable=self.Output_Enable_IntVar, value=1) self.rb_Output_On.pack(side=tk.LEFT, padx=10) self.rb_Output_On.state(["disabled"])
def clientd(self): while not self.should_quit: try: data = self.client_socket.recv(1024) if len(data): if data[:11] == 'clientlist:': self.clients = ast.literal_eval(data[11:]) for r in self.radios: r.destroy() for client in self.clients: r = ttk.Radiobutton(self.clients_frame, text=client, variable=self.dest, value=client) r.pack(anchor=Tkinter.W) self.radios.append(r) else: sender = get_nick(data) message = get_message(data) self.chat_text.config(state=Tkinter.NORMAL) self.chat_text.insert(Tkinter.END, 'From {0}'.format(sender), ('tag{0}'.format(self.__i))) self.chat_text.insert(Tkinter.END, ': {0}\n'.format(message), ('tag{0}'.format(self.__j))) self.chat_text.tag_config( 'tag{0}'.format(self.__i), justify=Tkinter.LEFT, foreground=color[color_hash(sender)], font='Times 14 bold', underline=True) self.chat_text.tag_config('tag{0}'.format(self.__j), justify=Tkinter.LEFT, foreground='black') self.chat_text.config(state=Tkinter.DISABLED) self.__i = self.__i + 2 self.__j = self.__j + 2 self.chat_text.see(Tkinter.END) else: break except: continue
def MyRadio ( f, txt, varValue, varName, cmd=None, row=0, col=0, stick='W', span=1, pad=(5,5,5,5), tip='No Tip number provided'): #def MyRadio ( f, txt, varValue, varName = None, cmd=None, row=0, col=0, stick='W', # span=1, pad=(5,5,5,5), tip='No Tip number provided'): # if varName is None: # # Determine type of var from varValue and create one # if type(varValue) is int: # varName = MyIntVar(varValue) # elif type(varValue) is boolean: # varName = MyBooleanVar(varValue) # elif type(varValue) is str: # varName = MyStringVar(varValue) if cmd is None: r = ttk.Radiobutton(f,text=txt,value=varValue,variable=varName, padding=pad) else: r = ttk.Radiobutton(f,text=txt,value=varValue,variable=varName, command=lambda:cmd(varValue),padding=pad) r.grid(row=row,column=col,sticky=stick, columnspan=span) ToolTip(r,msg=tip) return r # , varName # return RadioButton and BooleanVar
def __init__(self, parent, text, options, default=None): ttk.LabelFrame.__init__(self, parent, text=text) self.var = tk.StringVar() if default: self.var.set(default) for text, value in options: radio = ttk.Radiobutton(self, text=text, variable=self.var, value=value) radio.pack(side='top', fill='x')