def __init__(self, window): super(Parameters, self).__init__(window) self.window = window title = Label(self, text="Paramètres") self.usespace = IntVar() check_usespace = Checkbutton(self, text="Espace préféré", variable=self.usespace) valide = Button(self, text="Valider", command=self.validate) title.grid(row=0, column=0, padx=10, pady=10) check_usespace.grid(row=1, column=0, padx=10, pady=5) valide.grid(row=2, column=0, padx=10, pady=5) self.setup_ui()
def __init__(self, master=None): self.master = Tk() if not master else master self.master.title("Book Finder") self.master.resizable(0, 0) #We change the window icon directly with Tk self.master.tk.call('wm', 'iconphoto', self.master, '::tk::icons::question') self.stext = ScrolledText(master=self.master, bg='white', height=25, width=100) #We disable the edition self.stext.config(state="disabled") menu = Menu() menu_tools = Menu(tearoff=0) menu_tools.add_command(label="Search book", command=lambda: self.search_book()) menu_tools.add_command(label="Exit", command=self.master.destroy) menu.add_cascade(label="Menu", menu=menu_tools) menu_option = Menu(tearoff=0) menu_option.add_checkbutton( label="Don't download img", command=lambda: self.cmd2() if self.cmd2 else print("cmd2 not configured")) menu.add_cascade(label="Option", menu=menu_option) #We create a message box with Tk menu.add_command( label="About", command=lambda: self.master.tk.eval( "tk_messageBox -message {Book Finder} -detail {Make by pythonbrad} -icon info -title About" )) self.master.config(menu=menu) self.stext.pack() #This widget will print status self.label_status = Label(self.master, text="STATUS", font=('Arial', 14)) self.label_status.pack() self.progress_bar = Progressbar() self.progress_bar.pack() self.is_searching = False #It will contains widget in memory self.temp = [] #It will contains an external function #Who will be used by the function search_book self.cmd1 = None self.cmd2 = None
def build_tree(self): try: self.fr.destroy() except (NameError, AttributeError): pass self.fr = Frame(self.fra) self.fr.pack(fill='both', expand=False) lbl = Label(self.fr, text=self.csvFile) lbl.grid(column=0, row=0, sticky='n') self.tree = Treeview(self.fr, columns=self.treeColumns, show="headings", style='font.Treeview') self.tree.grid(column=0, row=1, sticky='ns') vsb = Scrollbar(self.fr, orient="vertical", command=self.tree.yview) vsb.grid(column=1, row=1, sticky='ns') hsb = Scrollbar(self.fr, orient="horizontal", command=self.tree.xview) hsb.grid(column=0, row=2, sticky='ew') self.tree.configure(xscrollcommand=hsb.set, yscrollcommand=vsb.set) self.fr.grid_columnconfigure(0, weight=1) self.fr.grid_rowconfigure(0, weight=1) if self.renew: for row in self.tree.get_children(): self.tree.delete(row) for col in self.treeColumns: #print(treeColumns,col,col.title()) self.tree.heading(col, text=col.title()) self.tree.column( col, width=font.Font(family="Segoe UI", size=12, weight="bold").measure(col.title()) + 10, stretch=False) for item in self.treeData: self.tree.insert('', 'end', values=item) for indx, val in enumerate(item): ilen = font.nametofont('TkDefaultFont').measure(val) if self.tree.column(self.treeColumns[indx], width=None) < ilen + 10: self.tree.column(self.treeColumns[indx], width=ilen + 10)
def __init__(self, notebook_page, caller): self.led_pwm_output_frame = Frame(notebook_page, padding=10, relief=SUNKEN) self.caller = caller self.colors = ['Blue', 'Yellow', 'Red', 'Green'] self.led_pins = [4, # Blue 17, # Yellow 27, # Red 5] # Green # an array of the execute buttons self.execute_buttons = [] # an array of the scale widgets self.drive_scales = [] # an array of the values for the scale widgets self.drive_values = [] for x in range(0, 4): # set the mode label with an associated signal channel number # noinspection PyPep8 l = Label(self.led_pwm_output_frame, text=(self.colors[x])) l.grid(row=x, column=0, padx=[20, 5], pady=[22, 0]) self.drive_values.append(DoubleVar()) drive_scale = Scale(self.led_pwm_output_frame, variable=self.drive_values[x], orient='horizontal', troughcolor='white', resolution=0.01, from_=0, to=100) self.drive_scales.append(drive_scale) drive_scale.grid(row=x, column=1) b = Button(self.led_pwm_output_frame, text='Set ' + self.colors[x], command=partial(self.set_drive_value, x)) self.execute_buttons.append(b) b.grid(row=x, column=2, pady=[22, 0], padx=40) self.led_pwm_output_frame.grid(row=0, column=0, sticky='EW', columnspan=49, padx=[170, 0], pady=[20, 0])
def on_create_labelframe(self, frame_name, col, row, colpad, rowpad, pos, pic=None): if pic is None: self.panel_control_lf = LabelFrame(master=self.dev_control_panel, text=frame_name) self.panel_control_lf.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky=pos) else: self.house_plan_lf = LabelFrame(master=self.dev_control_panel, text=frame_name) self.house_plan_lf.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky=pos) img = None try: img = Image.open( os.path.join(self.imgpath, str(self.plan[pic]))) print(str(self.plan[pic])) except IOError: pass print(img.mode, '- - - - ', img.size) img.rotate(90) # Bild Umdrehen img.thumbnail((self.pic_width, self.pic_height), Image.ANTIALIAS) # groesse des Bild anpassen img_lbl = ImageTk.PhotoImage( image=img ) # ohne dass --> UnboundLocalError: local variable 'img' # referenced before assignment img_lbl musst als label image zugewiesen werden # ohne dass - - > _tkinter.TclError: image specification must contain an odd number of elements self.house_lbl = Label(self.house_plan_lf, image=img_lbl) self.house_lbl.grid(column=0, row=0, padx=8, pady=5) self.house_lbl = img_lbl # und diese Zuweisung am Ende
def initUI(self): self.master.title("SBT") self.pack(fill=BOTH, expand=True) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) searchLabel = Label(self, text="Search:", font="24") searchLabel.grid(sticky=E, pady=4, padx=5, row=0, column=0) self.searchEntry = Entry(self) self.searchEntry.grid(sticky=E + W + S + N, pady=4, padx=5, row=0, column=1) self.searchEntry.focus_set() findButton = Button(self, text='Find', command=self.find) findButton.grid(sticky=W, pady=4, padx=5, row=0, column=2) openButton = Button(self, text="Open .audit file", command=self.openFile) openButton.grid(sticky=S, row=5, column=0, pady=4, padx=50) saveButton = Button(self, text="Save .audit file", command=self.saveFile) saveButton.grid(sticky=S, row=5, column=2, pady=4, padx=50) self.textBox = Text(self) self.textBox.grid(row=1, column=0, columnspan=3, rowspan=4, padx=5, sticky=E + W + S + N) self.scrollbar = Scrollbar(self) self.textBox.config(yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.textBox.yview) self.scrollbar.grid(column=3, row=1, rowspan=4, sticky=N + S + W)
def initItems(self): """Initialize all widgets here""" # An entry to enter feet value. self.feet_entry = Entry(self, width=7) self.feet_entry.grid(column=2, row=1, sticky=(W, E)) # A label to display translated meters. self.meters_lbl = Label(self, textvariable=self.meters_value) self.meters_value.set(0) self.meters_lbl.grid(column=2, row=2, sticky=(W, E)) # Different labels for text only. Label(self, text='feet').grid(column=3, row=1, sticky=W) Label(self, text='is equivalent to').grid(column=1, row=2, sticky=E) Label(self, text='meters').grid(column=3, row=2, sticky=W) # Button to calculate things. calc_btn = Button(self, text='Calculate', command=lambda: calculate(self)) calc_btn.grid(column=3, row=3, sticky=W) # This widget is just for fun. # Also it shows how to get an event callback when Entry widget is modified def callback(str): print(str.get()) entry_str = StringVar() entry_str.trace('w', lambda name, index, mode, str=entry_str: callback(str)) self.entry_widg = Entry(self, width=10, textvariable=entry_str) self.entry_widg.grid(column=1, row=4, sticky=(W, E)) # A really simple way to change label text: test_lbl = Label(self) test_lbl.grid(column=3, row=4, sticky=E) test_lbl['text'] = 'hello!' # Handling label's events ev_lbl = Label(self, text='Do something with me...', width=30) ev_lbl.grid(column=1, row=5, columnspan=2, rowspan=2) ev_lbl.bind('<Enter>', lambda e: ev_lbl.configure(text='Moved mouse inside')) ev_lbl.bind('<Leave>', lambda e: ev_lbl.configure(text='Moved mouse outside')) ev_lbl.bind( '<1>', lambda e: ev_lbl.configure(text='Clicked left mouse button!')) ev_lbl.bind( '<Double-1>', lambda e: ev_lbl.configure( text='Double clicked left mouse button!')) # Configure pads for all grid cells for child in self.winfo_children(): child.grid_configure(padx=5, pady=5) # As default, entry is focused self.feet_entry.focus()
def __init__(self, master, **kwargs): super(Download, self).__init__(master, borderwidth=20, **kwargs) self.fs = None self.tree = None self.logfile = None # User informations self.info_tree = False self.start_time = None info = Frame(self, borderwidth=10) self.info_label = Label(info, wraplength=350, borderwidth=20, justify='center', font=('a', 10, 'bold')) self.info_indis = Label(info) self.info_fams = Label(info) self.info_sources = Label(info) self.info_notes = Label(info) self.time = Label(info) self.info_label.grid(row=0, column=0, columnspan=2) self.info_indis.grid(row=1, column=0) self.info_fams.grid(row=1, column=1) self.info_sources.grid(row=2, column=0) self.info_notes.grid(row=2, column=1) self.time.grid(row=3, column=0, columnspan=2) self.form = Frame(self) self.sign_in = SignIn(self.form) self.options = None self.title = Label(self, text=_('Sign In to FamilySearch'), font=('a', 12, 'bold')) buttons = Frame(self) self.btn_quit = Button(buttons, text=_('Quit'), command=Thread(target=self.quit).start) self.btn_valid = Button(buttons, text=_('Sign In'), command=self.command_in_thread(self.login)) self.title.pack() self.sign_in.pack() self.form.pack() self.btn_quit.pack(side='left', padx=(0, 40)) self.btn_valid.pack(side='right', padx=(40, 0)) info.pack() buttons.pack(side='bottom') self.pack() self.update_needed = False
def __init__(self, master=None, **kw): """ GUI tab that handles interface and region selection and starting the server. :param master: root window :param kw: args """ FrameTab.__init__(self, master, **kw) self.wii_u_interface = None self.normal_interface = None self.drc_sim_c = None self.wpa_supplicant = None LoggerGui.extra("Initializing FrameRunServer") # Create Widgets self.label_wpa = Label(self, text="Wii U Connection:") self.label_backend = Label(self, text="Server Status:") self.label_wpa_status = Label(self) self.label_backend_status = Label(self) self.button_start = Button(self, text="Start") self.button_stop = Button(self, text="Stop") self.label_wiiu_interface = Label(self, text="Wii U Interface") self.label_normal_interface = Label(self, text="Normal Interface") self.dropdown_wiiu_interface = Combobox(self, state="readonly") self.dropdown_normal_interface = Combobox(self, state="readonly") self.label_interface_info = Label(self) self.label_region = Label(self, text="Region") self.dropdown_region = Combobox(self, state="readonly") # Events self.button_start.bind("<Button-1>", self.start_server) self.button_stop.bind("<Button-1>", self.stop_server) # Position widgets self.label_wpa.grid(column=0, row=0, sticky="e") self.label_backend.grid(column=0, row=1, sticky="e") self.label_wpa_status.grid(column=1, row=0, sticky="w") self.label_backend_status.grid(column=1, row=1, sticky="w") self.label_wiiu_interface.grid(column=0, row=2) self.label_normal_interface.grid(column=0, row=3) self.dropdown_wiiu_interface.grid(column=1, row=2, columnspan=2) self.dropdown_normal_interface.grid(column=1, row=3, columnspan=2) self.label_region.grid(column=0, row=4) self.dropdown_region.grid(column=1, row=4, columnspan=2) self.button_start.grid(column=1, row=5) self.button_stop.grid(column=2, row=5) self.label_interface_info.grid(column=0, row=6, columnspan=3) LoggerGui.extra("Initialized FrameRunServer")
def create_widgets(self): super().create_widgets() frame = self.frame pathlabel = Label(frame, anchor='w', justify='left', text='Help File Path: Enter URL or browse for file') self.pathvar = StringVar(self, self.filepath) self.path = Entry(frame, textvariable=self.pathvar, width=40) browse = Button(frame, text='Browse', width=8, command=self.browse_file) pathlabel.pack(anchor='w', padx=5, pady=3) self.path.pack(anchor='w', padx=5, pady=3) browse.pack(pady=3)
def find_text(self, event=None): search_toplevel = Toplevel(self) search_toplevel.title('查找文本') search_toplevel.transient(self) # 总是让搜索框显示在其父窗体之上 search_toplevel.resizable(False, False) Label(search_toplevel, text="查找全部:").grid(row=0, column=0, sticky='e') search_entry_widget = Entry(search_toplevel, width=25) search_entry_widget.grid(row=0, column=1, padx=2, pady=2, sticky='we') search_entry_widget.focus_set() ignore_case_value = IntVar() Checkbutton(search_toplevel, text='忽略大小写', variable=ignore_case_value).grid(row=1, column=1, sticky='e', padx=2, pady=2) Button(search_toplevel, text="查找", command=lambda: self. search_result(search_entry_widget.get(), ignore_case_value.get( ), search_toplevel, search_entry_widget)).grid(row=0, column=2, sticky='e' + 'w', padx=2, pady=2) def close_search_window(): self.content_text.tag_remove('match', '1.0', "end") search_toplevel.destroy() search_toplevel.protocol('WM_DELETE_WINDOW', close_search_window) return "break"
def __init__(self, parent, close_callback): """ Constructor """ Frame.__init__(self, parent) style = Style() style.configure('D.TButton', foreground='Brown4', font=("TkTextFont", 9)) self._close_cb = close_callback self.grid(padx=30, pady=30, rowspan=2, columnspan=2) Label(self, text="Book ID:").grid(row=2, column=1, padx=10, pady=10) self._book_id = Entry(self) self._book_id.grid(row=2, column=2, padx=10, pady=10) Button(self, text="Delete", width=15, style='D.TButton', command=self._validate_id).grid(row=4, column=1, padx=10, pady=10) Button(self, text="Cancel", width=15, command=self._close_cb).grid(row=4, column=2, padx=30)
def initUI(self): self.master.title("Buttons") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=2) frame.pack(fill=BOTH, expand=True) self.myLabel = Label(self, text="Blue Sky") self.myLabel.pack() self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT, padx=7, pady=7) okButton = Button(self, text="OK") okButton.pack(side=RIGHT)
def on_updated_09(self): if self.dict_btn['ALLE LICHTER AUS']['text'] == 'OFF': self.dict_btn['ALLE LICHTER AUS']['text'] = 'ON' self.dict_btn['ALLE LICHTER AUS'].configure(bg='#ff1a1a') print(self.dict_btn['ALLE LICHTER AUS']['text']) self.on_updated_action('ALLE LICHTER AUS') self.dict_btn['ALLE LICHTER AUS'].bind( '<Button-1>', self.on_thread_09(self.dict_btn['ALLE LICHTER AUS']['text'])) else: self.dict_btn['ALLE LICHTER AUS']['text'] = 'OFF' self.dict_btn['ALLE LICHTER AUS'].configure(bg='#00bfff') print("Last values of Va-09 = ", self.dict_tk_var['ALLE LICHTER AUS'].get()) try: img = Image.open( os.path.join(self.imgpath, self.plan['NICHST'])) img.rotate(90) img.thumbnail((self.pic_width, self.pic_height), Image.ANTIALIAS) img_lbl = ImageTk.PhotoImage(image=img) self.house_lbl = Label(self.house_plan_lf, image=img_lbl) self.house_lbl.grid(column=0, row=0, padx=8, pady=5) self.house_lbl = img_lbl print('Reset to: ', 'NICHST', ' STATUS: ', self.dict_btn['ALLE LICHTER AUS']['text']) except IOError as ierror: print('Fehler beim Laden des Bildes: -->', ierror) except KeyError as kerror: print('Variable nicht erkannt: --> ', kerror) if self.thread_dict['ALLE LICHTER AUS'].is_alive(): self.thread_dict['ALLE LICHTER AUS'].join(.25) print("STATS OF DICT NOW: ", self.thread_dict['ALLE LICHTER AUS'].is_alive()) during = self.dict_tk_var['ALLE LICHTER AUS'].get() print("STORED VALUE: ", during) print("REINIT TKVAT: ") self.dict_tk_var['ALLE LICHTER AUS'].set(0) print("TK VAR REINIT TO: ", self.dict_tk_var['ALLE LICHTER AUS'].get()) print("STATS OF DICT NOW 2: ", self.thread_dict['ALLE LICHTER AUS'].is_alive()) print("VERBRAUCH IN ALLE LICHTER AUS: ", (during * 1.), "watt min")
def __init__(self, parentdir: str): """\ Parameters --------- parentdir (str): The path of the directory where the SymLink will be placed """ self.initDir = Path(parentdir) Tk.__init__(self) wd = 400 ht = 100 self.title("Create Symbolic Link") self.attributes('-topmost', 1) x = ((self.winfo_screenwidth() - wd) // 2) y = ((self.winfo_screenheight() - ht) // 2) self.geometry(f'{wd}x{ht}+{x}+{y}') self.bind_all('<Escape>', lambda _: self.destroy()) lbl1 = Label( master=self, font='Ebrima 12', text="Would you like to make a Symlink for a folder or a file?") lbl1.place(anchor='center', relx=0.5, rely=0.3) folder_btn = Button(master=self, text="Folder", underline=0, command=lambda: self.createLink('folder'), width=10) folder_btn.place(anchor='center', relx=0.25, rely=0.66) folder_btn.focus_set() self.bind_all('<Return>', lambda _: folder_btn.invoke()) file_btn = Button(master=self, text=" File ", command=lambda: self.createLink('file'), width=10) file_btn.place(anchor='center', relx=0.5, rely=0.66) cancel_btn = Button(master=self, text="Cancel", command=self.destroy, width=10) cancel_btn.place(anchor='center', relx=0.75, rely=0.66) self.mainloop()
def stat_wrapper(self, *args, **kwargs): try: stats.make_stats(*args, **kwargs) except Exception: t = Toplevel(self.root) l = Label( t, text= "Произошла непредвиденная ошибка. Программа будет закрыта.\n" "Вы можете отправить файл error.txt автору программы, что бы он её есправил.\n" "Извините за причененные неудобства") l.pack() time.sleep(5) self.root.destroy() traceback.print_exc() exit(-1)
def __init__(self, w, text: str, lbl_width: int, info_width: int, info_bg: str, *args, **kwargs): super().__init__(w, *args, **kwargs) self.lbl = Label(self, width=lbl_width, text=text) self.lbl.grid(row=0, column=0) self.info = Entry(self, width=info_width, readonlybackground=info_bg, borderwidth=0, justify="left", state="readonly") self.info.grid(row=0, column=1) self.sep = Separator(self, orient="horizontal") self.sep.grid(row=1, column=0, columnspan=2, sticky="new")
def init_ui(self): self.master.title("Speech Demo") self.pack(fill=BOTH, expand=True) label_frame = LabelFrame(self, text="System words") label_frame.pack(fill=X, padx=40, pady=20) self.labels = [] rows = 8 cols = 2 for j in range(rows): for i in range(cols): k = i + j * cols label = Label(label_frame, text=labels[k]) label.config(font=("Cambria Math", 20)) label.grid(row=j, column=i, padx=20, pady=10) self.labels += [label] self.selected = None self.after(100, self.ontick)
def add_peak(self, loc): self.newPeakEntry.delete(0, "end") self.newPeakEntry.insert(0, "") i = 0 while self.energies[i] < loc: i += 1 self.peakGUIList.append( Label(self.KnownPeaksFrame, text="{:5f}, {:5f}, 1.00".format(self.energies[i], self.cps[i]))) self.removeBtns.append( Button(self.KnownPeaksFrame, text="Remove", command=lambda temp=len(self.peakGUIList) - 1: self. remove_peak(temp))) self.peakGUIList[-1].grid(row=len(self.peakGUIList) + 1, column=0) self.removeBtns[-1].grid(row=len(self.peakGUIList) + 1, column=1)
def initUI(self): self.master.title("Listbox") self.pack(fill=BOTH, expand=1) acts = ['Monkey', 'Tiger', 'Dog', 'Rabbit', 'Dark', 'House'] lb = Listbox(self) for i in acts: lb.insert(END, i) lb.bind("<<Animal>>", self.on_select) lb.pack(pady=15) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack()
def __init__(self, master): """Make boxes, register callbacks etc.""" Frame.__init__(self, master) self.label = Label(self, text="När är du född?") self.label.pack() self.entry_text = StringVar() self.entry_text.trace("w", lambda *args: self.onEntryChanged()) self.entry = Entry(self, width=date_entry_width, textvariable=self.entry_text) self.entry.insert(0, "ÅÅÅÅ-MM-DD") self.entry.pack(pady=small_pad) self.button = Button(self, text="Uppdatera", command=lambda: self.onDateChanged()) self.button.pack() self.entry.focus_set() self.entry.select_range(0, END) self.entry.bind("<Return>", lambda x: self.onDateChanged())
def __init__(self, master): top = self.top = Toplevel(master) top.title('Train-Test Ratio') top.attributes("-topmost", True) top.geometry("350x80") top.grid() top.resizable(0, 0) Label(top, text="Enter the ratio of training set " \ + "size to test set size:").grid(row=0, columnspan=6, sticky='nesw', padx=15, pady=7.5) self.e = Entry(top) self.e.insert(END, str(train_test_ratio)) self.e.grid(row=1, column=0, columnspan=5, sticky='w', padx=15) Button(top, text=' Ok ', command=self.cleanup) \ .grid(row=1, column=5, columnspan=1, sticky='e', padx=15) top.bind('<Return>', self.cleanup)
def initUI(self): self.master.title("Data Visualizer") self.pack(fill=BOTH, expand=True) self.columnconfigure(1, weight=1) self.columnconfigure(3, pad=7) self.columnconfigure(4, pad=7) self.rowconfigure(3, weight=1) self.rowconfigure(5, pad=7) lbl = Label(self, text="Code input") lbl.grid(sticky=W, pady=4, padx=5) self.area = Text(self) self.area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N) abtn = Button(self, text="Connect to racket", command=self.putMessage) abtn.grid(row=1, column=3) cbtn = Button(self, text="Close connection") cbtn.grid(row=2, column=3, pady=4) hbtn = Button(self, text="Help") hbtn.grid(row=5, column=0, padx=5) obtn = Button(self, text="OK") obtn.grid(row=5, column=2) quitB = Button(self, text="Quit", command=self.quit) quitB.grid(row=5, column=3) cv_img = cv2.cvtColor(cv2.imread("testim.jpg"), cv2.COLOR_BGR2RGB) height, width, no_channels = cv_img.shape canvas = Canvas(self, width=width, height=height) canvas.grid(column=4, row=0, columnspan=4) photo = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(cv_img)) canvas.create_image(0, 0, image=photo, anchor=NW)
def labelled_entry(master, entry_kwargs={}, label_kwargs={}, **label_groups): """ Creates an entry widget with a label master - tkinter.Widget The parent widget label_groups - 2-tuples containing label text and textvariable entry_kwargs - keyword arguments passed to each entry label_kwargs - keyword arguments passed to each label returns a dict of 2-tuples containing the Label and Entry under the kwarg keyword key """ returnval = {} for dict_key, (label_text, textvar) in label_groups.items(): returnval[dict_key] = ( Label(master, text=label_text, **label_kwargs), Entry(master, textvariable=textvar, **entry_kwargs), ) return returnval
def show_images(self): self.open_images() if self.usable_images == []: print('No images opened') return num_rows = self.number_of_rows num_cols = self.number_of_columns # Arrange images for r in range(0, num_rows): for c in range(0, num_cols): current_image = self.usable_images[r * num_cols + c] label = Label(self.image_frame, image=current_image) label.image = current_image label.grid(row=r, column=c) self.image_labels.append(label)
def add_column_headers(self, lab_frame): '''Add the labels for the columns. This needs to be in sync with the DaxModelParameter.render_ui() method. ''' row = self.get_row() stt = Style() lfont = stt.lookup("TLabel", "font") basefont = font.nametofont(lfont) stt.configure("Hdr.TLabel", font=(basefont.cget("family"), basefont.cget("size"), "bold underline")) cols = ["Parameter", "Value", "Frozen?", "Min", "Max", "Units"] for col, txt in enumerate(cols): label = Label(lab_frame, text=txt, style="Hdr.TLabel") label.grid(row=row, column=col) self.next_row()
def show_images(self): self.open_images() if self.usable_images == []: self.parent.print_to_console("No images opened") return num_rows = self.config.number_of_rows.get() num_cols = self.config.number_of_columns.get() # Arrange images for r in range(0, num_rows): for c in range(0, num_cols): current_image = self.usable_images[r * num_cols + c] label = Label(self.image_frame, image=current_image) label.image = current_image label.grid(row=r, column=c) self.image_labels.append(label)
def initUI(self): self.master.title("ListBox Application") self.pack(fill=BOTH, expand=1) acts = ['Scarlet Johansson', 'Rachel', 'Jessica Alba', 'Van Disel'] lb = Listbox(self) for actress in acts: lb.insert(END, actress) lb.bind("<<ListboxSelect>>", self.onSelect) lb.pack(pady=15) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack()
def start(self): # Create a label to show frame count. frame_count_label = Label(self, text="you should not see this") frame_count_label.pack() # Create the base class engine in this Toplevel window. GameplayUtilities.create_game_engine(GameEngine, master=self) # Spawn the ticking actor. actor = GameplayStatics.world.deferred_spawn_actor(MyActor, (0, 0)) # Set properties before calling tick. actor.label = frame_count_label actor.frame_count = 0 GameplayStatics.world.finish_deferred_spawn_actor(actor) # Ensure we stop the game engine when closing the test, # so that subsequent runs are fully restarted. self.bind("<Destroy>", self.on_destroy)
def labelled_widgets( master: Widget, labels: Sequence[str], widgets: Sequence[Type[Widget]], kwargs: Sequence[Dict], widget_kwargs: Dict = {}, label_kwargs: Dict = {}, ) -> List[Widget]: args = (labels, widgets, kwargs) size = sum(map(len, args)) if size % 3 != 0: raise ValueError("'{}', '{}', and '{}' must be of same length".format( 'labels', 'widgets', 'kwargs')) return_: List[Widget] = [] for (label, widget, kwarg) in zip(*args): return_.append(Label(master, text=label, **label_kwargs), ) return_.append(widget(master, **kwarg, **widget_kwargs)) return return_